X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b8c2f5377772c618b2b032bcd67cd32045c97fc9..f2d889b349cb060a44f610982972ac2d82b57426:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 696caa04e..ed17c94ab 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); @@ -408,7 +409,7 @@ void DolphinView::setZoomLevel(int level) if (level != zoomLevel()) { m_controller->setZoomLevel(level); - m_previewGenerator->updatePreviews(); + m_previewGenerator->updateIcons(); emit zoomLevelChanged(level); } } @@ -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: @@ -1149,15 +1156,18 @@ void DolphinView::slotRequestUrlChange(const KUrl& url) 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(); + if (!m_currentItemUrl.isEmpty()) { + 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(); + } } + m_currentItemUrl.clear(); } } @@ -1183,6 +1193,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 +1492,5 @@ QMimeData* DolphinView::selectionMimeData() const return m_dolphinModel->mimeData(selection.indexes()); } + #include "dolphinview.moc"