My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties 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 protected:
51  explicit ScopesInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
53 
54 public:
58  enum Roles {
59  RoleScope,
60  RoleId,
61  RoleVisible,
62  RoleTitle
63  };
64 
71  Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(int row) const = 0;
72 
79  Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(QString const& scopeId) const = 0;
80 
81  // @cond
82  virtual bool loaded() const = 0;
83  QHash<int, QByteArray> roleNames() const override
84  {
85  QHash<int, QByteArray> roles;
86  roles[RoleScope] = "scope";
87  roles[RoleId] = "id";
88  roles[RoleVisible] = "visible";
89  roles[RoleTitle] = "title";
90  return roles;
91  }
92  // @endcond
93 
94 Q_SIGNALS:
95  // @cond
96  void loadedChanged();
97  // @endcond
98 };
99 
100 }
101 }
102 }
103 
104 Q_DECLARE_METATYPE(unity::shell::scopes::ScopesInterface*)
105 
106 #endif
A list of scopes to display in the UI.
Definition: ScopesInterface.h:38
Object representing scope instance, which exposes model(s) with results.
Definition: ScopeInterface.h:38
Roles
Roles supported by the model.
Definition: ScopesInterface.h:58