]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
don't connect to non-existent signal
[dolphin.git] / src / dolphinview.cpp
index 88a2cff80ffad1c484ce86e2354c3ff0d5cd8091..8a102c94fb0e7f28fda8590accdbfd46aa178004 100644 (file)
@@ -781,12 +781,13 @@ void DolphinView::showPreview(const KFileItem* item, const QPixmap& pixmap)
 
 void DolphinView::restoreContentsPos()
 {
-    UrlNavigator::HistoryElem historyItem = m_urlNavigator->currentHistoryItem();
-    if (!historyItem.url().isEmpty()) {
+    KUrl currentUrl = m_urlNavigator->url();
+    if (!currentUrl.isEmpty()) {
         QAbstractItemView* view = itemView();
-        // TODO: view->setCurrentItem(historyItem.currentFileName());
-        view->horizontalScrollBar()->setValue(historyItem.contentsX());
-        view->verticalScrollBar()->setValue(historyItem.contentsY());
+        // TODO: view->setCurrentItem(m_urlNavigator->currentFileName());
+        QPoint pos = m_urlNavigator->savedPosition();
+        view->horizontalScrollBar()->setValue(pos.x());
+        view->verticalScrollBar()->setValue(pos.y());
     }
 }
 
@@ -840,14 +841,29 @@ void DolphinView::startDirLister(const KUrl& url, bool reload)
     m_blockContentsMovedSignal = true;
     m_dirLister->stop();
 
-    bool keepOldDirs = isColumnViewActive();
-    if (keepOldDirs && !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;
+    bool openDir = true;
+    bool keepOldDirs = isColumnViewActive() && !reload;
+    if (keepOldDirs) {
+        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