My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties Macros
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  };
74 
75  // @cond
76  virtual QString categoryId() const = 0;
77  virtual int count() const = 0;
78 
79  virtual void setCategoryId(QString const& id) = 0;
80  QHash<int, QByteArray> roleNames() const override
81  {
82  QHash<int, QByteArray> roles;
83  roles[RoleUri] = "uri";
84  roles[RoleCategoryId] = "categoryId";
85  roles[RoleDndUri] = "dndUri";
86  roles[RoleResult] = "result";
87  roles[RoleTitle] = "title";
88  roles[RoleArt] = "art";
89  roles[RoleSubtitle] = "subtitle";
90  roles[RoleMascot] = "mascot";
91  roles[RoleEmblem] = "emblem";
92  roles[RoleSummary] = "summary";
93  roles[RoleAttributes] = "attributes";
94  roles[RoleBackground] = "background";
95  return roles;
96  }
97 
98  // @endcond
99 
100 Q_SIGNALS:
101  // @cond
102  void categoryIdChanged();
103  void countChanged();
104  // @endcond
105 };
106 
107 }
108 }
109 }
110 
112 
113 #endif
A model of scope results for a particular category.
Definition: ResultsModelInterface.h:34
Roles
The Roles supported by this model.
Definition: ResultsModelInterface.h:59