My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros
ScopesInterface.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_SCOPESINTERFACE_H
18 #define UNITY_SHELL_SCOPES_SCOPESINTERFACE_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 
31 class ScopeInterface;
32 
38 class UNITY_API ScopesInterface : public QAbstractListModel
39 {
40  Q_OBJECT
41 
42  Q_ENUMS(Roles)
43 
44 
47  Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
48 
49 
52  Q_PROPERTY(int count READ count NOTIFY countChanged)
53 
54 
59  Q_PROPERTY(unity::shell::scopes::ScopeInterface* overviewScope READ overviewScope NOTIFY overviewScopeChanged)
60 
61 protected:
63  explicit ScopesInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
65 
66 public:
70  enum Roles {
71  RoleScope,
72  RoleId,
73  RoleTitle
74  };
75 
82  Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(int row) const = 0;
83 
89  Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(QString const& scopeId) const = 0;
90 
91  // @cond
92  virtual bool loaded() const = 0;
93  virtual int count() const = 0;
94  virtual unity::shell::scopes::ScopeInterface* overviewScope() const = 0;
95  QHash<int, QByteArray> roleNames() const override
96  {
97  QHash<int, QByteArray> roles;
98  roles[RoleScope] = "scope";
99  roles[RoleId] = "id";
100  roles[RoleTitle] = "title";
101  return roles;
102  }
103  // @endcond
104 
105 Q_SIGNALS:
106  // @cond
107  void loadedChanged();
108  void countChanged();
109  void overviewScopeChanged();
110  // @endcond
111 };
112 
113 }
114 }
115 }
116 
117 Q_DECLARE_METATYPE(unity::shell::scopes::ScopesInterface*)
118 
119 #endif
A list of scopes to display in the UI.
Definition: ScopesInterface.h:38
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Object representing scope instance, which exposes model(s) with results.
Definition: ScopeInterface.h:40
Roles
Roles supported by the model.
Definition: ScopesInterface.h:70