]> cloud.milkyroute.net Git - dolphin.git/commitdiff
don't forget to create missing columns when the URL is changed from e. g. "/home...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 24 Sep 2007 08:08:56 +0000 (08:08 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 24 Sep 2007 08:08:56 +0000 (08:08 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=716208

src/dolphincolumnview.cpp

index 9f7eddefb7046a2858c04f9b55c436c9ab9065fd..7a1e41331ad8d3a992f5b099a328c15bb1a347d0 100644 (file)
@@ -661,26 +661,44 @@ void DolphinColumnView::showColumn(const KUrl& url)
             requestActivation(column);
             return;
         } else if (!column->url().isParentOf(url)) {
-            // the column is no parent of the requested URL, hence it must
-            // be deleted and a new column must be loaded
+            // the column is no parent of the requested URL, hence
+            // just delete all remaining columns
             if (columnIndex > 0) {
                 setActiveColumnIndex(columnIndex - 1);
                 deleteInactiveChildColumns();
+                break;
             }
+        }
+        ++columnIndex;
+    }
+
+    // Create missing columns. Assuming that the path is "/home/peter/Temp/" and
+    // the target path is "/home/peter/Temp/a/b/c/", then the columns "a", "b" and
+    // "c" will be created.
+    const int lastIndex = m_columns.count() - 1;
+    Q_ASSERT(lastIndex >= 0);
 
-            const QModelIndex dirIndex = m_dolphinModel->indexForUrl(url);
+    const KUrl& activeUrl = m_columns[lastIndex]->url();
+    Q_ASSERT(activeUrl.isParentOf(url));
+    Q_ASSERT(activeUrl != url);
+
+    QString path = activeUrl.url(KUrl::AddTrailingSlash);
+    const QString targetPath = url.url(KUrl::AddTrailingSlash);
+    int slashIndex = path.count('/');
+    bool hasSubPath = (slashIndex >= 0);
+    while (hasSubPath) {
+        const QString subPath = targetPath.section('/', slashIndex, slashIndex);
+        if (subPath.isEmpty()) {
+            hasSubPath = false;
+        } else {
+            path += subPath + '/';
+            ++slashIndex;
+
+            const QModelIndex dirIndex = m_dolphinModel->indexForUrl(KUrl(path));
             if (dirIndex.isValid()) {
                 triggerItem(m_proxyModel->mapFromSource(dirIndex));
             }
-            return;
         }
-        ++columnIndex;
-    }
-
-    // no existing column has been replaced and a new column must be created
-    const QModelIndex dirIndex = m_dolphinModel->indexForUrl(url);
-    if (dirIndex.isValid()) {
-        triggerItem(m_proxyModel->mapFromSource(dirIndex));
     }
 }