]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.h
- allow the view implementations to attach custom actions to the context menu
[dolphin.git] / src / dolphincontroller.h
index 4e8885ef920b3d80d1aadf2a11f5a11cb8afd573..29dd7dfb1bfcc56dd7fa9d03226e88914a2a640e 100644 (file)
@@ -60,10 +60,12 @@ class QWidget;
  * - indicateSortingChange()
  * - indicateSortOrderChanged()
  * - triggerItem()
+ * - requestTab()
  * - handleKeyPressEvent()
  * - emitItemEntered()
  * - emitViewportEntered()
  * - replaceUrlByClipboard()
+ * - hideToolTip()
  *
  * The communication of the abstract view to the view implementations is done by:
  * - setUrl()
@@ -81,7 +83,7 @@ public:
     virtual ~DolphinController();
 
     /**
-     * Allows read access for the the view implementation to the abstract
+     * Allows read access for the view implementation to the abstract
      * Dolphin view.
      */
     const DolphinView* dolphinView() const;
@@ -119,9 +121,11 @@ public:
      * should be invoked by the view implementation when a context
      * menu should be opened. The abstract Dolphin view itself
      * takes care itself to get the selected items depending from
-     * \a pos.
+     * \a pos. It is possible to define a custom list of actions for
+     * the context menu by \a customActions.
      */
-    void triggerContextMenuRequest(const QPoint& pos);
+    void triggerContextMenuRequest(const QPoint& pos,
+                                   const QList<QAction*>& customActions = QList<QAction*>());
 
     /**
      * Requests an activation of the view and emits the signal
@@ -136,13 +140,13 @@ public:
      * Indicates that URLs are dropped above a destination. This method
      * should be invoked by the view implementation. The abstract Dolphin view
      * will start the corresponding action (copy, move, link).
-     * @param urls      URLs that are dropped above a destination.
+     * @param destItem  Item of the destination (can be null, see KFileItem::isNull()).
      * @param destPath  Path of the destination.
-     * @param destItem  Destination item (can be null, see KFileItem::isNull()).
+     * @param event     Drop event
      */
-    void indicateDroppedUrls(const KUrl::List& urls,
+    void indicateDroppedUrls(const KFileItem& destItem,
                              const KUrl& destPath,
-                             const KFileItem& destItem);
+                             QDropEvent* event);
 
     /**
      * Informs the abstract Dolphin view about a sorting change done inside
@@ -177,23 +181,13 @@ public:
 
     /**
      * Sets the zoom level to \a level and emits the signal zoomLevelChanged().
-     * It must be assured that the used level is inside the range 
+     * It must be assured that the used level is inside the range
      * DolphinController::zoomLevelMinimum() and
      * DolphinController::zoomLevelMaximum().
      * Is invoked by the abstract Dolphin view.
      */
     void setZoomLevel(int level);
     int zoomLevel() const;
-    
-    int zoomLevelMinimum() const;
-    int zoomLevelMaximum() const;
-    
-    /**
-     * Helper method for the view implementation to get
-     * the icon size for the zoom level \a level
-     * (see DolphinController::zoomLevel()).
-     */
-    static int iconSizeForZoomLevel(int level);
 
     /**
      * Tells the view implementation to zoom out by emitting the signal zoomOut()
@@ -215,6 +209,19 @@ public:
      */
     void replaceUrlByClipboard();
 
+    /** Emits the signal hideToolTip(). */
+    void emitHideToolTip();
+
+    /**
+     * Emits the signal itemTriggered() for the item \a item.
+     * The method can be used by the view implementations to
+     * trigger an item directly without mouse interaction.
+     * If the item triggering is done by the mouse, it is recommended
+     * to use QAbstractItemView::triggerItem(), as this will check
+     * the used mouse buttons to execute the correct action.
+     */
+    void emitItemTriggered(const KFileItem& item);
+
     /**
      * Returns the file item for the proxy index \a index of the view \a view.
      */
@@ -223,11 +230,21 @@ public:
 public slots:
     /**
      * Emits the signal itemTriggered() if the file item for the index \a index
-     * is not null. The method should be invoked by the
-     * controller parent whenever the user has triggered an item.
+     * is not null and the left mouse button has been pressed. If the item is
+     * null, the signal itemEntered() is emitted.
+     * The method should be invoked by the view implementations whenever the
+     * user has triggered an item with the mouse (see
+     * QAbstractItemView::clicked() or QAbstractItemView::doubleClicked()).
      */
     void triggerItem(const QModelIndex& index);
 
+    /**
+     * Emits the signal tabRequested(), if the file item for the index \a index
+     * represents a directory and when the middle mouse button has been pressed.
+     * The method should be invoked by the controller parent.
+     */
+    void requestTab(const QModelIndex& index);
+
     /**
      * Emits the signal itemEntered() if the file item for the index \a index
      * is not null. The method should be invoked by the controller parent
@@ -257,12 +274,14 @@ signals:
     /**
      * Is emitted if a context menu should be opened (see triggerContextMenuRequest()).
      * The abstract Dolphin view connects to this signal and will open the context menu.
-     * @param pos       Position relative to the view widget where the
-     *                  context menu should be opened. It is recommended
-     *                  to get the corresponding model index from
-     *                  this position.
+     * @param pos           Position relative to the view widget where the
+     *                      context menu should be opened. It is recommended
+     *                      to get the corresponding model index from
+     *                      this position.
+     * @param customActions List of actions that is added to the context menu when
+     *                      the menu is opened above the viewport.
      */
-    void requestContextMenu(const QPoint& pos);
+    void requestContextMenu(const QPoint& pos, QList<QAction*> customActions);
 
     /**
      * Is emitted if the view has been activated by e. g. a mouse click.
@@ -272,14 +291,14 @@ signals:
     void activated();
 
     /**
-     * Is emitted if the URLs \a urls have been dropped to the destination
+     * Is emitted if URLs have been dropped to the destination
      * path \a destPath. If the URLs have been dropped above an item of
      * the destination path, the item is indicated by \a destItem
      * (can be null, see KFileItem::isNull()).
      */
-    void urlsDropped(const KUrl::List& urls,
+    void urlsDropped(const KFileItem& destItem,
                      const KUrl& destPath,
-                     const KFileItem& destItem);
+                     QDropEvent* event);
 
     /**
      * Is emitted if the sorting has been changed to \a sorting by
@@ -345,12 +364,17 @@ signals:
      */
     void zoomLevelChanged(int level);
 
+    /**
+     * Is emitted if the abstract view should hide an open tooltip.
+     */
+    void hideToolTip();
+
 private slots:
-    void updateOpenTabState();
+    void updateMouseButtonState();
 
 private:
     int m_zoomLevel;
-    bool m_openTab; // TODO: this is a workaround until  Qt-issue 176832 has been fixed
+    static Qt::MouseButtons m_mouseButtons; // TODO: this is a workaround until  Qt-issue 176832 has been fixed
     KUrl m_url;
     DolphinView* m_dolphinView;
     QAbstractItemView* m_itemView;
@@ -376,14 +400,4 @@ inline int DolphinController::zoomLevel() const
     return m_zoomLevel;
 }
 
-inline int DolphinController::zoomLevelMinimum() const
-{
-    return 0;
-}
-
-inline int DolphinController::zoomLevelMaximum() const
-{
-    return 6;
-}
-
 #endif