]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Reorganise some code in DolphinView and DolphinViewContainer. This
authorFrank Reininghaus <frank78ac@googlemail.com>
Tue, 26 Jan 2010 12:18:08 +0000 (12:18 +0000)
committerFrank Reininghaus <frank78ac@googlemail.com>
Tue, 26 Jan 2010 12:18:08 +0000 (12:18 +0000)
makes it possible to restore the expanded folders in the Details View
when navigating in history (based on r1056438 and r1079843).

Also remove DolphinView::activateItem(const KUrl&) and DolphinView's
m_loadingDirectory member (they are not needed any more).

This will be in KDE 4.5.

BUG: 169886

svn path=/trunk/KDE/kdebase/apps/; revision=1080549

src/dolphinview.cpp
src/dolphinview.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index 21404745084c648207a179db5f6c9be41c0c4189..a2689b8c8bb664e21313f935617ccb6507381af2 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),
@@ -1025,13 +1024,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();
@@ -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,7 +1209,6 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
         return;
     }
 
-    m_loadingDirectory = true;
     m_expanderActive = false;
 
     KDirLister* dirLister = m_viewAccessor.dirLister();
@@ -1482,11 +1472,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
@@ -1552,6 +1537,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 +1592,6 @@ void DolphinView::restoreContentsPosition()
         Q_ASSERT(view != 0);
         view->horizontalScrollBar()->setValue(x);
         view->verticalScrollBar()->setValue(y);
-
-        m_loadingDirectory = false;
     }
 }
 
index 6c2f9aaf29b53fd3f82144050c1a1c354c535b87..cbbea498f3f9aba3b3a49928516b8e822ec5aa5d 100644 (file)
@@ -311,15 +311,6 @@ public:
     void setTabsForFilesEnabled(bool tabsForFiles);
     bool isTabsForFilesEnabled() const;
 
-    /**
-     * Marks the item \a url as active item as soon as it has
-     * been loaded by the directory lister. This is useful mark
-     * the previously visited directory as active when going
-     * back in history (the URL is known, but the item is not
-     * loaded yet).
-     */
-    void activateItem(const KUrl& url);
-
     /**
      * Returns true if the current view allows folders to be expanded,
      * i.e. presents a hierarchical view to the user.
@@ -797,7 +788,6 @@ private:
 
     bool m_active : 1;
     bool m_showPreview : 1;
-    bool m_loadingDirectory : 1;
     bool m_storedCategorizedSorting : 1;
     bool m_tabsForFiles : 1;
     bool m_isContextMenuOpen : 1;   // TODO: workaround for Qt-issue 207192
index 8f4427cb9dec8a451b8a4221f742ea7924320a87..89cf6cdbd0a7eda65c54e99a1cdf59b121e67c9b 100644 (file)
@@ -307,7 +307,6 @@ void DolphinViewContainer::slotDirListerCompleted()
     } else {
         updateStatusBar();
     }
-    QMetaObject::invokeMethod(this, "restoreViewState", Qt::QueuedConnection);
 
     // Enable the 'File'->'Create New...' menu only if the directory
     // supports writing.
@@ -369,13 +368,6 @@ void DolphinViewContainer::setNameFilter(const QString& nameFilter)
     delayedStatusBarUpdate();
 }
 
-void DolphinViewContainer::restoreViewState()
-{
-    QByteArray locationState = m_urlNavigator->locationState();
-    QDataStream stream(&locationState, QIODevice::ReadOnly);
-    m_view->restoreState(stream);
-}
-
 void DolphinViewContainer::activate()
 {
     setActive(true);
@@ -458,12 +450,11 @@ void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion com
 
 void DolphinViewContainer::slotHistoryChanged()
 {
-    const int index = m_urlNavigator->historyIndex();
-    if (index > 0) {       
-        // The "Go Forward" action is enabled. Try to mark
-        // the previous directory as active item:
-        const KUrl url = m_urlNavigator->locationUrl(index - 1);
-        m_view->activateItem(url);
+    QByteArray locationState = m_urlNavigator->locationState();
+
+    if (!locationState.isEmpty()) {
+        QDataStream stream(&locationState, QIODevice::ReadOnly);
+        m_view->restoreState(stream);
     }
 }
 
index ce5badfa286bc9224e649bb923bc6646d2bbeb13..50d7c94613af51ac2d9773638a26eb1bc8301a6f 100644 (file)
@@ -185,8 +185,6 @@ private slots:
      */
     void setNameFilter(const QString& nameFilter);
 
-    void restoreViewState();
-
     /**
      * Marks the view container as active
      * (see DolphinViewContainer::setActive()).