]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.h
don't lose the history of the URL navigator if the settings of the Icons View, Detail...
[dolphin.git] / src / dolphinview.h
index fd47e1fae24df9f7bab0e159077ceecc955db5af..b3b20600216b031182ed37e437d6dc47a27a3b49 100644 (file)
 #include <kparts/part.h>
 #include <kfileitem.h>
 #include <kfileitemdelegate.h>
-#include <kfileiconview.h>
 #include <kio/job.h>
 
-#include <urlnavigator.h>
+#include <kurlnavigator.h>
 
-#include <QDropEvent>
-#include <QLinkedList>
-#include <QListView>
-#include <QMouseEvent>
-#include <QVBoxLayout>
-#include <QWidget>
+#include <QtGui/QKeyEvent>
+#include <QtCore/QLinkedList>
+#include <QtGui/QListView>
+#include <QtGui/QBoxLayout>
+#include <QtGui/QWidget>
 
 class DolphinController;
 class FilterBar;
 class KFileItemDelegate;
 class KUrl;
 class KDirModel;
-class UrlNavigator;
+class KUrlNavigator;
+class DolphinColumnView;
 class DolphinDetailsView;
 class DolphinDirLister;
 class DolphinIconsView;
@@ -58,12 +57,13 @@ class ViewProperties;
  * @short Represents a view for the directory content
  *        including the navigation bar, filter bar and status bar.
  *
- * View modes for icons and details are supported. Currently
+ * View modes for icons, details and columns are supported. Currently
  * Dolphin allows to have up to two views inside the main window.
  *
  * @see DolphinIconsView
  * @see DolphinDetailsView
- * @see UrlNavigator
+ * @see DolphinColumnView
+ * @see KUrlNavigator
  * @see DolphinStatusBar
  */
 class DolphinView : public QWidget
@@ -71,12 +71,12 @@ class DolphinView : public QWidget
     Q_OBJECT
 
 public:
-       /**
-     * Defines the view mode for a directory. The view mode
-     * can be defined when constructing a DolphinView. The
-     * view mode is automatically updated if the directory itself
-     * defines a view mode (see class ViewProperties for details).
-     */
+    /**
+        * Defines the view mode for a directory. The view mode
+        * can be defined when constructing a DolphinView. The
+        * view mode is automatically updated if the directory itself
+        * defines a view mode (see class ViewProperties for details).
+        */
     enum Mode
     {
         /**
@@ -90,7 +90,12 @@ public:
          * for date, group and permissions.
          */
         DetailsView = 1,
-        MaxModeEnum = DetailsView
+
+        /**
+         * Each folder is shown in a separate column.
+         */
+        ColumnView = 2,
+        MaxModeEnum = ColumnView
     };
 
     /** Defines the sort order for the items of a directory. */
@@ -102,7 +107,8 @@ public:
         SortByPermissions,
         SortByOwner,
         SortByGroup,
