Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/appsmodel.h
Show All 18 Lines | |||||
19 | ***************************************************************************/ | 19 | ***************************************************************************/ | ||
20 | 20 | | |||
21 | #ifndef APPSMODEL_H | 21 | #ifndef APPSMODEL_H | ||
22 | #define APPSMODEL_H | 22 | #define APPSMODEL_H | ||
23 | 23 | | |||
24 | #include "abstractmodel.h" | 24 | #include "abstractmodel.h" | ||
25 | #include "appentry.h" | 25 | #include "appentry.h" | ||
26 | 26 | | |||
27 | #include <QQmlParserStatus> | ||||
28 | | ||||
27 | #include <KServiceGroup> | 29 | #include <KServiceGroup> | ||
28 | 30 | | |||
29 | class AppGroupEntry; | 31 | class AppGroupEntry; | ||
30 | 32 | | |||
31 | class QTimer; | 33 | class QTimer; | ||
32 | 34 | | |||
33 | class AppsModel : public AbstractModel | 35 | class AppsModel : public AbstractModel, public QQmlParserStatus | ||
34 | { | 36 | { | ||
35 | Q_OBJECT | 37 | Q_OBJECT | ||
38 | Q_INTERFACES(QQmlParserStatus) | ||||
39 | | ||||
40 | Q_PROPERTY(bool autoPopulate READ autoPopulate WRITE setAutoPopulate NOTIFY autoPopulateChanged) | ||||
36 | 41 | | |||
37 | Q_PROPERTY(bool paginate READ paginate WRITE setPaginate NOTIFY paginateChanged) | 42 | Q_PROPERTY(bool paginate READ paginate WRITE setPaginate NOTIFY paginateChanged) | ||
38 | Q_PROPERTY(int pageSize READ pageSize WRITE setPageSize NOTIFY pageSizeChanged) | 43 | Q_PROPERTY(int pageSize READ pageSize WRITE setPageSize NOTIFY pageSizeChanged) | ||
39 | Q_PROPERTY(bool flat READ flat WRITE setFlat NOTIFY flatChanged) | 44 | Q_PROPERTY(bool flat READ flat WRITE setFlat NOTIFY flatChanged) | ||
40 | Q_PROPERTY(bool sorted READ sorted WRITE setSorted NOTIFY sortedChanged) | 45 | Q_PROPERTY(bool sorted READ sorted WRITE setSorted NOTIFY sortedChanged) | ||
41 | Q_PROPERTY(bool showSeparators READ showSeparators WRITE setShowSeparators NOTIFY showSeparatorsChanged) | 46 | Q_PROPERTY(bool showSeparators READ showSeparators WRITE setShowSeparators NOTIFY showSeparatorsChanged) | ||
42 | Q_PROPERTY(bool showTopLevelItems READ showTopLevelItems WRITE setShowTopLevelItems NOTIFY showTopLevelItemsChanged) | 47 | Q_PROPERTY(bool showTopLevelItems READ showTopLevelItems WRITE setShowTopLevelItems NOTIFY showTopLevelItemsChanged) | ||
43 | Q_PROPERTY(int appNameFormat READ appNameFormat WRITE setAppNameFormat NOTIFY appNameFormatChanged) | 48 | Q_PROPERTY(int appNameFormat READ appNameFormat WRITE setAppNameFormat NOTIFY appNameFormatChanged) | ||
Show All 11 Lines | 51 | public: | |||
55 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | 60 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||
56 | 61 | | |||
57 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | 62 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | ||
58 | 63 | | |||
59 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | 64 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
60 | 65 | | |||
61 | Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) override; | 66 | Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) override; | ||
62 | 67 | | |||
68 | bool autoPopulate() const; | ||||
69 | void setAutoPopulate(bool populate); | ||||
70 | | ||||
63 | Q_INVOKABLE AbstractModel *modelForRow(int row) override; | 71 | Q_INVOKABLE AbstractModel *modelForRow(int row) override; | ||
64 | Q_INVOKABLE int rowForModel(AbstractModel *model) override; | 72 | Q_INVOKABLE int rowForModel(AbstractModel *model) override; | ||
65 | 73 | | |||
66 | int separatorCount() const override; | 74 | int separatorCount() const override; | ||
67 | 75 | | |||
68 | bool paginate() const; | 76 | bool paginate() const; | ||
69 | void setPaginate(bool paginate); | 77 | void setPaginate(bool paginate); | ||
70 | 78 | | |||
Show All 17 Lines | |||||
88 | 96 | | |||
89 | QObject *appletInterface() const; | 97 | QObject *appletInterface() const; | ||
90 | void setAppletInterface(QObject *appletInterface); | 98 | void setAppletInterface(QObject *appletInterface); | ||
91 | 99 | | |||
92 | QStringList hiddenEntries() const; | 100 | QStringList hiddenEntries() const; | ||
93 | 101 | | |||
94 | void entryChanged(AbstractEntry *entry) override; | 102 | void entryChanged(AbstractEntry *entry) override; | ||
95 | 103 | | |||
104 | void classBegin() override; | ||||
105 | void componentComplete() override; | ||||
106 | | ||||
96 | Q_SIGNALS: | 107 | Q_SIGNALS: | ||
97 | void cleared() const; | 108 | void cleared() const; | ||
109 | void autoPopulateChanged() const; | ||||
98 | void paginateChanged() const; | 110 | void paginateChanged() const; | ||
99 | void pageSizeChanged() const; | 111 | void pageSizeChanged() const; | ||
100 | void flatChanged() const; | 112 | void flatChanged() const; | ||
101 | void sortedChanged() const; | 113 | void sortedChanged() const; | ||
102 | void showSeparatorsChanged() const; | 114 | void showSeparatorsChanged() const; | ||
103 | void showTopLevelItemsChanged() const; | 115 | void showTopLevelItemsChanged() const; | ||
104 | void appNameFormatChanged() const; | 116 | void appNameFormatChanged() const; | ||
105 | void appletInterfaceChanged() const; | 117 | void appletInterfaceChanged() const; | ||
106 | void hiddenEntriesChanged() const; | 118 | void hiddenEntriesChanged() const; | ||
107 | 119 | | |||
108 | protected Q_SLOTS: | 120 | protected Q_SLOTS: | ||
109 | void refresh() override; | 121 | void refresh() override; | ||
110 | 122 | | |||
111 | protected: | 123 | protected: | ||
112 | void refreshInternal(); | 124 | void refreshInternal(); | ||
113 | 125 | | |||
126 | bool m_complete; | ||||
127 | | ||||
114 | bool m_paginate; | 128 | bool m_paginate; | ||
115 | int m_pageSize; | 129 | int m_pageSize; | ||
116 | 130 | | |||
117 | QList<AbstractEntry *> m_entryList; | 131 | QList<AbstractEntry *> m_entryList; | ||
118 | bool m_deleteEntriesOnDestruction; | 132 | bool m_deleteEntriesOnDestruction; | ||
119 | int m_separatorCount; | 133 | int m_separatorCount; | ||
120 | bool m_showSeparators; | 134 | bool m_showSeparators; | ||
121 | bool m_showTopLevelItems; | 135 | bool m_showTopLevelItems; | ||
122 | 136 | | |||
123 | QObject *m_appletInterface; | 137 | QObject *m_appletInterface; | ||
124 | 138 | | |||
125 | private Q_SLOTS: | 139 | private Q_SLOTS: | ||
126 | void checkSycocaChanges(const QStringList &changes); | 140 | void checkSycocaChanges(const QStringList &changes); | ||
127 | 141 | | |||
128 | private: | 142 | private: | ||
129 | void processServiceGroup(KServiceGroup::Ptr group); | 143 | void processServiceGroup(KServiceGroup::Ptr group); | ||
130 | void sortEntries(); | 144 | void sortEntries(); | ||
131 | 145 | | |||
146 | bool m_autoPopulate; | ||||
147 | | ||||
132 | QString m_description; | 148 | QString m_description; | ||
133 | QString m_entryPath; | 149 | QString m_entryPath; | ||
134 | bool m_staticEntryList; | 150 | bool m_staticEntryList; | ||
135 | QTimer *m_changeTimer; | 151 | QTimer *m_changeTimer; | ||
136 | bool m_flat; | 152 | bool m_flat; | ||
137 | bool m_sorted; | 153 | bool m_sorted; | ||
138 | AppEntry::NameFormat m_appNameFormat; | 154 | AppEntry::NameFormat m_appNameFormat; | ||
139 | QStringList m_hiddenEntries; | 155 | QStringList m_hiddenEntries; | ||
140 | static MenuEntryEditor *m_menuEntryEditor; | 156 | static MenuEntryEditor *m_menuEntryEditor; | ||
141 | }; | 157 | }; | ||
142 | 158 | | |||
143 | #endif | 159 | #endif |