]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Mark the last visitied directory as active when going back in history.
authorPeter Penz <peter.penz19@gmail.com>
Mon, 8 Jun 2009 05:55:46 +0000 (05:55 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 8 Jun 2009 05:55:46 +0000 (05:55 +0000)
BUG: 192811

svn path=/trunk/KDE/kdebase/apps/; revision=978757

src/dolphinview.cpp
src/dolphinview.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index cb846fe42338d9ea1fe26830ffea4b29f890a14e..8278d136a14b40f69d5fd80c02d8a7207f5177cf 100644 (file)
@@ -104,7 +104,7 @@ DolphinView::DolphinView(QWidget* parent,
     m_previewGenerator(0),
     m_toolTipManager(0),
     m_rootUrl(),
-    m_currentItemUrl(),
+    m_activeItemUrl(),
     m_createdItemUrl(),
     m_selectedItems(),
     m_newFileNames(),
@@ -608,9 +608,6 @@ QString DolphinView::statusBarText() const
 void DolphinView::setUrl(const KUrl& url)
 {
     m_newFileNames.clear();
-
-    // remember current item candidate (see slotDirListerCompleted())
-    m_currentItemUrl = url;
     updateView(url, KUrl());
 }
 
@@ -1100,6 +1097,11 @@ bool DolphinView::isTabsForFilesEnabled() const
     return m_tabsForFiles;
 }
 
+void DolphinView::activateItem(const KUrl& url)
+{
+    m_activeItemUrl = url;
+}
+
 bool DolphinView::itemsExpandable() const
 {
     return (m_detailsView != 0) && m_detailsView->itemsExpandable();
@@ -1191,9 +1193,9 @@ void DolphinView::slotRequestUrlChange(const KUrl& url)
 
 void DolphinView::slotDirListerCompleted()
 {
-    if (!m_currentItemUrl.isEmpty()) {
+    if (!m_activeItemUrl.isEmpty()) {
         // assure that the current item remains visible
-        const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
+        const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_activeItemUrl);
         if (dirIndex.isValid()) {
             const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
             QAbstractItemView* view = itemView();
@@ -1202,7 +1204,7 @@ void DolphinView::slotDirListerCompleted()
             if (clearSelection) {
                 view->clearSelection();
             }
-            m_currentItemUrl.clear();
+            m_activeItemUrl.clear();
         }
     }
 
index 24831e03b7d2d7b11e4595ffde48dc61fee77cf0..24f56f40325e57807e42321b530249c5c48b0d7a 100644 (file)
@@ -345,6 +345,15 @@ public:
     void setTabsForFilesEnabled(bool tabsForFiles);
     bool isTabsForFilesEnabled() const;
 
+    /**
+     * Marks the item \a url as active item as soon as it has
+     * been loaded by the directory lister. This is useful mark
+     * the previously visited directory as active when going
+     * back in history (the URL is known, but the item is not
+     * loaded yet).
+     */
+    void activateItem(const KUrl& url);
+
     /**
      * Returns true if the current view allows folders to be expanded,
      * i.e. presents a hierarchical view to the user.
@@ -786,7 +795,7 @@ private:
     ToolTipManager* m_toolTipManager;
 
     KUrl m_rootUrl;
-    KUrl m_currentItemUrl;
+    KUrl m_activeItemUrl;
     KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
     KFileItemList m_selectedItems; // this is used for making the View to remember selections after F5
 
index 9f61360d73a3db98b5305c92a2d08ae2c10ee186..cffffd70b2586b137315547699f5f42cdd01c1f7 100644 (file)
@@ -155,6 +155,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
 
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             this, SLOT(restoreView(const KUrl&)));
+    connect(m_urlNavigator, SIGNAL(historyChanged()),
+            this, SLOT(slotHistoryChanged()));
 
     m_statusBar = new DolphinStatusBar(this, m_view);
 
@@ -452,6 +454,17 @@ void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion com
     settings.save();
 }
 
+void DolphinViewContainer::slotHistoryChanged()
+{
+    const int index = m_urlNavigator->historyIndex();
+    if (index > 0) {
+        // The "Go Forward" action is enabled. Try to mark
+        // the previous directory as active item:
+        const KUrl url = m_urlNavigator->historyUrl(index - 1);
+        m_view->activateItem(url);
+    }
+}
+
 void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
 {
     KUrl url = item.targetUrl();
index e6fd8fd0a04ff75c4eefa14db3306412ab10ef38..db6ee69d54a99147effc3c24a0c47bace052a46b 100644 (file)
@@ -243,6 +243,8 @@ private slots:
      */
     void saveUrlCompletionMode(KGlobalSettings::Completion completion);
 
+    void slotHistoryChanged();
+
 private:
     bool m_showProgress;
     bool m_isFolderWritable;