From e54e6a9cdbc0e37e7c81abcea4e69838cddabaa3 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 28 May 2008 20:40:16 +0000 Subject: 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 --- src/dolphinview.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/dolphinview.cpp') 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()) { -- cgit v1.3