My Project
CategoriesInterface.h
1 /*
2  * Copyright (C) 2014 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef UNITY_SHELL_SCOPES_CATEGORESINTERFACE_H
18 #define UNITY_SHELL_SCOPES_CATEGORESINTERFACE_H
19 
20 #include <unity/SymbolExport.h>
21 
22 #include <QAbstractListModel>
23 
24 namespace unity
25 {
26 namespace shell
27 {
28 namespace scopes
29 {
30 
37 class UNITY_API CategoriesInterface : public QAbstractListModel
38 {
39  Q_OBJECT
40 
41  Q_ENUMS(Roles)
42 
43 protected:
45  explicit CategoriesInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
47 
48 public:
52  enum Roles {
53  RoleCategoryId,
54  RoleName,
55  RoleIcon,
56  RoleRawRendererTemplate,
57  RoleRenderer,
58  RoleComponents,
59  RoleHeaderLink,
60  RoleResults,
61  RoleCount
62  };
63 
70  Q_INVOKABLE virtual bool overrideCategoryJson(QString const& categoryId, QString const& json) = 0;
71 
80  Q_INVOKABLE virtual void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject) = 0;
81 
82  // @cond
83  QHash<int, QByteArray> roleNames() const override
84  {
85  QHash<int, QByteArray> roles;
86  roles[RoleCategoryId] = "categoryId";
87  roles[RoleName] = "name";
88  roles[RoleIcon] = "icon";
89  roles[RoleRawRendererTemplate] = "rawRendererTemplate";
90  roles[RoleRenderer] = "renderer";
91  roles[RoleComponents] = "components";
92  roles[RoleHeaderLink] = "headerLink";
93  roles[RoleResults] = "results";
94  roles[RoleCount] = "count";
95  return roles;
96  }
97  // @endcond
98 };
99 
100 }
101 }
102 }
103 
105 
106 #endif
Top-level namespace for all things Unity-related.
Definition: Version.h:37
A list of categories for a particular search.
Definition: CategoriesInterface.h:37
Roles
The roles supported by this model.
Definition: CategoriesInterface.h:52