X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b8ef5ebca1662526e994815d6e044652ce7ccf4a..48b58f830a585b773435c9af5ee2fe8f0c7c641d:/src/kitemviews/kitemlistcontroller.h diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index a88152622..2f84a6c2c 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -23,13 +23,13 @@ #ifndef KITEMLISTCONTROLLER_H #define KITEMLISTCONTROLLER_H -#include +#include "dolphin_export.h" +#include "kitemset.h" #include -#include #include -#include +class QTimer; class KItemModelBase; class KItemListKeyboardSearchManager; class KItemListSelectionManager; @@ -43,7 +43,6 @@ class QGraphicsSceneWheelEvent; class QHideEvent; class QInputMethodEvent; class QKeyEvent; -class QMimeData; class QShowEvent; class QTransform; @@ -57,13 +56,14 @@ class QTransform; * @see KItemModelBase * @see KItemListSelectionManager */ -class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject +class DOLPHIN_EXPORT KItemListController : public QObject { Q_OBJECT - Q_ENUMS(SelectionBehavior) Q_PROPERTY(KItemModelBase* model READ model WRITE setModel) Q_PROPERTY(KItemListView *view READ view WRITE setView) Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior) + Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior) + Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction) public: enum SelectionBehavior { @@ -71,14 +71,25 @@ public: SingleSelection, MultiSelection }; + Q_ENUM(SelectionBehavior) + + enum AutoActivationBehavior { + ActivationAndExpansion, + ExpansionOnly + }; + + enum MouseDoubleClickAction { + ActivateAndExpandItem, + ActivateItemOnly + }; /** * @param model Model of the controller. The ownership is passed to the controller. * @param view View of the controller. The ownership is passed to the controller. * @param parent Optional parent object. */ - KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent = 0); - virtual ~KItemListController(); + KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent = nullptr); + ~KItemListController() override; void setModel(KItemModelBase* model); KItemModelBase* model() const; @@ -91,6 +102,14 @@ public: void setSelectionBehavior(SelectionBehavior behavior); SelectionBehavior selectionBehavior() const; + void setAutoActivationBehavior(AutoActivationBehavior behavior); + AutoActivationBehavior autoActivationBehavior() const; + + void setMouseDoubleClickAction(MouseDoubleClickAction action); + MouseDoubleClickAction mouseDoubleClickAction() const; + + int indexCloseToMousePressedPosition() const; + /** * Sets the delay in milliseconds when dragging an object above an item * until the item gets activated automatically. A value of -1 indicates @@ -111,12 +130,11 @@ public: /** * If set to true, the signals itemActivated() and itemsActivated() are emitted - * after a single-click of the left mouse button. If set to false, a double-click - * is required. Per default the setting from KGlobalSettings::singleClick() is - * used. + * after a single-click of the left mouse button. If set to false (the default), + * the setting from style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) is used. */ - void setSingleClickActivation(bool singleClick); - bool singleClickActivation() const; + void setSingleClickActivationEnforced(bool singleClick); + bool singleClickActivationEnforced() const; virtual bool showEvent(QShowEvent* event); virtual bool hideEvent(QHideEvent* event); @@ -148,7 +166,7 @@ signals: * Is emitted if more than one item has been activated by pressing Return/Enter * when having a selection. */ - void itemsActivated(const QSet& indexes); + void itemsActivated(const KItemSet& indexes); void itemMiddleClicked(int index); @@ -213,9 +231,16 @@ signals: */ void aboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); + /** + * Is emitted if the Escape key is pressed. + */ + void escapePressed(); + void modelChanged(KItemModelBase* current, KItemModelBase* previous); void viewChanged(KItemListView* current, KItemListView* previous); + void selectedItemTextPressed(int index); + private slots: void slotViewScrollOffsetChanged(qreal current, qreal previous); @@ -283,10 +308,12 @@ private: void updateExtendedSelectionRegion(); private: - bool m_singleClickActivation; + bool m_singleClickActivationEnforced; bool m_selectionTogglePressed; bool m_clearSelectionIfItemsAreNotDragged; SelectionBehavior m_selectionBehavior; + AutoActivationBehavior m_autoActivationBehavior; + MouseDoubleClickAction m_mouseDoubleClickAction; KItemModelBase* m_model; KItemListView* m_view; KItemListSelectionManager* m_selectionManager; @@ -302,7 +329,7 @@ private: * the current selection it is remembered in m_oldSelection before the * rubberband gets activated. */ - QSet m_oldSelection; + KItemSet m_oldSelection; /** * Assuming a view is given with a vertical scroll-orientation, grouped items and