]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Remember the root-URL when saving the state of a view. This allows to restore a colum...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 8 Nov 2010 18:05:36 +0000 (18:05 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 8 Nov 2010 18:05:36 +0000 (18:05 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1194323

src/views/dolphinview.cpp
src/views/dolphinview.h
src/views/viewmodecontroller.h

index 2c2dbc23144be83fee9f4338cfc057716cd90ce9..101f98724b3f0a783da87598661eb46214b9918b 100644 (file)
@@ -83,7 +83,6 @@ DolphinView::DolphinView(QWidget* parent,
     m_viewModeController(0),
     m_viewAccessor(proxyModel),
     m_selectionChangedTimer(0),
-    m_rootUrl(),
     m_activeItemUrl(),
     m_restoredContentsPosition(),
     m_createdItemUrl(),
@@ -904,13 +903,18 @@ bool DolphinView::itemsExpandable() const
 
 void DolphinView::restoreState(QDataStream& stream)
 {
-    // current item
+    // Restore the URL of the current item that had the keyboard focus
     stream >> m_activeItemUrl;
 
-    // view position
+    // Restore the root URL
+    KUrl rootUrl;
+    stream >> rootUrl;
+    m_viewAccessor.setRootUrl(rootUrl);
+
+    // Restore the view position
     stream >> m_restoredContentsPosition;
 
-    // expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
+    // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
     QSet<KUrl> urlsToExpand;
     stream >> urlsToExpand;
     const DolphinDetailsViewExpander* expander = m_viewAccessor.setExpandedUrls(urlsToExpand);
@@ -925,7 +929,7 @@ void DolphinView::restoreState(QDataStream& stream)
 
 void DolphinView::saveState(QDataStream& stream)
 {
-    // current item
+    // Save the URL of the current item that has the keyboard focus
     KFileItem currentItem;
     const QAbstractItemView* view = m_viewAccessor.itemView();
 
@@ -935,19 +939,22 @@ void DolphinView::saveState(QDataStream& stream)
         currentItem = m_viewAccessor.dirModel()->itemForIndex(dirModelIndex);
     }
 
-    KUrl currentUrl;
+    KUrl currentItemUrl;
     if (!currentItem.isNull()) {
-        currentUrl = currentItem.url();
+        currentItemUrl = currentItem.url();
     }
 
-    stream << currentUrl;
+    stream << currentItemUrl;
+
+    // Save the root URL
+    stream << m_viewAccessor.rootUrl();
 
-    // view position
+    // Save view position
     const int x = view->horizontalScrollBar()->value();
     const int y = view->verticalScrollBar()->value();
     stream << QPoint(x, y);
 
-    // expanded folders (only relevant for the details view - the set will be empty in other view modes)
+    // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
     stream << m_viewAccessor.expandedUrls();
 }
 
@@ -1106,6 +1113,7 @@ void DolphinView::applyViewProperties()
     if (m_viewAccessor.itemView() == 0) {
         createView();
     }
+
     Q_ASSERT(m_viewAccessor.itemView() != 0);
     Q_ASSERT(m_viewAccessor.itemDelegate() != 0);
 
@@ -1282,6 +1290,7 @@ QItemSelection DolphinView::childrenMatchingPattern(const QModelIndex& parent, c
 }
 
 DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel* proxyModel) :
+    m_rootUrl(),
     m_iconsView(0),
     m_detailsView(0),
     m_columnsContainer(0),
@@ -1322,6 +1331,12 @@ void DolphinView::ViewAccessor::createView(QWidget* parent,
         m_columnsContainer = new DolphinColumnViewContainer(parent,
                                                             dolphinViewController,
                                                             viewModeController);
+        if (!m_rootUrl.isEmpty() && m_rootUrl.isParentOf(viewModeController->url())) {
+            // The column-view must show several columns starting with m_rootUrl as
+            // first column and viewModeController->url() as last column.
+            m_columnsContainer->showColumn(m_rootUrl);
+            m_columnsContainer->showColumn(viewModeController->url());
+        }
         break;
 
     default:
@@ -1365,7 +1380,6 @@ void DolphinView::ViewAccessor::deleteView()
     }
 }
 
-
 void DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url)
 {
     if (m_columnsContainer != 0) {
@@ -1403,9 +1417,14 @@ QWidget* DolphinView::ViewAccessor::layoutTarget() const
     return itemView();
 }
 
+void DolphinView::ViewAccessor::setRootUrl(const KUrl& rootUrl)
+{
+    m_rootUrl = rootUrl;
+}
+
 KUrl DolphinView::ViewAccessor::rootUrl() const
 {
-    return (m_columnsContainer != 0) ? m_columnsContainer->rootUrl() : KUrl();
+    return (m_columnsContainer != 0) ? m_columnsContainer->rootUrl() : m_rootUrl;
 }
 
 bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
@@ -1418,7 +1437,6 @@ bool DolphinView::ViewAccessor::itemsExpandable() const
     return (m_detailsView != 0) && m_detailsView->itemsExpandable();
 }
 
-
 QSet<KUrl> DolphinView::ViewAccessor::expandedUrls() const
 {
     if (m_detailsView != 0) {
index 5fcf1ab4de861606b120b254d874fc89e14885bb..d513eba1b17c167af8d40f0b8be401711f3ca39e 100644 (file)
@@ -756,6 +756,7 @@ private:
          */
         QWidget* layoutTarget() const;
 
+        void setRootUrl(const KUrl& rootUrl);
         KUrl rootUrl() const;
 
         bool supportsCategorizedSorting() const;
@@ -775,6 +776,7 @@ private:
         KDirLister* dirLister() const;
 
     private:
+        KUrl m_rootUrl;
         DolphinIconsView* m_iconsView;
         DolphinDetailsView* m_detailsView;
         DolphinColumnViewContainer* m_columnsContainer;
@@ -801,7 +803,6 @@ private:
 
     QTimer* m_selectionChangedTimer;
 
-    KUrl m_rootUrl;
     KUrl m_activeItemUrl;
     QPoint m_restoredContentsPosition;
     KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
index c7378d59ad759ad172baed9fe98de78cdbb75bcd..9435a21e645860b2c9d07551c6b4ee44b81828f6 100644 (file)
@@ -77,7 +77,7 @@ public:
      * Requests the view mode implementation to hide tooltips.
      */
     void requestToolTipHiding();
-    
+
 public slots:
     /**
      * Sets the URL to \a url and emits the signals cancelPreviews() and