]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix broken view state restoration
authorFrank Reininghaus <frank78ac@googlemail.com>
Sat, 26 Oct 2013 07:24:04 +0000 (09:24 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sat, 26 Oct 2013 07:24:04 +0000 (09:24 +0200)
The fix for bug 161385 (which was about Dolphin still showing an empty
view if a device that had been unmounted earlier was clicked in the
Places Panel) caused a regression: the view state (current item, scroll
position, Details View expansion state) was not restored any more when
going "Back".

The reason is that "m_view->reload()" in
DolphinViewContainer::setUrl(const KUrl& newUrl) was always executed
just after entering a directory, and that command overwrites this
information.

Distinguishing between "change URL" and "reload the view" works better
if it's done in DolphinMainWindow instead of DolphinViewContainer.

BUG: 326039
FIXED-IN: 4.11.3
REVIEW: 113290

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinviewcontainer.cpp

index ccef356ea2a01ab9a72916918817af4cd2b84959..9da73f96e4f39f0162e23576e0bfd8503c4f0652 100644 (file)
@@ -1417,6 +1417,19 @@ void DolphinMainWindow::slotPanelErrorMessage(const QString& error)
     activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
 }
 
+void DolphinMainWindow::slotPlaceActivated(const KUrl& url)
+{
+    DolphinViewContainer* view = activeViewContainer();
+
+    if (view->url() == url) {
+        // We can end up here if the user clicked a device in the Places Panel
+        // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
+        reloadView();
+    } else {
+        changeUrl(url);
+    }
+}
+
 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
 {
     Q_ASSERT(viewContainer);
@@ -1749,7 +1762,7 @@ void DolphinMainWindow::setupDockWidgets()
 
     addDockWidget(Qt::LeftDockWidgetArea, placesDock);
     connect(placesPanel, SIGNAL(placeActivated(KUrl)),
-            this, SLOT(changeUrl(KUrl)));
+            this, SLOT(slotPlaceActivated(KUrl)));
     connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
             this, SLOT(openNewTab(KUrl)));
     connect(placesPanel, SIGNAL(errorMessage(QString)),
index 7da5801ffe5f3603b29674cf2f0686dccb38b190..6b046c2ea076ee168e2c6b042ae0e2abfd0625cf 100644 (file)
@@ -466,6 +466,13 @@ private slots:
      */
     void slotPanelErrorMessage(const QString& error);
 
+    /**
+     * Is called if the user clicked an item in the Places Panel.
+     * Reloads the view if \a url is the current URL already, and changes the
+     * current URL otherwise.
+     */
+    void slotPlaceActivated(const KUrl& url);
+
 private:
     /**
      * Activates the given view, which means that
index c8fc757ba700252a9fc141a0e14ef7235132a0af..e7c571294be20f9ae13681be58a1de1f36762e62 100644 (file)
@@ -372,10 +372,6 @@ void DolphinViewContainer::setUrl(const KUrl& newUrl)
 {
     if (newUrl != m_urlNavigator->locationUrl()) {
         m_urlNavigator->setLocationUrl(newUrl);
-    } else if (m_view->itemsCount() == 0) {
-        // Maybe a previously unmounted device has been mounted again.
-        // Let's reload the view to be safe (see https://bugs.kde.org/show_bug.cgi?id=161385).
-        m_view->reload();
     }
 
     #ifdef KActivities_FOUND