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