Merge lp:~mzanetti/unity8/launcher-follow-unity-api into lp:unity8

Proposed by Michael Zanetti
Status: Rejected
Rejected by: Michael Zanetti
Proposed branch: lp:~mzanetti/unity8/launcher-follow-unity-api
Merge into: lp:unity8
Diff against target: 1645 lines (+916/-490)
30 files modified
Launcher/Launcher.qml (+2/-5)
Launcher/LauncherPanel.qml (+2/-1)
debian/control (+1/-0)
plugins/Unity/CMakeLists.txt (+3/-1)
plugins/Unity/Launcher/CMakeLists.txt (+36/-0)
plugins/Unity/Launcher/launcheritem.cpp (+114/-0)
plugins/Unity/Launcher/launcheritem.h (+68/-0)
plugins/Unity/Launcher/launchermodel.cpp (+102/-0)
plugins/Unity/Launcher/launchermodel.h (+52/-0)
plugins/Unity/Launcher/plugin.cpp (+45/-0)
plugins/Unity/Launcher/plugin.h (+34/-0)
plugins/Unity/Launcher/qmldir (+2/-0)
plugins/Unity/launchermodel.cpp (+0/-153)
plugins/Unity/launchermodel.h (+0/-86)
plugins/Unity/plugin.cpp (+0/-3)
tests/mocks/CMakeLists.txt (+1/-0)
tests/mocks/Unity/CMakeLists.txt (+1/-0)
tests/mocks/Unity/Launcher/CMakeLists.txt (+38/-0)
tests/mocks/Unity/Launcher/MockLauncherItem.cpp (+121/-0)
tests/mocks/Unity/Launcher/MockLauncherItem.h (+64/-0)
tests/mocks/Unity/Launcher/MockLauncherModel.cpp (+102/-0)
tests/mocks/Unity/Launcher/MockLauncherModel.h (+45/-0)
tests/mocks/Unity/Launcher/plugin.cpp (+45/-0)
tests/mocks/Unity/Launcher/plugin.h (+35/-0)
tests/mocks/Unity/Launcher/qmldir (+2/-0)
tests/qmltests/CMakeLists.txt (+1/-1)
tests/qmltests/plugins/Unity/CMakeLists.txt (+0/-1)
tests/qmltests/plugins/Unity/fake_launchermodel.cpp (+0/-150)
tests/qmltests/plugins/Unity/fake_launchermodel.h (+0/-86)
tests/qmltests/plugins/Unity/fake_unity_plugin.cpp (+0/-3)
To merge this branch: bzr merge lp:~mzanetti/unity8/launcher-follow-unity-api
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Needs Resubmitting
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Needs Fixing
Review via email: mp+172557@code.launchpad.net

Commit message

change launcher backend implementation to follow launcher API defined in lp:unity-api

Description of the change

This changes the launcher plugin in plugins/Unity/ to follow the launcher API defined in lp:unity-api:

-> move plugin from plugins/Unity to plugins/Unity/Launcher/ (because the API dictates to import Unity.Launcher 0.1)
-> change the mock implementation in tests/qmltests/plugins/ to follow the same API and move to /test/mocks/Unity/Launcher/
-> Adjust the UI code to load the LauncherModel as a singleton to reflect the API changes

The plugin in tests/mocks/ is meant to stay and feed the UI tests for the launcher with some mock data.

The plugin in plugins/ is the one that will be extended to be the real thing. It is subject to be removed to a separate project/repository in the short to mid-term.

To post a comment you must log in.
31. By Michael Zanetti

remove debug print from cmakelists.txt

32. By Michael Zanetti

find unity-shell-launcher instead of libunity-api

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

 libboost1.53-dev : Conflicts: libboost1.49-dev but 1.49.0-4 is to be installed.

So this waits for https://code.launchpad.net/~saviq/unity-api/any-boost/+merge/172525 to be released, right?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> libboost1.53-dev : Conflicts: libboost1.49-dev but 1.49.0-4 is to be
> installed.
>
> So this waits for https://code.launchpad.net/~saviq/unity-api/any-
> boost/+merge/172525 to be released, right?

Oh right, yes. Has a dependency on that one. Unfortunately setting a prerequisite branch doesn't help much in this case. So I guess we just have to wait.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

CMake Error at tests/mocks/Unity/Launcher/CMakeLists.txt:23 (add_library):
  Cannot find source file:

    /home/mzanetti/Development/unity-api/include/unity/shell/launcher/LauncherModelInterface.h

review: Needs Fixing
33. By Michael Zanetti

