]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
don't use KUrl::upUrl() (thanks to David for the hint!)
[dolphin.git] / src / dolphinview.cpp
index 030a6abaec8231ec8eba7e4d4b7c714fff8c71c1..bb84d32c01fe34c21152439cb6b27d1d93e77bbf 100644 (file)
@@ -295,8 +295,8 @@ void DolphinView::renameSelectedItems()
                 name.replace(replaceIndex, 1, number);
 
                 if (oldUrl.fileName() != name) {
-                    KUrl newUrl(oldUrl.upUrl());
-                    newUrl.addPath(name);
+                    KUrl newUrl = oldUrl;
+                    newUrl.setFileName(name);
                     m_mainWindow->rename(oldUrl, newUrl);
                 }
                 ++it;
@@ -323,8 +323,8 @@ void DolphinView::renameSelectedItems()
         }
         else {
             const KUrl& oldUrl = urls.first();
-            KUrl newUrl = oldUrl.upUrl();
-            newUrl.addPath(newName);
+            KUrl newUrl = oldUrl;
+            newUrl.setFileName(newName);
             m_mainWindow->rename(oldUrl, newUrl);
         }
     }
@@ -355,11 +355,6 @@ int DolphinView::contentsY() const
     return itemView()->verticalScrollBar()->value();
 }
 
-void DolphinView::refreshSettings()
-{
-    startDirLister(m_urlNavigator->url());
-}
-
 void DolphinView::emitRequestItemInfo(const KUrl& url)
 {
     emit requestItemInfo(url);
@@ -841,17 +836,42 @@ void DolphinView::startDirLister(const KUrl& url, bool reload)
     m_blockContentsMovedSignal = true;
     m_dirLister->stop();
 
-    bool keepOldDirs = isColumnViewActive() && !reload;
+    bool openDir = true;
+    bool keepOldDirs = isColumnViewActive();
     if (keepOldDirs) {
-        const KUrl& dirListerUrl = m_dirLister->url();
-        if ((dirListerUrl == url) || !m_dirLister->url().isParentOf(url)) {
-            // The current URL is not a child of the dir lister
-            // URL. This may happen when e. g. a bookmark has been selected
-            // and hence the view must be reset.
+        if (reload) {
             keepOldDirs = false;
+
+            const KUrl& dirListerUrl = m_dirLister->url();
+            if (dirListerUrl.isValid()) {
+                const KUrl::List dirs = m_dirLister->directories();
+                KUrl url;
+                foreach (url, dirs) {
+                    m_dirLister->updateDirectory(url);
+                }
+                openDir = false;
+            }
         }
+        else if (m_dirLister->directories().contains(url)) {
+            // The dir lister contains the directory already, so
+            // KDirLister::openUrl() may not been invoked twice.
+            m_dirLister->updateDirectory(url);
+            openDir = false;
+        }
+        else {
+            const KUrl& dirListerUrl = m_dirLister->url();
+            if ((dirListerUrl == url) || !m_dirLister->url().isParentOf(url)) {
+                // The current URL is not a child of the dir lister
+                // URL. This may happen when e. g. a bookmark has been selected
+                // and hence the view must be reset.
+                keepOldDirs = false;
+            }
+        }
+    }
+
+    if (openDir) {
+        m_dirLister->openUrl(url, keepOldDirs, reload);
     }
-    m_dirLister->openUrl(url, keepOldDirs, reload);
 }
 
 QString DolphinView::defaultStatusBarText() const