]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.h
fix issue that the view properties are not read out correctly for first directory...
[dolphin.git] / src / dolphinview.h
index 5b820fe8e631b02220afebc2420e4f366d7ee8e7..f6b85f96b74e9cee4d9abdb2a889328934d7f39f 100644 (file)
 
 #include <kparts/part.h>
 #include <kfileitem.h>
-#include <kfileiconview.h>
+#include <kfileitemdelegate.h>
 #include <kio/job.h>
 
-#include <urlnavigator.h>
+#include <kurlnavigator.h>
 
 #include <QDropEvent>
 #include <QLinkedList>
 
 class DolphinController;
 class FilterBar;
+class KFileItemDelegate;
 class KUrl;
 class KDirModel;
-class UrlNavigator;
+class KUrlNavigator;
+class DolphinColumnView;
 class DolphinDetailsView;
 class DolphinDirLister;
 class DolphinIconsView;
@@ -56,12 +58,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
@@ -69,12 +72,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
     {
         /**
@@ -88,7 +91,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. */
@@ -113,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);
@@ -156,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.
@@ -177,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();
 
@@ -209,19 +235,11 @@ 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.
-     */
+    /** 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.
@@ -248,7 +266,6 @@ public:
      */
     void rename(const KUrl& source, const QString& newName);
 
-    /** Returns the status bar of the view. */
     DolphinStatusBar* statusBar() const;
 
     /**
@@ -267,7 +284,7 @@ public:
 
     /**
      * Returns true, if the URL shown by the navigation bar is editable.
-     * @see UrlNavigator
+     * @see KUrlNavigator
      */
     bool isUrlEditable() const;
 
@@ -301,11 +318,17 @@ public:
     /** Returns the current used sort order (Qt::Ascending or Qt::Descending). */
     Qt::SortOrder sortOrder() const;
 
-    /** Refreshs the view settings by reading out the stored settings. */
-    void refreshSettings();
+    /** Sets the additional information which should be shown for the items. */
+    void setAdditionalInfo(KFileItemDelegate::AdditionalInformation info);
 
-    /** Returns the UrlNavigator of the view for read access. */
-    const UrlNavigator* urlNavigator() const { return m_urlNavigator; }
+    /** Returns the additional information which should be shown for the items. */
+    KFileItemDelegate::AdditionalInformation additionalInfo() const;
+
+    /** 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
@@ -327,11 +350,6 @@ public:
     /** Reloads the current directory. */
     void reload();
 
-    /**
-     * Declare this View as the activeview of the mainWindow()
-     */
-    void declareViewActive();
-
 public slots:
     /**
      * Popups the filter bar above the status bar if \a show is true.
@@ -351,6 +369,14 @@ public slots:
      */
     void requestActivation();
 
+    /**
+     * Request of a selection change. The view will do its best to accomodate
+     * 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. */
     void urlChanged(const KUrl& url);
@@ -367,12 +393,18 @@ 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);
 
     /** Is emitted if the sort order (ascending or descending) has been changed. */
     void sortOrderChanged(Qt::SortOrder order);
 
+    /** Is emitted if the addtional information for an item has been changed. */
+    void additionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
+
     /**
      * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
      * It the URL is empty, no item information request is pending.
@@ -383,11 +415,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.
@@ -399,7 +429,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);
 
@@ -409,6 +439,19 @@ private slots:
      */
     void updateItemCount();
 
+    /**
+     * Generates a preview image for each file item in \a items.
+     * The current preview settings (maximum size, 'Show Preview' menu)
+     * are respected.
+     */
+    void generatePreviews(const KFileItemList& items);
+
+    /**
+     * Replaces the icon of the item \a item by the preview pixmap
+     * \a pixmap.
+     */
+    void showPreview(const KFileItem* item, const QPixmap& pixmap);
+
     /**
      * Restores the x- and y-position of the contents if the
      * current view is part of the history.
@@ -438,13 +481,19 @@ private slots:
     void openContextMenu(const QPoint& pos);
 
     /**
-     * Drops the URLs \a urls at the position \a pos.
-     * The position is used to check whether the dropping
-     * is done above an item or above the viewport.
+     * Drops the URLs \a urls to the index \a index. \a source
+     * indicates the widget where the dragging has been started from.
      */
     void dropUrls(const KUrl::List& urls,
-                  const QPoint& pos);
+                  const QModelIndex& index,
+                  QWidget* source);
 
+    /**
+     * Drops the URLs \a urls at the
+     * destination \a destination.
+     */
+    void dropUrls(const KUrl::List& urls,
+                  const KUrl& destination);
     /**
      * Updates the view properties of the current URL to the
      * sorting given by \a sorting.
@@ -457,6 +506,21 @@ private slots:
      */
     void updateSortOrder(Qt::SortOrder order);
 
+    /**
+     * Emits the signal contentsMoved with the current coordinates
+     * of the viewport as parameters.
+     */
+    void emitContentsMoved();
+
+    /**
+     * Updates the activation state of the view by checking whether
+     * the currently active view is this view.
+     */
+    void updateActivationState();
+
+    /** Applies an item effect to all cut items of the clipboard. */
+    void updateCutItems();
+
 private:
     void startDirLister(const KUrl& url, bool reload = false);
 
@@ -473,16 +537,11 @@ private:
     QString selectionStatusBarText() const;
 
     /**
-     * Creates a new view representing the given view mode (DolphinView::viewMode()).
+     * Creates a new view representing the given view mode (DolphinView::mode()).
      * The current view will get deleted.
      */
     void createView();
 
-    /**
-     * Returns the column index used in the KDirModel depending on \a sorting.
-     */
-    int columnIndex(Sorting sorting) const;
-
     /**
      * Selects all items by using the selection flags \a flags. This is a helper
      * method for the slots DolphinView::selectAll() and DolphinView::invertSelection().
@@ -495,8 +554,44 @@ private:
      */
     QAbstractItemView* itemView() const;
 
+    /**
+     * Returns true if the index is valid and represents
+     * the column KDirModel::Name.
+     */
+    bool isValidNameIndex(const QModelIndex& index) const;
+
+    /**
+     * Returns true, if the item \a item has been cut into
+     * the clipboard.
+     */
+    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;
     Mode m_mode;
 
     int m_iconSize;
@@ -505,11 +600,13 @@ 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;
     DolphinStatusBar* m_statusBar;
@@ -517,6 +614,8 @@ private:
     KDirModel* m_dirModel;
     DolphinDirLister* m_dirLister;
     DolphinSortFilterProxyModel* m_proxyModel;
+
+    QList<CutItem> m_cutItemsCache;
 };
 
 #endif // _DOLPHINVIEW_H_