Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.h
Show All 16 Lines | |||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #ifndef SIDEBARMODE_H | 20 | #ifndef SIDEBARMODE_H | ||
21 | #define SIDEBARMODE_H | 21 | #define SIDEBARMODE_H | ||
22 | 22 | | |||
23 | #include "BaseMode.h" | 23 | #include "BaseMode.h" | ||
24 | #include <QWidget> | 24 | #include <QWidget> | ||
25 | #include <QStandardItemModel> | ||||
25 | 26 | | |||
26 | class ModuleView; | 27 | class ModuleView; | ||
27 | class KAboutData; | 28 | class KAboutData; | ||
28 | class QModelIndex; | 29 | class QModelIndex; | ||
29 | class QAbstractItemView; | 30 | class QAbstractItemView; | ||
30 | class QAbstractItemModel; | 31 | class QAbstractItemModel; | ||
31 | class QAction; | 32 | class QAction; | ||
32 | 33 | | |||
33 | class FocusHackWidget : public QWidget { | 34 | class FocusHackWidget : public QWidget { | ||
34 | Q_OBJECT | 35 | Q_OBJECT | ||
35 | public: | 36 | public: | ||
36 | explicit FocusHackWidget(QWidget *parent = nullptr); | 37 | explicit FocusHackWidget(QWidget *parent = nullptr); | ||
37 | ~FocusHackWidget() override; | 38 | ~FocusHackWidget() override; | ||
38 | 39 | | |||
39 | public Q_SLOTS: | 40 | public Q_SLOTS: | ||
40 | void focusNext(); | 41 | void focusNext(); | ||
41 | void focusPrevious(); | 42 | void focusPrevious(); | ||
42 | }; | 43 | }; | ||
43 | 44 | | |||
45 | class SubcategoryModel : public QStandardItemModel | ||||
46 | { | ||||
47 | Q_OBJECT | ||||
48 | Q_PROPERTY(QString title READ title NOTIFY titleChanged) | ||||
49 | | ||||
50 | public: | ||||
51 | explicit SubcategoryModel(QAbstractItemModel *parentModel, QObject *parent = nullptr); | ||||
52 | | ||||
53 | QString title() const; | ||||
54 | | ||||
55 | void setParentIndex(const QModelIndex &activeModule); | ||||
56 | | ||||
57 | Q_SIGNALS: | ||||
58 | void titleChanged(); | ||||
59 | | ||||
60 | private: | ||||
61 | QAbstractItemModel *m_parentModel; | ||||
62 | QString m_title; | ||||
63 | }; | ||||
64 | | ||||
44 | class SidebarMode : public BaseMode | 65 | class SidebarMode : public BaseMode | ||
45 | { | 66 | { | ||
46 | Q_OBJECT | 67 | Q_OBJECT | ||
47 | 68 | | |||
48 | Q_PROPERTY(QAbstractItemModel *categoryModel READ categoryModel CONSTANT) | 69 | Q_PROPERTY(QAbstractItemModel *categoryModel READ categoryModel CONSTANT) | ||
70 | Q_PROPERTY(QAbstractItemModel *searchModel READ searchModel CONSTANT) | ||||
49 | Q_PROPERTY(QAbstractItemModel *subCategoryModel READ subCategoryModel CONSTANT) | 71 | Q_PROPERTY(QAbstractItemModel *subCategoryModel READ subCategoryModel CONSTANT) | ||
50 | Q_PROPERTY(QAbstractItemModel *mostUsedModel READ mostUsedModel CONSTANT) | 72 | Q_PROPERTY(QAbstractItemModel *mostUsedModel READ mostUsedModel CONSTANT) | ||
51 | Q_PROPERTY(int activeCategory READ activeCategory WRITE setActiveCategory NOTIFY activeCategoryChanged) | 73 | Q_PROPERTY(int activeCategoryRow READ activeCategoryRow NOTIFY activeCategoryRowChanged) | ||
52 | Q_PROPERTY(int activeSubCategory READ activeSubCategory WRITE setActiveSubCategory NOTIFY activeSubCategoryChanged) | 74 | Q_PROPERTY(int activeSearchRow READ activeSearchRow NOTIFY activeSearchRowChanged) | ||
75 | Q_PROPERTY(int activeSubCategoryRow READ activeSubCategoryRow NOTIFY activeSubCategoryRowChanged) | ||||
53 | Q_PROPERTY(int width READ width NOTIFY widthChanged) | 76 | Q_PROPERTY(int width READ width NOTIFY widthChanged) | ||
54 | Q_PROPERTY(bool actionMenuVisible READ actionMenuVisible NOTIFY actionMenuVisibleChanged) | 77 | Q_PROPERTY(bool actionMenuVisible READ actionMenuVisible NOTIFY actionMenuVisibleChanged) | ||
55 | Q_PROPERTY(bool introPageVisible READ introPageVisible WRITE setIntroPageVisible NOTIFY introPageVisibleChanged) | 78 | Q_PROPERTY(bool introPageVisible READ introPageVisible WRITE setIntroPageVisible NOTIFY introPageVisibleChanged) | ||
56 | 79 | | |||
57 | public: | 80 | public: | ||
58 | SidebarMode(QObject * parent, const QVariantList& ); | 81 | SidebarMode(QObject * parent, const QVariantList& ); | ||
59 | ~SidebarMode() override; | 82 | ~SidebarMode() override; | ||
60 | QWidget * mainWidget() override; | 83 | QWidget * mainWidget() override; | ||
61 | void initEvent() override; | 84 | void initEvent() override; | ||
62 | void giveFocus() override; | 85 | void giveFocus() override; | ||
63 | KAboutData * aboutData() override; | 86 | KAboutData * aboutData() override; | ||
64 | ModuleView * moduleView() const override; | 87 | ModuleView * moduleView() const override; | ||
65 | QAbstractItemModel *categoryModel() const; | 88 | QAbstractItemModel *categoryModel() const; | ||
89 | QAbstractItemModel *searchModel() const; | ||||
66 | QAbstractItemModel *subCategoryModel() const; | 90 | QAbstractItemModel *subCategoryModel() const; | ||
67 | QAbstractItemModel *mostUsedModel() const; | 91 | QAbstractItemModel *mostUsedModel() const; | ||
68 | 92 | | |||
69 | int activeCategory() const; | 93 | int activeCategoryRow() const; | ||
70 | void setActiveCategory(int cat); | 94 | int activeSubCategoryRow() const; | ||
71 | 95 | int activeSearchRow() const; | |||
72 | int activeSubCategory() const; | | |||
73 | void setActiveSubCategory(int cat); | | |||
74 | 96 | | |||
75 | int width() const; | 97 | int width() const; | ||
76 | 98 | | |||
77 | bool actionMenuVisible() const; | 99 | bool actionMenuVisible() const; | ||
78 | 100 | | |||
79 | bool introPageVisible() const; | 101 | bool introPageVisible() const; | ||
80 | void setIntroPageVisible(const bool &introPageVisible); | 102 | void setIntroPageVisible(const bool &introPageVisible); | ||
81 | 103 | | |||
82 | Q_INVOKABLE QAction *action(const QString &name) const; | 104 | Q_INVOKABLE QAction *action(const QString &name) const; | ||
83 | // QML doesn't understand QIcon, otherwise we could get it from the QAction itself | 105 | // QML doesn't understand QIcon, otherwise we could get it from the QAction itself | ||
84 | Q_INVOKABLE QString actionIconName(const QString &name) const; | 106 | Q_INVOKABLE QString actionIconName(const QString &name) const; | ||
85 | Q_INVOKABLE void requestToolTip(int index, const QRectF &rect); | 107 | Q_INVOKABLE void requestToolTip(const QModelIndex &index, const QRectF &rect); | ||
86 | Q_INVOKABLE void requestSubCategoryToolTip(int index, const QRectF &rect); | | |||
87 | Q_INVOKABLE void requestMostUsedToolTip(int index, const QRectF &rect); | 108 | Q_INVOKABLE void requestMostUsedToolTip(int index, const QRectF &rect); | ||
88 | Q_INVOKABLE void hideToolTip(); | 109 | Q_INVOKABLE void hideToolTip(); | ||
89 | Q_INVOKABLE void hideSubCategoryToolTip(); | | |||
90 | Q_INVOKABLE void hideMostUsedToolTip(); | 110 | Q_INVOKABLE void hideMostUsedToolTip(); | ||
91 | Q_INVOKABLE void loadMostUsed(int index); | | |||
92 | Q_INVOKABLE void showActionMenu(const QPoint &position); | 111 | Q_INVOKABLE void showActionMenu(const QPoint &position); | ||
93 | 112 | | |||
113 | Q_INVOKABLE void loadModule(const QModelIndex& activeModule); | ||||
114 | | ||||
94 | protected: | 115 | protected: | ||
95 | QList<QAbstractItemView*> views() const override; | 116 | QList<QAbstractItemView*> views() const override; | ||
96 | bool eventFilter(QObject* watched, QEvent* event) override; | 117 | bool eventFilter(QObject* watched, QEvent* event) override; | ||
97 | 118 | | |||
98 | private Q_SLOTS: | 119 | private Q_SLOTS: | ||
99 | void changeModule( const QModelIndex& activeModule ); | | |||
100 | void moduleLoaded(); | 120 | void moduleLoaded(); | ||
101 | void initWidget(); | 121 | void initWidget(); | ||
102 | 122 | | |||
103 | Q_SIGNALS: | 123 | Q_SIGNALS: | ||
104 | void activeCategoryChanged(); | 124 | void activeCategoryRowChanged(); | ||
105 | void activeSubCategoryChanged(); | 125 | void activeSubCategoryRowChanged(); | ||
126 | void activeSearchRowChanged(); | ||||
106 | void widthChanged(); | 127 | void widthChanged(); | ||
107 | void actionMenuVisibleChanged(); | 128 | void actionMenuVisibleChanged(); | ||
108 | void introPageVisibleChanged(); | 129 | void introPageVisibleChanged(); | ||
109 | 130 | | |||
110 | private: | 131 | private: | ||
111 | class Private; | 132 | class Private; | ||
112 | Private *const d; | 133 | Private *const d; | ||
113 | }; | 134 | }; | ||
114 | 135 | | |||
115 | #endif | 136 | #endif |