From bcbf0b44d62691f9bbbe8db8b0d006a5c996ed60 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 21 Sep 2007 19:39:43 +0000 Subject: [PATCH] restore the focus of the active column after the reloading has been finished svn path=/trunk/KDE/kdebase/apps/; revision=715305 --- src/dolphincolumnview.cpp | 20 ++++++++++++++++---- src/dolphincolumnview.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index 6d4f58425..d5e1e47be 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -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::iterator start = m_columns.begin() + 1; QList::iterator end = m_columns.end(); for (QList::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; + } } } } diff --git a/src/dolphincolumnview.h b/src/dolphincolumnview.h index 37deffd2c..2f10a9be8 100644 --- a/src/dolphincolumnview.h +++ b/src/dolphincolumnview.h @@ -150,6 +150,7 @@ private: private: DolphinController* m_controller; + bool m_restoreActiveColumnFocus; int m_index; int m_contentX; QList m_columns; -- 2.47.3