]> cloud.milkyroute.net Git - dolphin.git/commitdiff
restore the focus of the active column after the reloading has been finished
authorPeter Penz <peter.penz19@gmail.com>
Fri, 21 Sep 2007 19:39:43 +0000 (19:39 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 21 Sep 2007 19:39:43 +0000 (19:39 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=715305

src/dolphincolumnview.cpp
src/dolphincolumnview.h

index 6d4f584259ec03c746ae9f68684dd249460a6b60..d5e1e47be0df3c2cb06d640bef17d18b3b5d0241 100644 (file)
@@ -384,6 +384,7 @@ void ColumnWidget::deactivate()
 DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* controller) :
     QAbstractItemView(parent),
     m_controller(controller),
+    m_restoreActiveColumnFocus(false),
     m_index(-1),
     m_contentX(0),
     m_columns(),
@@ -473,11 +474,18 @@ void DolphinColumnView::reload()
     // the same content as the first column. As this is not wanted, all columns
     // except of the first column are temporary hidden until the root index can
     // be updated again.
+    m_restoreActiveColumnFocus = false;
     QList<ColumnWidget*>::iterator start = m_columns.begin() + 1;
     QList<ColumnWidget*>::iterator end = m_columns.end();
     for (QList<ColumnWidget*>::iterator it = start; it != end; ++it) {
-        (*it)->hide();
-        (*it)->setRootIndex(QModelIndex());
+        ColumnWidget* column = (*it);
+        if (column->isActive() && column->hasFocus()) {
+            // because of hiding the column, it will lose the focus
+            // -> remember that the focus should be restored after reloading
+            m_restoreActiveColumnFocus = true;
+        }
+        column->hide();
+        column->setRootIndex(QModelIndex());
    }
 
     // all columns are hidden, now reload the directory lister
@@ -714,8 +722,8 @@ void DolphinColumnView::triggerReloadColumns(const QModelIndex& index)
 
 void DolphinColumnView::reloadColumns()
 {
-    const int count = m_columns.count() - 1; // ignore the last column
-    for (int i = 0; i < count; ++i) {
+    const int end = m_columns.count() - 2; // next to last column
+    for (int i = 0; i <= end; ++i) {
         ColumnWidget* nextColumn = m_columns[i + 1];
         const QModelIndex rootIndex = nextColumn->rootIndex();
         if (!rootIndex.isValid()) {
@@ -724,6 +732,10 @@ void DolphinColumnView::reloadColumns()
             if (proxyIndex.isValid()) {
                 nextColumn->setRootIndex(proxyIndex);
                 nextColumn->show();
+                if (nextColumn->isActive() && m_restoreActiveColumnFocus) {
+                    nextColumn->setFocus();
+                    m_restoreActiveColumnFocus = false;
+                }
             }
         }
     }
index 37deffd2cc44cd4bc20513ae4738447bf88a768b..2f10a9be8f29feac8642b8cdd0530da62180f102 100644 (file)
@@ -150,6 +150,7 @@ private:
 
 private:
     DolphinController* m_controller;
+    bool m_restoreActiveColumnFocus;
     int m_index;
     int m_contentX;
     QList<ColumnWidget*> m_columns;