My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros
ApplicationManagerInterface.h
1 /*
2  * Copyright 2013 Canonical Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authors:
17  * Michael Zanetti <michael.zanetti@canonical.com>
18  */
19 
20 #ifndef UNITY_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
21 #define UNITY_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
22 
23 #include <unity/SymbolExport.h>
24 
25 #include <QtCore/QObject>
26 #include <QtCore/QAbstractListModel>
27 
28 namespace unity
29 {
30 namespace shell
31 {
32 namespace application
33 {
34 
35 class ApplicationInfoInterface;
36 
43 class UNITY_API ApplicationManagerInterface: public QAbstractListModel
44 {
45  Q_OBJECT
46  Q_ENUMS(Roles)
47 
48 
53  Q_PROPERTY(int count READ count NOTIFY countChanged)
54 
55 
60  Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
61 
62 
67  Q_PROPERTY(bool suspended READ suspended WRITE setSuspended NOTIFY suspendedChanged)
68 
69 protected:
71  ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
72  {
73  m_roleNames.insert(RoleAppId, "appId");
74  m_roleNames.insert(RoleName, "name");
75  m_roleNames.insert(RoleComment, "comment");
76  m_roleNames.insert(RoleIcon, "icon");
77  m_roleNames.insert(RoleStage, "stage");
78  m_roleNames.insert(RoleState, "state");
79  m_roleNames.insert(RoleFocused, "focused");
80 
81  connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));
82  connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));
83  connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
84  connect(this, SIGNAL(layoutChanged()), SIGNAL(countChanged()));
85  }
87 
88 public:
94  enum Roles {
95  RoleAppId = Qt::UserRole,
96  RoleName,
97  RoleComment,
98  RoleIcon,
99  RoleStage,
100  RoleState,
101  RoleFocused,
102  };
103 
105  virtual ~ApplicationManagerInterface() {}
106 
107  virtual QHash<int, QByteArray> roleNames() const
108  {
109  return m_roleNames;
110  }
111 
112  int count() const {
113  return rowCount();
114  }
115 
116  virtual QString focusedApplicationId() const = 0;
117 
118  virtual bool suspended() const = 0;
119  virtual void setSuspended(bool suspended) = 0;
121 
130  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *get(int index) const = 0;
131 
140  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
141 
150  Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
151 
162  Q_INVOKABLE virtual bool focusApplication(const QString &appId) = 0;
163 
167  Q_INVOKABLE virtual void unfocusCurrentApplication() = 0;
168 
176  Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;
177 
184  Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
185 
186 Q_SIGNALS:
188  void countChanged();
190 
197  void focusRequested(const QString &appId);
198 
202  void focusedApplicationIdChanged();
203 
207  void suspendedChanged();
208 
214  void applicationAdded(const QString &appId);
215 
221  void applicationRemoved(const QString &appId);
222 
223 protected:
225  QHash<int, QByteArray> m_roleNames;
227 };
228 
229 } // namespace application
230 } // namespace shell
231 } // namespace unity
232 
233 #endif // UNITY_SHELL_APPLICATIONMANAGER_APPLICATIONINFO_H
The Application manager.
Definition: ApplicationManagerInterface.h:43
Roles
The Roles supported by the model.
Definition: ApplicationManagerInterface.h:94
Top-level namespace for all things Unity-related.
Definition: Version.h:37
A class that holds information about applications.
Definition: ApplicationInfoInterface.h:42