From: Rahman Duran Date: Mon, 30 Mar 2009 07:18:32 +0000 (+0000) Subject: BUG: 187732 X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/91a6bbf95a603965a4afea666ed0392fb5aa0fbb BUG: 187732 Make Dolphin to remember selected files after view refresh. svn path=/trunk/KDE/kdebase/apps/; revision=946726 --- diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 56fdf4ad1..57a2551ad 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -106,6 +106,7 @@ DolphinView::DolphinView(QWidget* parent, m_rootUrl(), m_currentItemUrl(), m_createdItemUrl(), + m_selectedItems(), m_expandedDragSource(0) { m_topLayout = new QVBoxLayout(this); @@ -1109,6 +1110,12 @@ void DolphinView::selectAndScrollToCreatedItem() m_createdItemUrl = KUrl(); } +void DolphinView::restoreSelection() +{ + disconnect(m_dirLister, SIGNAL(completed()), this, SLOT(restoreSelection())); + changeSelection(m_selectedItems); +} + void DolphinView::emitContentsMoved() { // only emit the contents moved signal if: @@ -1183,6 +1190,11 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload) m_loadingDirectory = true; + if (reload) { + m_selectedItems = selectedItems(); + connect(m_dirLister, SIGNAL(completed()), this, SLOT(restoreSelection())); + } + m_dirLister->stop(); m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags); @@ -1477,4 +1489,5 @@ QMimeData* DolphinView::selectionMimeData() const return m_dolphinModel->mimeData(selection.indexes()); } + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index c18785151..385bcd50f 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -657,6 +657,11 @@ private slots: */ void selectAndScrollToCreatedItem(); + /** + * Restore selection after view refresh. + */ + void restoreSelection(); + private: void loadDirectory(const KUrl& url, bool reload = false); @@ -760,6 +765,7 @@ private: KUrl m_rootUrl; KUrl m_currentItemUrl; 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 QAbstractItemView* m_expandedDragSource; };