]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.h
assure that the widgets of the panels are resized after receiving the Polish event
[dolphin.git] / src / dolphinview.h
index 822eb52b01281de855946db981ae0969984808f5..17f1395acf8bf5acd6a96335ff3943f9dfea8410 100644 (file)
@@ -45,7 +45,6 @@ class DolphinController;
 class DolphinColumnViewContainer;
 class DolphinDetailsView;
 class DolphinIconsView;
-class DolphinMainWindow;
 class DolphinModel;
 class DolphinSortFilterProxyModel;
 class KFilePreviewGenerator;
@@ -54,6 +53,7 @@ class KActionCollection;
 class KDirLister;
 class KUrl;
 class ViewProperties;
+class DolphinDetailsViewExpander;
 
 /**
  * @short Represents a view for the directory content.
@@ -112,9 +112,7 @@ public:
         SortByOwner,
         SortByGroup,
         SortByType,
-        SortByRating,
-        SortByTags,
-        MaxSortEnum = SortByTags
+        MaxSortEnum = SortByType
     };
 
     /**
@@ -181,22 +179,12 @@ public:
     bool supportsCategorizedSorting() const;
 
     /**
-     * Selects all items.
-     * @see DolphinView::selectedItems()
+     * Marks the items indicated by \p urls to get selected after the
+     * directory DolphinView::url() has been loaded. Note that nothing
+     * gets selected if no loading of a directory has been triggered
+     * by DolphinView::setUrl() or DolphinView::reload().
      */
-    void selectAll();
-
-    /**
-     * Inverts the current selection: selected items get unselected,
-     * unselected items get selected.
-     * @see DolphinView::selectedItems()
-     */
-    void invertSelection();
-
-    /** Returns true, if at least one item is selected. */
-    bool hasSelection() const;
-
-    void clearSelection();
+    void markUrlsAsSelected(const QList<KUrl>& urls);
 
     /**
      * Returns the selected items. The list is empty if no item has been
@@ -218,6 +206,8 @@ public:
      */
     int selectedItemsCount() const;
 
+    QItemSelectionModel* selectionModel() const;
+
     /**
      * Sets the upper left position of the view content
      * to (x,y). The content of the view might be larger than the visible area
@@ -225,6 +215,13 @@ public:
      */
     void setContentsPosition(int x, int y);
 
+    /**
+     * Sets the upper left position of the view content
+     * to (x,y) after the directory loading is finished.
+     * This is useful when going back or forward in history.
+     */
+    void setRestoredContentsPosition(const QPoint& pos);
+
     /** Returns the upper left position of the view content. */
     QPoint contentsPosition() const;
 
@@ -356,6 +353,16 @@ public:
      */
     bool itemsExpandable() const;
 
+    /**
+     * Restores the view state (current item, contents position, details view expansion state)
+     */
+    void restoreState(QDataStream &stream);
+
+    /**
+     * Saves the view state (current item, contents position, details view expansion state)
+     */
+    void saveState(QDataStream &stream);
+
 public slots:
     /**
      * Changes the directory to \a url. If the current directory is equal to
@@ -364,12 +371,22 @@ public slots:
     void setUrl(const KUrl& url);
 
     /**
-     * Request of a selection change. The view will do its best to accommodate
-     * the request, but it is not guaranteed that all items in \a selection
-     * will actually get selected. The view will e.g. not select items which
-     * are not in the currently displayed folder.
+     * Selects all items.
+     * @see DolphinView::selectedItems()
      */
-    void changeSelection(const KFileItemList& selection);
+    void selectAll();
+
+    /**
+     * Inverts the current selection: selected items get unselected,
+     * unselected items get selected.
+     * @see DolphinView::selectedItems()
+     */
+    void invertSelection();
+
+    /** Returns true, if at least one item is selected. */
+    bool hasSelection() const;
+
+    void clearSelection();
 
     /**
      * Triggers the renaming of the currently selected items, where
@@ -389,7 +406,7 @@ public slots:
 
     /**
      * Copies all selected items to the clipboard and marks
-     * the items as cutted.
+     * the items as cut.
      */
     void cutSelectedItems();
 
