]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
* share Context Menu page settings from dolphin with konqueror
[dolphin.git] / src / dolphinview.cpp
index 696caa04e2114d4ec30b944df62c34dec16d42e5..ed17c94abdedd23320243b811a0cfe27acf1a31e 100644 (file)
@@ -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"