]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
Get back names, and use "using" keyword to keep GCC silent on "method foo on base...
[dolphin.git] / src / dolphinview.cpp
index 21404745084c648207a179db5f6c9be41c0c4189..c5f6c91d391e4dd01f54c30d61bdcf461709b742 100644 (file)
@@ -81,7 +81,6 @@ DolphinView::DolphinView(QWidget* parent,
     QWidget(parent),
     m_active(true),
     m_showPreview(false),
-    m_loadingDirectory(false),
     m_storedCategorizedSorting(false),
     m_tabsForFiles(false),
     m_isContextMenuOpen(false),
@@ -109,8 +108,6 @@ DolphinView::DolphinView(QWidget* parent,
 
     connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
             this, SIGNAL(urlChanged(const KUrl&)));
-    connect(m_controller, SIGNAL(requestUrlChange(const KUrl&)),
-            this, SLOT(slotRequestUrlChange(const KUrl&)));
 
     connect(m_controller, SIGNAL(requestContextMenu(const QPoint&, const QList<QAction*>&)),
             this, SLOT(openContextMenu(const QPoint&, const QList<QAction*>&)));
@@ -536,22 +533,30 @@ QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) c
 
 void DolphinView::setUrl(const KUrl& url)
 {
-    if (m_controller->url() == url) {
-        return;
-    }
+    if (m_controller->url() != url) {
+        m_newFileNames.clear();
 
-    m_newFileNames.clear();
+        m_controller->setUrl(url); // emits urlChanged, which we forward
+        m_viewAccessor.prepareUrlChange(url);
+        applyViewProperties();
+        loadDirectory(url);
 
-    m_controller->setUrl(url); // emits urlChanged, which we forward
-    m_viewAccessor.prepareUrlChange(url);
-    applyViewProperties();
-    loadDirectory(url);
+        // When changing the URL there is no need to keep the version
+        // data of the previous URL.
+        m_viewAccessor.dirModel()->clearVersionData();
 
-    // When changing the URL there is no need to keep the version
-    // data of the previous URL.
-    m_viewAccessor.dirModel()->clearVersionData();
+        emit startedPathLoading(url);
+    }
 
-    emit startedPathLoading(url);
+    // the selection model might have changed in the case of a column view
+    QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
+    if (m_selectionModel != selectionModel) {
+        disconnect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+                   this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+        m_selectionModel = selectionModel;
+        connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+                this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+    }
 }
 
 void DolphinView::selectAll()
@@ -1025,13 +1030,6 @@ bool DolphinView::isTabsForFilesEnabled() const
     return m_tabsForFiles;
 }
 
-void DolphinView::activateItem(const KUrl& url)
-{
-    // TODO: If DolphinViewContainer uses DolphinView::restoreState(...) to restore the
-    // view state in KDE 4.5, this function can be removed.
-    m_activeItemUrl = url;
-}
-
 bool DolphinView::itemsExpandable() const
 {
     return m_viewAccessor.itemsExpandable();
@@ -1125,12 +1123,6 @@ void DolphinView::slotDeleteFileFinished(KJob* job)
     }
 }
 
-void DolphinView::slotRequestUrlChange(const KUrl& url)
-{
-    emit requestUrlChange(url);
-    m_controller->setUrl(url);
-}
-
 void DolphinView::slotDirListerCompleted()
 {
     if (!m_expanderActive) {
@@ -1159,7 +1151,6 @@ void DolphinView::slotDirListerCompleted()
 void DolphinView::slotLoadingCompleted()
 {
     m_expanderActive = false;
-    m_loadingDirectory = false;
 
     if (!m_activeItemUrl.isEmpty()) {
         // assure that the current item remains visible
@@ -1218,19 +1209,8 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
         return;
     }
 
-    m_loadingDirectory = true;
-    m_expanderActive = false;
-
     KDirLister* dirLister = m_viewAccessor.dirLister();
     dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
-
-    KDirLister* rootDirLister = m_viewAccessor.rootDirLister();
-    if (dirLister != rootDirLister) {
-        // In the case of the column view the root directory lister can be different. Assure
-        // that it gets synchronized (clients from DolphinView are not aware that internally
-        // different directory listers are used).
-        rootDirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
-    }
 }
 
 void DolphinView::applyViewProperties()
@@ -1337,8 +1317,8 @@ void DolphinView::createView()
         m_selectionModel = view->selectionModel();
     }
     m_selectionModel->setParent(this);
-    connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
-            this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
+    connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+            this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
 
     setFocusProxy(m_viewAccessor.layoutTarget());
     m_topLayout->insertWidget(1, m_viewAccessor.layoutTarget());
@@ -1482,11 +1462,6 @@ void DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url)
     if (m_columnsContainer != 0) {
         m_columnsContainer->showColumn(url);
     }
-
-    if(!m_detailsViewExpander.isNull()) {
-        // stop expanding items in the current folder
-        m_detailsViewExpander->stop();
-    }
 }
 
 QAbstractItemView* DolphinView::ViewAccessor::itemView() const
@@ -1524,11 +1499,6 @@ KUrl DolphinView::ViewAccessor::rootUrl() const
     return (m_columnsContainer != 0) ? m_columnsContainer->rootUrl() : KUrl();
 }
 
-KDirLister* DolphinView::ViewAccessor::rootDirLister() const
-{
-    return static_cast<DolphinModel*>(m_proxyModel->sourceModel())->dirLister();
-}
-
 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
 {
     return m_iconsView != 0;
@@ -1552,6 +1522,11 @@ QSet<KUrl> DolphinView::ViewAccessor::expandedUrls() const
 const DolphinDetailsViewExpander* DolphinView::ViewAccessor::setExpandedUrls(const QSet<KUrl>& urlsToExpand)
 {
     if ((m_detailsView != 0) && m_detailsView->itemsExpandable() && !urlsToExpand.isEmpty()) {
+        // Check if another expander is already active and stop it if necessary.
+        if(!m_detailsViewExpander.isNull()) {
+            m_detailsViewExpander->stop();
+        }
+
         m_detailsViewExpander = new DolphinDetailsViewExpander(m_detailsView, urlsToExpand);
         return m_detailsViewExpander;
     }
@@ -1602,8 +1577,6 @@ void DolphinView::restoreContentsPosition()
         Q_ASSERT(view != 0);
         view->horizontalScrollBar()->setValue(x);
         view->verticalScrollBar()->setValue(y);
-
-        m_loadingDirectory = false;
     }
 }