]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.h
Restore the "Edit->Selection" menu from Konqueror 3 for file
[dolphin.git] / src / dolphinview.h
index 08fe70e5f116cf92686dc20c00ffd1a1f8cbb8f9..97054b7542c8f6fbde3965125d37d0dc078ec88b 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at>             *
  *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -53,8 +53,8 @@ class KAction;
 class KActionCollection;
 class KDirLister;
 class KUrl;
-class VersionControlObserver;
 class ViewProperties;
+class DolphinDetailsViewExpander;
 
 /**
  * @short Represents a view for the directory content.
@@ -181,24 +181,6 @@ public:
      */
     bool supportsCategorizedSorting() const;
 
-    /**
-     * Selects all items.
-     * @see DolphinView::selectedItems()
-     */
-    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();
-
     /**
      * Returns the selected items. The list is empty if no item has been
      * selected.
@@ -219,6 +201,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
@@ -226,6 +210,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;
 
@@ -357,6 +348,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,6 +365,24 @@ public slots:
      */
     void setUrl(const KUrl& url);
 
+    /**
+     * Selects all items.
+     * @see DolphinView::selectedItems()
+     */
+    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();
+
     /**
      * 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
@@ -390,7 +409,7 @@ public slots:
 
     /**
      * Copies all selected items to the clipboard and marks
-     * the items as cutted.
+     * the items as cut.
      */
     void cutSelectedItems();
 
@@ -560,7 +579,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:
@@ -671,16 +689,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
@@ -702,6 +719,17 @@ private slots:
      */
     void restoreSelection();
 
+    /**
+     * 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 restoreContentsPosition();
+
 private:
     void loadDirectory(const KUrl& url, bool reload = false);
 
@@ -719,8 +747,6 @@ private:
 
     void deleteView();
 
-    void initializeView();
-
     /**
      * Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
      * Pastes the clipboard data into the URL \a url.
@@ -764,6 +790,7 @@ private:
     {
     public:
         ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
+        ~ViewAccessor();
 
         void createView(QWidget* parent, DolphinController* controller, Mode mode);
         void deleteView();
@@ -787,8 +814,9 @@ private:
         KUrl rootUrl() 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
@@ -806,6 +834,8 @@ private:
         DolphinDetailsView* m_detailsView;
         DolphinColumnViewContainer* m_columnsContainer;
         DolphinSortFilterProxyModel* m_proxyModel;
+        QAbstractItemView* m_dragSource;
+        QPointer<DolphinDetailsViewExpander> m_detailsViewExpander;
     };
 
     bool m_active : 1;
@@ -816,6 +846,7 @@ 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;
 
@@ -825,13 +856,12 @@ private:
     DolphinController* m_controller;
     ViewAccessor m_viewAccessor;
 
-    QItemSelectionModel* m_selectionModel;
+    QItemSelectionModel* m_selectionModel; // allow to switch views without losing the selection
     QTimer* m_selectionChangedTimer;
 
-    VersionControlObserver* m_versionControlObserver;
-
     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
 
@@ -841,8 +871,6 @@ private:
      * slotDirListerCompleted().
      */
     QSet<QString> m_newFileNames;
-
-    QAbstractItemView* m_expandedDragSource; // TODO: move to ViewAccessor
 };
 
 /// Allow using DolphinView::Mode in QVariant