use real unity-api api also for tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :
review: Needs Resubmitting

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Launcher/Launcher.qml'
2--- Launcher/Launcher.qml 2013-07-01 21:13:41 +0000
3+++ Launcher/Launcher.qml 2013-07-03 08:52:27 +0000
4@@ -19,6 +19,7 @@
5 import Ubuntu.Components 0.1
6 import Ubuntu.Gestures 0.1
7 import Unity 0.1
8+import Unity.Launcher 0.1
9
10 Item {
11 id: root
12@@ -96,10 +97,6 @@
13 }
14 }
15
16- LauncherModel {
17- id: launcherModel
18- }
19-
20 MouseArea {
21 id: launcherDragArea
22 enabled: root.state == "visible"
23@@ -152,7 +149,7 @@
24 bottom: parent.bottom
25 }
26 x: -width
27- model: launcherModel
28+ model: LauncherModel
29
30 property bool animate: true
31
32
33=== modified file 'Launcher/LauncherPanel.qml'
34--- Launcher/LauncherPanel.qml 2013-06-25 13:25:45 +0000
35+++ Launcher/LauncherPanel.qml 2013-07-03 08:52:27 +0000
36@@ -17,6 +17,7 @@
37 import QtQuick 2.0
38 import Ubuntu.Components 0.1
39 import Unity 0.1
40+import Unity.Launcher 0.1
41 import "../Components/ListItems"
42
43 Item {
44@@ -139,7 +140,7 @@
45 maxAngle: 60
46
47 onClicked: {
48- root.applicationSelected(launcherModel.get(index).desktopFile);
49+ root.applicationSelected(LauncherModel.get(index).desktopFile);
50 }
51 }
52
53
54=== modified file 'debian/control'
55--- debian/control 2013-06-20 07:58:53 +0000
56+++ debian/control 2013-07-03 08:52:27 +0000
57@@ -13,6 +13,7 @@
58 libpulse-dev,
59 libqt5v8-5-private-dev,
60 libunity-core-6.0-dev (<< 7.80),
61+ libunity-api-dev,
62 libxcb1-dev,
63 pkg-config,
64 python3,
65
66=== modified file 'plugins/Unity/CMakeLists.txt'
67--- plugins/Unity/CMakeLists.txt 2013-06-06 10:37:13 +0000
68+++ plugins/Unity/CMakeLists.txt 2013-07-03 08:52:27 +0000
69@@ -19,7 +19,6 @@
70 categoryfilter.cpp
71 plugin.cpp
72 bottombarvisibilitycommunicatorshell.cpp
73- launchermodel.cpp
74 )
75
76 add_library(Unity-qml MODULE
77@@ -47,3 +46,6 @@
78 install(FILES qmldir
79 DESTINATION ${SHELL_APP_DIR}/plugins/Unity
80 )
81+
82+
83+add_subdirectory(Launcher)
84
85=== added directory 'plugins/Unity/Launcher'
86=== added file 'plugins/Unity/Launcher/CMakeLists.txt'
87--- plugins/Unity/Launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000
88+++ plugins/Unity/Launcher/CMakeLists.txt 2013-07-03 08:52:27 +0000
89@@ -0,0 +1,36 @@
90+# Dependencies
91+include(FindPkgConfig)
92+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher)
93+
94+include_directories(
95+ ${CMAKE_CURRENT_SOURCE_DIR}
96+ ${CMAKE_CURRENT_BINARY_DIR}
97+ ${LAUNCHER_API_INCLUDEDIR}
98+)
99+
100+set(QMLLAUNCHERPLUGIN_SRC
101+ plugin.cpp
102+ launchermodel.cpp
103+ launcheritem.cpp
104+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
105+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
106+ )
107+
108+add_library(UnityLauncher-qml MODULE
109+ ${QMLLAUNCHERPLUGIN_SRC}
110+ )
111+
112+qt5_use_modules(UnityLauncher-qml Qml)
113+
114+# copy qmldir file into build directory for shadow builds
115+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
116+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
117+ )
118+
119+install(TARGETS UnityLauncher-qml
120+ DESTINATION ${SHELL_APP_DIR}/plugins/Unity/Launcher/
121+ )
122+
123+install(FILES qmldir
124+ DESTINATION ${SHELL_APP_DIR}/plugins/Unity/Launcher/
125+ )
126
127=== added file 'plugins/Unity/Launcher/launcheritem.cpp'
128--- plugins/Unity/Launcher/launcheritem.cpp 1970-01-01 00:00:00 +0000
129+++ plugins/Unity/Launcher/launcheritem.cpp 2013-07-03 08:52:27 +0000
130@@ -0,0 +1,114 @@
131+/*
132+ * Copyright (C) 2013 Canonical, Ltd.
133+ *
134+ * Authors:
135+ * Michael Zanetti <michael.zanetti@canonical.com>
136+ *
137+ * This program is free software; you can redistribute it and/or modify
138+ * it under the terms of the GNU General Public License as published by
139+ * the Free Software Foundation; version 3.
140+ *
141+ * This program is distributed in the hope that it will be useful,
142+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
143+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+ * GNU General Public License for more details.
145+ *
146+ * You should have received a copy of the GNU General Public License
147+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
148+ */
149+
150+#include "launcheritem.h"
151+
152+LauncherItem::LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent) :
153+ LauncherItemInterface(parent),
154+ m_desktopFile(desktopFile),
155+ m_name(name),
156+ m_icon(icon),
157+ m_favorite(false),
158+ m_running(false),
159+ m_recent(false),
160+ m_progress(-1),
161+ m_count(0)
162+{
163+
164+}
165+
166+QString LauncherItem::desktopFile() const
167+{
168+ return m_desktopFile;
169+}
170+
171+QString LauncherItem::name() const
172+{
173+ return m_name;
174+}
175+
176+QString LauncherItem::icon() const
177+{
178+ return m_icon;
179+}
180+
181+bool LauncherItem::favorite() const
182+{
183+ return m_favorite;
184+}
185+
186+void LauncherItem::setFavorite(bool favorite)
187+{
188+ if (m_favorite != favorite) {
189+ m_favorite = favorite;
190+ Q_EMIT favoriteChanged(favorite);
191+ }
192+}
193+
194+bool LauncherItem::running() const
195+{
196+ return m_running;
197+}
198+
199+void LauncherItem::setRunning(bool running)
200+{
201+ if (m_running != running) {
202+ m_running = running;
203+ Q_EMIT runningChanged(running);
204+ }
205+}
206+
207+bool LauncherItem::recent() const
208+{
209+ return m_recent;
210+}
211+
212+void LauncherItem::setRecent(bool recent)
213+{
214+ if (m_recent != recent) {
215+ m_recent = recent;
216+ Q_EMIT recentChanged(recent);
217+ }
218+}
219+
220+int LauncherItem::progress() const
221+{
222+ return m_progress;
223+}
224+
225+void LauncherItem::setProgress(int progress)
226+{
227+ if (m_progress != progress) {
228+ m_progress = progress;
229+ Q_EMIT progressChanged(progress);
230+ }
231+}
232+
233+int LauncherItem::count() const
234+{
235+ return m_count;
236+}
237+
238+void LauncherItem::setCount(int count)
239+{
240+ if (m_count != count) {
241+ m_count = count;
242+ Q_EMIT countChanged(count);
243+ }
244+}
245
246=== added file 'plugins/Unity/Launcher/launcheritem.h'
247--- plugins/Unity/Launcher/launcheritem.h 1970-01-01 00:00:00 +0000
248+++ plugins/Unity/Launcher/launcheritem.h 2013-07-03 08:52:27 +0000
249@@ -0,0 +1,68 @@
250+/*
251+ * Copyright (C) 2013 Canonical, Ltd.
252+ *
253+ * Authors:
254+ * Michael Zanetti <michael.zanetti@canonical.com>
255+ *
256+ * This program is free software; you can redistribute it and/or modify
257+ * it under the terms of the GNU General Public License as published by
258+ * the Free Software Foundation; version 3.
259+ *
260+ * This program is distributed in the hope that it will be useful,
261+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
262+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263+ * GNU General Public License for more details.
264+ *
265+ * You should have received a copy of the GNU General Public License
266+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
267+ */
268+
269+#ifndef LAUNCHERITEM_H
270+#define LAUNCHERITEM_H
271+
272+#include <unity/shell/launcher/LauncherItemInterface.h>
273+
274+using namespace unity::shell::launcher;
275+
276+class LauncherItem: public LauncherItemInterface
277+{
278+ Q_OBJECT
279+public:
280+ LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
281+
282+ QString desktopFile() const;
283+
284+ QString name() const;
285+ QString icon() const;
286+
287+ bool favorite() const;
288+ void setFavorite(bool favorite);
289+
290+ bool running() const;
291+ void setRunning(bool running);
292+
293+ bool recent() const;
294+ void setRecent(bool recent);
295+
296+ int progress() const;
297+ void setProgress(int progress);
298+
299+ int count() const;
300+ void setCount(int count);
301+
302+Q_SIGNALS:
303+ void favoriteChanged(bool favorite);
304+ void runningChanged(bool running);
305+
306+private:
307+ QString m_desktopFile;
308+ QString m_name;
309+ QString m_icon;
310+ bool m_favorite;
311+ bool m_running;
312+ bool m_recent;
313+ int m_progress;
314+ int m_count;
315+};
316+
317+#endif // LAUNCHERITEM_H
318
319=== added file 'plugins/Unity/Launcher/launchermodel.cpp'
320--- plugins/Unity/Launcher/launchermodel.cpp 1970-01-01 00:00:00 +0000
321+++ plugins/Unity/Launcher/launchermodel.cpp 2013-07-03 08:52:27 +0000
322@@ -0,0 +1,102 @@
323+/*
324+ * Copyright (C) 2013 Canonical, Ltd.
325+ *
326+ * Authors:
327+ * Michael Zanetti <michael.zanetti@canonical.com>
328+ *
329+ * This program is free software; you can redistribute it and/or modify
330+ * it under the terms of the GNU General Public License as published by
331+ * the Free Software Foundation; version 3.
332+ *
333+ * This program is distributed in the hope that it will be useful,
334+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
335+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
336+ * GNU General Public License for more details.
337+ *
338+ * You should have received a copy of the GNU General Public License
339+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
340+ */
341+
342+#include "launchermodel.h"
343+#include "launcheritem.h"
344+
345+LauncherModel::LauncherModel(QObject *parent): LauncherModelInterface(parent)
346+{
347+ // FIXME: Dummy data... Aggregate real data from backends
348+
349+ // Fake favorites
350+ LauncherItem *item = new LauncherItem("/usr/share/applications/phone-app.desktop", "Phone", "phone-app");
351+ m_list.append(item);
352+ item = new LauncherItem("/usr/share/applications/camera-app.desktop", "Camera", "camera");
353+ m_list.append(item);
354+ item = new LauncherItem("/usr/share/applications/gallery-app.desktop", "Gallery", "gallery");
355+ m_list.append(item);
356+ item = new LauncherItem("/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook");
357+ m_list.append(item);
358+ item = new LauncherItem("/usr/share/applications/webbrowser-app.desktop", "Browser", "browser");
359+ m_list.append(item);
360+ item = new LauncherItem("/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter");
361+ m_list.append(item);
362+ item = new LauncherItem("/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail");
363+ m_list.append(item);
364+ item = new LauncherItem("/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather");
365+ m_list.append(item);
366+ item = new LauncherItem("/usr/share/applications/notes-app.desktop", "Notepad", "notepad");
367+ m_list.append(item);
368+ item = new LauncherItem("/usr/share/applications/ubuntu-calendar-app.desktop","Calendar", "calendar");
369+ m_list.append(item);
370+}
371+
372+LauncherModel::~LauncherModel()
373+{
374+ while (!m_list.empty()) {
375+ m_list.takeFirst()->deleteLater();
376+ }
377+}
378+
379+int LauncherModel::rowCount(const QModelIndex &parent) const
380+{
381+ Q_UNUSED(parent)
382+ return m_list.count();
383+}
384+
385+QVariant LauncherModel::data(const QModelIndex &index, int role) const
386+{
387+ LauncherItem *item = m_list.at(index.row());
388+ switch(role) {
389+ case RoleName:
390+ return item->name();
391+ case RoleIcon:
392+ return item->icon();
393+ case RoleFavorite:
394+ return item->favorite();
395+ }
396+
397+ return QVariant();
398+}
399+
400+unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
401+{
402+ if (index < 0 || index >= m_list.count()) {
403+ return 0;
404+ }
405+ return m_list.at(index);
406+}
407+
408+void LauncherModel::move(int oldIndex, int newIndex)
409+{
410+ beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
411+ m_list.move(oldIndex, newIndex);
412+ endMoveRows();
413+}
414+
415+QHash<int, QByteArray> LauncherModel::roleNames() const
416+{
417+ QHash<int, QByteArray> roles;
418+ roles.insert(RoleDesktopFile, "desktopFile");
419+ roles.insert(RoleName, "name");
420+ roles.insert(RoleIcon, "icon");
421+ roles.insert(RoleFavorite, "favorite");
422+ roles.insert(RoleRunning, "runnng");
423+ return roles;
424+}
425
426=== added file 'plugins/Unity/Launcher/launchermodel.h'
427--- plugins/Unity/Launcher/launchermodel.h 1970-01-01 00:00:00 +0000
428+++ plugins/Unity/Launcher/launchermodel.h 2013-07-03 08:52:27 +0000
429@@ -0,0 +1,52 @@
430+/*
431+ * Copyright (C) 2013 Canonical, Ltd.
432+ *
433+ * Authors:
434+ * Michael Zanetti <michael.zanetti@canonical.com>
435+ *
436+ * This program is free software; you can redistribute it and/or modify
437+ * it under the terms of the GNU General Public License as published by
438+ * the Free Software Foundation; version 3.
439+ *
440+ * This program is distributed in the hope that it will be useful,
441+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
442+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
443+ * GNU General Public License for more details.
444+ *
445+ * You should have received a copy of the GNU General Public License
446+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
447+ */
448+
449+#ifndef LAUNCHERMODELH
450+#define LAUNCHERMODEL_H
451+
452+#include <unity/shell/launcher/LauncherModelInterface.h>
453+
454+#include <QAbstractListModel>
455+
456+class LauncherItem;
457+
458+using namespace unity::shell::launcher;
459+
460+class LauncherModel: public LauncherModelInterface
461+{
462+ Q_OBJECT
463+
464+public:
465+ LauncherModel(QObject *parent = 0);
466+ ~LauncherModel();
467+
468+ int rowCount(const QModelIndex &parent) const;
469+
470+ QVariant data(const QModelIndex &index, int role) const;
471+
472+ Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
473+ Q_INVOKABLE void move(int oldIndex, int newIndex);
474+
475+ QHash<int, QByteArray> roleNames() const;
476+
477+private:
478+ QList<LauncherItem*> m_list;
479+};
480+
481+#endif // LAUNCHERMODEL_H
482
483=== added file 'plugins/Unity/Launcher/plugin.cpp'
484--- plugins/Unity/Launcher/plugin.cpp 1970-01-01 00:00:00 +0000
485+++ plugins/Unity/Launcher/plugin.cpp 2013-07-03 08:52:27 +0000
486@@ -0,0 +1,45 @@
487+/*
488+ * Copyright (C) 2013 Canonical, Ltd.
489+ *
490+ * This program is free software; you can redistribute it and/or modify
491+ * it under the terms of the GNU General Public License as published by
492+ * the Free Software Foundation; version 3.
493+ *
494+ * This program is distributed in the hope that it will be useful,
495+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
496+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
497+ * GNU General Public License for more details.
498+ *
499+ * You should have received a copy of the GNU General Public License
500+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
501+ *
502+ * Author: Michael Zanetti <michael.zanetti@canonical.com>
503+ */
504+
505+// Qt
506+#include <QtQml>
507+
508+// self
509+#include "plugin.h"
510+
511+// local
512+#include "launchermodel.h"
513+#include "launcheritem.h"
514+
515+
516+using namespace unity::shell::launcher;
517+
518+static QObject* modelProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
519+{
520+ return new LauncherModel();
521+}
522+void UnityLauncherPlugin::registerTypes(const char *uri)
523+{
524+ Q_ASSERT(uri == QLatin1String("Unity.Launcher"));
525+
526+ qmlRegisterUncreatableType<LauncherModelInterface>(uri, 0, 1, "LauncherModelInterface", "Abstract Interface. Cannot be instantiated.");
527+ qmlRegisterUncreatableType<LauncherItemInterface>(uri, 0, 1, "LauncherItemInterface", "Abstract Interface. Cannot be instantiated.");
528+
529+ qmlRegisterSingletonType<LauncherModel>(uri, 0, 1, "LauncherModel", modelProvider);
530+ qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create new Launcher Items in QML. Get them from the LauncherModel.");
531+}
532
533=== added file 'plugins/Unity/Launcher/plugin.h'
534--- plugins/Unity/Launcher/plugin.h 1970-01-01 00:00:00 +0000
535+++ plugins/Unity/Launcher/plugin.h 2013-07-03 08:52:27 +0000
536@@ -0,0 +1,34 @@
537+/*
538+ * Copyright (C) 2013 Canonical, Ltd.
539+ *
540+ * This program is free software; you can redistribute it and/or modify
541+ * it under the terms of the GNU General Public License as published by
542+ * the Free Software Foundation; version 3.
543+ *
544+ * This program is distributed in the hope that it will be useful,
545+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
546+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
547+ * GNU General Public License for more details.
548+ *
549+ * You should have received a copy of the GNU General Public License
550+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
551+ *
552+ * Author: Michael Zanetti <michael.zanetti@canonical.com>
553+ */
554+
555+#ifndef UNITY_LAUNCHER_PLUGIN_H
556+#define UNITY_LAUNCHER_PLUGIN_H
557+
558+#include <QtQml/QQmlEngine>
559+#include <QtQml/QQmlExtensionPlugin>
560+
561+class UnityLauncherPlugin : public QQmlExtensionPlugin
562+{
563+ Q_OBJECT
564+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
565+
566+public:
567+ void registerTypes(const char *uri);
568+};
569+
570+#endif
571
572=== added file 'plugins/Unity/Launcher/qmldir'
573--- plugins/Unity/Launcher/qmldir 1970-01-01 00:00:00 +0000
574+++ plugins/Unity/Launcher/qmldir 2013-07-03 08:52:27 +0000
575@@ -0,0 +1,2 @@
576+module Unity.Launcher
577+plugin UnityLauncher-qml
578
579=== removed file 'plugins/Unity/launchermodel.cpp'
580--- plugins/Unity/launchermodel.cpp 2013-06-05 22:03:08 +0000
581+++ plugins/Unity/launchermodel.cpp 1970-01-01 00:00:00 +0000
582@@ -1,153 +0,0 @@
583-/*
584- * Copyright (C) 2011 Canonical, Ltd.
585- *
586- * Authors:
587- * Michael Zanetti <michael.zanetti@canonical.com>
588- *
589- * This program is free software; you can redistribute it and/or modify
590- * it under the terms of the GNU General Public License as published by
591- * the Free Software Foundation; version 3.
592- *
593- * This program is distributed in the hope that it will be useful,
594- * but WITHOUT ANY WARRANTY; without even the implied warranty of
595- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
596- * GNU General Public License for more details.
597- *
598- * You should have received a copy of the GNU General Public License
599- * along with this program. If not, see <http://www.gnu.org/licenses/>.
600- */
601-
602-#include "launchermodel.h"
603-
604-LauncherModel::LauncherModel(QObject *parent): QAbstractListModel(parent)
605-{
606- // FIXME: Dummy data... Aggregate real data from backends
607-
608- // Fake favorites
609- LauncherItem *item = new LauncherItem("/usr/share/applications/phone-app.desktop", "Phone", "phone-app");
610- m_list.append(item);
611- item = new LauncherItem("/usr/share/applications/camera-app.desktop", "Camera", "camera");
612- m_list.append(item);
613- item = new LauncherItem("/usr/share/applications/gallery-app.desktop", "Gallery", "gallery");
614- m_list.append(item);
615- item = new LauncherItem("/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook");
616- m_list.append(item);
617- item = new LauncherItem("/usr/share/applications/webbrowser-app.desktop", "Browser", "browser");
618- m_list.append(item);
619- item = new LauncherItem("/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter");
620- m_list.append(item);
621- item = new LauncherItem("/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail");
622- m_list.append(item);
623- item = new LauncherItem("/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather");
624- m_list.append(item);
625- item = new LauncherItem("/usr/share/applications/notes-app.desktop", "Notepad", "notepad");
626- m_list.append(item);
627- item = new LauncherItem("/usr/share/applications/ubuntu-calendar-app.desktop","Calendar", "calendar");
628- m_list.append(item);
629-}
630-
631-LauncherModel::~LauncherModel()
632-{
633- while (!m_list.empty()) {
634- m_list.takeFirst()->deleteLater();
635- }
636-}
637-
638-int LauncherModel::rowCount(const QModelIndex &parent) const
639-{
640- Q_UNUSED(parent)
641- return m_list.count();
642-}
643-
644-QVariant LauncherModel::data(const QModelIndex &index, int role) const
645-{
646- LauncherItem *item = m_list.at(index.row());
647- switch(role) {
648- case RoleName:
649- return item->name();
650- case RoleIcon:
651- return item->icon();
652- case RoleFavorite:
653- return item->favorite();
654- }
655-
656- return QVariant();
657-}
658-
659-LauncherItem *LauncherModel::get(int index) const
660-{
661- if (index < 0 || index >= m_list.count()) {
662- return 0;
663- }
664- return m_list.at(index);
665-}
666-
667-void LauncherModel::move(int oldIndex, int newIndex)
668-{
669- beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
670- m_list.move(oldIndex, newIndex);
671- endMoveRows();
672-}
673-
674-QHash<int, QByteArray> LauncherModel::roleNames() const
675-{
676- QHash<int, QByteArray> roles;
677- roles.insert(RoleDesktopFile, "desktopFile");
678- roles.insert(RoleName, "name");
679- roles.insert(RoleIcon, "icon");
680- roles.insert(RoleFavorite, "favorite");
681- roles.insert(RoleRunning, "runnng");
682- return roles;
683-}
684-
685-
686-LauncherItem::LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent):
687- QObject(parent),
688- m_desktopFile(desktopFile),
689- m_name(name),
690- m_icon(icon),
691- m_favorite(false)
692-{
693-
694-}
695-
696-QString LauncherItem::desktopFile() const
697-{
698- return m_desktopFile;
699-}
700-
701-QString LauncherItem::name() const
702-{
703- return m_name;
704-}
705-
706-QString LauncherItem::icon() const
707-{
708- return m_icon;
709-}
710-
711-bool LauncherItem::favorite() const
712-{
713- return m_favorite;
714-}
715-
716-void LauncherItem::setFavorite(bool favorite)
717-{
718- if (m_favorite != favorite) {
719- m_favorite = favorite;
720- Q_EMIT favoriteChanged(m_favorite);
721- }
722-}
723-
724-bool LauncherItem::running() const
725-{
726- return m_running;
727-}
728-
729-void LauncherItem::setRunning(bool running)
730-{
731- if (m_running != running) {
732- m_running = running;
733- Q_EMIT runningChanged(running);
734- }
735-}
736
737=== removed file 'plugins/Unity/launchermodel.h'
738--- plugins/Unity/launchermodel.h 2013-06-05 22:03:08 +0000
739+++ plugins/Unity/launchermodel.h 1970-01-01 00:00:00 +0000
740@@ -1,86 +0,0 @@
741-/*
742- * Copyright (C) 2011 Canonical, Ltd.
743- *
744- * Authors:
745- * Michael Zanetti <michael.zanetti@canonical.com>
746- *
747- * This program is free software; you can redistribute it and/or modify
748- * it under the terms of the GNU General Public License as published by
749- * the Free Software Foundation; version 3.
750- *
751- * This program is distributed in the hope that it will be useful,
752- * but WITHOUT ANY WARRANTY; without even the implied warranty of
753- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
754- * GNU General Public License for more details.
755- *
756- * You should have received a copy of the GNU General Public License
757- * along with this program. If not, see <http://www.gnu.org/licenses/>.
758- */
759-
760-#include <QAbstractListModel>
761-
762-class LauncherItem;
763-
764-class LauncherModel: public QAbstractListModel
765-{
766- Q_OBJECT
767-
768-public:
769- enum Roles {
770- RoleDesktopFile = Qt::UserRole,
771- RoleName,
772- RoleIcon,
773- RoleFavorite,
774- RoleRunning
775- };
776-
777- LauncherModel(QObject *parent = 0);
778- ~LauncherModel();
779-
780- int rowCount(const QModelIndex &parent) const;
781-
782- QVariant data(const QModelIndex &index, int role) const;
783-
784- Q_INVOKABLE LauncherItem* get(int index) const;
785- Q_INVOKABLE void move(int oldIndex, int newIndex);
786-
787- QHash<int, QByteArray> roleNames() const;
788-
789-private:
790- QList<LauncherItem*> m_list;
791-};
792-
793-class LauncherItem: public QObject
794-{
795- Q_OBJECT
796- Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT)
797- Q_PROPERTY(QString name READ name CONSTANT)
798- Q_PROPERTY(QString icon READ icon CONSTANT)
799- Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
800- Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
801-
802-public:
803- LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
804-
805- QString desktopFile() const;
806-
807- QString name() const;
808- QString icon() const;
809-
810- bool favorite() const;
811- void setFavorite(bool favorite);
812-
813- bool running() const;
814- void setRunning(bool running);
815-
816-Q_SIGNALS:
817- void favoriteChanged(bool favorite);
818- void runningChanged(bool running);
819-
820-private:
821- QString m_desktopFile;
822- QString m_name;
823- QString m_icon;
824- bool m_favorite;
825- bool m_running;
826-};
827
828=== modified file 'plugins/Unity/plugin.cpp'
829--- plugins/Unity/plugin.cpp 2013-06-06 15:55:43 +0000
830+++ plugins/Unity/plugin.cpp 2013-07-03 08:52:27 +0000
831@@ -29,7 +29,6 @@
832 #include "categories.h"
833 #include "categoryfilter.h"
834 #include "bottombarvisibilitycommunicatorshell.h"
835-#include "launchermodel.h"
836
837 // libqtdee
838 #include "deelistmodel.h"
839@@ -45,8 +44,6 @@
840 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
841 qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");
842 qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
843- qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");
844- qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create new Launcher Items in QML. Get them from the LauncherModel.");
845 qmlRegisterUncreatableType<BottomBarVisibilityCommunicatorShell>(uri, 0, 1, "BottomBarVisibilityCommunicatorShell", "Can't create BottomBarVisibilityCommunicatorShell");
846 }
847
848
849=== modified file 'tests/mocks/CMakeLists.txt'
850--- tests/mocks/CMakeLists.txt 2013-06-05 22:03:08 +0000
851+++ tests/mocks/CMakeLists.txt 2013-07-03 08:52:27 +0000
852@@ -1,2 +1,3 @@
853 add_subdirectory(LightDM)
854 add_subdirectory(Ubuntu)
855+add_subdirectory(Unity)
856
857=== added directory 'tests/mocks/Unity'
858=== added file 'tests/mocks/Unity/CMakeLists.txt'
859--- tests/mocks/Unity/CMakeLists.txt 1970-01-01 00:00:00 +0000
860+++ tests/mocks/Unity/CMakeLists.txt 2013-07-03 08:52:27 +0000
861@@ -0,0 +1,1 @@
862+add_subdirectory(Launcher)
863
864=== added directory 'tests/mocks/Unity/Launcher'
865=== added file 'tests/mocks/Unity/Launcher/CMakeLists.txt'
866--- tests/mocks/Unity/Launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000
867+++ tests/mocks/Unity/Launcher/CMakeLists.txt 2013-07-03 08:52:27 +0000
868@@ -0,0 +1,38 @@
869+set(CMAKE_AUTOMOC ON)
870+
871+include(FindPkgConfig)
872+find_package(Qt5Core REQUIRED)
873+find_package(Qt5Quick REQUIRED)
874+
875+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher)
876+
877+include_directories(
878+ ${CMAKE_CURRENT_SOURCE_DIR}
879+ ${LAUNCHER_API_INCLUDEDIR}
880+)
881+
882+set(MockLauncherModel_SOURCES
883+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
884+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
885+ plugin.cpp
886+ MockLauncherModel.cpp
887+ MockLauncherItem.cpp
888+)
889+
890+add_library(MockLauncherPlugin MODULE ${MockLauncherModel_SOURCES})
891+
892+qt5_use_modules(MockLauncherPlugin Core Quick)
893+
894+# copy files into build directory for shadow builds
895+add_custom_target(LauncherPluginQmlDirFile ALL
896+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" ${CMAKE_CURRENT_BINARY_DIR}
897+ DEPENDS qmldir
898+)
899+
900+install(TARGETS MockLauncherPlugin
901+ DESTINATION ${SHELL_APP_DIR}/plugins/mocks/Unity/Launcher
902+ )
903+
904+install(FILES qmldir
905+ DESTINATION ${SHELL_APP_DIR}/plugins/mocks/Unity/Launcher
906+ )
907
908=== added file 'tests/mocks/Unity/Launcher/MockLauncherItem.cpp'
909--- tests/mocks/Unity/Launcher/MockLauncherItem.cpp 1970-01-01 00:00:00 +0000
910+++ tests/mocks/Unity/Launcher/MockLauncherItem.cpp 2013-07-03 08:52:27 +0000
911@@ -0,0 +1,121 @@
912+/*
913+ * Copyright 2013 Canonical Ltd.
914+ *
915+ * This program is free software; you can redistribute it and/or modify
916+ * it under the terms of the GNU Lesser General Public License as published by
917+ * the Free Software Foundation; version 3.
918+ *
919+ * This program is distributed in the hope that it will be useful,
920+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
921+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
922+ * GNU Lesser General Public License for more details.
923+ *
924+ * You should have received a copy of the GNU Lesser General Public License
925+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
926+ *
927+ * Authors:
928+ * Michael Zanetti <michael.zanetti@canonical.com>
929+ */
930+
931+#include "MockLauncherItem.h"
932+
933+using namespace unity::shell::launcher;
934+
935+MockLauncherItem::MockLauncherItem(const QString& desktopFile, const QString& name, const QString& icon, QObject* parent):
936+ LauncherItemInterface(parent),
937+ m_desktopFile(desktopFile),
938+ m_name(name),
939+ m_icon(icon),
940+ m_favorite(false),
941+ m_running(false),
942+ m_recent(false),
943+ m_progress(8),
944+ m_count(8)
945+{
946+
947+}
948+
949+QString MockLauncherItem::desktopFile() const
950+{
951+ return m_desktopFile;
952+}
953+
954+QString MockLauncherItem::name() const
955+{
956+ return m_name;
957+}
958+
959+QString MockLauncherItem::icon() const
960+{
961+ return m_icon;
962+}
963+
964+bool MockLauncherItem::favorite() const
965+{
966+ return m_favorite;
967+}
968+
969+void MockLauncherItem::setFavorite(bool favorite)
970+{
971+ if (m_favorite != favorite)
972+ {
973+ m_favorite = favorite;
974+ Q_EMIT favoriteChanged(m_favorite);
975+ }
976+}
977+
978+bool MockLauncherItem::running() const
979+{
980+ return m_running;
981+}
982+
983+void MockLauncherItem::setRunning(bool running)
984+{
985+ if (m_running != running)
986+ {
987+ m_running = running;
988+ Q_EMIT runningChanged(running);
989+ }
990+}
991+
992+bool MockLauncherItem::recent() const
993+{
994+ return m_recent;
995+}
996+
997+void MockLauncherItem::setRecent(bool recent)
998+{
999+ if (m_recent != recent)
1000+ {
1001+ m_recent = recent;
1002+ Q_EMIT recentChanged(recent);
1003+ }
1004+}
1005+
1006+int MockLauncherItem::progress() const
1007+{
1008+ return m_progress;
1009+}
1010+
1011+void MockLauncherItem::setProgress(int progress)
1012+{
1013+ if (m_progress != progress)
1014+ {
1015+ m_progress = progress;
1016+ Q_EMIT progressChanged(progress);
1017+ }
1018+}
1019+
1020+int MockLauncherItem::count() const
1021+{
1022+ return m_count;
1023+}
1024+
1025+void MockLauncherItem::setCount(int count)
1026+{
1027+ if (m_count != count)
1028+ {
1029+ m_count = count;
1030+ Q_EMIT countChanged(count);
1031+ }
1032+}
1033
1034=== added file 'tests/mocks/Unity/Launcher/MockLauncherItem.h'
1035--- tests/mocks/Unity/Launcher/MockLauncherItem.h 1970-01-01 00:00:00 +0000
1036+++ tests/mocks/Unity/Launcher/MockLauncherItem.h 2013-07-03 08:52:27 +0000
1037@@ -0,0 +1,64 @@
1038+/*
1039+ * Copyright 2013 Canonical Ltd.
1040+ *
1041+ * This program is free software; you can redistribute it and/or modify
1042+ * it under the terms of the GNU Lesser General Public License as published by
1043+ * the Free Software Foundation; version 3.
1044+ *
1045+ * This program is distributed in the hope that it will be useful,
1046+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1047+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1048+ * GNU Lesser General Public License for more details.
1049+ *
1050+ * You should have received a copy of the GNU Lesser General Public License
1051+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1052+ *
1053+ * Authors:
1054+ * Michael Zanetti <michael.zanetti@canonical.com>
1055+ */
1056+
1057+#ifndef MOCKLAUNCHERITEM_H
1058+#define MOCKLAUNCHERITEM_H
1059+
1060+#include <unity/shell/launcher/LauncherItemInterface.h>
1061+
1062+using namespace unity::shell::launcher;
1063+
1064+class MockLauncherItem: public LauncherItemInterface
1065+{
1066+ Q_OBJECT
1067+public:
1068+ MockLauncherItem(const QString& desktopFile, const QString& name, const QString& icon, QObject* parent = 0);
1069+
1070+ QString desktopFile() const;
1071+
1072+ QString name() const;
1073+ QString icon() const;
1074+
1075+ bool favorite() const;
1076+ void setFavorite(bool favorite);
1077+
1078+ bool running() const;
1079+ void setRunning(bool running);
1080+
1081+ bool recent() const;
1082+ void setRecent(bool recent);
1083+
1084+ int progress() const;
1085+ void setProgress(int progress);
1086+
1087+ int count() const;
1088+ void setCount(int count);
1089+
1090+private:
1091+ QString m_desktopFile;
1092+ QString m_name;
1093+ QString m_icon;
1094+ bool m_favorite;
1095+ bool m_running;
1096+ bool m_recent;
1097+ int m_progress;
1098+ int m_count;
1099+};
1100+
1101+#endif // MOCKLAUNCHERITEM_H
1102
1103=== added file 'tests/mocks/Unity/Launcher/MockLauncherModel.cpp'
1104--- tests/mocks/Unity/Launcher/MockLauncherModel.cpp 1970-01-01 00:00:00 +0000
1105+++ tests/mocks/Unity/Launcher/MockLauncherModel.cpp 2013-07-03 08:52:27 +0000
1106@@ -0,0 +1,102 @@
1107+/*
1108+ * Copyright 2013 Canonical Ltd.
1109+ *
1110+ * This program is free software; you can redistribute it and/or modify
1111+ * it under the terms of the GNU Lesser General Public License as published by
1112+ * the Free Software Foundation; version 3.
1113+ *
1114+ * This program is distributed in the hope that it will be useful,
1115+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1116+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1117+ * GNU Lesser General Public License for more details.
1118+ *
1119+ * You should have received a copy of the GNU Lesser General Public License
1120+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1121+ *
1122+ * Authors:
1123+ * Michael Zanetti <michael.zanetti@canonical.com>
1124+ */
1125+
1126+#include "MockLauncherModel.h"
1127+#include "MockLauncherItem.h"
1128+
1129+MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
1130+{
1131+ LauncherItemInterface *item = new MockLauncherItem("/usr/share/applications/phone-app.desktop", "Phone", "phone-app");
1132+ m_list.append(item);
1133+ item = new MockLauncherItem("/usr/share/applications/camera-app.desktop", "Camera", "camera");
1134+ m_list.append(item);
1135+ item = new MockLauncherItem("/usr/share/applications/gallery-app.desktop", "Gallery", "gallery");
1136+ m_list.append(item);
1137+ item = new MockLauncherItem("/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook");
1138+ m_list.append(item);
1139+ item = new MockLauncherItem("/usr/share/applications/webbrowser-app.desktop", "Browser", "browser");
1140+ m_list.append(item);
1141+ item = new MockLauncherItem("/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter");
1142+ m_list.append(item);
1143+ item = new MockLauncherItem("/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail");
1144+ m_list.append(item);
1145+ item = new MockLauncherItem("/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather");
1146+ m_list.append(item);
1147+ item = new MockLauncherItem("/usr/share/applications/notes-app.desktop", "Notepad", "notepad");
1148+ m_list.append(item);
1149+ item = new MockLauncherItem("/usr/share/applications/ubuntu-calendar-app.desktop","Calendar", "calendar");
1150+ m_list.append(item);
1151+}
1152+
1153+MockLauncherModel::~MockLauncherModel()
1154+{
1155+ while (!m_list.empty())
1156+ {
1157+ m_list.takeFirst()->deleteLater();
1158+ }
1159+}
1160+
1161+// cppcheck-suppress unusedFunction
1162+int MockLauncherModel::rowCount(const QModelIndex& parent) const
1163+{
1164+ Q_UNUSED(parent)
1165+ return m_list.count();
1166+}
1167+
1168+QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
1169+{
1170+ LauncherItemInterface *item = m_list.at(index.row());
1171+ switch(role)
1172+ {
1173+ case RoleDesktopFile:
1174+ return item->desktopFile();
1175+ case RoleName:
1176+ return item->name();
1177+ case RoleIcon:
1178+ return item->icon();
1179+ case RoleFavorite:
1180+ return item->favorite();
1181+ case RoleRunning:
1182+ return item->running();
1183+ case RoleRecent:
1184+ return item->recent();
1185+ case RoleProgress:
1186+ return item->progress();
1187+ case RoleCount:
1188+ return item->count();
1189+ }
1190+
1191+ return QVariant();
1192+}
1193+
1194+unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index) const
1195+{
1196+ if (index < 0 || index >= m_list.count())
1197+ {
1198+ return 0;
1199+ }
1200+ return m_list.at(index);
1201+}
1202+
1203+void MockLauncherModel::move(int oldIndex, int newIndex)
1204+{
1205+ beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
1206+ m_list.move(oldIndex, newIndex);
1207+ endMoveRows();
1208+}
1209
1210=== added file 'tests/mocks/Unity/Launcher/MockLauncherModel.h'
1211--- tests/mocks/Unity/Launcher/MockLauncherModel.h 1970-01-01 00:00:00 +0000
1212+++ tests/mocks/Unity/Launcher/MockLauncherModel.h 2013-07-03 08:52:27 +0000
1213@@ -0,0 +1,45 @@
1214+/*
1215+ * Copyright 2013 Canonical Ltd.
1216+ *
1217+ * This program is free software; you can redistribute it and/or modify
1218+ * it under the terms of the GNU Lesser General Public License as published by
1219+ * the Free Software Foundation; version 3.
1220+ *
1221+ * This program is distributed in the hope that it will be useful,
1222+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1223+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1224+ * GNU Lesser General Public License for more details.
1225+ *
1226+ * You should have received a copy of the GNU Lesser General Public License
1227+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1228+ *
1229+ * Authors:
1230+ * Michael Zanetti <michael.zanetti@canonical.com>
1231+ */
1232+
1233+#ifndef MOCKLAUNCHERMODEL_H
1234+#define MOCKLAUNCHERMODEL_H
1235+
1236+#include <unity/shell/launcher/LauncherModelInterface.h>
1237+
1238+using namespace unity::shell::launcher;
1239+
1240+class MockLauncherModel: public LauncherModelInterface
1241+{
1242+ Q_OBJECT
1243+
1244+public:
1245+ MockLauncherModel(QObject* parent = 0);
1246+ ~MockLauncherModel();
1247+
1248+ int rowCount(const QModelIndex& parent) const;
1249+
1250+ QVariant data(const QModelIndex& index, int role) const;
1251+
1252+ Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const;
1253+ Q_INVOKABLE void move(int oldIndex, int newIndex);
1254+private:
1255+ QList<LauncherItemInterface*> m_list;
1256+};
1257+
1258+#endif // MOCKLAUNCHERMODEL_H
1259
1260=== added file 'tests/mocks/Unity/Launcher/plugin.cpp'
1261--- tests/mocks/Unity/Launcher/plugin.cpp 1970-01-01 00:00:00 +0000
1262+++ tests/mocks/Unity/Launcher/plugin.cpp 2013-07-03 08:52:27 +0000
1263@@ -0,0 +1,45 @@
1264+/*
1265+ * Copyright 2013 Canonical Ltd.
1266+ *
1267+ * This program is free software; you can redistribute it and/or modify
1268+ * it under the terms of the GNU Lesser General Public License as published by
1269+ * the Free Software Foundation; version 3.
1270+ *
1271+ * This program is distributed in the hope that it will be useful,
1272+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1273+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1274+ * GNU Lesser General Public License for more details.
1275+ *
1276+ * You should have received a copy of the GNU Lesser General Public License
1277+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1278+ *
1279+ * Authors:
1280+ * Michael Zanetti <michael.zanetti@canonical.com>
1281+ */
1282+
1283+#include "plugin.h"
1284+#include "MockLauncherModel.h"
1285+#include "MockLauncherItem.h"
1286+
1287+#include <unity/shell/launcher/LauncherModelInterface.h>
1288+#include <unity/shell/launcher/LauncherItemInterface.h>
1289+
1290+#include <QtQml/qqml.h>
1291+
1292+using namespace unity::shell::launcher;
1293+
1294+static QObject* modelProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
1295+{
1296+ return new MockLauncherModel();
1297+}
1298+
1299+// cppcheck-suppress unusedFunction
1300+void TestLauncherPlugin::registerTypes(const char* uri)
1301+{
1302+ // @uri Unity.Launcher
1303+ qmlRegisterUncreatableType<LauncherModelInterface>(uri, 0, 1, "LauncherModelInterface", "Abstract Interface. Cannot be instantiated.");
1304+ qmlRegisterUncreatableType<LauncherItemInterface>(uri, 0, 1, "LauncherItemInterface", "Abstract Interface. Cannot be instantiated.");
1305+
1306+ qmlRegisterSingletonType<MockLauncherModel>(uri, 0, 1, "LauncherModel", modelProvider);
1307+ qmlRegisterUncreatableType<MockLauncherItem>(uri, 0, 1, "LauncherItem", "Can't create LauncherItems in QML. Get them from the LauncherModel");
1308+}
1309
1310=== added file 'tests/mocks/Unity/Launcher/plugin.h'
1311--- tests/mocks/Unity/Launcher/plugin.h 1970-01-01 00:00:00 +0000
1312+++ tests/mocks/Unity/Launcher/plugin.h 2013-07-03 08:52:27 +0000
1313@@ -0,0 +1,35 @@
1314+/*
1315+ * Copyright 2013 Canonical Ltd.
1316+ *
1317+ * This program is free software; you can redistribute it and/or modify
1318+ * it under the terms of the GNU Lesser General Public License as published by
1319+ * the Free Software Foundation; version 3.
1320+ *
1321+ * This program is distributed in the hope that it will be useful,
1322+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1323+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1324+ * GNU Lesser General Public License for more details.
1325+ *
1326+ * You should have received a copy of the GNU Lesser General Public License
1327+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1328+ *
1329+ * Authors:
1330+ * Michael Zanetti <michael.zanetti@canonical.com>
1331+ */
1332+
1333+
1334+#ifndef TESTLAUNCHER_PLUGIN_H
1335+#define TESTLAUNCHER_PLUGIN_H
1336+
1337+#include <QtQml/QQmlExtensionPlugin>
1338+
1339+class TestLauncherPlugin : public QQmlExtensionPlugin
1340+{
1341+ Q_OBJECT
1342+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
1343+
1344+public:
1345+ void registerTypes(const char* uri);
1346+};
1347+
1348+#endif // TESTLAUNCHER_PLUGIN_H
1349
1350=== added file 'tests/mocks/Unity/Launcher/qmldir'
1351--- tests/mocks/Unity/Launcher/qmldir 1970-01-01 00:00:00 +0000
1352+++ tests/mocks/Unity/Launcher/qmldir 2013-07-03 08:52:27 +0000
1353@@ -0,0 +1,2 @@
1354+module Unity.Launcher
1355+plugin MockLauncherPlugin
1356
1357=== modified file 'tests/qmltests/CMakeLists.txt'
1358--- tests/qmltests/CMakeLists.txt 2013-07-01 08:00:40 +0000
1359+++ tests/qmltests/CMakeLists.txt 2013-07-03 08:52:27 +0000
1360@@ -57,7 +57,7 @@
1361 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
1362 add_qml_test(Hud Hud)
1363 add_qml_test(Hud Result)
1364-add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
1365+add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins/ ${CMAKE_BINARY_DIR}/tests/mocks/ ${qmltest_DEFAULT_IMPORT_PATHS})
1366 add_qml_test(Notifications Notifications IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
1367 add_qml_test(Panel IndicatorRow)
1368 add_qml_test(Panel Indicators)
1369
1370=== modified file 'tests/qmltests/plugins/Unity/CMakeLists.txt'
1371--- tests/qmltests/plugins/Unity/CMakeLists.txt 2013-06-12 15:03:07 +0000
1372+++ tests/qmltests/plugins/Unity/CMakeLists.txt 2013-07-03 08:52:27 +0000
1373@@ -25,7 +25,6 @@
1374 fake_scope.cpp
1375 fake_scopes.cpp
1376 fake_unity_plugin.cpp
1377- fake_launchermodel.cpp
1378 )
1379
1380 add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})
1381
1382=== removed file 'tests/qmltests/plugins/Unity/fake_launchermodel.cpp'
1383--- tests/qmltests/plugins/Unity/fake_launchermodel.cpp 2013-06-05 22:03:08 +0000
1384+++ tests/qmltests/plugins/Unity/fake_launchermodel.cpp 1970-01-01 00:00:00 +0000
1385@@ -1,150 +0,0 @@
1386-/*
1387- * Copyright (C) 2011 Canonical, Ltd.
1388- *
1389- * Authors:
1390- * Michael Zanetti <michael.zanetti@canonical.com>
1391- *
1392- * This program is free software; you can redistribute it and/or modify
1393- * it under the terms of the GNU General Public License as published by
1394- * the Free Software Foundation; version 3.
1395- *
1396- * This program is distributed in the hope that it will be useful,
1397- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1398- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1399- * GNU General Public License for more details.
1400- *
1401- * You should have received a copy of the GNU General Public License
1402- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1403- */
1404-
1405-#include "launchermodel.h"
1406-
1407-LauncherModel::LauncherModel(QObject *parent): QAbstractListModel(parent)
1408-{
1409- LauncherItem *item = new LauncherItem("/usr/share/applications/phone-app.desktop", "Phone", "phone-app");
1410- m_list.append(item);
1411- item = new LauncherItem("/usr/share/applications/camera-app.desktop", "Camera", "camera");
1412- m_list.append(item);
1413- item = new LauncherItem("/usr/share/applications/gallery-app.desktop", "Gallery", "gallery");
1414- m_list.append(item);
1415- item = new LauncherItem("/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook");
1416- m_list.append(item);
1417- item = new LauncherItem("/usr/share/applications/webbrowser-app.desktop", "Browser", "browser");
1418- m_list.append(item);
1419- item = new LauncherItem("/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter");
1420- m_list.append(item);
1421- item = new LauncherItem("/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail");
1422- m_list.append(item);
1423- item = new LauncherItem("/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather");
1424- m_list.append(item);
1425- item = new LauncherItem("/usr/share/applications/notes-app.desktop", "Notepad", "notepad");
1426- m_list.append(item);
1427- item = new LauncherItem("/usr/share/applications/ubuntu-calendar-app.desktop","Calendar", "calendar");
1428- m_list.append(item);
1429-}
1430-
1431-LauncherModel::~LauncherModel()
1432-{
1433- while (!m_list.empty()) {
1434- m_list.takeFirst()->deleteLater();
1435- }
1436-}
1437-
1438-int LauncherModel::rowCount(const QModelIndex &parent) const
1439-{
1440- Q_UNUSED(parent)
1441- return m_list.count();
1442-}
1443-
1444-QVariant LauncherModel::data(const QModelIndex &index, int role) const
1445-{
1446- LauncherItem *item = m_list.at(index.row());
1447- switch(role) {
1448- case RoleName:
1449- return item->name();
1450- case RoleIcon:
1451- return item->icon();
1452- case RoleFavorite:
1453- return item->favorite();
1454- }
1455-
1456- return QVariant();
1457-}
1458-
1459-LauncherItem *LauncherModel::get(int index) const
1460-{
1461- if (index < 0 || index >= m_list.count()) {
1462- return 0;
1463- }
1464- return m_list.at(index);
1465-}
1466-
1467-void LauncherModel::move(int oldIndex, int newIndex)
1468-{
1469- beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
1470- m_list.move(oldIndex, newIndex);
1471- endMoveRows();
1472-}
1473-
1474-QHash<int, QByteArray> LauncherModel::roleNames() const
1475-{
1476- QHash<int, QByteArray> roles;
1477- roles.insert(RoleDesktopFile, "desktopFile");
1478- roles.insert(RoleName, "name");
1479- roles.insert(RoleIcon, "icon");
1480- roles.insert(RoleFavorite, "favorite");
1481- roles.insert(RoleRunning, "runnng");
1482- return roles;
1483-}
1484-
1485-
1486-LauncherItem::LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent):
1487- QObject(parent),
1488- m_desktopFile(desktopFile),
1489- m_name(name),
1490- m_icon(icon),
1491- m_favorite(false)
1492-{
1493-
1494-}
1495-
1496-QString LauncherItem::desktopFile() const
1497-{
1498- return m_desktopFile;
1499-}
1500-
1501-QString LauncherItem::name() const
1502-{
1503- return m_name;
1504-}
1505-
1506-QString LauncherItem::icon() const
1507-{
1508- return m_icon;
1509-}
1510-
1511-bool LauncherItem::favorite() const
1512-{
1513- return m_favorite;
1514-}
1515-
1516-void LauncherItem::setFavorite(bool favorite)
1517-{
1518- if (m_favorite != favorite) {
1519- m_favorite = favorite;
1520- Q_EMIT favoriteChanged(m_favorite);
1521- }
1522-}
1523-
1524-bool LauncherItem::running() const
1525-{
1526- return m_running;
1527-}
1528-
1529-void LauncherItem::setRunning(bool running)
1530-{
1531- if (m_running != running) {
1532- m_running = running;
1533- Q_EMIT runningChanged(running);
1534- }
1535-}
1536
1537=== removed file 'tests/qmltests/plugins/Unity/fake_launchermodel.h'
1538--- tests/qmltests/plugins/Unity/fake_launchermodel.h 2013-06-05 22:03:08 +0000
1539+++ tests/qmltests/plugins/Unity/fake_launchermodel.h 1970-01-01 00:00:00 +0000
1540@@ -1,86 +0,0 @@
1541-/*
1542- * Copyright (C) 2011 Canonical, Ltd.
1543- *
1544- * Authors:
1545- * Michael Zanetti <michael.zanetti@canonical.com>
1546- *
1547- * This program is free software; you can redistribute it and/or modify
1548- * it under the terms of the GNU General Public License as published by
1549- * the Free Software Foundation; version 3.
1550- *
1551- * This program is distributed in the hope that it will be useful,
1552- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1553- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1554- * GNU General Public License for more details.
1555- *
1556- * You should have received a copy of the GNU General Public License
1557- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1558- */
1559-
1560-#include <QAbstractListModel>
1561-
1562-class LauncherItem;
1563-
1564-class LauncherModel: public QAbstractListModel
1565-{
1566- Q_OBJECT
1567-
1568-public:
1569- enum Roles {
1570- RoleDesktopFile = Qt::UserRole,
1571- RoleName,
1572- RoleIcon,
1573- RoleFavorite,
1574- RoleRunning
1575- };
1576-
1577- LauncherModel(QObject *parent = 0);
1578- ~LauncherModel();
1579-
1580- int rowCount(const QModelIndex &parent) const;
1581-
1582- QVariant data(const QModelIndex &index, int role) const;
1583-
1584- Q_INVOKABLE LauncherItem* get(int index) const;
1585- Q_INVOKABLE void move(int oldIndex, int newIndex);
1586-
1587- QHash<int, QByteArray> roleNames() const;
1588-
1589-private:
1590- QList<LauncherItem*> m_list;
1591-};
1592-
1593-class LauncherItem: public QObject
1594-{
1595- Q_OBJECT
1596- Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT)
1597- Q_PROPERTY(QString name READ name CONSTANT)
1598- Q_PROPERTY(QString icon READ icon CONSTANT)
1599- Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
1600- Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
1601-
1602-public:
1603- LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
1604-
1605- QString desktopFile() const;
1606-
1607- QString name() const;
1608- QString icon() const;
1609-
1610- bool favorite() const;
1611- void setFavorite(bool favorite);
1612-
1613- bool running() const;
1614- void setRunning(bool running);
1615-
1616-Q_SIGNALS:
1617- void favoriteChanged(bool favorite);
1618- void runningChanged(bool running);
1619-
1620-private:
1621- QString m_desktopFile;
1622- QString m_name;
1623- QString m_icon;
1624- bool m_favorite;
1625- bool m_running;
1626-};
1627
1628=== modified file 'tests/qmltests/plugins/Unity/fake_unity_plugin.cpp'
1629--- tests/qmltests/plugins/Unity/fake_unity_plugin.cpp 2013-06-12 15:03:07 +0000
1630+++ tests/qmltests/plugins/Unity/fake_unity_plugin.cpp 2013-07-03 08:52:27 +0000
1631@@ -23,7 +23,6 @@
1632 #include "fake_scopes.h"
1633 #include "categories.h"
1634 #include "categoryfilter.h"
1635-#include "fake_launchermodel.h"
1636
1637 // External
1638 #include <glib-object.h>
1639@@ -41,6 +40,4 @@
1640 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
1641 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
1642 qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");
1643- qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");
1644- qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create");
1645 }

Subscribers

People subscribed via source and target branches