@@ -559,7 +576,6 @@ signals:
 protected:
     /** @see QWidget::mouseReleaseEvent */
     virtual void mouseReleaseEvent(QMouseEvent* event);
-    virtual void wheelEvent(QWheelEvent* event);
     virtual bool eventFilter(QObject* watched, QEvent* event);
 
 private slots:
@@ -583,7 +599,7 @@ private slots:
      * the signal is emitted only after no selection change has been done
      * within a small delay.
      */
-    void emitDelayedSelectionChangedSignal();
+    void slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
 
     /**
      * Is called by emitDelayedSelectionChangedSignal() and emits the
@@ -670,16 +686,15 @@ private slots:
     void slotDirListerCompleted();
 
     /**
-     * Is invoked when the KDirLister indicates refreshed items.
+     * Invoked when the loading of the directory is finished.
+     * Restores the active item and the scroll position if possible.
      */
-    void slotRefreshItems();
+    void slotLoadingCompleted();
 
     /**
-     * If \a view can be positively identified as not being the source for the
-     * current drag operation, deleteLater() it immediately.  Else stores
-     * it for later deletion.
+     * Is invoked when the KDirLister indicates refreshed items.
      */
-    void deleteWhenNotDragSource(QAbstractItemView* view);
+    void slotRefreshItems();
 
     /**
      * Observes the item with the URL \a url. As soon as the directory
@@ -697,9 +712,15 @@ private slots:
     void selectAndScrollToCreatedItem();
 
     /**
-     * Restore selection after view refresh.
+     * Called when a redirection happens.
+     * Testcase: fish://localhost
+     */
+    void slotRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+
+    /**
+     * Restores the contents position, if history information about the old position is available.
      */
-    void restoreSelection();
+    void restoreContentsPosition();
 
 private:
     void loadDirectory(const KUrl& url, bool reload = false);
@@ -761,6 +782,7 @@ private:
     {
     public:
         ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
+        ~ViewAccessor();
 
         void createView(QWidget* parent, DolphinController* controller, Mode mode);
         void deleteView();
@@ -782,10 +804,12 @@ private:
         QWidget* layoutTarget() const;
 
         KUrl rootUrl() const;
+        KDirLister* rootDirLister() const;
 
         bool supportsCategorizedSorting() const;
-        bool hasExpandableFolders() const;
         bool itemsExpandable() const;
+        QSet<KUrl> expandedUrls() const;
+        const DolphinDetailsViewExpander* setExpandedUrls(const QSet<KUrl>& urlsToExpand);
 
         /**
          * Returns true, if a reloading of the items is required
@@ -803,6 +827,8 @@ private:
         DolphinDetailsView* m_detailsView;
         DolphinColumnViewContainer* m_columnsContainer;
         DolphinSortFilterProxyModel* m_proxyModel;
+        QAbstractItemView* m_dragSource;
+        QPointer<DolphinDetailsViewExpander> m_detailsViewExpander;
     };
 
     bool m_active : 1;
@@ -813,10 +839,10 @@ private:
     bool m_isContextMenuOpen : 1;   // TODO: workaround for Qt-issue 207192
     bool m_ignoreViewProperties : 1;
     bool m_assureVisibleCurrentIndex : 1;
+    bool m_expanderActive : 1;
 
     Mode m_mode;
 
-    DolphinMainWindow* m_mainWindow;
     QVBoxLayout* m_topLayout;
 
     DolphinController* m_controller;
@@ -827,6 +853,7 @@ private:
 
     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
     KFileItemList m_selectedItems; // this is used for making the View to remember selections after F5
 
@@ -836,8 +863,6 @@ private:
      * slotDirListerCompleted().
      */
     QSet<QString> m_newFileNames;
-
-    QAbstractItemView* m_expandedDragSource; // TODO: move to ViewAccessor
 };
 
 /// Allow using DolphinView::Mode in QVariant