diff options
| author | Peter Penz <[email protected]> | 2008-05-28 20:40:16 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-05-28 20:40:16 +0000 |
| commit | e54e6a9cdbc0e37e7c81abcea4e69838cddabaa3 (patch) | |
| tree | cc6f04e75706796a9a53424663e02f77d62b24a8 /src/dolphinview.cpp | |
| parent | b445156dd40a16877058f8228900679cb27aa4cc (diff) | |
Move the code for restoring the current item from DolphinViewContainer to DolphinView, as the DolphinView must be able to do this without advice from the container.
Beside that this simplifies the code it also fixes a regression of having empty tabs.
svn path=/trunk/KDE/kdebase/apps/; revision=813828
Diffstat (limited to 'src/dolphinview.cpp')
| -rw-r--r-- | src/dolphinview.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index f0a4487c9..ae6ea5ec7 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -84,7 +84,9 @@ DolphinView::DolphinView(QWidget* parent, m_dirLister(dirLister), m_proxyModel(proxyModel), m_iconManager(0), - m_toolTipManager(0) + m_toolTipManager(0), + m_rootUrl(), + m_currentItemUrl() { m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); @@ -123,6 +125,9 @@ DolphinView::DolphinView(QWidget* parent, connect(m_controller, SIGNAL(viewportEntered()), this, SLOT(clearHoverInformation())); + connect(m_dirLister, SIGNAL(completed()), + this, SLOT(restoreCurrentItem())); + applyViewProperties(url); m_topLayout->addWidget(itemView()); } @@ -347,20 +352,6 @@ 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(); @@ -493,6 +484,8 @@ void DolphinView::calculateItemCount(int& fileCount, int& folderCount) void DolphinView::setUrl(const KUrl& url) { + // remember current item candidate (see restoreCurrentItem()) + m_currentItemUrl = url; updateView(url, KUrl()); } @@ -969,6 +962,21 @@ void DolphinView::slotDeleteFileFinished(KJob* job) } } + +void DolphinView::restoreCurrentItem() +{ + const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl); + 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::loadDirectory(const KUrl& url, bool reload) { if (!url.isValid()) { |
