My Project
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 
52  Q_PROPERTY(int count READ count NOTIFY countChanged)
53 
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 
94  Q_INVOKABLE virtual void setFavorite(QString const& scopeId, bool favorite) = 0;
95 
99  Q_INVOKABLE virtual void moveFavoriteTo(QString const& scopeId, int index) = 0;
100 
101  // @cond
102  virtual bool loaded() const = 0;
103  virtual int count() const = 0;
104  virtual unity::shell::scopes::ScopeInterface* overviewScope() const = 0;
105  QHash<int, QByteArray> roleNames() const override
106  {
107  QHash<int, QByteArray> roles;
108  roles[RoleScope] = "scope";
109  roles[RoleId] = "id";
110  roles[RoleTitle] = "title";
111  return roles;
112  }
113  // @endcond
114 
115  Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
116 
117 Q_SIGNALS:
118  // @cond
119  void loadedChanged();
120  void countChanged();
121  void overviewScopeChanged();
122  // @endcond
123 };
124 
125 }
126 }
127 }
128 
129 Q_DECLARE_METATYPE(unity::shell::scopes::ScopesInterface*)
130 
131 #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