My Project
ResultsModelInterface.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_RESULTSMODELINTERFACE_H
18 #define UNITY_SHELL_SCOPES_RESULTSMODELINTERFACE_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 
34 class UNITY_API ResultsModelInterface : public QAbstractListModel
35 {
36  Q_OBJECT
37 
38  Q_ENUMS(Roles)
39 
40 
43  Q_PROPERTY(QString categoryId READ categoryId WRITE setCategoryId NOTIFY categoryIdChanged)
44 
48  Q_PROPERTY(int count READ count NOTIFY countChanged)
49 
50 protected:
52  explicit ResultsModelInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
54 
55 public:
59  enum Roles {
60  RoleUri,
61  RoleCategoryId,
62  RoleDndUri,
63  RoleResult,
64  // card components
65  RoleTitle,
66  RoleArt,
67  RoleSubtitle,
68  RoleMascot,
69  RoleEmblem,
70  RoleSummary,
71  RoleAttributes,
72  RoleBackground,
73  RoleOverlayColor
74  };
75 
76  // @cond
77  virtual QString categoryId() const = 0;
78  virtual int count() const = 0;
79 
80  virtual void setCategoryId(QString const& id) = 0;
81  QHash<int, QByteArray> roleNames() const override
82  {
83  QHash<int, QByteArray> roles;
84  roles[RoleUri] = "uri";
85  roles[RoleCategoryId] = "categoryId";
86  roles[RoleDndUri] = "dndUri";
87  roles[RoleResult] = "result";
88  roles[RoleTitle] = "title";
89  roles[RoleArt] = "art";
90  roles[RoleSubtitle] = "subtitle";
91  roles[RoleMascot] = "mascot";
92  roles[RoleEmblem] = "emblem";
93  roles[RoleSummary] = "summary";
94  roles[RoleAttributes] = "attributes";
95  roles[RoleBackground] = "background";
96  roles[RoleOverlayColor] = "overlayColor";
97  return roles;
98  }
99 
100  // @endcond
101 
102 Q_SIGNALS:
103  // @cond
104  void categoryIdChanged();
105  void countChanged();
106  // @endcond
107 };
108 
109 }
110 }
111 }
112 
114 
115 #endif
A model of scope results for a particular category.
Definition: ResultsModelInterface.h:34
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Roles
The Roles supported by this model.
Definition: ResultsModelInterface.h:59