diff options
| author | Frank Reininghaus <[email protected]> | 2009-11-30 08:15:22 +0000 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2009-11-30 08:15:22 +0000 |
| commit | 56a81a196f9db867bc69f23fe46c239045f784ca (patch) | |
| tree | c0d99f9f07ade1b8a86db429aafd913f91ef7f2c /src | |
| parent | bd47f7f9785943147d79041ada1f073b78cf718d (diff) | |
When the view is reloaded in Dolphin or the DolphinPart inside
Konqueror, restore the selection, the current item, the scroll
position, and the expanded folders in the Details View.
BUG: 169893
BUG: 187732
svn path=/trunk/KDE/kdebase/apps/; revision=1056438
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinview.cpp | 30 | ||||
| -rw-r--r-- | src/dolphinview.h | 5 |
2 files changed, 14 insertions, 21 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index e057c950a..fe4296409 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -438,8 +438,16 @@ KFileItemDelegate::InformationList DolphinView::additionalInfo() const void DolphinView::reload() { + QByteArray viewState; + QDataStream saveStream(&viewState, QIODevice::WriteOnly); + saveState(saveStream); + m_selectedItems = selectedItems(); + setUrl(url()); loadDirectory(url(), true); + + QDataStream restoreStream(viewState); + restoreState(restoreStream); } void DolphinView::refresh() @@ -593,11 +601,7 @@ void DolphinView::invertSelection() void DolphinView::clearSelection() { - QItemSelectionModel* selModel = m_viewAccessor.itemView()->selectionModel(); - const QModelIndex currentIndex = selModel->currentIndex(); - selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current | - QItemSelectionModel::Clear); - m_selectedItems.clear(); + m_viewAccessor.itemView()->clearSelection(); } void DolphinView::changeSelection(const KFileItemList& selection) @@ -1143,12 +1147,6 @@ void DolphinView::selectAndScrollToCreatedItem() m_createdItemUrl = KUrl(); } -void DolphinView::restoreSelection() -{ - disconnect(m_viewAccessor.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection())); - changeSelection(m_selectedItems); -} - void DolphinView::emitContentsMoved() { // TODO: If DolphinViewContainer uses DolphinView::saveState(...) to save the @@ -1234,6 +1232,11 @@ void DolphinView::slotLoadingCompleted() } } + if (!m_selectedItems.isEmpty()) { + changeSelection(m_selectedItems); + m_selectedItems.clear(); + } + // Restore the contents position. This has to be done using a Qt::QueuedConnection // because the view might not be in its final state yet. QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection); @@ -1262,11 +1265,6 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload) m_loadingDirectory = true; m_expanderActive = false; - if (reload) { - m_selectedItems = selectedItems(); - connect(m_viewAccessor.dirLister(), SIGNAL(completed()), this, SLOT(restoreSelection())); - } - m_viewAccessor.dirLister()->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags); } diff --git a/src/dolphinview.h b/src/dolphinview.h index 97054b754..770391610 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -715,11 +715,6 @@ private slots: void selectAndScrollToCreatedItem(); /** - * Restore selection after view refresh. - */ - void restoreSelection(); - - /** * Called when a redirection happens. * Testcase: fish://localhost */ |
