]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixing bugs in new folders in tabs feature
authorAlexander Saoutkin <a.saoutkin@gmail.com>
Mon, 2 Sep 2019 21:15:08 +0000 (23:15 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Mon, 2 Sep 2019 21:15:08 +0000 (23:15 +0200)
Summary:
Fixing bug where urls in secondary view containers would not be considered
for the open new folders in tabs feature.

Test Plan: Manual testing. Testing for no regressions. Testing that URL is found if in secondary view container

Reviewers: elvisangelaccio

Reviewed By: elvisangelaccio

Subscribers: kfm-devel, ngraham

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D23655

src/dolphinmainwindow.cpp
src/dolphintabwidget.cpp
src/dolphintabwidget.h

index 19f7906629ad75dd2145c15d2ea0b37b8c5d93e9..c9ed9c5cd5045b2d4f58bd8f7e171159d62f03da 100644 (file)
@@ -2089,7 +2089,7 @@ void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
 
 bool DolphinMainWindow::isUrlOpen(const QString& url)
 {
-    if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))) >= 0) {
+    if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))).first >= 0) {
         return true;
     } else {
         return false;
index defd089c16075cf48e1ca31e0a3779eb0aba7faf..7928c510e2aaa4df15ab281eaf863966baa80422 100644 (file)
@@ -186,9 +186,15 @@ void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
     QList<QUrl>::const_iterator it = dirs.constBegin();
     while (it != dirs.constEnd()) {
         const QUrl& primaryUrl = *(it++);
-        const int index = getIndexByUrl(primaryUrl);
-        if (index >= 0) {
-            setCurrentIndex(index);
+        const QPair<int, bool> viewLocation = getIndexByUrl(primaryUrl);
+        if (viewLocation.first >= 0) {
+            setCurrentIndex(viewLocation.first);
+            const auto tabPage = tabPageAt(viewLocation.first);
+            if (viewLocation.second) {
+                tabPage->primaryViewContainer()->setActive(true);
+            } else {
+                tabPage->secondaryViewContainer()->setActive(true);
+            }
             continue;
         }
         if (splitView && (it != dirs.constEnd())) {
@@ -381,16 +387,17 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const
     return name.replace('&', QLatin1String("&&"));
 }
 
-int DolphinTabWidget::getIndexByUrl(const QUrl& url) const
+QPair<int, bool> DolphinTabWidget::getIndexByUrl(const QUrl& url) const
 {
     for (int i = 0; i < count(); i++) {
-        // Conversion to display string is necessary to deal with the '~' alias.
-        // i.e. to acknowledge that ~/ is equivalent to /home/user/
-        const QUrl tabUrl = tabPageAt(i)->activeViewContainer()->url();
-        if (url == tabUrl ||
-            url.toDisplayString(QUrl::StripTrailingSlash) == tabUrl.toDisplayString(QUrl::StripTrailingSlash)) {
-            return i;
+        const auto tabPage = tabPageAt(i);
+        if (url == tabPage->primaryViewContainer()->url()) {
+            return qMakePair(i, true);
+        }
+
+        if (tabPage->splitViewEnabled() && url == tabPage->secondaryViewContainer()->url()) {
+            return qMakePair(i, false);
         }
     }
-    return -1;
+    return qMakePair(-1, false);
 }
index 3e8301725c71e83c69fca4ab62d570aae87d5f51..7eb001b21924e6bf9b13ef7cc439dd919be58324 100644 (file)
@@ -80,9 +80,13 @@ public:
 
     /**
      * @param url The URL that we would like
-     * @return index of the tab with the desired URL. returns -1 if not found
+     * @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.
      */
-    int getIndexByUrl(const QUrl& url) const;
+    QPair<int, bool> getIndexByUrl(const QUrl& url) const;
 
 signals:
     /**