Changeset View
Changeset View
Standalone View
Standalone View
core/MenuModel.h
Show All 35 Lines | |||||
36 | * @author Ben Cooksley <bcooksley@kde.org> | 36 | * @author Ben Cooksley <bcooksley@kde.org> | ||
37 | * @author Will Stephenson <wstephenson@kde.org> | 37 | * @author Will Stephenson <wstephenson@kde.org> | ||
38 | */ | 38 | */ | ||
39 | class SYSTEMSETTINGSVIEW_EXPORT MenuModel : public QAbstractItemModel | 39 | class SYSTEMSETTINGSVIEW_EXPORT MenuModel : public QAbstractItemModel | ||
40 | { | 40 | { | ||
41 | Q_OBJECT | 41 | Q_OBJECT | ||
42 | 42 | | |||
43 | public: | 43 | public: | ||
44 | enum Roles { | ||||
45 | MenuItemRole = Qt::UserRole, | ||||
46 | | ||||
47 | /** | ||||
48 | * Role used to request the keywords to filter the items when searching. | ||||
49 | */ | ||||
50 | UserFilterRole, | ||||
51 | | ||||
52 | /** | ||||
53 | * Role used to request the weight of a module, used to sort the items. | ||||
54 | */ | ||||
55 | UserSortRole, | ||||
56 | | ||||
57 | DepthRole, | ||||
58 | | ||||
59 | IsCategoryRole | ||||
60 | }; | ||||
61 | | ||||
44 | /** | 62 | /** | ||
45 | * Creates a MenuModel using the MenuItem specified. The MenuItem must always be valid | 63 | * Creates a MenuModel using the MenuItem specified. The MenuItem must always be valid | ||
46 | * throughout the life of the MenuModel, otherwise it will cause crashes. | 64 | * throughout the life of the MenuModel, otherwise it will cause crashes. | ||
47 | * | 65 | * | ||
48 | * @param menuRoot The MenuItem to use as the basis for providing information. | 66 | * @param menuRoot The MenuItem to use as the basis for providing information. | ||
49 | * @param parent The QObject to use as a parent of the MenuModel. | 67 | * @param parent The QObject to use as a parent of the MenuModel. | ||
50 | */ | 68 | */ | ||
51 | explicit MenuModel( MenuItem * menuRoot, QObject *parent = nullptr ); | 69 | explicit MenuModel( MenuItem * menuRoot, QObject *parent = nullptr ); | ||
52 | 70 | | |||
53 | /** | 71 | /** | ||
54 | * Destroys the MenuModel. The menuRoot will not be destroyed. | 72 | * Destroys the MenuModel. The menuRoot will not be destroyed. | ||
55 | */ | 73 | */ | ||
56 | ~MenuModel() override; | 74 | ~MenuModel() override; | ||
57 | 75 | | |||
76 | QHash<int, QByteArray> roleNames() const override; | ||||
77 | | ||||
58 | /** | 78 | /** | ||
59 | * Please see Qt QAbstractItemModel documentation for more details.\n | 79 | * Please see Qt QAbstractItemModel documentation for more details.\n | ||
60 | * Provides the name, tooltip, icon, category, keywords and the internal MenuItem to views. | 80 | * Provides the name, tooltip, icon, category, keywords and the internal MenuItem to views. | ||
61 | * | 81 | * | ||
62 | * @param index The QModelIndex you want information about. | 82 | * @param index The QModelIndex you want information about. | ||
63 | * @param role The information role you want information about. | 83 | * @param role The information role you want information about. | ||
64 | * @returns The data requested for the role provided from the QModelIndex provided. | 84 | * @returns The data requested for the role provided from the QModelIndex provided. | ||
65 | */ | 85 | */ | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
125 | * Revokes the exception granted above. After this, the MenuItem's parents will return their children | 145 | * Revokes the exception granted above. After this, the MenuItem's parents will return their children | ||
126 | * as normal and the grand children will return their true parents, restoring normal operation. | 146 | * as normal and the grand children will return their true parents, restoring normal operation. | ||
127 | * It has no effect if the MenuItem does not have an exception. | 147 | * It has no effect if the MenuItem does not have an exception. | ||
128 | * | 148 | * | ||
129 | * @param exception The MenuItem to revoke an exception from. | 149 | * @param exception The MenuItem to revoke an exception from. | ||
130 | */ | 150 | */ | ||
131 | void removeException( MenuItem * exception ); | 151 | void removeException( MenuItem * exception ); | ||
132 | 152 | | |||
133 | /** | | |||
134 | * Role used to request the keywords to filter the items when searching. | | |||
135 | */ | | |||
136 | static const int UserFilterRole; | | |||
137 | | ||||
138 | /** | | |||
139 | * Role used to request the weight of a module, used to sort the items. | | |||
140 | */ | | |||
141 | static const int UserSortRole; | | |||
142 | | ||||
143 | protected: | 153 | protected: | ||
144 | /** | 154 | /** | ||
145 | * Provides the MenuItem which is used internally to provide information. | 155 | * Provides the MenuItem which is used internally to provide information. | ||
146 | * | 156 | * | ||
147 | * @returns The MenuItem used internally. | 157 | * @returns The MenuItem used internally. | ||
148 | */ | 158 | */ | ||
149 | MenuItem* rootItem() const; | 159 | MenuItem* rootItem() const; | ||
150 | 160 | | |||
Show All 22 Lines |