My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros
LauncherModelInterface.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_LAUNCHER_LAUNCHERMODELINTERFACE_H
21 #define UNITY_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
22 
23 #include <unity/SymbolExport.h>
24 
25 #include <unity/shell/application/ApplicationManagerInterface.h>
26 
27 #include <QtCore/QAbstractListModel>
28 
29 namespace unity
30 {
31 namespace shell
32 {
33 namespace launcher
34 {
35 
36 class LauncherItemInterface;
37 
43 class UNITY_API LauncherModelInterface: public QAbstractListModel
44 {
45  Q_OBJECT
46 
54  Q_PROPERTY(unity::shell::application::ApplicationManagerInterface* applicationManager
55  READ applicationManager WRITE setApplicationManager NOTIFY applicationManagerChanged)
56 
57 protected:
59  LauncherModelInterface(QObject *parent = 0): QAbstractListModel(parent) {
60  m_roleNames.insert(RoleAppId, "appId");
61  m_roleNames.insert(RoleName, "name");
62  m_roleNames.insert(RoleIcon, "icon");
63  m_roleNames.insert(RolePinned, "pinned");
64  m_roleNames.insert(RoleRunning, "running");
65  m_roleNames.insert(RoleRecent, "recent");
66  m_roleNames.insert(RoleProgress, "progress");
67  m_roleNames.insert(RoleCount, "count");
68  m_roleNames.insert(RoleCountVisible, "countVisible");
69  m_roleNames.insert(RoleFocused, "focused");
70  }
72 
73 public:
79  enum Roles {
80  RoleAppId = Qt::UserRole,
81  RoleName,
82  RoleIcon,
83  RolePinned,
84  RoleRunning,
85  RoleRecent,
86  RoleProgress,
87  RoleCount,
88  RoleCountVisible,
89  RoleFocused
90  };
91 
92  virtual ~LauncherModelInterface() {}
93 
100  Q_INVOKABLE virtual void move(int oldIndex, int newIndex) = 0;
101 
110  Q_INVOKABLE virtual unity::shell::launcher::LauncherItemInterface *get(int index) const = 0;
111 
125  Q_INVOKABLE virtual void pin(const QString &appId, int index = -1) = 0;
126 
134  Q_INVOKABLE virtual void requestRemove(const QString &appId) = 0;
135 
136 
143  Q_INVOKABLE virtual void quickListActionInvoked(const QString &appId, int actionIndex) = 0;
144 
145 
151  Q_INVOKABLE virtual void setUser(const QString &username) = 0;
152 
154  virtual unity::shell::application::ApplicationManagerInterface *applicationManager() const = 0;
155  virtual void setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager) = 0;
156 
157  virtual QHash<int, QByteArray> roleNames() const
158  {
159  return m_roleNames;
160  }
162 
163 Q_SIGNALS:
165  void applicationManagerChanged();
167 
168 protected:
170  QHash<int, QByteArray> m_roleNames;
172 
173 };
174 
175 } // namespace launcher
176 } // namespace shell
177 } // namespace unity
178 
179 #endif // UNITY_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
A list of launcher items to be displayed.
Definition: LauncherModelInterface.h:43
The Application manager.
Definition: ApplicationManagerInterface.h:43
Roles
The Roles supported by the model.
Definition: LauncherModelInterface.h:79
Top-level namespace for all things Unity-related.
Definition: Version.h:37
An item presented in the launcher.
Definition: LauncherItemInterface.h:43