class QAbstractItemView;
class DolphinView;
class KUrl;
-class QBrush;
class QPoint;
-class QRect;
-class QWidget;
// TODO: get rid of all the state duplications in the controller and allow read access
// to the Dolphin view for all view implementations
* - indicateDroppedUrls()
* - indicateSortingChange()
* - indicateSortOrderChanged()
+ * - indicateSortFoldersFirstChanged()
* - triggerItem()
* - requestTab()
* - handleKeyPressEvent()
* - emitItemEntered()
* - emitViewportEntered()
+ * - emitSelectionChanged()
* - replaceUrlByClipboard()
* - hideToolTip()
+ * - setVersionControlActions()
*
* The communication of the abstract view to the view implementations is done by:
* - setUrl()
- * - setShowHiddenFiles()
- * - setShowPreview()
* - indicateActivationChange()
+ * - setNameFilter()
* - setZoomLevel()
+ * - versionControlActions()
*/
class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
{
void setUrl(const KUrl& url);
const KUrl& url() const;
+ /**
+ * Sets the URL to \a url and does nothing else. Called when
+ * a redirection happens.
+ */
+ void redirectToUrl(const KUrl& url);
+
/**
* Changes the current item view where the controller is working. This
* is only necessary for views like the tree view, where internally
* 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
*/
void indicateSortOrderChange(Qt::SortOrder order);
+ /**
+ * Informs the abstract Dolphin view about a change between separate sorting
+ * (with folders first) and mixed sorting of files and folders done inside
+ * the view implementation. This method should be invoked by the view
+ * implementation (e. g. the details view uses this method in combination
+ * with the details header).
+ */
+ void indicateSortFoldersFirstChange(bool foldersFirst);
+
/**
* Informs the abstract Dolphin view about an additional information change
* done inside the view implementation. This method should be invoked by the
/**
* 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;
-
+
+ /**
+ * Sets the available version control actions. Is called by the view
+ * implementation as soon as the controller has send the signal
+ * requestVersionControlActions().
+ */
+ void setVersionControlActions(QList<QAction*> actions);
+
+ /**
+ * Returns the version control actions that are provided for the items \p items.
+ * Is called by the abstract Dolphin view to show the version control actions
+ * inside the context menu.
+ */
+ QList<QAction*> versionControlActions(const KFileItemList& items);
+
+ /**
+ * Sets the name filter to \a and emits the signal nameFilterChanged().
+ */
+ void setNameFilter(const QString& nameFilter);
+ QString nameFilter() const;
+
/**
* Tells the view implementation to zoom out by emitting the signal zoomOut()
* and is invoked by the abstract Dolphin view.
* nothing will be done.
*/
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.
*/
* Emits the signal itemTriggered() if the file item for the index \a index
* 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 controller parent whenever the
- * user has triggered an item.
+ * 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.
+ * The method should be invoked by the view implementation.
*/
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
+ * is not null. The method should be invoked by the view implementation
* whenever the mouse cursor is above an item.
*/
void emitItemEntered(const QModelIndex& index);
/**
* Emits the signal viewportEntered(). The method should be invoked by
- * the controller parent whenever the mouse cursor is above the viewport.
+ * the view implementation whenever the mouse cursor is above the viewport.
*/
void emitViewportEntered();
+ /**
+ * Emits the signal selectionChanged(). The method should be invoked by
+ * the view implementation whenever the selection has been changed.
+ */
+ void emitSelectionChanged();
+
signals:
/**
* Is emitted if the URL for the Dolphin controller has been changed
/**
* 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.
*/
void sortOrderChanged(Qt::SortOrder order);
+ /**
+ * Is emitted if 'sort folders first' has been changed to \a foldersFirst
+ * by the view implementation (see indicateSortOrderChanged().
+ * The abstract Dolphin view connects
+ * to this signal to update its menu actions.
+ */
+ void sortFoldersFirstChanged(bool foldersFirst);
+
/**
* Is emitted if the additional info has been changed to \a info
* by the view implementation. The abstract Dolphin view connects
/**
* Is emitted if the mouse cursor has entered
- * the viewport (see emitViewportEntered().
+ * the viewport (see emitViewportEntered()).
* The abstract Dolphin view connects to this signal.
*/
void viewportEntered();
+ /**
+ * Is emitted whenever the selection of the view implementation
+ * has been changed (see emitSelectionChanged()). The abstract
+ * Dolphin view connects to this signal.
+ */
+ void selectionChanged();
+
+ /**
+ * Is emitted if the view should respect the name filter \a nameFilter. The view
+ * implementation must connect to this signal if it supports name filters.
+ */
+ void nameFilterChanged(const QString& nameFilter);
+
/**
* Is emitted if the view should change the zoom to \a level. The view implementation
* must connect to this signal if it supports zooming.
*/
void zoomLevelChanged(int level);
-
+
/**
* Is emitted if the abstract view should hide an open tooltip.
*/
void hideToolTip();
+ /**
+ * Is emitted if pending previews should be canceled (e. g. because of an URL change).
+ */
+ void cancelPreviews();
+
+ /**
+ * Requests the view implementation to invoke DolphinController::setVersionControlActions(),
+ * so that they can be returned with DolphinController::versionControlActions() for
+ * the abstract Dolphin view.
+ */
+ void requestVersionControlActions(const KFileItemList& items);
+
private slots:
void updateMouseButtonState();
private:
int m_zoomLevel;
- Qt::MouseButtons m_mouseButtons; // TODO: this is a workaround until Qt-issue 176832 has been fixed
+ QString m_nameFilter;
+ 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;
+ QList<QAction*> m_versionControlActions;
};
inline const DolphinView* DolphinController::dolphinView() const