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  RoleQuickPreviewData
75  };
76 
77  // @cond
78  virtual QString categoryId() const = 0;
79  virtual int count() const = 0;
80 
81  virtual void setCategoryId(QString const& id) = 0;
82  QHash<int, QByteArray> roleNames() const override
83  {
84  QHash<int, QByteArray> roles;
85  roles[RoleUri] = "uri";
86  roles[RoleCategoryId] = "categoryId";
87  roles[RoleDndUri] = "dndUri";
88  roles[RoleQuickPreviewData] = "quickPreviewData";
89  roles[RoleResult] = "result";
90  roles[RoleTitle] = "title";
91  roles[RoleArt] = "art";
92  roles[RoleSubtitle] = "subtitle";
93  roles[RoleMascot] = "mascot";
94  roles[RoleEmblem] = "emblem";
95  roles[RoleSummary] = "summary";
96  roles[RoleAttributes] = "attributes";
97  roles[RoleBackground] = "background";
98  roles[RoleOverlayColor] = "overlayColor";
99  return roles;
100  }
101 
102  // @endcond
103 
104 Q_SIGNALS:
105  // @cond
106  void categoryIdChanged();
107  void countChanged();
108  // @endcond
109 };
110 
111 }
112 }
113 }
114 
116 
117 #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