diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -2160,10 +2160,6 @@ bool DolphinMainWindow::isUrlOpen(const QString& url) { - if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))).first >= 0) { - return true; - } else { - return false; - } + return m_tabWidget->isUrlOpen(QUrl::fromUserInput((url))); } diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h --- a/src/dolphintabwidget.h +++ b/src/dolphintabwidget.h @@ -79,14 +79,10 @@ void refreshViews(); /** - * @param url The URL that we would like - * @return a QPair with first containing the index of the tab with the - * desired URL or -1 if not found. Second says true if URL is in primary - * view container, false otherwise. False means the URL is in the secondary - * view container, unless first == -1. In that case the value of second - * is meaningless. + * @return Whether any of the tab pages contains @p url in their primary + * or secondary view. */ - QPair getIndexByUrl(const QUrl& url) const; + bool isUrlOpen(const QUrl& url) const; signals: /** @@ -221,6 +217,16 @@ */ QString tabName(DolphinTabPage* tabPage) const; + /** + * @param url The URL that we would like + * @return a QPair with first containing the index of the tab with the + * desired URL or -1 if not found. Second says true if URL is in primary + * view container, false otherwise. False means the URL is in the secondary + * view container, unless first == -1. In that case the value of second + * is meaningless. + */ + QPair indexByUrl(const QUrl& url) const; + private: /** Caches the (negated) places panel visibility */ bool m_placesSelectorVisible; diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -130,6 +130,11 @@ } } +bool DolphinTabWidget::isUrlOpen(const QUrl &url) const +{ + return indexByUrl(url).first >= 0; +} + void DolphinTabWidget::openNewActivatedTab() { const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer(); @@ -187,11 +192,13 @@ QList::const_iterator it = dirs.constBegin(); while (it != dirs.constEnd()) { const QUrl& primaryUrl = *(it++); - const QPair viewLocation = getIndexByUrl(primaryUrl); - if (viewLocation.first >= 0) { - setCurrentIndex(viewLocation.first); - const auto tabPage = tabPageAt(viewLocation.first); - if (viewLocation.second) { + const QPair indexInfo = indexByUrl(primaryUrl); + const int index = indexInfo.first; + const bool isInPrimaryView = indexInfo.second; + if (index >= 0) { + setCurrentIndex(index); + const auto tabPage = tabPageAt(index); + if (isInPrimaryView) { tabPage->primaryViewContainer()->setActive(true); } else { tabPage->secondaryViewContainer()->setActive(true); @@ -400,7 +407,7 @@ return name.replace('&', QLatin1String("&&")); } -QPair DolphinTabWidget::getIndexByUrl(const QUrl& url) const +QPair DolphinTabWidget::indexByUrl(const QUrl& url) const { for (int i = 0; i < count(); i++) { const auto tabPage = tabPageAt(i);