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 
45  Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
46 
47 
50  Q_PROPERTY(int count READ count NOTIFY countChanged)
51 
57  Q_PROPERTY(unity::shell::scopes::ScopeInterface* overviewScope READ overviewScope NOTIFY overviewScopeChanged)
58 
59 protected:
61  explicit ScopesInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
63 
64 public:
68  enum Roles {
69  RoleScope,
70  RoleId,
71  RoleTitle
72  };
73  Q_ENUM(Roles)
74 
75 
81  Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(int row) const = 0;
82 
88  Q_INVOKABLE virtual unity::shell::scopes::ScopeInterface* getScope(QString const& scopeId) const = 0;
89 
93  Q_INVOKABLE virtual void setFavorite(QString const& scopeId, bool favorite) = 0;
94 
98  Q_INVOKABLE virtual void moveFavoriteTo(QString const& scopeId, int index) = 0;
99 
100  // @cond
101  virtual bool loaded() const = 0;
102  virtual int count() const = 0;
103  virtual unity::shell::scopes::ScopeInterface* overviewScope() const = 0;
104  QHash<int, QByteArray> roleNames() const override
105  {
106  QHash<int, QByteArray> roles;
107  roles[RoleScope] = "scope";
108  roles[RoleId] = "id";
109  roles[RoleTitle] = "title";
110  return roles;
111  }
112  // @endcond
113 
114  Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
115 
116 Q_SIGNALS:
117  // @cond
118  void loadedChanged();
119  void countChanged();
120  void overviewScopeChanged();
121  // @endcond
122 };
123 
124 }
125 }
126 }
127 
128 Q_DECLARE_METATYPE(unity::shell::scopes::ScopesInterface*)
129 
130 #endif
unity::shell::scopes::ScopesInterface
A list of scopes to display in the UI.
Definition: ScopesInterface.h:38
unity
Top-level namespace for all things Unity-related.
Definition: Version.h:37
unity::shell::scopes::ScopesInterface::Roles
Roles
Roles supported by the model.
Definition: ScopesInterface.h:68
unity::shell::scopes::ScopeInterface
Object representing scope instance, which exposes model(s) with results.
Definition: ScopeInterface.h:42