-        MaxSortEnum = SortByGroup
+        SortByType,
+        MaxSortEnum = SortByType
     };
 
     DolphinView(DolphinMainWindow* mainwindow,
@@ -115,7 +121,7 @@ public:
 
     /**
      * Sets the current active URL.
-     * The signals UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+     * The signals KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
      * are emitted.
      */
     void setUrl(const KUrl& url);
@@ -158,6 +164,24 @@ public:
     void setShowHiddenFiles(bool show);
     bool showHiddenFiles() const;
 
+    /**
+     * Summarizes all sorted items by their category \a categorized
+     * is true.
+     * If the view properties should be remembered for each directory
+     * (GeneralSettings::globalViewProps() returns false), then the
+     * categorized sorting setting will be be stored automatically.
+     */
+    void setCategorizedSorting(bool categorized);
+    bool categorizedSorting() const;
+
+    /**
+     * Returns true, if the categorized sorting is supported by the current
+     * used mode (see DolphinView::setMode()). Currently only DolphinView::IconsView
+     * supports categorizations. To check whether the categorized
+     * sorting is set, use DolphinView::categorizedSorting().
+     */
+    bool supportsCategorizedSorting() const;
+
     /**
      * Triggers the renaming of the currently selected items, where
      * the user must input a new name for the items.
@@ -179,28 +203,28 @@ public:
 
     /**
      * Goes back one step in the URL history. The signals
-     * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+     * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
      * are submitted.
      */
     void goBack();
 
     /**
      * Goes forward one step in the Url history. The signals
-     * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+     * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
      * are submitted.
      */
     void goForward();
 
     /**
      * Goes up one step of the Url path. The signals
-     * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+     * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
      * are submitted.
      */
     void goUp();
 
     /**
-     * Goes to the home URL. The signals UrlNavigator::urlChanged()
-     * and UrlNavigator::historyChanged() are submitted.
+     * Goes to the home URL. The signals KUrlNavigator::urlChanged()
+     * and KUrlNavigator::historyChanged() are submitted.
      */
     void goHome();
 
@@ -211,14 +235,6 @@ public:
      */
     void setUrlEditable(bool editable);
 
-    /**
-     * Returns the complete URL history. The index 0 indicates the oldest
-     * history element.
-     * @param index     Output parameter which indicates the current
-     *                  index of the location.
-     */
-    const QLinkedList<UrlNavigator::HistoryElem> urlHistory(int& index) const;
-
     /** Returns true, if at least one item is selected. */
     bool hasSelection() const;
 
@@ -268,7 +284,7 @@ public:
 
     /**
      * Returns true, if the URL shown by the navigation bar is editable.
-     * @see UrlNavigator
+     * @see KUrlNavigator
      */
     bool isUrlEditable() const;
 
@@ -308,11 +324,11 @@ public:
     /** Returns the additional information which should be shown for the items. */
     KFileItemDelegate::AdditionalInformation additionalInfo() const;
 
-    /** Refreshs the view settings by reading out the stored settings. */
-    void refreshSettings();
-
-    /** Returns the UrlNavigator of the view for read access. */
-    const UrlNavigator* urlNavigator() const { return m_urlNavigator; }
+    /** Returns the KUrlNavigator of the view for read access. */
+    const KUrlNavigator* urlNavigator() const
+    {
+        return m_urlNavigator;
+    }
 
     /**
      * Triggers to request user information for the item given
@@ -334,6 +350,13 @@ public:
     /** Reloads the current directory. */
     void reload();
 
+    /**
+     * Refreshs the view to get synchronized with the (updated) Dolphin settings.
+     * This method only needs to get invoked if the view settings for the Icons View,
+     * Details View or Columns View have been changed.
+     */
+    void refresh();
+
 public slots:
     /**
      * Popups the filter bar above the status bar if \a show is true.
@@ -353,8 +376,13 @@ public slots:
      */
     void requestActivation();
 
-    /** Applies an item effect to all cut items of the clipboard. */
-    void updateCutItems();
+    /**
+     * 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.
+     */
+    void changeSelection(const KFileItemList& selection);
 
 signals:
     /** Is emitted if URL of the view has been changed to \a url. */
@@ -372,6 +400,9 @@ signals:
     /** Is emitted if the 'show hidden files' property has been changed. */
     void showHiddenFilesChanged();
 
+    /** Is emitted if the 'categorized sorting' property has been changed. */
+    void categorizedSortingChanged();
+
     /** Is emitted if the sorting by name, size or date has been changed. */
     void sortingChanged(DolphinView::Sorting sorting);
 
@@ -391,11 +422,9 @@ signals:
     void contentsMoved(int x, int y);
 
     /**
-     * Is emitted whenever the selection has been changed. The current selection can
-     * be retrieved by mainWindow()->activeView()->selectedItems() or by
-     * mainWindow()->activeView()->selectedUrls().
+     * Is emitted whenever the selection has been changed.
      */
-    void selectionChanged();
+    void selectionChanged(const KFileItemList& selection);
 
     /**
      * Is emitted whenever the filter bar has been turned show or hidden.
@@ -407,7 +436,7 @@ protected:
     virtual void mouseReleaseEvent(QMouseEvent* event);
 
 private slots:
-    void loadDirectory(const KUrl& kurl);
+    void changeDirectory(const KUrl& url);
     void triggerItem(const QModelIndex& index);
     void updateProgress(int percent);
 
@@ -428,7 +457,7 @@ private slots:
      * Replaces the icon of the item \a item by the preview pixmap
      * \a pixmap.
      */
-    void showPreview(const KFileItem* item, const QPixmap& pixmap);
+    void showPreview(const KFileItem& item, const QPixmap& pixmap);
 
     /**
      * Restores the x- and y-position of the contents if the
@@ -496,6 +525,9 @@ private slots:
      */
     void updateActivationState();
 
+    /** Applies an item effect to all cut items of the clipboard. */
+    void updateCutItems();
+
 private:
     void startDirLister(const KUrl& url, bool reload = false);
 
@@ -541,8 +573,33 @@ private:
      */
     bool isCutItem(const KFileItem& item) const;
 
+    /** Applies an item effect to all cut items. */
+    void applyCutItemEffect();
+
+    /**
+     * Returns true, if the ColumnView is activated. As the column view
+     * requires some special handling for iterating through directories,
+     * this method has been introduced for convenience.
+     */
+    bool isColumnViewActive() const
+    {
+        return m_columnView != 0;
+    }
+
 private:
+    /**
+     * Remembers the original pixmap for an item before
+     * the cut effect is applied.
+     */
+    struct CutItem
+    {
+        KUrl url;
+        QPixmap pixmap;
+    };
+
     bool m_showProgress;
+    bool m_blockContentsMovedSignal;
+    bool m_initializeColumnView;
     Mode m_mode;
 
     int m_iconSize;
@@ -551,11 +608,12 @@ private:
 
     DolphinMainWindow* m_mainWindow;
     QVBoxLayout* m_topLayout;
-    UrlNavigator* m_urlNavigator;
+    KUrlNavigator* m_urlNavigator;
 
     DolphinController* m_controller;
     DolphinIconsView* m_iconsView;
     DolphinDetailsView* m_detailsView;
+    DolphinColumnView* m_columnView;
     KFileItemDelegate* m_fileItemDelegate;
 
     FilterBar* m_filterBar;
@@ -564,6 +622,8 @@ private:
     KDirModel* m_dirModel;
     DolphinDirLister* m_dirLister;
     DolphinSortFilterProxyModel* m_proxyModel;
+
+    QList<CutItem> m_cutItemsCache;
 };
 
 #endif // _DOLPHINVIEW_H_