]> cloud.milkyroute.net Git - dolphin.git/commitdiff
when going back in history apply the keyboard focus to the the previously shown directory
authorPeter Penz <peter.penz19@gmail.com>
Tue, 20 May 2008 21:21:48 +0000 (21:21 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 20 May 2008 21:21:48 +0000 (21:21 +0000)
BUG: 156550
BUG: 158590

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

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

index 2618dea275d5d25bd7b91ef3932aa5e7337ec9a6..f0a4487c939d10e5ec9eb7e532e7a69b5e1e82a6 100644 (file)
@@ -347,6 +347,20 @@ QPoint DolphinView::contentsPosition() const
     return QPoint(x, y);
 }
 
+void DolphinView::setCurrentItem(const KUrl& url)
+{
+    const QModelIndex dirIndex = m_dolphinModel->indexForUrl(url);
+    if (dirIndex.isValid()) {
+        const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+        QAbstractItemView* view = itemView();
+        const bool clearSelection = !hasSelection();
+        view->setCurrentIndex(proxyIndex);
+        if (clearSelection) {
+            view->clearSelection();
+        }
+    }
+}
+
 void DolphinView::zoomIn()
 {
     m_controller->triggerZoomIn();
index 5d88e4f545f8436301c824404b42a8b2977c8066..7085355674a7224b6ffd0def1af3202e26492ddc 100644 (file)
@@ -233,6 +233,12 @@ public:
     /** Returns the upper left position of the view content. */
     QPoint contentsPosition() const;
 
+    /**
+     * Sets the current item (= item that has the keyboard focus) to
+     * the item with the URL \a url.
+     */
+    void setCurrentItem(const KUrl& url);
+
     /** Increases the size of the current set view mode. */
     void zoomIn();
 
index ae9defc1add178ebd84aafd92706772f80dbeae0..6bc620ee21b217e12bae6a948fa38b30339afd3b 100644 (file)
@@ -68,7 +68,9 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
     m_filterBar(0),
     m_statusBar(0),
     m_dirLister(0),
-    m_proxyModel(0)
+    m_proxyModel(0),
+    m_previousUrl(),
+    m_currentUrl()
 {
     hide();
 
@@ -167,14 +169,18 @@ DolphinViewContainer::~DolphinViewContainer()
     m_dirLister = 0; // deleted by m_dolphinModel
 }
 
-void DolphinViewContainer::setUrl(const KUrl& url)
+void DolphinViewContainer::setUrl(const KUrl& newUrl)
 {
-    m_urlNavigator->setUrl(url);
+    if (newUrl != m_currentUrl) {
+        m_previousUrl = m_currentUrl;
+        m_currentUrl = newUrl;
+        m_urlNavigator->setUrl(newUrl);
+    }
 }
 
 const KUrl& DolphinViewContainer::url() const
 {
-    return m_urlNavigator->url();
+    return m_currentUrl;
 }
 
 void DolphinViewContainer::setActive(bool active)
@@ -228,7 +234,7 @@ void DolphinViewContainer::slotDirListerCompleted()
     }
 
     updateStatusBar();
-
+    m_view->setCurrentItem(m_previousUrl);
     QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
 }
 
index b4f799cb1ff6ad7d80eed354ff200763240e0ac2..a0ddcb71171e051609fd1142cd8f427ed0e5eb8c 100644 (file)
@@ -230,6 +230,9 @@ private:
     DolphinModel* m_dolphinModel;
     DolphinDirLister* m_dirLister;
     DolphinSortFilterProxyModel* m_proxyModel;
+
+    KUrl m_previousUrl;
+    KUrl m_currentUrl;
 };
 
 inline const DolphinStatusBar* DolphinViewContainer::statusBar() const