on xenial help sign in
merge with trunk (moves changes in scope to lp:unity-scopes-shell)
a072b35Michael Zanetti
Components/PageHeader.qml+1−1
@@ -30,7 +30,7 @@ Item {
30
30
31 property bool searchEntryEnabled: false
31 property bool searchEntryEnabled: false
32 property alias searchQuery: searchField.text
32 property alias searchQuery: searchField.text
33− property ListModel searchHistory: SearchHistoryModel {}
33+ property ListModel searchHistory
34 property Scope scope
34 property Scope scope
35
35
36 height: units.gu(8.5)
36 height: units.gu(8.5)
Dash/Dash.qml+3
@@ -26,6 +26,8 @@ Showable {
26
26
27 visible: shown
27 visible: shown
28
28
29+ property ListModel searchHistory: SearchHistoryModel {}
30+
29 property alias contentProgress: dashContent.contentProgress
31 property alias contentProgress: dashContent.contentProgress
30 property string showScopeOnLoaded: "home.scope"
32 property string showScopeOnLoaded: "home.scope"
31 property real contentScale: 1.0
33 property real contentScale: 1.0
@@ -63,6 +65,7 @@ Showable {
63 anchors.fill: parent
65 anchors.fill: parent
64 model: filteredScopes
66 model: filteredScopes
65 scopes: scopes
67 scopes: scopes
68+ searchHistory: dash.searchHistory
66 onMovementStarted: dashbar.startNavigation()
69 onMovementStarted: dashbar.startNavigation()
67 onMovementEnded: dashbar.stopNavigation()
70 onMovementEnded: dashbar.stopNavigation()
68 onContentFlickStarted: dashbar.finishNavigation()
71 onContentFlickStarted: dashbar.finishNavigation()
Dash/DashApps.qml+3
@@ -30,6 +30,9 @@ GenericScopeView {
30 property var mainStageApplicationsModel: shell.applicationManager.mainStageApplications
30 property var mainStageApplicationsModel: shell.applicationManager.mainStageApplications
31 property var sideStageApplicationModel: shell.applicationManager.sideStageApplications
31 property var sideStageApplicationModel: shell.applicationManager.sideStageApplications
32
32
33+ //FIXME an alias to itself shouldn't be required. More than likely a Qt bug. Try removing with newer Qt.
34+ property alias searchHistory: scopeView.searchHistory
35+
33 ListModel {
36 ListModel {
34 id: dummyVisibilityModifier
37 id: dummyVisibilityModifier
35
38
Dash/DashContent.qml+2−1
@@ -27,6 +27,7 @@ Item {
27 property alias currentIndex: dashContentList.currentIndex
27 property alias currentIndex: dashContentList.currentIndex
28
28
29 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
29 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
30+ property ListModel searchHistory
30
31
31 signal movementStarted()
32 signal movementStarted()
32 signal movementEnded()
33 signal movementEnded()
@@ -127,7 +128,7 @@ Item {
127 onLoaded: {
128 onLoaded: {
128 item.scope = Qt.binding(function() { return scope })
129 item.scope = Qt.binding(function() { return scope })
129 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
130 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
130− item.searchHistory = Qt.binding(function() { return shell.searchHistory })
131+ item.searchHistory = Qt.binding(function() { return dashContent.searchHistory })
131 dashContentList.movementStarted.connect(item.movementStarted)
132 dashContentList.movementStarted.connect(item.movementStarted)
132 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
133 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
133 dashContent.scopeLoaded(item.scope.id)
134 dashContent.scopeLoaded(item.scope.id)
Dash/GenericScopeView.qml+1
@@ -293,6 +293,7 @@ FocusScope {
293 text: scopeView.scope.name
293 text: scopeView.scope.name
294 searchEntryEnabled: true
294 searchEntryEnabled: true
295 scope: scopeView.scope
295 scope: scopeView.scope
296+ searchHistory: scopeView.searchHistory
296 }
297 }
297 }
298 }
298
299
Greeter/Lockscreen.qml+6−18
@@ -17,7 +17,6 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import "../Components"
19import "../Components"
20−import LightDM 0.1 as LightDM
21
20
22Showable {
21Showable {
23 id: root
22 id: root
@@ -37,7 +36,7 @@ Showable {
37
36
38 property url background: ""
37 property url background: ""
39
38
40− signal unlocked()
39+ signal entered(string passphrase)
41 signal cancel()
40 signal cancel()
42 signal emergencyCall()
41 signal emergencyCall()
43
42
@@ -53,6 +52,10 @@ Showable {
53 pinPadLoader.resetting = false;
52 pinPadLoader.resetting = false;
54 }
53 }
55
54
55+ function clear(showAnimation) {
56+ pinPadLoader.item.clear(showAnimation);
57+ }
58+
56 Rectangle {
59 Rectangle {
57 // In case background fails to load or is undefined
60 // In case background fails to load or is undefined
58 id: backgroundBackup
61 id: backgroundBackup
@@ -92,7 +95,7 @@ Showable {
92 target: pinPadLoader.item
95 target: pinPadLoader.item
93
96
94 onEntered: {
97 onEntered: {
95− LightDM.Greeter.respond(passphrase);
98+ root.entered(passphrase);
96 }
99 }
97
100
98 onCancel: {
101 onCancel: {
@@ -150,19 +153,4 @@ Showable {
150 anchors.horizontalCenter: parent.horizontalCenter
153 anchors.horizontalCenter: parent.horizontalCenter
151 }
154 }
152 }
155 }
153−
154− Connections {
155− target: LightDM.Greeter
156−
157− onAuthenticationComplete: {
158− if (LightDM.Greeter.promptless) {
159− return;
160− }
161− if (LightDM.Greeter.authenticated) {
162− root.unlocked();
163− } else {
164− pinPadLoader.item.clear(true);
165− }
166− }
167− }
168}
156}
Greeter/PassphraseLockscreen.qml+1
@@ -82,6 +82,7 @@ Item {
82
82
83 WrongPasswordAnimation {
83 WrongPasswordAnimation {
84 id: wrongPasswordAnimation
84 id: wrongPasswordAnimation
85+ objectName: "wrongPasswordAnimation"
85 target: pinentryField
86 target: pinentryField
86 }
87 }
87}
88}
Greeter/PinLockscreen.qml+1
@@ -210,6 +210,7 @@ Column {
210
210
211 WrongPasswordAnimation {
211 WrongPasswordAnimation {
212 id: wrongPasswordAnimation
212 id: wrongPasswordAnimation
213+ objectName: "wrongPasswordAnimation"
213 target: pinentryField
214 target: pinentryField
214 }
215 }
215}
216}
Notifications/Notification.qml+3−7
@@ -23,7 +23,7 @@ import Utils 0.1
23UbuntuShape {
23UbuntuShape {
24 id: notification
24 id: notification
25
25
26− property alias iconSource: avatarIcon.source
26+ property alias iconSource: icon.fileSource
27 property alias secondaryIconSource: secondaryIcon.source
27 property alias secondaryIconSource: secondaryIcon.source
28 property alias summary: summaryLabel.text
28 property alias summary: summaryLabel.text
29 property alias body: bodyLabel.text
29 property alias body: bodyLabel.text
@@ -102,18 +102,14 @@ UbuntuShape {
102 right: parent.right
102 right: parent.right
103 }
103 }
104
104
105− UbuntuShape {
105+ ShapedIcon {
106 id: icon
106 id: icon
107
107
108 objectName: "icon"
108 objectName: "icon"
109 width: units.gu(6)
109 width: units.gu(6)
110 height: units.gu(6)
110 height: units.gu(6)
111+ shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
111 visible: iconSource !== undefined && iconSource != ""
112 visible: iconSource !== undefined && iconSource != ""
112− image: Image {
113− id: avatarIcon
114−
115− fillMode: Image.PreserveAspectCrop
116− }
117 }
113 }
118
114
119 Image {
115 Image {
plugins/Unity/ratingoptionsmodel.cpp → Notifications/ShapedIcon.qmlrenamed+20−13
@@ -1,9 +1,6 @@
1/*
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
3 *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
6 * the Free Software Foundation; version 3.
@@ -17,17 +14,27 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
15 */
19
16
20−// self
17+import QtQuick 2.0
21−#include "ratingoptionsmodel.h"
18+import Ubuntu.Components 0.1
19+
20+Item {
21+ property string fileSource
22+ property bool shaped
23+
24+ UbuntuShape {
25+ objectName: "shapedIcon"
26+ anchors.fill: parent
27+ visible: shaped
28+ image: realImage
29+ }
22
30
23−// local
31+ Image {
24−#include "ratingfilteroption.h"
32+ id: realImage
25
33
26−RatingOptionsModel::RatingOptionsModel(bool showAllOption, QObject *parent) :
34+ objectName: "nonShapedIcon"
27− GenericOptionsModel(showAllOption, parent)
35+ anchors.fill: parent
28−{
36+ visible: !shaped
29− for (int i=1; i<=5; i++) {
37+ source: fileSource
30− auto opt = new RatingFilterOption(QString::number(i), i*0.2f, this);
38+ fillMode: Image.PreserveAspectCrop
31− addOption(opt);
32 }
39 }
33}
40}
Panel/Indicators/client/IndicatorsTree.qml+2−3
@@ -29,10 +29,9 @@ Page {
29
29
30 property string busName: unityModel.busName
30 property string busName: unityModel.busName
31 property string actionsObjectPath
31 property string actionsObjectPath
32− property var menuObjectPaths: undefined
32+ property string menuObjectPath
33− readonly property string device: "phone"
34
33
35− property string deviceMenuObjectPath: menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
34+ property string deviceMenuObjectPath: menuObjectPath
36
35
37 function start() {
36 function start() {
38 }
37 }
Shell.qml+12−3
@@ -61,8 +61,6 @@ FocusScope {
61 }
61 }
62 }
62 }
63
63
64− property ListModel searchHistory: SearchHistoryModel {}
65−
66 property var applicationManager: ApplicationManagerWrapper {}
64 property var applicationManager: ApplicationManagerWrapper {}
67
65
68 Binding {
66 Binding {
@@ -416,7 +414,7 @@ FocusScope {
416 height: parent.height - panel.panelHeight
414 height: parent.height - panel.panelHeight
417 background: shell.background
415 background: shell.background
418
416
419− onUnlocked: lockscreen.hide()
417+ onEntered: LightDM.Greeter.respond(passphrase);
420 onCancel: greeter.show()
418 onCancel: greeter.show()
421
419
422 Component.onCompleted: {
420 Component.onCompleted: {
@@ -442,6 +440,17 @@ FocusScope {
442 lockscreen.show();
440 lockscreen.show();
443 }
441 }
444 }
442 }
443+
444+ onAuthenticationComplete: {
445+ if (LightDM.Greeter.promptless) {
446+ return;
447+ }
448+ if (LightDM.Greeter.authenticated) {
449+ lockscreen.hide();
450+ } else {
451+ lockscreen.clear(true);
452+ }
453+ }
445 }
454 }
446
455
447 Greeter {
456 Greeter {
build+1
@@ -50,6 +50,7 @@ install_dependencies() {
50 ubuntu-mobile-icons \
50 ubuntu-mobile-icons \
51 unity-scope-home \
51 unity-scope-home \
52 unity-lens-applications \
52 unity-lens-applications \
53+ unity-plugin-scopes \
53 || exit 5
54 || exit 5
54}
55}
55
56
debian/changelog+6
@@ -1,3 +1,9 @@
1+unity8 (7.84-0ubuntu1) UNRELEASED; urgency=low
2+
3+ * Depend on the separate scopes plugin
4+
5+ -- Michal Hruby <michal.hruby@canonical.com> Wed, 13 Nov 2013 12:43:39 +0000
6+
1unity8 (7.83+14.04.20131106-0ubuntu1) trusty; urgency=low
7unity8 (7.83+14.04.20131106-0ubuntu1) trusty; urgency=low
2
8
3 [ Andrea Cimitan ]
9 [ Andrea Cimitan ]
debian/control+3−1
@@ -18,7 +18,7 @@ Build-Depends: cmake,
18 libqmenumodel-dev (>= 0.2.7),
18 libqmenumodel-dev (>= 0.2.7),
19 libqt5v8-5-private-dev,
19 libqt5v8-5-private-dev,
20 libsigc++-2.0-dev,
20 libsigc++-2.0-dev,
21− libunity-api-dev (>= 7.80.3),
21+ libunity-api-dev (>= 7.80.4),
22 libunity-core-6.0-dev (>= 7.1.1),
22 libunity-core-6.0-dev (>= 7.1.1),
23 libunity-dev (>= 7.0.12),
23 libunity-dev (>= 7.0.12),
24 libunity-mir-dev,
24 libunity-mir-dev,
@@ -79,6 +79,8 @@ Depends: gsettings-desktop-schemas,
79 unity8-fake-env | qtubuntu-shell,
79 unity8-fake-env | qtubuntu-shell,
80 unity8-private (= ${binary:Version}),
80 unity8-private (= ${binary:Version}),
81 unity8-private | unity-launcher-impl,
81 unity8-private | unity-launcher-impl,
82+ unity-plugin-scopes | unity-scopes-impl,
83+ unity-scopes-impl-0,
82# for setcap:
84# for setcap:
83 libcap2-bin,
85 libcap2-bin,
84 ${misc:Depends},
86 ${misc:Depends},
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+17
@@ -479,6 +479,12 @@ void ListViewWithPageHeader::componentComplete()
479
479
480void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
480void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
481{
481{
482+ // Check we are not being taken down and don't paint anything
483+ // TODO Check if we still need this in 5.2
484+ // For reproduction just inifnite loop testDash or testDashContent
485+ if (!QQmlEngine::contextForObject(this)->parentContext())
486+ return;
487+
482 QQuickFlickable::viewportMoved(orient);
488 QQuickFlickable::viewportMoved(orient);
483// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
489// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
484 qreal diff = m_previousContentY - contentY();
490 qreal diff = m_previousContentY - contentY();
@@ -855,6 +861,11 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
855 }
861 }
856#endif
862#endif
857// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
863// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
864+ // Check we are not being taken down and don't paint anything
865+ // TODO Check if we still need this in 5.2
866+ // For reproduction just inifnite loop testDash or testDashContent
867+ if (!QQmlEngine::contextForObject(this)->parentContext())
868+ return;
858
869
859 item->setParentItem(m_clipItem);
870 item->setParentItem(m_clipItem);
860 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
871 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
@@ -1235,6 +1246,12 @@ void ListViewWithPageHeader::layout()
1235
1246
1236void ListViewWithPageHeader::updatePolish()
1247void ListViewWithPageHeader::updatePolish()
1237{
1248{
1249+ // Check we are not being taken down and don't paint anything
1250+ // TODO Check if we still need this in 5.2
1251+ // For reproduction just inifnite loop testDash or testDashContent
1252+ if (!QQmlEngine::contextForObject(this)->parentContext())
1253+ return;
1254+
1238 Q_FOREACH(ListItem *item, m_itemsToRelease)
1255 Q_FOREACH(ListItem *item, m_itemsToRelease)
1239 reallyReleaseItem(item);
1256 reallyReleaseItem(item);
1240 m_itemsToRelease.clear();
1257 m_itemsToRelease.clear();
plugins/Unity/CMakeLists.txt−69
@@ -1,71 +1,2 @@
1−# export_qmlplugin macro
2−include(Plugins)
3−
4add_subdirectory(Indicators)
1add_subdirectory(Indicators)
5−
6−# Dependencies
7−include(FindPkgConfig)
8−pkg_check_modules(QTDEE REQUIRED libdee-qt5>=3.2)
9−pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0>=7.1.1)
10−
11−include_directories(
12− ${CMAKE_CURRENT_SOURCE_DIR}
13− ${CMAKE_CURRENT_BINARY_DIR}
14− ${QTDEE_INCLUDE_DIRS}
15− ${UNITYCORE_INCLUDE_DIRS}
16− ${Qt5DBus_INCLUDE_DIRS}
17−)
18−
19−set(QMLPLUGIN_SRC
20− abstractfilteroption.cpp
21− scope.cpp
22− scopes.cpp
23− categories.cpp
24− checkoptionfilter.cpp
25− filter.cpp
26− filteroption.cpp
27− filters.cpp
28− genericoptionsmodel.cpp
29− ratingoptionsmodel.cpp
30− unityoptionsmodel.cpp
31− categoryresults.cpp
32− plugin.cpp
33− multirangefilter.cpp
34− radiooptionfilter.cpp
35− ratingsfilter.cpp
36− ratingfilteroption.cpp
37− applicationpreview.cpp
38− genericpreview.cpp
39− moviepreview.cpp
40− musicpreview.cpp
41− musicpreviewtrackmodel.cpp
42− preview.cpp
43− previewaction.cpp
44− previewinfohint.cpp
45− result.cpp
46− showallfilteroption.cpp
47− signalslist.cpp
48− socialpreview.cpp
49− socialpreviewcomment.cpp
50− iconutils.cpp
51− variantutils.cpp
52−)
53−
54−add_library(Unity-qml MODULE
55− ${QMLPLUGIN_SRC}
56− )
57−
58−target_link_libraries(Unity-qml
59− ${QTDEE_LDFLAGS}
60− ${UNITYCORE_LDFLAGS}
61− ${Qt5DBus_LIBRARIES}
62− ${Qt5Gui_LIBRARIES}
63− )
64−
65−qt5_use_modules(Unity-qml Qml)
66−
67−# export the qmldir qmltypes and plugin files
68−export_qmlfiles(Unity Unity)
69−export_qmlplugin(Unity 0.1 Unity TARGETS Unity-qml)
70−
71add_subdirectory(Launcher)
2add_subdirectory(Launcher)
plugins/Unity/Indicators/indicator.cpp+8−16
@@ -31,32 +31,24 @@ Indicator::~Indicator()
31{
31{
32}
32}
33
33
34−void Indicator::init(const QString& busName, const QSettings& settings)
34+void Indicator::init(const QString &profile, const QString& busName, const QSettings& settings)
35{
35{
36 setId(settings.value("Indicator Service/Name").toString());
36 setId(settings.value("Indicator Service/Name").toString());
37− setPosition(settings.value("Indicator Service/Position", QVariant::fromValue(0)).toInt());
38
37
39− QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
38+ QVariant pos = settings.value(profile + "/Position");
40−
39+ if (!pos.isValid())
41− QVariantMap mapMenuObjectPaths;
40+ pos = settings.value("Indicator Service/Position", QVariant::fromValue(0));
42− Q_FOREACH(const QString& childGroup, settings.childGroups())
41+ setPosition(pos.toInt());
43− {
44− if (childGroup == "Indicator Service")
45− continue;
46
42
47− QString menuPath = childGroup+"/ObjectPath";
43+ QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
48− if (settings.contains(menuPath))
44+ QString menuObjectPath = settings.value(profile + "/ObjectPath").toString();
49− {
50− mapMenuObjectPaths[childGroup] = settings.value(menuPath).toString();
51− }
52− }
53
45
54 QVariantMap properties;
46 QVariantMap properties;
55 properties.clear();
47 properties.clear();
56 properties.insert("busType", 1);
48 properties.insert("busType", 1);
57 properties.insert("busName", busName);
49 properties.insert("busName", busName);
58 properties.insert("actionsObjectPath", actionObjectPath);
50 properties.insert("actionsObjectPath", actionObjectPath);
59− properties.insert("menuObjectPaths", mapMenuObjectPaths);
51+ properties.insert("menuObjectPath", menuObjectPath);
60 setIndicatorProperties(properties);
52 setIndicatorProperties(properties);
61}
53}
62
54
plugins/Unity/Indicators/indicator.h+1−1
@@ -35,7 +35,7 @@ public:
35 Indicator(QObject *parent = 0);
35 Indicator(QObject *parent = 0);
36 virtual ~Indicator();
36 virtual ~Indicator();
37
37
38− void init(const QString& busName, const QSettings& settings);
38+ void init(const QString &profile, const QString& busName, const QSettings& settings);
39
39
40 QString identifier() const;
40 QString identifier() const;
41 int position() const;
41 int position() const;
plugins/Unity/Indicators/indicatorsmanager.cpp+3−1
@@ -26,6 +26,8 @@
26
26
27#include "paths.h"
27#include "paths.h"
28
28
29+const QString profile = "phone";
30+
29
31
30class IndicatorsManager::IndicatorData
32class IndicatorsManager::IndicatorData
31{
33{
@@ -298,7 +300,7 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
298 Indicator::Ptr new_indicator(new Indicator(this));
300 Indicator::Ptr new_indicator(new Indicator(this));
299 data->m_indicator = new_indicator;
301 data->m_indicator = new_indicator;
300 QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
302 QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
301− new_indicator->init(data->m_fileInfo.fileName(), settings);
303+ new_indicator->init(profile, data->m_fileInfo.fileName(), settings);
302 return new_indicator;
304 return new_indicator;
303}
305}
304
306
plugins/Unity/Indicators/qml/IndicatorBase.qml+3−4
@@ -24,16 +24,15 @@ import Unity.Indicators 0.1 as Indicators
24Item {
24Item {
25 id: indicatorItem
25 id: indicatorItem
26
26
27− enabled: menuObjectPaths.hasOwnProperty(device)
27+ enabled: menuObjectPath != ""
28
28
29 //const
29 //const
30 property string busName
30 property string busName
31 property string actionsObjectPath
31 property string actionsObjectPath
32− property var menuObjectPaths: undefined
32+ property string menuObjectPath
33− readonly property string device: "phone"
34 property string rootMenuType: "com.canonical.indicator.root"
33 property string rootMenuType: "com.canonical.indicator.root"
35
34
36− property string deviceMenuObjectPath: menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
35+ property string deviceMenuObjectPath: menuObjectPath
37
36
38 property alias menuModel: cachedModel.model
37 property alias menuModel: cachedModel.model
39
38
plugins/Unity/abstractfilteroption.cppdeleted−25
@@ -1,25 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "abstractfilteroption.h"
21−
22−AbstractFilterOption::AbstractFilterOption(QObject *parent)
23− : QObject(parent)
24−{
25−}
plugins/Unity/abstractfilteroption.hdeleted−58
@@ -1,58 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef ABSTRACTFILTEROPTION_H
21−#define ABSTRACTFILTEROPTION_H
22−
23−// Qt
24−#include <QObject>
25−#include <QMetaType>
26−
27−class Q_DECL_EXPORT AbstractFilterOption : public QObject
28−{
29− Q_OBJECT
30−
31− Q_PROPERTY(QString id READ id NOTIFY idChanged)
32− Q_PROPERTY(QString name READ name NOTIFY nameChanged)
33− Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
34− Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
35−
36−public:
37− /* getters */
38− virtual QString id() const = 0;
39− virtual QString name() const = 0;
40− virtual QString iconHint() const = 0;
41− virtual bool active() const = 0;
42−
43− /* setters */
44− virtual void setActive(bool active) = 0;
45−
46−protected:
47− AbstractFilterOption(QObject *parent);
48−
49−Q_SIGNALS:
50− void idChanged(const QString &);
51− void nameChanged(const QString &);
52− void iconHintChanged(const QString &);
53− void activeChanged(bool);
54−};
55−
56−Q_DECLARE_METATYPE(AbstractFilterOption*)
57−
58−#endif // ABSTRACTFILTEROPTION_H
plugins/Unity/applicationpreview.cppdeleted−100
@@ -1,100 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// local
21−#include "applicationpreview.h"
22−#include "iconutils.h"
23−
24−#include <QDebug>
25−
26−ApplicationPreview::ApplicationPreview(QObject *parent):
27− Preview(parent),
28− m_unityAppPreview(nullptr)
29−{
30−}
31−
32−QString ApplicationPreview::lastUpdate() const
33−{
34− if (m_unityAppPreview) {
35− return QString::fromStdString(m_unityAppPreview->last_update());
36− } else {
37− qWarning() << "Preview not set";
38− }
39− return QString();
40−}
41−
42−QString ApplicationPreview::copyright() const
43−{
44− if (m_unityAppPreview) {
45− return QString::fromStdString(m_unityAppPreview->copyright());
46− } else {
47− qWarning() << "Preview not set";
48− }
49− return QString();
50−}
51−
52−QString ApplicationPreview::license() const
53−{
54− if (m_unityAppPreview) {
55− return QString::fromStdString(m_unityAppPreview->license());
56− } else {
57− qWarning() << "Preview not set";
58− }
59− return QString();
60−}
61−
62−QString ApplicationPreview::appIcon() const
63−{
64− if (m_unityAppPreview) {
65− auto giconString = g_icon_to_string(m_unityAppPreview->app_icon());
66− QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
67− g_free(giconString);
68− return result;
69− } else {
70− qWarning() << "Preview not set";
71− }
72− return QString();
73−}
74−
75−float ApplicationPreview::rating() const
76−{
77− if (m_unityAppPreview) {
78− return m_unityAppPreview->rating();
79− } else {
80− qWarning() << "Preview not set";
81− }
82− return 0.0f;
83−}
84−
85−unsigned int ApplicationPreview::numRatings() const
86−{
87− if (m_unityAppPreview) {
88− return m_unityAppPreview->num_ratings();
89− } else {
90− qWarning() << "Preview not set";
91− }
92− return 0;
93−}
94−
95−void ApplicationPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
96−{
97− m_unityAppPreview = std::dynamic_pointer_cast<unity::dash::ApplicationPreview>(unityPreview);
98−
99− Q_EMIT previewChanged();
100−}
plugins/Unity/applicationpreview.hdeleted−66
@@ -1,66 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef APPLICATIONPREVIEW_H
21−#define APPLICATIONPREVIEW_H
22−
23−// local
24−#include "preview.h"
25−
26−// Qt
27−#include <QObject>
28−#include <QMetaType>
29−
30−// libunity-core
31−#include <UnityCore/ApplicationPreview.h>
32−
33−class Q_DECL_EXPORT ApplicationPreview: public Preview
34−{
35− Q_OBJECT
36−
37− Q_PROPERTY(QString lastUpdate READ lastUpdate NOTIFY previewChanged)
38− Q_PROPERTY(QString copyright READ copyright NOTIFY previewChanged)
39− Q_PROPERTY(QString license READ license NOTIFY previewChanged)
40− Q_PROPERTY(QString appIcon READ appIcon NOTIFY previewChanged)
41− Q_PROPERTY(float rating READ rating NOTIFY previewChanged)
42− Q_PROPERTY(unsigned int numRatings READ numRatings NOTIFY previewChanged)
43−
44−public:
45− explicit ApplicationPreview(QObject *parent = 0);
46−
47− QString lastUpdate() const;
48− QString copyright() const;
49− QString license() const;
50− QString appIcon() const;
51− float rating() const;
52− unsigned int numRatings() const;
53−
54−Q_SIGNALS:
55− void previewChanged();
56−
57−protected:
58− void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
59−
60−private:
61− unity::dash::ApplicationPreview::Ptr m_unityAppPreview;
62−};
63−
64−Q_DECLARE_METATYPE(ApplicationPreview *)
65−
66−#endif
plugins/Unity/categories.cppdeleted−299
@@ -1,299 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− * Michal Hruby <michal.hruby@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// self
22−#include "categories.h"
23−#include "categoryresults.h"
24−#include <QDebug>
25−
26−// TODO: use something from libunity once it's public
27−enum CategoryColumn {
28− ID,
29− DISPLAY_NAME,
30− ICON_HINT,
31− RENDERER_NAME,
32− HINTS
33−};
34−
35−Categories::Categories(QObject* parent)
36− : DeeListModel(parent)
37−{
38− m_roles[Categories::RoleCategoryId] = "categoryId";
39− m_roles[Categories::RoleName] = "name";
40− m_roles[Categories::RoleIcon] = "icon";
41− m_roles[Categories::RoleRenderer] = "renderer";
42− m_roles[Categories::RoleContentType] = "contentType";
43− m_roles[Categories::RoleRendererHint] = "rendererHint";
44− m_roles[Categories::RoleProgressSource] = "progressSource";
45− m_roles[Categories::RoleHints] = "hints";
46− m_roles[Categories::RoleResults] = "results";
47− m_roles[Categories::RoleCount] = "count";
48−
49− // TODO This should not be needed but accumulatting the count changes
50− // makes the visualization more stable and also makes crashes on fast
51− // change of the search term harder to reproduce
52− m_timer.setSingleShot(true);
53− m_timer.setInterval(50);
54− connect(&m_timer, &QTimer::timeout, this, &Categories::onEmitCountChanged);
55−}
56−
57−DeeListModel*
58−Categories::getResults(int index) const
59−{
60− if (!m_results.contains(index)) {
61− CategoryResults* results = new CategoryResults(const_cast<Categories*>(this));
62− results->setCategoryIndex(index);
63− connect(results, &DeeListModel::countChanged, this, &Categories::onCountChanged);
64−
65− unsigned categoryIndex = static_cast<unsigned>(index);
66− auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
67− if (unity_results) {
68− results->setModel(unity_results->model());
69− } else {
70− // No results model returned by unity core; this can be the case when the global
71− // results model of this scope is still not set in unity core. Don't set backend
72− // model in DeeListModel - it will still beahve properly as an empty model. Since
73− // we're connected to the category model change signal, and it is set by unity core
74− // at the same time as results model (on channel opening), we'll reset category
75− // results models with proper models when we're notifed again.
76− qWarning() << "No results model for category" << categoryIndex;
77− }
78−
79− m_results.insert(index, results);
80− }
81−
82− return m_results[index];
83−}
84−
85−void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
86−{
87− m_updatedCategories.clear();
88− // FIXME: this might destroy the renderer view and re-create it, optimize?
89− Q_FOREACH(DeeListModel* model, m_results) {
90− delete model;
91− }
92− m_results.clear();
93− m_categoryOrder.clear();
94−
95− setModel(model);
96−}
97−
98−void Categories::onCategoryOrderChanged(const std::vector<unsigned int>& cat_order)
99−{
100− for (unsigned int pos = 0; pos<cat_order.size(); pos++)
101− {
102− unsigned int cat = cat_order[pos];
103− const int old_pos = m_categoryOrder.indexOf(cat);
104−
105− if (old_pos < 0) {
106− qWarning() << "No such category index:" << cat;
107− continue;
108− }
109−
110− if (static_cast<int>(pos) != old_pos) {
111− int target_pos = pos;
112− if (target_pos > old_pos)
113− target_pos++;
114− const bool status = beginMoveRows(QModelIndex(), old_pos, old_pos, QModelIndex(), target_pos);
115− if (status)
116− m_categoryOrder.move(old_pos, pos);
117− else
118− qWarning() << "beginMoveRows failed:" << old_pos << target_pos;
119− endMoveRows();
120− }
121− }
122−}
123−
124−void
125−Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
126−{
127− m_unityScope = scope;
128−
129− // no need to call this, we'll get notified
130− //setModel(m_unityScope->categories()->model());
131−
132− m_signals.disconnectAll();
133− m_signals << m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
134−
135− // FIXME: Don't handle category order changes for now as it causes UI issues (https://bugs.launchpad.net/unity8/+bug/1239584).
136− //m_signals << m_unityScope->category_order.changed.connect(sigc::mem_fun(this, &Categories::onCategoryOrderChanged));
137−}
138−
139−void
140−Categories::onCountChanged()
141−{
142− CategoryResults* results = qobject_cast<CategoryResults*>(sender());
143− if (results) {
144− if (!m_updatedCategories.contains(results->categoryIndex())) {
145− m_updatedCategories << results->categoryIndex();
146− }
147− m_timer.start();
148− }
149−}
150−
151−void Categories::onRowCountChanged()
152−{
153− QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(sender());
154− // find the corresponding category index
155− for (auto iter = m_overriddenCategories.begin(); iter != m_overriddenCategories.end(); ++iter) {
156− if (iter.value() == model) {
157− for (int i = 0; i < rowCount(); i++) {
158− auto id = data(index(i), RoleCategoryId).toString();
159− if (id != iter.key()) continue;
160− QVector<int> roles;
161− roles.append(RoleCount);
162− QModelIndex changedIndex = index(i);
163− Q_EMIT dataChanged(changedIndex, changedIndex, roles);
164− break;
165− }
166− }
167− }
168−}
169−
170−void
171−Categories::onEmitCountChanged()
172−{
173− QVector<int> roles;
174− roles.append(Categories::RoleCount);
175− Q_FOREACH(int categoryIndex, m_updatedCategories) {
176− if (!m_results.contains(categoryIndex)) continue;
177− const int realIndex = m_categoryOrder.indexOf(categoryIndex);
178− const QModelIndex changedIndex = index(realIndex);
179− Q_EMIT dataChanged(changedIndex, changedIndex, roles);
180− }
181− m_updatedCategories.clear();
182−}
183−
184−QHash<int, QByteArray>
185−Categories::roleNames() const
186−{
187− return m_roles;
188−}
189−
190−void Categories::onOverrideModelDestroyed()
191−{
192− QObject* model = sender();
193− auto iter = m_overriddenCategories.begin();
194− while (iter != m_overriddenCategories.end()) {
195− if (iter.value() == model) {
196− iter = m_overriddenCategories.erase(iter);
197− continue;
198− }
199− ++iter;
200− }
201−}
202−
203−void Categories::overrideResults(const QString& categoryId, QAbstractItemModel* model)
204−{
205− m_overriddenCategories[categoryId] = model;
206− // watch the model
207− connect(model, &QObject::destroyed, this, &Categories::onOverrideModelDestroyed);
208− connect(model, &QAbstractItemModel::rowsInserted, this, &Categories::onRowCountChanged);
209− connect(model, &QAbstractItemModel::rowsRemoved, this, &Categories::onRowCountChanged);
210− connect(model, &QAbstractItemModel::modelReset, this, &Categories::onRowCountChanged);
211−
212− // emit the dataChanged signal if the category is already in the model
213− for (int i = 0; i < rowCount(); i++) {
214− auto id = data(index(i), RoleCategoryId).toString();
215− if (id != categoryId) continue;
216− QVector<int> roles;
217− roles.append(RoleCount);
218− roles.append(RoleResults);
219− QModelIndex changedIndex = index(i);
220− Q_EMIT dataChanged(changedIndex, changedIndex, roles);
221− break;
222− }
223−}
224−
225−QVariant
226−Categories::data(const QModelIndex& index, int role) const
227−{
228− if (!index.isValid()) {
229− return QVariant();
230− }
231−
232− if (m_categoryOrder.size() != rowCount())
233− {
234− // populate category order vector with 0..n
235− m_categoryOrder.clear();
236− const unsigned int lim = rowCount();
237− for (unsigned int i = 0; i<lim; i++) {
238− m_categoryOrder.append(i);
239− }
240− }
241−
242− int realRow = index.row();
243− if (index.row() < m_categoryOrder.size()) {
244− realRow = m_categoryOrder[index.row()];
245− } else {
246− qWarning() << "Invalid index" << index.row();
247− return QVariant();
248− }
249−
250− const QModelIndex realIndex = createIndex(realRow, index.column());
251−
252− switch (role) {
253− case RoleCategoryId:
254− return DeeListModel::data(realIndex, CategoryColumn::ID);
255− case RoleName:
256− return DeeListModel::data(realIndex, CategoryColumn::DISPLAY_NAME);
257− case RoleIcon:
258− return DeeListModel::data(realIndex, CategoryColumn::ICON_HINT);
259− case RoleRenderer:
260− return DeeListModel::data(realIndex, CategoryColumn::RENDERER_NAME);
261− case RoleContentType:
262− {
263− auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash();
264− return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
265− }
266− case RoleRendererHint:
267− {
268− auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash();
269− return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString());
270− }
271− case RoleProgressSource:
272− {
273− auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash();
274− return hints.contains("progress-source") ? hints["progress-source"] : QVariant();
275− }
276− case RoleHints:
277− return DeeListModel::data(realIndex, CategoryColumn::HINTS);
278− case RoleResults:
279− if (m_overriddenCategories.size() > 0)
280− {
281− auto id = DeeListModel::data(realIndex, CategoryColumn::ID).toString();
282− if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
283− return QVariant::fromValue(m_overriddenCategories[id]);
284− }
285− return QVariant::fromValue(getResults(realRow));
286− case RoleCount:
287− if (m_overriddenCategories.size() > 0)
288− {
289− auto id = DeeListModel::data(realIndex, CategoryColumn::ID).toString();
290− if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
291− {
292− return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
293− }
294− }
295− return QVariant::fromValue(getResults(realRow)->rowCount());
296− default:
297− return QVariant();
298− }
299−}
plugins/Unity/categories.hdeleted−95
@@ -1,95 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− * Michal Hruby <michal.hruby@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−
22−#ifndef CATEGORIES_H
23−#define CATEGORIES_H
24−
25−// unity-core
26−#include <UnityCore/Scope.h>
27−
28−// dee-qt
29−#include "deelistmodel.h"
30−
31−#include <QPointer>
32−#include <QSet>
33−#include <QTimer>
34−
35−// local
36−#include "signalslist.h"
37−
38−class Categories : public DeeListModel
39−{
40− Q_OBJECT
41−
42− Q_ENUMS(Roles)
43−
44−public:
45− explicit Categories(QObject* parent = 0);
46−
47− enum Roles {
48− RoleCategoryId,
49− RoleName,
50− RoleIcon,
51− RoleRenderer,
52− RoleContentType,
53− RoleRendererHint,
54− RoleProgressSource,
55− RoleHints,
56− RoleResults,
57− RoleCount
58− };
59−
60− Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
61−
62− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
63−
64− QHash<int, QByteArray> roleNames() const;
65−
66− /* setters */
67− void setUnityScope(const unity::dash::Scope::Ptr& scope);
68−
69−private Q_SLOTS:
70− void onCountChanged();
71− void onRowCountChanged();
72− void onEmitCountChanged();
73− void onOverrideModelDestroyed();
74−
75−private:
76− void onCategoriesModelChanged(unity::glib::Object<DeeModel> model);
77− void onCategoryOrderChanged(const std::vector<unsigned int>& cat_order);
78−
79− DeeListModel* getResults(int index) const;
80−
81− unity::dash::Scope::Ptr m_unityScope;
82− QTimer m_timer;
83− QSet<int> m_updatedCategories;
84− QHash<int, QByteArray> m_roles;
85− QMap<QString, QAbstractItemModel*> m_overriddenCategories;
86− mutable QMap<int, DeeListModel*> m_results;
87− SignalsList m_signals;
88−
89− /* Category order array contains indices of actual categories in the underlying DeeListModel.
90− It's used internally to reflect category order reported by scope.
91− */
92− mutable QList<unsigned int> m_categoryOrder;
93−};
94−
95−#endif // CATEGORIES_H
plugins/Unity/checkoptionfilter.cppdeleted−65
@@ -1,65 +0,0 @@
1−/*
2− * Copyright (C) 2011 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// Self
21−#include "checkoptionfilter.h"
22−
23−// local
24−#include "unityoptionsmodel.h"
25−
26−CheckOptionFilter::CheckOptionFilter(QObject *parent) :
27− Filter(parent),
28− m_unityCheckOptionFilter(nullptr),
29− m_options(nullptr)
30−{
31−}
32−
33−GenericOptionsModel* CheckOptionFilter::options() const
34−{
35− return m_options;
36−}
37−
38−void CheckOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
39−{
40− Filter::setUnityFilter(filter);
41− m_unityCheckOptionFilter = std::dynamic_pointer_cast<unity::dash::CheckOptionFilter>(m_unityFilter);
42− onOptionsChanged(m_unityCheckOptionFilter->options);
43−}
44−
45−void CheckOptionFilter::onOptionsChanged(unity::dash::CheckOptionFilter::CheckOptions options)
46−{
47− if (m_options != nullptr) {
48− m_signals.disconnectAll();
49− delete m_options;
50− m_options = nullptr;
51− }
52−
53− m_options = new UnityOptionsModel(this, options,
54− m_unityCheckOptionFilter->option_added,
55− m_unityCheckOptionFilter->option_removed,
56− m_unityCheckOptionFilter->show_all_button);
57−
58− connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
59− connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
60−
61− /* Property change signals */
62− m_signals << m_unityCheckOptionFilter->options.changed.connect(sigc::mem_fun(this, &CheckOptionFilter::onOptionsChanged));
63−
64− Q_EMIT optionsChanged();
65−}
plugins/Unity/checkoptionfilter.hdeleted−57
@@ -1,57 +0,0 @@
1−/*
2− * Copyright (C) 2011 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef CHECKOPTIONFILTER_H
21−#define CHECKOPTIONFILTER_H
22−
23−// Qt
24−#include <QObject>
25−#include <QMetaType>
26−
27−// libunity-core
28−#include <UnityCore/CheckOptionFilter.h>
29−
30−// Local
31−#include "filter.h"
32−#include "signalslist.h"
33−
34−class Q_DECL_EXPORT CheckOptionFilter : public Filter
35−{
36− Q_OBJECT
37−
38−public:
39− explicit CheckOptionFilter(QObject *parent = nullptr);
40−
41− /* getters */
42− GenericOptionsModel* options() const override;
43−
44−protected:
45− void setUnityFilter(unity::dash::Filter::Ptr filter) override;
46−
47−private:
48− void onOptionsChanged(unity::dash::CheckOptionFilter::CheckOptions filter);
49−
50− unity::dash::CheckOptionFilter::Ptr m_unityCheckOptionFilter;
51− SignalsList m_signals;
52− GenericOptionsModel* m_options;
53−};
54−
55−Q_DECLARE_METATYPE(CheckOptionFilter*)
56−
57−#endif // CHECKOPTIONFILTER_H
plugins/Unity/filter.cppdeleted−129
@@ -1,129 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "filter.h"
23−
24−// local
25−#include "ratingsfilter.h"
26−#include "radiooptionfilter.h"
27−#include "checkoptionfilter.h"
28−#include "multirangefilter.h"
29−
30−// libunity-core
31−#include <UnityCore/Filter.h>
32−#include <UnityCore/RatingsFilter.h>
33−#include <UnityCore/RadioOptionFilter.h>
34−#include <UnityCore/CheckOptionFilter.h>
35−#include <UnityCore/MultiRangeFilter.h>
36−
37−// Qt
38−#include <QDebug>
39−
40−Filter::Filter(QObject *parent) :
41− QObject(parent)
42−{
43−}
44−
45−QString Filter::id() const
46−{
47− if (!m_unityFilter)
48− return QString::Null();
49− return QString::fromStdString(m_unityFilter->id());
50−}
51−
52−QString Filter::name() const
53−{
54− if (!m_unityFilter)
55− return QString::Null();
56− return QString::fromStdString(m_unityFilter->name());
57−}
58−
59−QString Filter::iconHint() const
60−{
61− if (!m_unityFilter)
62− return QString::Null();
63− return QString::fromStdString(m_unityFilter->icon_hint());
64−}
65−
66−QString Filter::rendererName() const
67−{
68− if (!m_unityFilter)
69− return QString::Null();
70− return QString::fromStdString(m_unityFilter->renderer_name());
71−}
72−
73−bool Filter::visible() const
74−{
75− if (!m_unityFilter)
76− return false;
77− return m_unityFilter->visible();
78−}
79−
80−bool Filter::collapsed() const
81−{
82− if (!m_unityFilter)
83− return false;
84− return m_unityFilter->collapsed();
85−}
86−
87−bool Filter::filtering() const
88−{
89− if (!m_unityFilter)
90− return false;
91− return m_unityFilter->filtering();
92−}
93−
94−void Filter::clear()
95−{
96− if (m_unityFilter)
97− m_unityFilter->Clear();
98−}
99−
100−void Filter::setUnityFilter(unity::dash::Filter::Ptr unityFilter)
101−{
102− m_unityFilter = unityFilter;
103−}
104−
105−Filter* Filter::newFromUnityFilter(unity::dash::Filter::Ptr unityFilter)
106−{
107− Filter* filter;
108−
109− if (typeid(*unityFilter) == typeid(unity::dash::RatingsFilter)) {
110− filter = new RatingsFilter;
111− } else if (typeid(*unityFilter) == typeid(unity::dash::CheckOptionFilter)) {
112− filter = new CheckOptionFilter;
113− } else if (typeid(*unityFilter) == typeid(unity::dash::RadioOptionFilter)) {
114− filter = new RadioOptionFilter;
115− } else if (typeid(*unityFilter) == typeid(unity::dash::MultiRangeFilter)) {
116− filter = new MultiRangeFilter;
117− } else {
118− qWarning() << "Filter of unknown type: " << typeid(*unityFilter).name();
119− return nullptr;
120− }
121−
122− filter->setUnityFilter(unityFilter);
123− return filter;
124−}
125−
126−bool Filter::hasUnityFilter(unity::dash::Filter::Ptr unityFilter) const
127−{
128− return m_unityFilter == unityFilter;
129−}
plugins/Unity/filter.hdeleted−75
@@ -1,75 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−#ifndef FILTER_H
22−#define FILTER_H
23−
24−// Qt
25−#include <QObject>
26−#include <QMetaType>
27−
28−// libunity-core
29−#include <UnityCore/Filter.h>
30−
31−class GenericOptionsModel;
32−
33−class Q_DECL_EXPORT Filter : public QObject
34−{
35− Q_OBJECT
36−
37− Q_PROPERTY(QString id READ id CONSTANT)
38− Q_PROPERTY(QString name READ name CONSTANT)
39− Q_PROPERTY(QString iconHint READ iconHint CONSTANT)
40− Q_PROPERTY(QString rendererName READ rendererName CONSTANT)
41− Q_PROPERTY(bool visible READ visible CONSTANT)
42− Q_PROPERTY(bool collapsed READ collapsed CONSTANT)
43− Q_PROPERTY(bool filtering READ filtering CONSTANT)
44− Q_PROPERTY(GenericOptionsModel* options READ options NOTIFY optionsChanged)
45−
46−public:
47− explicit Filter(QObject *parent = nullptr);
48−
49− /* getters */
50− QString id() const;
51− QString name() const;
52− QString iconHint() const;
53− QString rendererName() const;
54− bool visible() const;
55− bool collapsed() const;
56− bool filtering() const;
57− virtual GenericOptionsModel* options() const = 0;
58−
59− static Filter* newFromUnityFilter(unity::dash::Filter::Ptr unityFilter);
60− bool hasUnityFilter(unity::dash::Filter::Ptr unityFilter) const;
61−
62−public Q_SLOTS:
63− void clear();
64−
65−Q_SIGNALS:
66− void optionsChanged();
67−
68−protected:
69− unity::dash::Filter::Ptr m_unityFilter;
70− virtual void setUnityFilter(unity::dash::Filter::Ptr unityFilter);
71−};
72−
73−Q_DECLARE_METATYPE(Filter*)
74−
75−#endif // FILTER_H
plugins/Unity/filteroption.cppdeleted−91
@@ -1,91 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "filteroption.h"
23−
24−// libunity-core
25−#include <UnityCore/Filter.h>
26−
27−FilterOption::FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent) :
28− AbstractFilterOption(parent), m_unityFilterOption(nullptr)
29−{
30− setUnityFilterOption(unityFilterOption);
31−}
32−
33−QString FilterOption::id() const
34−{
35− return QString::fromStdString(m_unityFilterOption->id());
36−}
37−
38−QString FilterOption::name() const
39−{
40− return QString::fromStdString(m_unityFilterOption->name());
41−}
42−
43−QString FilterOption::iconHint() const
44−{
45− return QString::fromStdString(m_unityFilterOption->icon_hint());
46−}
47−
48−bool FilterOption::active() const
49−{
50− return m_unityFilterOption->active();
51−}
52−
53−void FilterOption::setActive(bool active)
54−{
55− m_unityFilterOption->active = active;
56−}
57−
58−void FilterOption::setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption)
59−{
60− if (m_unityFilterOption != nullptr) {
61− m_signals.disconnectAll();
62− }
63−
64− m_unityFilterOption = unityFilterOption;
65−
66− /* Property change signals */
67− m_signals << m_unityFilterOption->id.changed.connect(sigc::mem_fun(this, &FilterOption::onIdChanged))
68− << m_unityFilterOption->name.changed.connect(sigc::mem_fun(this, &FilterOption::onNameChanged))
69− << m_unityFilterOption->icon_hint.changed.connect(sigc::mem_fun(this, &FilterOption::onIconHintChanged))
70− << m_unityFilterOption->active.changed.connect(sigc::mem_fun(this, &FilterOption::onActiveChanged));
71−}
72−
73−void FilterOption::onIdChanged(const std::string &id)
74−{
75− Q_EMIT idChanged(QString::fromStdString(id));
76−}
77−
78−void FilterOption::onNameChanged(const std::string &name)
79−{
80− Q_EMIT nameChanged(QString::fromStdString(name));
81−}
82−
83−void FilterOption::onIconHintChanged(const std::string &iconHint)
84−{
85− Q_EMIT iconHintChanged(QString::fromStdString(iconHint));
86−}
87−
88−void FilterOption::onActiveChanged(bool active)
89−{
90− Q_EMIT activeChanged(active);
91−}
plugins/Unity/filteroption.hdeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−#ifndef FILTEROPTION_H
22−#define FILTEROPTION_H
23−
24−// Local
25−#include "abstractfilteroption.h"
26−#include "signalslist.h"
27−
28−// libunity-core
29−#include <UnityCore/Filter.h>
30−
31−class Q_DECL_EXPORT FilterOption : public AbstractFilterOption
32−{
33− Q_OBJECT
34−
35−public:
36− explicit FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent = nullptr);
37−
38− /* getters */
39− QString id() const override;
40− QString name() const override;
41− QString iconHint() const override;
42− bool active() const override;
43−
44− /* setters */
45− void setActive(bool active) override;
46−
47−private:
48− void onIdChanged(const std::string &id);
49− void onNameChanged(const std::string &name);
50− void onIconHintChanged(const std::string &iconHint);
51− void onActiveChanged(bool active);
52−
53− void setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption);
54− SignalsList m_signals;
55−
56− unity::dash::FilterOption::Ptr m_unityFilterOption;
57−};
58−
59−Q_DECLARE_METATYPE(FilterOption*)
60−
61−#endif // FILTEROPTION_H
plugins/Unity/filters.cppdeleted−165
@@ -1,165 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "filters.h"
23−
24−// Local
25−#include "filter.h"
26−#include "genericoptionsmodel.h"
27−
28−// Qt
29−#include <QDebug>
30−
31−Filters::Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent) :
32− QAbstractListModel(parent), m_unityFilters(unityFilters)
33−{
34− for (unsigned int i=0; i<m_unityFilters->count(); i++) {
35− unity::dash::Filter::Ptr unityFilter = m_unityFilters->FilterAtIndex(i);
36− addFilter(unityFilter, i);
37− }
38− m_unityFilters->filter_added.connect(sigc::mem_fun(this, &Filters::onFilterAdded));
39− m_unityFilters->filter_changed.connect(sigc::mem_fun(this, &Filters::onFilterChanged));
40− m_unityFilters->filter_removed.connect(sigc::mem_fun(this, &Filters::onFilterRemoved));
41−}
42−
43−Filters::~Filters()
44−{
45− while (!m_filters.isEmpty()) {
46− delete m_filters.takeFirst();
47− }
48−}
49−
50−int Filters::rowCount(const QModelIndex& parent) const
51−{
52− Q_UNUSED(parent)
53−
54− return m_unityFilters->count();
55−}
56−
57−QVariant Filters::data(const QModelIndex& index, int role) const
58−{
59− if (!index.isValid()) {
60− return QVariant();
61− }
62−
63− Filter* filter = m_filters.at(index.row());
64− switch (role)
65− {
66− case Filters::RoleId:
67− return filter->id();
68− case Filters::RoleName:
69− case Qt::DisplayRole:
70− return filter->name();
71− case Filters::RoleIconHint:
72− return filter->iconHint();
73− case Filters::RoleRendererName:
74− return filter->rendererName();
75− case Filters::RoleVisible:
76− return filter->visible();
77− case Filters::RoleCollapsed:
78− return filter->collapsed();
79− case Filters::RoleFiltering:
80− return filter->filtering();
81− case Filters::RoleOptions:
82− return QVariant::fromValue(filter->options());
83− default:
84− break;
85− }
86− return QVariant();
87−}
88−
89−QHash<int, QByteArray> Filters::roleNames() const
90−{
91− QHash<int, QByteArray> roles;
92− roles[Filters::RoleId] = "id";
93− roles[Filters::RoleName] = "name";
94− roles[Filters::RoleIconHint] = "iconHint";
95− roles[Filters::RoleRendererName] = "rendererName";
96− roles[Filters::RoleVisible] = "visible";
97− roles[Filters::RoleCollapsed] = "collapsed";
98− roles[Filters::RoleFiltering] = "filtering";
99− roles[Filters::RoleOptions] = "options";
100− return roles;
101−}
102−
103−Filter* Filters::getFilter(const QString& id) const
104−{
105− Q_FOREACH (Filter* filter, m_filters) {
106− if (filter->id() == id) {
107− return filter;
108− }
109− }
110− return nullptr;
111−}
112−
113−void Filters::onFilterAdded(unity::dash::Filter::Ptr unityFilter)
114−{
115− if (unityFilter == nullptr) {
116− return;
117− }
118−
119− int index = m_filters.count();
120− addFilter(unityFilter, index);
121−}
122−
123−void Filters::onFilterChanged(unity::dash::Filter::Ptr unityFilter)
124−{
125− if (unityFilter == nullptr) {
126− return;
127− }
128−
129− QModelIndex filterIndex = index(indexForFilter(unityFilter));
130− Q_EMIT dataChanged(filterIndex, filterIndex);
131−}
132−
133−void Filters::onFilterRemoved(unity::dash::Filter::Ptr unityFilter)
134−{
135− removeFilter(indexForFilter(unityFilter));
136−}
137−
138−void Filters::addFilter(unity::dash::Filter::Ptr unityFilter, int index)
139−{
140− beginInsertRows(QModelIndex(), index, index);
141− Filter* filter = Filter::newFromUnityFilter(unityFilter);
142− if (filter != nullptr) {
143− m_filters.insert(index, filter);
144− }
145− endInsertRows();
146−}
147−
148−void Filters::removeFilter(int index)
149−{
150− beginRemoveRows(QModelIndex(), index, index);
151− Filter* filter = m_filters.takeAt(index);
152− delete filter;
153− endRemoveRows();
154−}
155−
156−int Filters::indexForFilter(unity::dash::Filter::Ptr unityFilter)
157−{
158− for (int index=0; index<m_filters.count(); index++) {
159− if (m_filters[index]->hasUnityFilter(unityFilter)) {
160− return index;
161− }
162− }
163− qWarning() << "Filter" << QString::fromStdString(unityFilter->name()) << "not found in local cache.";
164− return -1;
165−}
plugins/Unity/filters.hdeleted−77
@@ -1,77 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−#ifndef FILTERS_H
22−#define FILTERS_H
23−
24−// Qt
25−#include <QAbstractListModel>
26−#include <QList>
27−
28−// libunity-core
29−#include <UnityCore/Filters.h>
30−#include <UnityCore/Filter.h>
31−
32−class Filter;
33−
34−class Filters : public QAbstractListModel
35−{
36− Q_OBJECT
37−
38− Q_ENUMS(Roles)
39−
40−public:
41− explicit Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent = nullptr);
42− ~Filters();
43−
44− enum Roles {
45− RoleId = Qt::UserRole,
46− RoleName,
47− RoleIconHint,
48− RoleRendererName,
49− RoleVisible,
50− RoleCollapsed,
51− RoleFiltering,
52− RoleOptions
53− };
54−
55− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
56− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
57− QHash<int, QByteArray> roleNames() const override;
58−
59− Filter* getFilter(const QString& id) const;
60−
61−private:
62− void onFilterAdded(unity::dash::Filter::Ptr unityFilter);
63− void onFilterChanged(unity::dash::Filter::Ptr unityFilter);
64− void onFilterRemoved(unity::dash::Filter::Ptr unityFilter);
65−
66− void addFilter(unity::dash::Filter::Ptr unityFilter, int index);
67− void removeFilter(int index);
68−
69− int indexForFilter(unity::dash::Filter::Ptr unityFilter);
70−
71− unity::dash::Filters::Ptr m_unityFilters;
72− QList<Filter*> m_filters;
73−};
74−
75−Q_DECLARE_METATYPE(Filters*)
76−
77−#endif // FILTERS_H
plugins/Unity/genericoptionsmodel.cppdeleted−187
@@ -1,187 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// self
21−#include "genericoptionsmodel.h"
22−
23−// local
24−#include "abstractfilteroption.h"
25−#include "showallfilteroption.h"
26−
27−GenericOptionsModel::GenericOptionsModel(bool showAllOption, QObject *parent)
28− : QAbstractListModel(parent)
29−{
30− if (showAllOption)
31− {
32− auto showAll = new ShowAllFilterOption(this);
33− connect(showAll, SIGNAL(activeChanged(bool)), this, SLOT(onOptionChanged()));
34− connect(showAll, SIGNAL(activeChanged(bool)), this, SLOT(onShowAllClicked(bool)));
35− addOption(showAll);
36− }
37−}
38−
39−GenericOptionsModel::~GenericOptionsModel()
40−{
41− Q_FOREACH(auto opt, m_options)
42− {
43− opt->deleteLater();
44− }
45−}
46−
47−QHash<int, QByteArray> GenericOptionsModel::roleNames() const
48−{
49− QHash<int, QByteArray> roles;
50− roles[GenericOptionsModel::RoleId] = "id";
51− roles[GenericOptionsModel::RoleName] = "name";
52− roles[GenericOptionsModel::RoleIconHint] = "iconHint";
53− roles[GenericOptionsModel::RoleActive] = "active";
54− return roles;
55−}
56−
57−QVariant GenericOptionsModel::data(const QModelIndex& index, int role) const
58−{
59− if (!index.isValid()) {
60− return QVariant();
61− }
62−
63− auto filterOption = m_options[index.row()];
64− switch (role)
65− {
66− case GenericOptionsModel::RoleId:
67− return filterOption->id();
68− case GenericOptionsModel::RoleName:
69− case Qt::DisplayRole:
70− return filterOption->name();
71− case GenericOptionsModel::RoleIconHint:
72− return filterOption->iconHint();
73− case GenericOptionsModel::RoleActive:
74− return filterOption->active();
75− default:
76− break;
77− }
78−
79− return QVariant();
80−}
81−
82−int GenericOptionsModel::rowCount(const QModelIndex& /* parent */) const
83−{
84− return m_options.size();
85−}
86−
87−void GenericOptionsModel::setActive(int idx, bool value)
88−{
89− if (idx >= 0 && idx < m_options.size())
90− {
91− m_options[idx]->setActive(value);
92− }
93−}
94−
95−void GenericOptionsModel::setActive(const QString &id, bool value)
96−{
97− Q_FOREACH(auto opt, m_options) {
98− if (opt->id() == id) {
99− opt->setActive(value);
100− break;
101− }
102− }
103−}
104−
105−AbstractFilterOption* GenericOptionsModel::getRawOption(QVector<AbstractFilterOption *>::size_type idx) const
106−{
107− if (idx < m_options.size())
108− {
109− return m_options[idx];
110− }
111− return nullptr;
112−}
113−
114−void GenericOptionsModel::ensureTheOnlyActive(AbstractFilterOption *activeOption)
115−{
116− if (activeOption->active()) {
117− // disable all other options
118− Q_FOREACH(auto opt, m_options) {
119− if (opt != activeOption && opt->active()) {
120− opt->setActive(false);
121− }
122− }
123− }
124−}
125−
126−void GenericOptionsModel::addOption(AbstractFilterOption *option, int index)
127−{
128− if (index >= 0)
129− m_options.insert(index, option);
130− else
131− m_options.append(option);
132−
133− connect(option, SIGNAL(idChanged(const QString &)), this, SLOT(onOptionChanged()));
134− connect(option, SIGNAL(nameChanged(const QString &)), this, SLOT(onOptionChanged()));
135− connect(option, SIGNAL(iconHintChanged(const QString &)), this, SLOT(onOptionChanged()));
136− connect(option, SIGNAL(activeChanged(bool)), this, SLOT(onOptionChanged()));
137− connect(option, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged()));
138−}
139−
140−void GenericOptionsModel::removeOption(int index)
141−{
142− m_options[index]->deleteLater();
143− m_options.remove(index);
144−}
145−
146−int GenericOptionsModel::indexOf(const QString &option_id)
147−{
148− int row = 0;
149− Q_FOREACH(auto opt, m_options)
150− {
151− if (opt->id() == option_id)
152− {
153− return row;
154− }
155− ++row;
156− }
157− return -1;
158−}
159−
160−void GenericOptionsModel::onOptionChanged()
161−{
162− AbstractFilterOption *option = dynamic_cast<AbstractFilterOption*>(QObject::sender());
163− if (option)
164− {
165− int idx = indexOf(option->id());
166− if (idx >= 0)
167− {
168− QModelIndex optionIndex = index(idx);
169− Q_EMIT dataChanged(optionIndex, optionIndex);
170− }
171− }
172−}
173−
174−void GenericOptionsModel::onActiveChanged()
175−{
176− AbstractFilterOption *option = dynamic_cast<AbstractFilterOption*>(QObject::sender());
177− if (option)
178− {
179− Q_EMIT activeChanged(option);
180− }
181−}
182−
183−void GenericOptionsModel::onShowAllClicked(bool active)
184−{
185− if (active)
186− Q_EMIT showAllActivated();
187−}
plugins/Unity/genericoptionsmodel.hdeleted−79
@@ -1,79 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef GENERICOPTIONSMODEL_H
21−#define GENERICOPTIONSMODEL_H
22−
23−// Qt
24−#include <QObject>
25−#include <QAbstractListModel>
26−#include <QHash>
27−#include <QVector>
28−
29−class AbstractFilterOption;
30−
31−class Q_DECL_EXPORT GenericOptionsModel : public QAbstractListModel
32−{
33− Q_OBJECT
34−
35− Q_ENUMS(Roles)
36−
37−public:
38− GenericOptionsModel(bool showAllOption = false, QObject *parent = nullptr);
39− ~GenericOptionsModel();
40−
41− enum Roles {
42− RoleId = Qt::UserRole,
43− RoleName,
44− RoleIconHint,
45− RoleActive
46− };
47−
48− QHash<int, QByteArray> roleNames() const override;
49− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
50− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
51−
52− Q_INVOKABLE void setActive(int idx, bool value);
53− Q_INVOKABLE void setActive(const QString &id, bool value);
54−
55− AbstractFilterOption* getRawOption(QVector<AbstractFilterOption *>::size_type idx) const;
56−
57−public Q_SLOTS:
58− virtual void ensureTheOnlyActive(AbstractFilterOption *activeOption);
59−
60−Q_SIGNALS:
61− void activeChanged(AbstractFilterOption *option);
62− void showAllActivated();
63−
64−protected Q_SLOTS:
65− void onOptionChanged();
66− void onActiveChanged();
67− void onShowAllClicked(bool active);
68−
69−protected:
70− void addOption(AbstractFilterOption *option, int index = -1);
71− void removeOption(int index);
72− int indexOf(const QString &option_id);
73−
74− QVector<AbstractFilterOption *> m_options;
75−};
76−
77−Q_DECLARE_METATYPE(GenericOptionsModel*)
78−
79−#endif // GENERICOPTIONSMODEL_H
plugins/Unity/genericpreview.cppdeleted−31
@@ -1,31 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// local
21−#include "genericpreview.h"
22−
23−GenericPreview::GenericPreview(QObject *parent):
24− Preview(parent)
25−{
26−}
27−
28−void GenericPreview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
29−{
30− Q_EMIT previewChanged();
31−}
plugins/Unity/moviepreview.cppdeleted−67
@@ -1,67 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// local
21−#include "moviepreview.h"
22−
23−// Qt
24−#include <QDebug>
25−
26−MoviePreview::MoviePreview(QObject *parent):
27− Preview(parent),
28− m_unityMoviePreview(nullptr)
29−{
30−}
31−
32−QString MoviePreview::year() const
33−{
34− if (m_unityMoviePreview) {
35− return QString::fromStdString(m_unityMoviePreview->year());
36− } else {
37− qWarning() << "Preview not set";
38− }
39− return QString();
40−}
41−
42−float MoviePreview::rating() const
43−{
44− if (m_unityMoviePreview) {
45− return m_unityMoviePreview->rating();
46− } else {
47− qWarning() << "Preview not set";
48− }
49− return 0.0f;
50−}
51−
52−unsigned int MoviePreview::numRatings() const
53−{
54− if (m_unityMoviePreview) {
55− return m_unityMoviePreview->num_ratings();
56− } else {
57− qWarning() << "Preview not set";
58− }
59− return 0;
60−}
61−
62−void MoviePreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
63−{
64− m_unityMoviePreview = std::dynamic_pointer_cast<unity::dash::MoviePreview>(unityPreview);
65−
66− Q_EMIT previewChanged();
67−}
plugins/Unity/moviepreview.hdeleted−60
@@ -1,60 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef MOVIEPREVIEW_H
21−#define MOVIEPREVIEW_H
22−
23−// local
24−#include "preview.h"
25−
26−// Qt
27−#include <QObject>
28−#include <QMetaType>
29−
30−// libunity-core
31−#include <UnityCore/MoviePreview.h>
32−
33−class Q_DECL_EXPORT MoviePreview: public Preview
34−{
35− Q_OBJECT
36−
37− Q_PROPERTY(QString year READ year NOTIFY previewChanged)
38− Q_PROPERTY(float rating READ rating NOTIFY previewChanged)
39− Q_PROPERTY(unsigned int numRatings READ numRatings NOTIFY previewChanged)
40−
41−public:
42− explicit MoviePreview(QObject *parent = 0);
43−
44− QString year() const;
45− float rating() const;
46− unsigned int numRatings() const;
47−
48−Q_SIGNALS:
49− void previewChanged();
50−
51−protected:
52− void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
53−
54−private:
55− unity::dash::MoviePreview::Ptr m_unityMoviePreview;
56−};
57−
58−Q_DECLARE_METATYPE(MoviePreview *)
59−
60−#endif
plugins/Unity/multirangefilter.cppdeleted−65
@@ -1,65 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "multirangefilter.h"
23−
24−// local
25−#include "unityoptionsmodel.h"
26−
27−MultiRangeFilter::MultiRangeFilter(QObject *parent) :
28− Filter(parent), m_unityMultiRangeFilter(nullptr), m_options(nullptr)
29−{
30−}
31−
32−GenericOptionsModel* MultiRangeFilter::options() const
33−{
34− return m_options;
35−}
36−
37−void MultiRangeFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
38−{
39− Filter::setUnityFilter(filter);
40− m_unityMultiRangeFilter = std::dynamic_pointer_cast<unity::dash::MultiRangeFilter>(m_unityFilter);
41−
42− onOptionsChanged(m_unityMultiRangeFilter->options);
43−}
44−
45−void MultiRangeFilter::onOptionsChanged(unity::dash::MultiRangeFilter::Options options)
46−{
47− if (m_options != nullptr) {
48− m_signals.disconnectAll();
49− delete m_options;
50− m_options = nullptr;
51− }
52−
53− m_options = new UnityOptionsModel(this, options,
54− m_unityMultiRangeFilter->option_added,
55− m_unityMultiRangeFilter->option_removed,
56− m_unityMultiRangeFilter->show_all_button);
57−
58− connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
59− connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
60−
61− /* Property change signals */
62− m_signals << m_unityMultiRangeFilter->options.changed.connect(sigc::mem_fun(this, &MultiRangeFilter::onOptionsChanged));
63−
64− Q_EMIT optionsChanged();
65−}
plugins/Unity/multirangefilter.hdeleted−60
@@ -1,60 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−#ifndef MULTIRANGEFILTER_H
22−#define MULTIRANGEFILTER_H
23−
24−// Qt
25−#include <QObject>
26−#include <QMetaType>
27−
28−// libunity-core
29−#include <UnityCore/MultiRangeFilter.h>
30−
31−// Local
32−#include "filter.h"
33−#include "signalslist.h"
34−
35−class GenericOptionsModel;
36−
37−class Q_DECL_EXPORT MultiRangeFilter : public Filter
38−{
39− Q_OBJECT
40−
41−public:
42− explicit MultiRangeFilter(QObject *parent = nullptr);
43−
44− /* getters */
45− GenericOptionsModel* options() const override;
46−
47−protected:
48− void setUnityFilter(unity::dash::Filter::Ptr filter) override;
49−
50−private:
51− unity::dash::MultiRangeFilter::Ptr m_unityMultiRangeFilter;
52− SignalsList m_signals;
53− GenericOptionsModel* m_options;
54−
55− void onOptionsChanged(unity::dash::MultiRangeFilter::Options);
56−};
57−
58−Q_DECLARE_METATYPE(MultiRangeFilter*)
59−
60−#endif // MULTIRANGEFILTER_H
plugins/Unity/musicpreview.cppdeleted−53
@@ -1,53 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "musicpreview.h"
21−#include "musicpreviewtrackmodel.h"
22−
23−#include <QDebug>
24−
25−MusicPreview::MusicPreview(QObject *parent):
26− Preview(parent),
27− m_unityMusicPreview(nullptr)
28−{
29− m_tracks = new MusicPreviewTrackModel(this);
30−}
31−
32−void MusicPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
33−{
34− m_unityMusicPreview = std::dynamic_pointer_cast<unity::dash::MusicPreview>(unityPreview);
35− m_tracks->setModel(m_unityMusicPreview->GetTracksModel()->model());
36− m_unityMusicPreview->GetTracksModel()->model.changed.connect(sigc::mem_fun(this, &MusicPreview::onTracksModelChanged));
37−
38− Q_EMIT previewChanged();
39− Q_EMIT tracksChanged();
40−}
41−
42−MusicPreviewTrackModel* MusicPreview::tracks() const
43−{
44− if (m_unityMusicPreview == nullptr) {
45− qWarning() << "Preview not set";
46− }
47− return m_tracks;
48−}
49−
50−void MusicPreview::onTracksModelChanged(unity::glib::Object<DeeModel> /* model */)
51−{
52− m_tracks->setModel(m_unityMusicPreview->GetTracksModel()->model());
53−}
plugins/Unity/musicpreview.hdeleted−62
@@ -1,62 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef MUSICPREVIEW_H
21−#define MUSICPREVIEW_H
22−
23−// local
24−#include "preview.h"
25−
26−// Qt
27−#include <QObject>
28−#include <QMetaType>
29−
30−// libunity-core
31−#include <UnityCore/MusicPreview.h>
32−
33−class MusicPreviewTrackModel;
34−
35−class Q_DECL_EXPORT MusicPreview: public Preview
36−{
37− Q_OBJECT
38−
39− Q_PROPERTY(MusicPreviewTrackModel* tracks READ tracks NOTIFY tracksChanged)
40−
41−public:
42− explicit MusicPreview(QObject *parent = 0);
43−
44− MusicPreviewTrackModel* tracks() const;
45−
46−Q_SIGNALS:
47− void tracksChanged();
48−
49−protected:
50− void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
51−
52−private Q_SLOTS:
53− void onTracksModelChanged(unity::glib::Object<DeeModel> model);
54−
55−private:
56− unity::dash::MusicPreview::Ptr m_unityMusicPreview;
57− MusicPreviewTrackModel *m_tracks;
58−};
59−
60−Q_DECLARE_METATYPE(MusicPreview *)
61−
62−#endif
plugins/Unity/musicpreviewtrackmodel.cppdeleted−71
@@ -1,71 +0,0 @@
1−/*
2− * Copyright (C) 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 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− * Authors:
17− * Michael Zanetti <michael.zanetti@canonical.com>
18− */
19−
20−#include "musicpreviewtrackmodel.h"
21−
22−#include <QTime>
23−
24−// TODO: use something from libunity once it's public
25−enum ResultsColumn {
26− URI,
27− TRACK_NO,
28− TITLE,
29− LENGTH,
30− PLAY_STATE,
31− PROGRESS
32−};
33−
34−MusicPreviewTrackModel::MusicPreviewTrackModel(QObject *parent): DeeListModel(parent)
35−{
36− m_roles.insert(RoleUri, "uri");
37− m_roles.insert(RoleTrackNo, "trackNo");
38− m_roles.insert(RoleTitle, "title");
39− m_roles.insert(RoleLength, "length");
40− m_roles.insert(RolePlayState, "playState");
41− m_roles.insert(RoleProgress, "progress");
42−}
43−
44−QVariant MusicPreviewTrackModel::data(const QModelIndex &index, int role) const
45−{
46− switch(role) {
47− case RoleUri:
48− return DeeListModel::data(index, ResultsColumn::URI);
49− case RoleTrackNo:
50− return DeeListModel::data(index, ResultsColumn::TRACK_NO);
51− case RoleTitle:
52− return DeeListModel::data(index, ResultsColumn::TITLE);
53− case RoleLength: {
54− QTime length = QTime(0,0).addSecs(DeeListModel::data(index, ResultsColumn::LENGTH).toInt());
55− if (length.hour() > 0) {
56− return length.toString("h:mm:ss");
57− }
58− return length.toString("m:ss");
59− }
60− case RolePlayState:
61− return DeeListModel::data(index, ResultsColumn::PLAY_STATE);
62− case RoleProgress:
63− return DeeListModel::data(index, ResultsColumn::PROGRESS);
64− }
65− return QVariant();
66−}
67−
68−QHash<int, QByteArray> MusicPreviewTrackModel::roleNames() const
69−{
70− return m_roles;
71−}
plugins/Unity/musicpreviewtrackmodel.hdeleted−50
@@ -1,50 +0,0 @@
1−/*
2− * Copyright (C) 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 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− * Authors:
17− * Michael Zanetti <michael.zanetti@canonical.com>
18− */
19−
20−#ifndef MUSICPREVIEWTRACKMODEL_H
21−#define MUSICPREVIEWTRACKMODEL_H
22−
23−#include "deelistmodel.h"
24−
25−class Q_DECL_EXPORT MusicPreviewTrackModel : public DeeListModel
26−{
27− Q_OBJECT
28− Q_ENUMS(Roles)
29−
30−public:
31− explicit MusicPreviewTrackModel(QObject* parent = 0);
32−
33− enum Roles {
34− RoleUri,
35− RoleTrackNo,
36− RoleTitle,
37− RoleLength,
38− RolePlayState,
39− RoleProgress
40− };
41−
42− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
43−
44− QHash<int, QByteArray> roleNames() const;
45−
46−private:
47− QHash<int, QByteArray> m_roles;
48−};
49−
50−#endif // MUSICPREVIEWTRACKMODEL_H
plugins/Unity/plugin.cppdeleted−64
@@ -1,64 +0,0 @@
1−/*
2− * Copyright (C) 2012 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− * Author: Michał Sawicz <michal.sawicz@canonical.com>
17− */
18−
19−// Qt
20−#include <qqml.h>
21−
22−// self
23−#include "plugin.h"
24−
25−// local
26−#include "preview.h"
27−#include "previewaction.h"
28−#include "previewinfohint.h"
29−#include "socialpreviewcomment.h"
30−#include "scope.h"
31−#include "scopes.h"
32−#include "categories.h"
33−#include "categoryresults.h"
34−#include "genericoptionsmodel.h"
35−#include "result.h"
36−#include "musicpreviewtrackmodel.h"
37−
38−// libqtdee
39−#include "deelistmodel.h"
40−
41−void UnityPlugin::registerTypes(const char *uri)
42−{
43− Q_ASSERT(uri == QLatin1String("Unity"));
44− qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
45− qmlRegisterUncreatableType<PreviewAction>(uri, 0, 1, "PreviewAction", "Can't create PreviewAction object in QML.");
46− qmlRegisterUncreatableType<PreviewInfoHint>(uri, 0, 1, "PreviewInfoHint", "Can't create PreviewInfoHint object in QML.");
47− qmlRegisterUncreatableType<SocialPreviewComment>(uri, 0, 1, "SocialPreviewComment", "Can't create SocialPreviewComment object in QML.");
48− qmlRegisterUncreatableType<GenericOptionsModel>(uri, 0, 1, "GenericOptionsModel", "Can't create options model in QML.");
49− qmlRegisterUncreatableType<Result>(uri, 0, 1, "Result", "Can't create result object in QML.");
50− qmlRegisterType<Scope>(uri, 0, 1, "Scope");
51− qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
52− qmlRegisterType<Categories>(uri, 0, 1, "Categories");
53− qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create new Category Results in QML. Get them from Categories instance.");
54− qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
55− qmlRegisterType<MusicPreviewTrackModel>(uri, 0, 1, "MusicPreviewTrackModel");
56−}
57−
58−void UnityPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
59−{
60− QQmlExtensionPlugin::initializeEngine(engine, uri);
61−#ifndef GLIB_VERSION_2_36
62− g_type_init();
63−#endif
64−}
plugins/Unity/plugin.hdeleted−35
@@ -1,35 +0,0 @@
1−/*
2− * Copyright (C) 2012 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− * Author: Michał Sawicz <michal.sawicz@canonical.com>
17− */
18−
19−#ifndef UNITY_PLUGIN_H
20−#define UNITY_PLUGIN_H
21−
22−#include <QtQml/QQmlEngine>
23−#include <QtQml/QQmlExtensionPlugin>
24−
25−class UnityPlugin : public QQmlExtensionPlugin
26−{
27− Q_OBJECT
28− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29−
30−public:
31− void registerTypes(const char *uri);
32− void initializeEngine(QQmlEngine *engine, const char *uri);
33−};
34−
35−#endif
plugins/Unity/preview.cppdeleted−199
@@ -1,199 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// local
21−#include "preview.h"
22−#include "previewaction.h"
23−#include "previewinfohint.h"
24−#include "genericpreview.h"
25−#include "applicationpreview.h"
26−#include "moviepreview.h"
27−#include "musicpreview.h"
28−#include "socialpreview.h"
29−#include "iconutils.h"
30−#include "variantutils.h"
31−
32−// Qt
33−#include <QDebug>
34−#include <QtAlgorithms>
35−
36−#include <UnityCore/GenericPreview.h>
37−#include <UnityCore/ApplicationPreview.h>
38−#include <UnityCore/MoviePreview.h>
39−#include <UnityCore/MusicPreview.h>
40−#include <UnityCore/SocialPreview.h>
41−
42−#include <UnityCore/GLibWrapper.h>
43−
44−Preview::Preview(QObject *parent):
45− QObject(parent),
46− m_unityPreview(nullptr),
47− m_result(new Result(this))
48−{
49−}
50−
51−QString Preview::rendererName() const
52−{
53− if (m_unityPreview) {
54− return QString::fromStdString(m_unityPreview->renderer_name());
55− } else {
56− qWarning() << "Preview not set";
57− }
58− return QString();
59−}
60−
61−QString Preview::title() const
62−{
63− if (m_unityPreview) {
64− return QString::fromStdString(m_unityPreview->title());
65− } else {
66− qWarning() << "Preview not set";
67− }
68− return QString();
69−}
70−
71−QString Preview::subtitle () const
72−{
73− if (m_unityPreview) {
74− return QString::fromStdString(m_unityPreview->subtitle());
75− } else {
76− qWarning() << "Preview not set";
77− }
78− return QString();
79−}
80−
81−QString Preview::description() const
82−{
83− if (m_unityPreview) {
84− return QString::fromStdString(m_unityPreview->description());
85− } else {
86− qWarning() << "Preview not set";
87− }
88− return QString();
89−}
90−
91−QVariant Preview::actions()
92−{
93− return QVariant::fromValue(m_actions);
94−}
95−
96−QVariant Preview::infoHints()
97−{
98− return QVariant::fromValue(m_infoHints);
99−}
100−
101−QVariantMap Preview::infoHintsHash() const
102−{
103− return m_infoHintsHash;
104−}
105−
106−QString Preview::image() const
107−{
108− if (m_unityPreview) {
109− if (m_unityPreview->image() != nullptr) {
110− auto giconString = g_icon_to_string(m_unityPreview->image());
111− QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
112− g_free(giconString);
113− return result;
114− } else {
115− QString sourceMedia(QString::fromStdString(m_unityPreview->image_source_uri()));
116− QString thumbnailUri(uriToThumbnailerProviderString(sourceMedia, m_result->mimeType(), m_result->metadata().toHash()));
117− if (!thumbnailUri.isNull()) return thumbnailUri;
118− }
119− } else {
120− qWarning() << "Preview not set";
121− }
122− return QString::null;
123−}
124−
125−QVariant Preview::result() const
126−{
127− return QVariant::fromValue(m_result);
128−}
129−
130−Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
131−{
132− Preview* preview = nullptr;
133−
134− if (dynamic_cast<unity::dash::GenericPreview *>(unityPreview.get()) != nullptr) {
135− preview = new GenericPreview();
136− } else if (dynamic_cast<unity::dash::MusicPreview *>(unityPreview.get()) != nullptr) {
137− preview = new MusicPreview();
138− } else if (dynamic_cast<unity::dash::MoviePreview *>(unityPreview.get()) != nullptr) {
139− preview = new MoviePreview();
140− } else if (dynamic_cast<unity::dash::ApplicationPreview *>(unityPreview.get()) != nullptr) {
141− preview = new ApplicationPreview();
142− } else if (dynamic_cast<unity::dash::SocialPreview *>(unityPreview.get()) != nullptr) {
143− preview = new SocialPreview();
144− } else {
145− qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
146− preview = new GenericPreview();
147− }
148−
149− preview->setUnityPreviewBase(unityPreview);
150− preview->setUnityPreview(unityPreview);
151−
152− return preview;
153−}
154−
155−void Preview::setUnityPreviewBase(unity::dash::Preview::Ptr unityPreview)
156−{
157− m_unityPreview = unityPreview;
158− m_result->setPreview(unityPreview);
159−
160− qDeleteAll(m_infoHints);
161− m_infoHints.clear();
162− m_infoHintsHash.clear();
163− qDeleteAll(m_actions);
164− m_actions.clear();
165−
166− for (auto unityInfoHint: m_unityPreview->GetInfoHints()) {
167− auto hint = new PreviewInfoHint(this);
168− hint->setUnityInfoHint(unityInfoHint);
169− m_infoHints.append(hint);
170− m_infoHintsHash[hint->id()] = QVariant::fromValue(hint);
171− }
172−
173− for (auto unityAction: m_unityPreview->GetActions()) {
174− auto action = new PreviewAction(this);
175− action->setUnityAction(unityAction);
176− m_actions.append(action);
177− }
178−}
179−
180−void Preview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
181−{
182− // default implementation does nothing
183−}
184−
185−void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
186−{
187− if (m_unityPreview) {
188− auto unityHints = convertToHintsMap(hints);
189− m_actionCancellable.Renew();
190− m_unityPreview->PerformAction(actionId.toStdString(), unityHints, nullptr, m_actionCancellable);
191− } else {
192− qWarning() << "Preview not set";
193− }
194−}
195−
196−void Preview::cancelAction()
197−{
198− m_actionCancellable.Cancel();
199−}
plugins/Unity/preview.hdeleted−89
@@ -1,89 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef PREVIEW_H
21−#define PREVIEW_H
22−
23−// Qt
24−#include <QObject>
25−#include <QString>
26−#include <QMetaType>
27−#include <QList>
28−#include <QVariantMap>
29−
30−// libunity-core
31−#include <UnityCore/Preview.h>
32−
33−// local
34−#include "result.h"
35−#include "previewaction.h"
36−#include <UnityCore/GLibWrapper.h>
37−
38−class Q_DECL_EXPORT Preview : public QObject
39−{
40− Q_OBJECT
41−
42− Q_PROPERTY(QString rendererName READ rendererName NOTIFY previewChanged)
43− Q_PROPERTY(QString title READ title NOTIFY previewChanged)
44− Q_PROPERTY(QString subtitle READ subtitle NOTIFY previewChanged)
45− Q_PROPERTY(QString description READ description NOTIFY previewChanged)
46− Q_PROPERTY(QVariant actions READ actions NOTIFY previewChanged)
47− Q_PROPERTY(QVariant infoHints READ infoHints NOTIFY previewChanged)
48− Q_PROPERTY(QVariantMap infoMap READ infoHintsHash NOTIFY previewChanged)
49− Q_PROPERTY(QString image READ image NOTIFY previewChanged)
50− Q_PROPERTY(QVariant result READ result NOTIFY previewChanged)
51−
52−public:
53− explicit Preview(QObject *parent = 0);
54− static Preview* newFromUnityPreview(unity::dash::Preview::Ptr unityPreview);
55−
56− QString rendererName() const;
57− QString title() const;
58− QString subtitle() const;
59− QString description() const;
60− QVariant actions();
61− QVariant infoHints();
62− QVariantMap infoHintsHash() const;
63− QString image() const;
64− QVariant result() const;
65−
66− Q_INVOKABLE void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
67− Q_INVOKABLE void cancelAction();
68−
69−Q_SIGNALS:
70− void previewChanged();
71−
72−protected:
73− virtual void setUnityPreview(unity::dash::Preview::Ptr unityPreview);
74−
75− unity::dash::Preview::Ptr m_unityPreview;
76− Result* m_result;
77−
78−private:
79− void setUnityPreviewBase(unity::dash::Preview::Ptr unityPreview);
80−
81− QList<QObject *> m_actions;
82− QList<QObject *> m_infoHints;
83− QVariantMap m_infoHintsHash;
84− unity::glib::Cancellable m_actionCancellable;
85−};
86−
87−Q_DECLARE_METATYPE(Preview *)
88−
89−#endif
plugins/Unity/previewaction.cppdeleted−75
@@ -1,75 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "previewaction.h"
21−
22−PreviewAction::PreviewAction(QObject *parent)
23− : QObject(parent),
24− m_unityAction(nullptr)
25−{
26−}
27−
28−void PreviewAction::setUnityAction(unity::dash::Preview::ActionPtr unityAction)
29−{
30− m_unityAction = unityAction;
31−
32− Q_EMIT previewActionChanged();
33−}
34−
35−QString PreviewAction::id() const
36−{
37− if (m_unityAction)
38− return QString::fromStdString(m_unityAction->id);
39− return QString();
40−}
41−
42−QString PreviewAction::displayName() const
43−{
44− if (m_unityAction)
45− return QString::fromStdString(m_unityAction->display_name);
46− return QString();
47−}
48−
49−QString PreviewAction::iconHint() const
50−{
51− if (m_unityAction)
52− return QString::fromStdString(m_unityAction->icon_hint);
53− return QString();
54−}
55−
56−QString PreviewAction::extraText() const
57−{
58− if (m_unityAction)
59− return QString::fromStdString(m_unityAction->extra_text);
60− return QString();
61−}
62−
63−QString PreviewAction::activationUri() const
64−{
65− if (m_unityAction)
66− return QString::fromStdString(m_unityAction->activation_uri);
67− return QString();
68−}
69−
70−LayoutHint PreviewAction::layoutHint() const
71−{
72− if (m_unityAction)
73− return static_cast<LayoutHint>(m_unityAction->layout_hint);
74− return LayoutHint::None;
75−}
plugins/Unity/previewaction.hdeleted−71
@@ -1,71 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef PREVIEWACTION_H
21−#define PREVIEWACTION_H
22−
23−// Qt
24−#include <QObject>
25−#include <QList>
26−
27−// libuinity-core
28−#include <UnityCore/Preview.h>
29−
30−enum LayoutHint // keep in sync with unty::dash::LayoutHint
31−{
32− None,
33− Left,
34− Right,
35− Top,
36− Bottom
37−};
38−
39−class Q_DECL_EXPORT PreviewAction : public QObject
40−{
41− Q_OBJECT
42−
43− Q_PROPERTY(QString id READ id NOTIFY previewActionChanged)
44− Q_PROPERTY(QString displayName READ displayName NOTIFY previewActionChanged)
45− Q_PROPERTY(QString iconHint READ iconHint NOTIFY previewActionChanged)
46− Q_PROPERTY(QString extraText READ extraText NOTIFY previewActionChanged)
47− Q_PROPERTY(QString activationUri READ activationUri NOTIFY previewActionChanged)
48− Q_PROPERTY(LayoutHint layoutHint READ layoutHint NOTIFY previewActionChanged)
49−
50−public:
51− explicit PreviewAction(QObject *parent = 0);
52− void setUnityAction(unity::dash::Preview::ActionPtr unityAction);
53−
54− QString id() const;
55− QString displayName() const;
56− QString iconHint() const;
57− QString extraText() const;
58− QString activationUri() const;
59− LayoutHint layoutHint() const;
60−
61−Q_SIGNALS:
62− void previewActionChanged();
63−
64−private:
65− unity::dash::Preview::ActionPtr m_unityAction;
66−};
67−
68−Q_DECLARE_METATYPE(PreviewAction *)
69−Q_DECLARE_METATYPE(LayoutHint)
70−
71−#endif
plugins/Unity/previewinfohint.cppdeleted−67
@@ -1,67 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include <deelistmodel.h>
21−// local
22−#include "previewinfohint.h"
23−
24−PreviewInfoHint::PreviewInfoHint(QObject *parent):
25− QObject(parent),
26− m_unityInfoHint(nullptr)
27−{
28−}
29−
30−void PreviewInfoHint::setUnityInfoHint(unity::dash::Preview::InfoHintPtr unityInfoHint)
31−{
32− m_unityInfoHint = unityInfoHint;
33−
34− Q_EMIT previewInfoHintChanged();
35−}
36−
37−QString PreviewInfoHint::id() const
38−{
39− if (m_unityInfoHint) {
40− return QString::fromStdString(m_unityInfoHint->id);
41− }
42− return QString();
43−}
44−
45−QString PreviewInfoHint::displayName() const
46−{
47− if (m_unityInfoHint) {
48− return QString::fromStdString(m_unityInfoHint->display_name);
49− }
50− return QString();
51−}
52−
53−QString PreviewInfoHint::iconHint() const
54−{
55− if (m_unityInfoHint) {
56− return QString::fromStdString(m_unityInfoHint->icon_hint);
57− }
58− return QString();
59−}
60−
61−QVariant PreviewInfoHint::value() const
62−{
63− if (m_unityInfoHint) {
64− return DeeListModel::VariantForData(m_unityInfoHint->value);
65− }
66− return QVariant();
67−}
plugins/Unity/previewinfohint.hdeleted−58
@@ -1,58 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef PREVIEWINFOHINT_H
21−#define PREVIEWINFOHINT_H
22−
23−// Qt
24−#include <QObject>
25−#include <QString>
26−#include <QVariant>
27−
28−// libunity-core
29−#include <UnityCore/Preview.h>
30−
31−class PreviewInfoHint : public QObject
32−{
33− Q_OBJECT
34−
35− Q_PROPERTY(QString id READ id NOTIFY previewInfoHintChanged)
36− Q_PROPERTY(QString displayName READ displayName NOTIFY previewInfoHintChanged)
37− Q_PROPERTY(QString iconHint READ iconHint NOTIFY previewInfoHintChanged)
38− Q_PROPERTY(QVariant value READ value NOTIFY previewInfoHintChanged)
39−
40−public:
41− explicit PreviewInfoHint(QObject *parent = 0);
42− void setUnityInfoHint(unity::dash::Preview::InfoHintPtr unityInfoHint);
43−
44− QString id() const;
45− QString displayName() const;
46− QString iconHint() const;
47− QVariant value() const;
48−
49−Q_SIGNALS:
50− void previewInfoHintChanged();
51−
52−private:
53− unity::dash::Preview::InfoHintPtr m_unityInfoHint;
54−};
55−
56−Q_DECLARE_METATYPE(PreviewInfoHint *)
57−
58−#endif
plugins/Unity/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Unity
2−plugin Unity-qml
3−typeinfo plugin.qmltypes
plugins/Unity/radiooptionfilter.cppdeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "radiooptionfilter.h"
23−
24−// local
25−#include "unityoptionsmodel.h"
26−
27−RadioOptionFilter::RadioOptionFilter(QObject *parent) :
28− Filter(parent), m_unityRadioOptionFilter(nullptr), m_options(nullptr)
29−{
30−}
31−
32−GenericOptionsModel* RadioOptionFilter::options() const
33−{
34− return m_options;
35−}
36−
37−void RadioOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
38−{
39− Filter::setUnityFilter(filter);
40− m_unityRadioOptionFilter = std::dynamic_pointer_cast<unity::dash::RadioOptionFilter>(m_unityFilter);
41−
42− onOptionsChanged(m_unityRadioOptionFilter->options);
43−}
44−
45−void RadioOptionFilter::onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions)
46−{
47− if (m_options != nullptr) {
48− m_signals.disconnectAll();
49− delete m_options;
50− m_options = nullptr;
51− }
52− m_options = new UnityOptionsModel(this, m_unityRadioOptionFilter->options,
53− m_unityRadioOptionFilter->option_added,
54− m_unityRadioOptionFilter->option_removed,
55− m_unityRadioOptionFilter->show_all_button);
56− connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
57−
58− m_signals << m_unityRadioOptionFilter->options.changed.connect(sigc::mem_fun(this, &RadioOptionFilter::onOptionsChanged));
59−
60− Q_EMIT optionsChanged();
61−}
plugins/Unity/radiooptionfilter.hdeleted−59
@@ -1,59 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−#ifndef RADIOOPTIONFILTER_H
22−#define RADIOOPTIONFILTER_H
23−
24−// Qt
25−#include <QObject>
26−#include <QMetaType>
27−
28−// libunity-core
29−#include <UnityCore/RadioOptionFilter.h>
30−
31−// Local
32−#include "filter.h"
33−#include "filteroption.h"
34−#include "signalslist.h"
35−
36−class Q_DECL_EXPORT RadioOptionFilter : public Filter
37−{
38− Q_OBJECT
39−
40−public:
41− explicit RadioOptionFilter(QObject *parent = nullptr);
42−
43− /* getters */
44− GenericOptionsModel* options() const override;
45−
46−protected:
47− void setUnityFilter(unity::dash::Filter::Ptr filter) override;
48−
49−private:
50− unity::dash::RadioOptionFilter::Ptr m_unityRadioOptionFilter;
51− GenericOptionsModel* m_options;
52− SignalsList m_signals;
53−
54− void onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions);
55−};
56−
57−Q_DECLARE_METATYPE(RadioOptionFilter*)
58−
59−#endif // RADIOOPTIONFILTER_H
plugins/Unity/ratingfilteroption.cppdeleted−62
@@ -1,62 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// self
21−#include "ratingfilteroption.h"
22−
23−RatingFilterOption::RatingFilterOption(const QString &id, float value, QObject *parent) :
24− AbstractFilterOption(parent),
25− m_active(false),
26− m_id(id),
27− m_value(value)
28−{
29−}
30−
31−QString RatingFilterOption::id() const
32−{
33− return m_id;
34−}
35−
36−QString RatingFilterOption::name() const
37−{
38− return QString::Null();
39−}
40−
41−QString RatingFilterOption::iconHint() const
42−{
43− return QString::Null();
44−}
45−
46−float RatingFilterOption::value() const
47−{
48− return m_value;
49−}
50−
51−bool RatingFilterOption::active() const
52−{
53− return m_active;
54−}
55−
56−void RatingFilterOption::setActive(bool active)
57−{
58− if (active != m_active) {
59− m_active = active;
60− Q_EMIT activeChanged(m_active);
61− }
62−}
plugins/Unity/ratingfilteroption.hdeleted−53
@@ -1,53 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef RATINGFILTEROPTION_H
21−#define RATINGFILTEROPTION_H
22−
23−// local
24−#include "abstractfilteroption.h"
25−
26−class Q_DECL_EXPORT RatingFilterOption : public AbstractFilterOption
27−{
28− Q_OBJECT
29−
30− Q_PROPERTY(float value READ value CONSTANT)
31−
32−public:
33− explicit RatingFilterOption(const QString &id, float ratingValue, QObject *parent = nullptr);
34−
35− /* getters */
36− QString id() const override;
37− QString name() const override;
38− QString iconHint() const override;
39− bool active() const override;
40− float value() const;
41−
42− /* setters */
43− void setActive(bool active) override;
44−
45−private:
46− bool m_active;
47− QString m_id;
48− float m_value;
49−};
50−
51−Q_DECLARE_METATYPE(RatingFilterOption*)
52−
53−#endif // RATINGFILTEROPTION_H
plugins/Unity/ratingoptionsmodel.hdeleted−33
@@ -1,33 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef RATINGOPTIONSMODEL_H
21−#define RATINGOPTIONSMODEL_H
22−
23−#include "genericoptionsmodel.h"
24−
25−class RatingOptionsModel : public GenericOptionsModel
26−{
27− Q_OBJECT
28−
29−public:
30− RatingOptionsModel(bool showAllOption, QObject *parent);
31−};
32−
33−#endif // RATINGOPTIONSMODEL_H
plugins/Unity/ratingsfilter.cppdeleted−73
@@ -1,73 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "ratingsfilter.h"
23−
24−// local
25−#include "ratingfilteroption.h"
26−#include "ratingoptionsmodel.h"
27−
28−RatingsFilter::RatingsFilter(QObject *parent) :
29− Filter(parent),
30− m_unityRatingsFilter(nullptr),
31− m_options(nullptr)
32−{
33−}
34−
35−GenericOptionsModel* RatingsFilter::options() const
36−{
37− return m_options;
38−}
39−
40−float RatingsFilter::rating() const
41−{
42− if (m_unityRatingsFilter)
43− {
44− return m_unityRatingsFilter->rating;
45− }
46− return 0.0f;
47−}
48−
49−void RatingsFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
50−{
51− Filter::setUnityFilter(filter);
52− m_unityRatingsFilter = std::dynamic_pointer_cast<unity::dash::RatingsFilter>(m_unityFilter);
53−
54− delete m_options;
55−
56− m_options = new RatingOptionsModel(m_unityRatingsFilter->show_all_button, this);
57− connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
58− connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), this, SLOT(onActiveChanged(AbstractFilterOption *)));
59− connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
60−
61− Q_EMIT optionsChanged();
62−}
63−
64−void RatingsFilter::onActiveChanged(AbstractFilterOption *option)
65−{
66− RatingFilterOption *ratingOption = dynamic_cast<RatingFilterOption*>(option);
67− if (ratingOption != nullptr)
68− {
69− const float val = ratingOption->active() ? ratingOption->value() : 0.0f;
70− m_unityRatingsFilter->rating = val;
71− Q_EMIT ratingChanged(val);
72− }
73−}
plugins/Unity/ratingsfilter.hdeleted−66
@@ -1,66 +0,0 @@
1−/*
2− * Copyright (C) 2011, 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Pawel Stolowski <pawel.stolowski@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−#ifndef RATINGSFILTER_H
22−#define RATINGSFILTER_H
23−
24−// Qt
25−#include <QObject>
26−#include <QMetaType>
27−
28−// libunity-core
29−#include <UnityCore/RatingsFilter.h>
30−
31−// Local
32−#include "filter.h"
33−
34−class GenericOptionsModel;
35−class AbstractFilterOption;
36−
37−class Q_DECL_EXPORT RatingsFilter : public Filter
38−{
39− Q_OBJECT
40−
41− Q_PROPERTY(float rating READ rating NOTIFY ratingChanged)
42−
43−public:
44− explicit RatingsFilter(QObject *parent = nullptr);
45−
46− /* getters */
47− GenericOptionsModel* options() const override;
48− float rating() const;
49−
50−Q_SIGNALS:
51− void ratingChanged(float);
52−
53−protected:
54− void setUnityFilter(unity::dash::Filter::Ptr filter) override;
55−
56−protected Q_SLOTS:
57− void onActiveChanged(AbstractFilterOption *option);
58−
59−private:
60− unity::dash::RatingsFilter::Ptr m_unityRatingsFilter;
61− GenericOptionsModel *m_options;
62−};
63−
64−Q_DECLARE_METATYPE(RatingsFilter*)
65−
66−#endif // RATINGSFILTER_H
plugins/Unity/result.cppdeleted−82
@@ -1,82 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "result.h"
21−#include "variantutils.h"
22−
23−Result::Result(QObject *parent) :
24− QObject(parent)
25−{
26−}
27−
28−Result::Result(unity::dash::Preview::Ptr preview, QObject *parent) :
29− QObject(parent),
30− m_preview(preview)
31−{
32−}
33−
34−void Result::setPreview(unity::dash::Preview::Ptr preview)
35−{
36− m_preview = preview;
37−}
38−
39−QString Result::uri() const
40−{
41− return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.uri) : QString::null;
42−}
43−
44−QString Result::iconHint() const
45−{
46− return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.icon_hint) : QString::null;
47−}
48−
49−unsigned Result::categoryIndex() const
50−{
51− return m_preview != nullptr ? m_preview->preview_result.category_index : 0;
52−}
53−
54−unsigned Result::resultType() const
55−{
56− return m_preview != nullptr ? m_preview->preview_result.result_type : 0;
57−}
58−
59−QString Result::mimeType() const
60−{
61− return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.mimetype) : QString::null;
62−}
63−
64−QString Result::title() const
65−{
66− return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.name) : QString::null;
67−}
68−
69−QString Result::comment() const
70−{
71− return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.comment) : QString::null;
72−}
73−
74−QString Result::dndUri() const
75−{
76− return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.dnd_uri) : QString::null;
77−}
78−
79−QVariant Result::metadata() const
80−{
81− return m_preview != nullptr ? convertToQVariantHash(m_preview->preview_result.hints) : QVariant();
82−}
plugins/Unity/result.hdeleted−69
@@ -1,69 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef RESULT_H
21−#define RESULT_H
22−
23−// Qt
24−#include <QObject>
25−#include <QVariant>
26−
27−// libunity-core
28−#include <UnityCore/Preview.h>
29−
30−class Q_DECL_EXPORT Result : public QObject
31−{
32− Q_OBJECT
33−
34− Q_PROPERTY(QString uri READ uri CONSTANT)
35− Q_PROPERTY(QString iconHint READ iconHint CONSTANT)
36− Q_PROPERTY(unsigned categoryIndex READ categoryIndex CONSTANT)
37− Q_PROPERTY(unsigned resultType READ resultType CONSTANT)
38− Q_PROPERTY(QString mimeType READ mimeType CONSTANT)
39− Q_PROPERTY(QString title READ title CONSTANT)
40− Q_PROPERTY(QString comment READ comment CONSTANT)
41− Q_PROPERTY(QString dndUri READ dndUri CONSTANT)
42− Q_PROPERTY(QVariant metadata READ metadata CONSTANT)
43−
44−public:
45− Result(QObject *parent = nullptr);
46− Result(unity::dash::Preview::Ptr preview, QObject *parent = nullptr);
47−
48− void setPreview(unity::dash::Preview::Ptr preview);
49−
50− QString uri() const;
51− QString iconHint() const;
52− unsigned categoryIndex() const;
53− unsigned resultType() const;
54− QString mimeType() const;
55− QString title() const;
56− QString comment() const;
57− QString dndUri() const;
58− QVariant metadata() const;
59−
60−private:
61− /* Keep reference to the original preview to access result attributes via it, rather than keeping copies of them;
62− this will save us a bit on copying, especially as UI is mostly interested in just uri.
63− */
64− unity::dash::Preview::Ptr m_preview;
65−};
66−
67−Q_DECLARE_METATYPE(Result *)
68−
69−#endif
plugins/Unity/scope.cppdeleted−413
@@ -1,413 +0,0 @@
1−/*
2− * Copyright (C) 2011 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− * Michal Hruby <michal.hruby@canonical.com>
7− *
8− * This program is free software; you can redistribute it and/or modify
9− * it under the terms of the GNU General Public License as published by
10− * the Free Software Foundation; version 3.
11− *
12− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19− */
20−
21−// Self
22−#include "scope.h"
23−
24−// local
25−#include "categories.h"
26−#include "preview.h"
27−#include "variantutils.h"
28−
29−// Qt
30−#include <QUrl>
31−#include <QUrlQuery>
32−#include <QDebug>
33−#include <QtGui/QDesktopServices>
34−#include <QQmlEngine>
35−
36−#include <UnityCore/Variant.h>
37−#include <UnityCore/GLibWrapper.h>
38−
39−#include <libintl.h>
40−#include <glib.h>
41−
42−Scope::Scope(QObject *parent) : QObject(parent)
43− , m_formFactor("phone")
44− , m_isActive(false)
45− , m_searchInProgress(false)
46−{
47− m_categories.reset(new Categories(this));
48−
49− connect(this, &Scope::isActiveChanged, this, &Scope::scopeIsActiveChanged);
50−}
51−
52−QString Scope::id() const
53−{
54− return QString::fromStdString(m_unityScope->id());
55−}
56−
57−QString Scope::name() const
58−{
59− return QString::fromStdString(m_unityScope->name());
60−}
61−
62−QString Scope::iconHint() const
63−{
64− return QString::fromStdString(m_unityScope->icon_hint());
65−}
66−
67−QString Scope::description() const
68−{
69− return QString::fromStdString(m_unityScope->description());
70−}
71−
72−QString Scope::searchHint() const
73−{
74− return QString::fromStdString(m_unityScope->search_hint());
75−}
76−
77−bool Scope::searchInProgress() const
78−{
79− return m_searchInProgress;
80−}
81−
82−bool Scope::visible() const
83−{
84− return m_unityScope->visible();
85−}
86−
87−QString Scope::shortcut() const
88−{
89− return QString::fromStdString(m_unityScope->shortcut());
90−}
91−
92−bool Scope::connected() const
93−{
94− return m_unityScope->connected();
95−}
96−
97−Categories* Scope::categories() const
98−{
99− return m_categories.get();
100−}
101−
102−QString Scope::searchQuery() const
103−{
104− return m_searchQuery;
105−}
106−
107−QString Scope::noResultsHint() const
108−{
109− return m_noResultsHint;
110−}
111−
112−QString Scope::formFactor() const
113−{
114− return m_formFactor;
115−}
116−
117−bool Scope::isActive() const
118−{
119− return m_isActive;
120−}
121−
122−Filters* Scope::filters() const
123−{
124− return m_filters.get();
125−}
126−
127−void Scope::setSearchQuery(const QString& search_query)
128−{
129− /* Checking for m_searchQuery.isNull() which returns true only when the string
130− has never been set is necessary because when search_query is the empty
131− string ("") and m_searchQuery is the null string,
132− search_query != m_searchQuery is still true.
133− */
134− using namespace std::placeholders;
135−
136− if (m_searchQuery.isNull() || search_query != m_searchQuery) {
137− m_searchQuery = search_query;
138− m_cancellable.Renew();
139− m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
140− Q_EMIT searchQueryChanged();
141− if (!m_searchInProgress) {
142− m_searchInProgress = true;
143− Q_EMIT searchInProgressChanged();
144− }
145− }
146−}
147−
148−void Scope::setNoResultsHint(const QString& hint) {
149− if (hint != m_noResultsHint) {
150− m_noResultsHint = hint;
151− Q_EMIT noResultsHintChanged();
152− }
153−}
154−
155−void Scope::setFormFactor(const QString& form_factor) {
156− if (form_factor != m_formFactor) {
157− m_formFactor = form_factor;
158− if (m_unityScope) {
159− m_unityScope->form_factor = m_formFactor.toStdString();
160− synchronizeStates(); // will trigger a re-search
161− }
162− Q_EMIT formFactorChanged();
163− }
164−}
165−
166−void Scope::setActive(const bool active) {
167− if (active != m_isActive) {
168− m_isActive = active;
169− Q_EMIT isActiveChanged(m_isActive);
170− }
171−}
172−
173−unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
174− const QVariant &category, const QVariant &result_type,
175− const QVariant &mimetype, const QVariant &title,
176− const QVariant &comment, const QVariant &dnd_uri,
177− const QVariant &metadata)
178−{
179− unity::dash::LocalResult res;
180− res.uri = uri.toString().toStdString();
181− res.icon_hint = icon_hint.toString().toStdString();
182− res.category_index = category.toUInt();
183− res.result_type = result_type.toUInt();
184− res.mimetype = mimetype.toString().toStdString();
185− res.name = title.toString().toStdString();
186− res.comment = comment.toString().toStdString();
187− res.dnd_uri = dnd_uri.toString().toStdString();
188− res.hints = convertToHintsMap(metadata);
189−
190− return res;
191−}
192−
193−// FIXME: Change to use row index.
194−void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
195− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
196− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
197−{
198− auto res = createLocalResult(uri, icon_hint, category, result_type, mimetype, title, comment, dnd_uri, metadata);
199− m_unityScope->Activate(res);
200−}
201−
202−// FIXME: Change to use row index.
203−void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
204− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
205− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
206−{
207− QVariant real_metadata(metadata);
208− // handle overridden results, since QML doesn't support defining maps
209− if (metadata.type() == QVariant::String) {
210− real_metadata = QVariant::fromValue(subscopeUriToMetadataHash(metadata.toString()));
211− }
212−
213− auto res = createLocalResult(uri, icon_hint, category, result_type, mimetype, title, comment, dnd_uri, real_metadata);
214− m_previewCancellable.Renew();
215−
216− // canned queries don't have previews, must be activated
217− if (uri.toString().startsWith("x-unity-no-preview-scopes-query://")) {
218− m_unityScope->Activate(res);
219− } else {
220− m_unityScope->Preview(res, nullptr, m_previewCancellable);
221− }
222−}
223−
224−void Scope::cancelActivation()
225−{
226− m_previewCancellable.Cancel();
227−}
228−
229−void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
230−{
231− Q_EMIT activated();
232− // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
233− switch (type)
234− {
235− case unity::dash::NOT_HANDLED:
236− fallbackActivate(QString::fromStdString(result.uri));
237− break;
238− case unity::dash::SHOW_DASH:
239− Q_EMIT showDash();
240− break;
241− case unity::dash::HIDE_DASH:
242− Q_EMIT hideDash();
243− break;
244− case unity::dash::GOTO_DASH_URI:
245− if (hints.find("goto-uri") != hints.end()) {
246− Q_EMIT gotoUri(QString::fromStdString(g_variant_get_string(hints.at("goto-uri"), nullptr)));
247− } else {
248− qWarning() << "Missing goto-uri hint for GOTO_DASH_URI activation reply";
249− }
250− break;
251− case unity::dash::PERFORM_SEARCH:
252− if (hints.find("query") != hints.end()) {
253− // note: this will emit searchQueryChanged, and shell will call setSearchQuery back with a new query,
254− // but it will get ignored.
255− setSearchQuery(QString::fromStdString(g_variant_get_string(hints.at("query"), nullptr)));
256− }
257− break;
258− default:
259− qWarning() << "Unhandled activation response:" << type;
260− }
261−}
262−
263−void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::dash::Preview::Ptr const& preview)
264−{
265− Q_EMIT activated();
266− auto prv = Preview::newFromUnityPreview(preview);
267− // is this the best solution? QML may need to keep more than one preview instance around, so we can't own it.
268− // passing it by value is not possible.
269− QQmlEngine::setObjectOwnership(prv, QQmlEngine::JavaScriptOwnership);
270− Q_EMIT previewReady(prv);
271−}
272−
273−void Scope::fallbackActivate(const QString& uri)
274−{
275− /* Tries various methods to trigger a sensible action for the given 'uri'.
276− If it has no understanding of the given scheme it falls back on asking
277− Qt to open the uri.
278− */
279− QUrl url(uri);
280− if (url.scheme() == "file") {
281− /* Override the files place's default URI handler: we want the file
282− manager to handle opening folders, not the dash.
283−
284− Ref: https://bugs.launchpad.net/upicek/+bug/689667
285− */
286− QDesktopServices::openUrl(url);
287− return;
288− }
289− if (url.scheme() == "application") {
290− // get the full path to the desktop file
291− QString path(url.path().isEmpty() ? url.authority() : url.path());
292− if (path.startsWith("/")) {
293− Q_EMIT activateApplication(path);
294− } else {
295− // TODO: use the new desktop file finder/parser when it's ready
296− gchar* full_path = nullptr;
297− GKeyFile* key_file = g_key_file_new();
298− QString apps_path = "applications/" + path;
299− if (g_key_file_load_from_data_dirs(key_file, apps_path.toLocal8Bit().constData(), &full_path,
300− G_KEY_FILE_NONE, nullptr)) {
301− path = full_path;
302− Q_EMIT activateApplication(path);
303− } else {
304− qWarning() << "Unable to activate " << path;
305− }
306− g_key_file_free(key_file);
307− g_free(full_path);
308− }
309− return;
310− }
311−
312− qDebug() << "Trying to open" << uri;
313−
314− /* Try our luck */
315− QDesktopServices::openUrl(uri); //url?
316−}
317−
318−void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
319−{
320− m_unityScope = scope;
321−
322− m_categories->setUnityScope(m_unityScope);
323− m_filters.reset(new Filters(m_unityScope->filters, this));
324−
325− m_unityScope->form_factor = m_formFactor.toStdString();
326− /* Property change signals */
327− m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged));
328− m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged));
329− m_unityScope->icon_hint.changed.connect(sigc::mem_fun(this, &Scope::iconHintChanged));
330− m_unityScope->description.changed.connect(sigc::mem_fun(this, &Scope::descriptionChanged));
331− m_unityScope->search_hint.changed.connect(sigc::mem_fun(this, &Scope::searchHintChanged));
332− m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
333− m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
334− m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
335− m_unityScope->results_dirty.changed.connect(sigc::mem_fun(this, &Scope::resultsDirtyToggled));
336−
337− /* FIXME: signal should be forwarded instead of calling the handler directly */
338− m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
339−
340− m_unityScope->preview_ready.connect(sigc::mem_fun(this, &Scope::onPreviewReady));
341−
342− /* Synchronize local states with m_unityScope right now and whenever
343− m_unityScope becomes connected */
344− /* FIXME: should emit change notification signals for all properties */
345− connect(this, SIGNAL(connectedChanged(bool)), SLOT(synchronizeStates()));
346− synchronizeStates();
347−}
348−
349−unity::dash::Scope::Ptr Scope::unityScope() const
350−{
351− return m_unityScope;
352−}
353−
354−void Scope::synchronizeStates()
355−{
356− using namespace std::placeholders;
357−
358− if (connected()) {
359− /* Forward local states to m_unityScope */
360− if (!m_searchQuery.isNull()) {
361− m_cancellable.Renew();
362− m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
363− if (!m_searchInProgress) {
364− m_searchInProgress = true;
365− Q_EMIT searchInProgressChanged();
366− }
367− }
368− }
369−}
370−
371−void Scope::scopeIsActiveChanged()
372−{
373− if (!isActive() || !m_unityScope || !m_unityScope->results_dirty()) return;
374−
375− // force new search
376− synchronizeStates();
377−}
378−
379−void Scope::resultsDirtyToggled(bool results_dirty)
380−{
381− if (!results_dirty || !isActive()) return;
382−
383− // force new search
384− synchronizeStates();
385−}
386−
387−void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
388−{
389− QString hint;
390−
391− GError* error = const_cast<unity::glib::Error&>(err);
392−
393− if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
394− if (m_searchInProgress) {
395− m_searchInProgress = false;
396− Q_EMIT searchInProgressChanged();
397− }
398− } else {
399− // no need to check the results hint, we're still searching
400− return;
401− }
402−
403− if (!m_unityScope->results()->count()) {
404− unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
405− if (it != hints.end()) {
406− hint = QString::fromStdString(it->second.GetString());
407− } else {
408− hint = QString::fromUtf8(dgettext("unity", "Sorry, there is nothing that matches your search."));
409− }
410− }
411−
412− setNoResultsHint(hint);
413−}
plugins/Unity/scope.hdeleted−154
@@ -1,154 +0,0 @@
1−/*
2− * Copyright (C) 2011 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef SCOPE_H
21−#define SCOPE_H
22−
23−// Qt
24−#include <QObject>
25−#include <QString>
26−#include <QMetaType>
27−
28−// libunity-core
29−#include <UnityCore/Scope.h>
30−#include <UnityCore/Results.h>
31−#include <UnityCore/GLibWrapper.h>
32−
33−#include "categories.h"
34−#include "filters.h"
35−
36−class Preview;
37−
38−class Scope : public QObject
39−{
40− Q_OBJECT
41−
42− Q_PROPERTY(QString id READ id NOTIFY idChanged)
43− Q_PROPERTY(QString name READ name NOTIFY nameChanged)
44− Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
45− Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
46− Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
47− Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
48− Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
49− Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
50− Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
51− Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
52− Q_PROPERTY(Filters* filters READ filters NOTIFY filtersChanged)
53−
54− Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
55− Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
56− Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
57− Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
58−
59−public:
60− explicit Scope(QObject *parent = 0);
61−
62− /* getters */
63− QString id() const;
64− QString name() const;
65− QString iconHint() const;
66− QString description() const;
67− QString searchHint() const;
68− bool visible() const;
69− QString shortcut() const;
70− bool connected() const;
71− bool searchInProgress() const;
72− Categories* categories() const;
73− Filters* filters() const;
74− QString searchQuery() const;
75− QString noResultsHint() const;
76− QString formFactor() const;
77− bool isActive() const;
78−
79− /* setters */
80− void setSearchQuery(const QString& search_query);
81− void setNoResultsHint(const QString& hint);
82− void setFormFactor(const QString& form_factor);
83− void setActive(const bool);
84−
85− Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
86− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
87− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
88− Q_INVOKABLE void preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
89− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
90− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
91− Q_INVOKABLE void cancelActivation();
92−
93− void setUnityScope(const unity::dash::Scope::Ptr& scope);
94− unity::dash::Scope::Ptr unityScope() const;
95−
96−Q_SIGNALS:
97− void idChanged(const std::string&);
98− void dbusNameChanged(const std::string&);
99− void dbusPathChanged(const std::string&);
100− void nameChanged(const std::string&);
101− void iconHintChanged(const std::string&);
102− void descriptionChanged(const std::string&);
103− void searchHintChanged(const std::string&);
104− void searchInProgressChanged();
105− void visibleChanged(bool);
106− void shortcutChanged(const std::string&);
107− void connectedChanged(bool);
108− void categoriesChanged();
109− void searchQueryChanged();
110− void noResultsHintChanged();
111− void formFactorChanged();
112− void isActiveChanged(bool);
113− void filtersChanged();
114−
115− // signals triggered by activate(..) or preview(..) requests.
116− void previewReady(Preview *preview);
117− void showDash();
118− void hideDash();
119− void gotoUri(const QString &uri);
120− void activated();
121−
122− void activateApplication(const QString &desktop);
123−
124−private Q_SLOTS:
125− void synchronizeStates();
126− void scopeIsActiveChanged();
127− void onSearchFinished(std::string const &, unity::glib::HintsMap const &, unity::glib::Error const&);
128−
129−private:
130− unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,
131− const QVariant &category, const QVariant &result_type,
132− const QVariant &mimetype, const QVariant &title,
133− const QVariant &comment, const QVariant &dnd_uri,
134− const QVariant &metadata);
135− void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints);
136− void onPreviewReady(unity::dash::LocalResult const& result, unity::dash::Preview::Ptr const& preview);
137− void fallbackActivate(const QString& uri);
138− void resultsDirtyToggled(bool);
139−
140− unity::dash::Scope::Ptr m_unityScope;
141− std::unique_ptr<Categories> m_categories;
142− std::unique_ptr<Filters> m_filters;
143− QString m_searchQuery;
144− QString m_noResultsHint;
145− QString m_formFactor;
146− bool m_isActive;
147− bool m_searchInProgress;
148− unity::glib::Cancellable m_cancellable;
149− unity::glib::Cancellable m_previewCancellable;
150−};
151−
152−Q_DECLARE_METATYPE(Scope*)
153−
154−#endif // SCOPE_H
plugins/Unity/scopes.cppdeleted−176
@@ -1,176 +0,0 @@
1−/*
2− * Copyright (C) 2011 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// Self
21−#include "scopes.h"
22−
23−// Local
24−#include "scope.h"
25−
26−// Qt
27−#include <QDebug>
28−#include <QtCore/QStringList>
29−#include <QtGui/QKeySequence>
30−
31−Scopes::Scopes(QObject *parent)
32− : QAbstractListModel(parent)
33− , m_unityScopes(std::make_shared<unity::dash::GSettingsScopes>())
34− , m_loaded(false)
35−{
36− m_roles[Scopes::RoleScope] = "scope";
37− m_roles[Scopes::RoleId] = "id";
38− m_roles[Scopes::RoleVisible] = "visible";
39−
40− m_unityScopes->scope_added.connect(sigc::mem_fun(this, &Scopes::onScopeAdded));
41− m_unityScopes->scope_removed.connect(sigc::mem_fun(this, &Scopes::onScopeRemoved));
42− m_unityScopes->scopes_reordered.connect(sigc::mem_fun(this, &Scopes::onScopesReordered));
43− m_unityScopes->LoadScopes();
44−}
45−
46−QHash<int, QByteArray> Scopes::roleNames() const
47−{
48− return m_roles;
49−}
50−
51−int Scopes::rowCount(const QModelIndex& parent) const
52−{
53− Q_UNUSED(parent)
54−
55− return m_scopes.count();
56−}
57−
58−QVariant Scopes::data(const QModelIndex& index, int role) const
59−{
60− Q_UNUSED(role)
61−
62− if (!index.isValid()) {
63− return QVariant();
64− }
65−
66− Scope* scope = m_scopes.at(index.row());
67−
68− if (role == Scopes::RoleScope) {
69− return QVariant::fromValue(scope);
70− } else if (role == Scopes::RoleId) {
71− return QVariant::fromValue(scope->id());
72− } else if (role == Scopes::RoleVisible) {
73− return QVariant::fromValue(scope->visible());
74− } else {
75− return QVariant();
76− }
77−}
78−
79−QVariant Scopes::get(int row) const
80−{
81− return data(QAbstractListModel::index(row), 0);
82−}
83−
84−QVariant Scopes::get(const QString& scope_id) const
85−{
86− Q_FOREACH(Scope* scope, m_scopes) {
87− if (scope->id() == scope_id) {
88− return QVariant::fromValue(scope);
89− }
90− }
91−
92− return QVariant();
93−}
94−
95−bool Scopes::loaded() const
96−{
97− return m_loaded;
98−}
99−
100−void Scopes::onScopeAdded(const unity::dash::Scope::Ptr& scope, int /*position*/)
101−{
102− int index = m_scopes.count();
103− beginInsertRows(QModelIndex(), index, index);
104− addUnityScope(scope);
105− endInsertRows();
106−
107− // FIXME: do only once after all loaded?
108− m_loaded = true;
109− Q_EMIT loadedChanged(m_loaded);
110−}
111−
112−void Scopes::onScopesLoaded()
113−{
114−}
115−
116−void Scopes::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
117−{
118− auto id = QString::fromStdString(scope->id);
119− auto index = findScopeById(id);
120− if (index >= 0) {
121− beginRemoveRows(QModelIndex(), index, index);
122− removeUnityScope(index);
123− endRemoveRows();
124−
125− Q_EMIT scopeRemoved(id, index);
126− }
127−}
128−
129−void Scopes::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
130−{
131− // FIXME Should use beginMoveRows()/endMoveRows() to not recreate the UI for every scope.
132− beginResetModel();
133−
134− // remove existing scopes
135− for (auto i=m_scopes.count()-1; i>=0; i--) {
136− removeUnityScope(i);
137− }
138−
139− // re-create scopes
140− for (uint i=0; i<scopes.size(); i++) {
141− addUnityScope(scopes[i]);
142− }
143− endResetModel();
144−}
145−
146−void Scopes::onScopePropertyChanged()
147−{
148− QModelIndex scopeIndex = index(m_scopes.indexOf(qobject_cast<Scope*>(sender())));
149− Q_EMIT dataChanged(scopeIndex, scopeIndex);
150−}
151−
152−void Scopes::addUnityScope(const unity::dash::Scope::Ptr& unity_scope)
153−{
154− Scope* scope = new Scope(this);
155− scope->setUnityScope(unity_scope);
156− /* DOCME */
157− QObject::connect(scope, SIGNAL(visibleChanged(bool)), this, SLOT(onScopePropertyChanged()));
158− m_scopes.append(scope);
159−}
160−
161−void Scopes::removeUnityScope(int index)
162−{
163− Scope* scope = m_scopes.takeAt(index);
164−
165− delete scope;
166−}
167−
168−int Scopes::findScopeById(const QString& scope_id)
169−{
170− for (int i=0; i<m_scopes.count(); i++) {
171− if (m_scopes[i]->id() == scope_id) {
172− return i;
173− }
174− }
175− return -1;
176−}
plugins/Unity/scopes.hdeleted−94
@@ -1,94 +0,0 @@
1−/*
2− * Copyright (C) 2011 Canonical, Ltd.
3− *
4− * Authors:
5− * Florian Boucault <florian.boucault@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef SCOPES_H
21−#define SCOPES_H
22−
23−// Qt
24−#include <QAbstractListModel>
25−#include <QList>
26−
27−// libunity-core
28−#include <UnityCore/Scope.h>
29−#include <UnityCore/GSettingsScopes.h>
30−
31−namespace unity
32−{
33−namespace dash
34−{
35−class Scopes;
36−}
37−}
38−
39−class Hotkey;
40−class Scope;
41−
42−class Scopes : public QAbstractListModel
43−{
44− Q_OBJECT
45−
46− Q_ENUMS(Roles)
47−
48− Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
49−
50−public:
51− explicit Scopes(QObject *parent = 0);
52− ~Scopes() = default;
53−
54− enum Roles {
55− RoleScope,
56− RoleId,
57− RoleVisible
58− };
59−
60− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
61− Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
62−
63− Q_INVOKABLE QVariant get(int row) const;
64− Q_INVOKABLE QVariant get(const QString& scope_id) const;
65−
66− QHash<int, QByteArray> roleNames() const;
67−
68− bool loaded() const;
69−
70−Q_SIGNALS:
71− void activateScopeRequested(const QString& scope_id);
72− void loadedChanged(bool loaded);
73− void scopeRemoved(const QString& scope_id, int index);
74−
75−private Q_SLOTS:
76− void onScopesLoaded();
77− void onScopeAdded(const unity::dash::Scope::Ptr& scope, int position);
78− void onScopeRemoved(const unity::dash::Scope::Ptr& scope);
79− void onScopesReordered(const unity::dash::Scopes::ScopeList& scopes);
80− void onScopePropertyChanged();
81−
82−private:
83− unity::dash::GSettingsScopesReader::Ptr m_scopesReader;
84− unity::dash::Scopes::Ptr m_unityScopes;
85− QList<Scope*> m_scopes;
86− QHash<int, QByteArray> m_roles;
87− bool m_loaded;
88−
89− void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
90− void removeUnityScope(int index);
91− int findScopeById(const QString& scope_id);
92−};
93−
94−#endif // SCOPES_H
plugins/Unity/showallfilteroption.cppdeleted−60
@@ -1,60 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// self
21−#include "showallfilteroption.h"
22−
23−#include <libintl.h>
24−
25−unsigned int ShowAllFilterOption::m_showAllCount = 0;
26−
27−ShowAllFilterOption::ShowAllFilterOption(QObject *parent) :
28− AbstractFilterOption(parent),
29− m_active(false)
30−{
31− m_id = QString("show_all::%1").arg(m_showAllCount++);
32−}
33−
34−QString ShowAllFilterOption::id() const
35−{
36− return m_id;
37−}
38−
39−QString ShowAllFilterOption::name() const
40−{
41− return QString::fromUtf8(dgettext("unity", "All"));
42−}
43−
44−QString ShowAllFilterOption::iconHint() const
45−{
46− return QString::Null();
47−}
48−
49−bool ShowAllFilterOption::active() const
50−{
51− return m_active;
52−}
53−
54−void ShowAllFilterOption::setActive(bool active)
55−{
56− if (active != m_active) {
57− m_active = active;
58− Q_EMIT activeChanged(m_active);
59− }
60−}
plugins/Unity/showallfilteroption.hdeleted−51
@@ -1,51 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef SHOWALLFILTEROPTION_H
21−#define SHOWALLFILTEROPTION_H
22−
23−// local
24−#include "abstractfilteroption.h"
25−
26−class Q_DECL_EXPORT ShowAllFilterOption : public AbstractFilterOption
27−{
28− Q_OBJECT
29−
30−public:
31− explicit ShowAllFilterOption(QObject *parent = nullptr);
32−
33− /* getters */
34− QString id() const override;
35− QString name() const override;
36− QString iconHint() const override;
37− bool active() const override;
38−
39− /* setters */
40− void setActive(bool active) override;
41−
42−private:
43− bool m_active;
44− QString m_id;
45−
46− static unsigned int m_showAllCount;
47−};
48−
49−Q_DECLARE_METATYPE(ShowAllFilterOption*)
50−
51−#endif // SHOWALLFILTEROPTION_H
plugins/Unity/signalslist.cppdeleted−39
@@ -1,39 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "signalslist.h"
21−
22−void SignalsList::append(const sigc::connection &c)
23−{
24− m_signals.append(c);
25−}
26−
27−void SignalsList::disconnectAll()
28−{
29− Q_FOREACH(auto sig, m_signals) {
30− sig.disconnect();
31− }
32− m_signals.clear();
33−}
34−
35−SignalsList& SignalsList::operator<<(const sigc::connection &c)
36−{
37− append(c);
38− return *this;
39−}
plugins/Unity/signalslist.hdeleted−38
@@ -1,38 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef SIGNALSLIST_H
21−#define SIGNALSLIST_H
22−
23−#include <QList>
24−#include <sigc++/sigc++.h>
25−
26−class Q_DECL_EXPORT SignalsList
27−{
28−public:
29− void append(const sigc::connection &c);
30− void disconnectAll();
31−
32− SignalsList& operator<<(const sigc::connection &c);
33−
34−private:
35− QList<sigc::connection> m_signals;
36−};
37−
38−#endif // SIGNALSLIST_H
plugins/Unity/socialpreview.cppdeleted−87
@@ -1,87 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "socialpreview.h"
21−#include "socialpreviewcomment.h"
22−#include "iconutils.h"
23−
24−#include <QDebug>
25−
26−SocialPreview::SocialPreview(QObject *parent):
27− Preview(parent),
28− m_unitySocialPreview(nullptr)
29−{
30−}
31−
32−QString SocialPreview::sender() const
33−{
34− if (m_unitySocialPreview) {
35− return QString::fromStdString(m_unitySocialPreview->sender());
36− } else {
37− qWarning() << "Preview not set";
38− }
39− return QString();
40−}
41−
42−QString SocialPreview::content() const
43−{
44− if (m_unitySocialPreview) {
45− return QString::fromStdString(m_unitySocialPreview->content());
46− } else {
47− qWarning() << "Preview not set";
48− }
49− return QString();
50−}
51−
52−QString SocialPreview::avatar() const
53−{
54− if (m_unitySocialPreview) {
55− auto giconString = g_icon_to_string(m_unitySocialPreview->avatar());
56− QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
57− g_free(giconString);
58− return result;
59− } else {
60− qWarning() << "Preview not set";
61− }
62− return QString();
63−}
64−
65−QVariant SocialPreview::comments()
66−{
67− return QVariant::fromValue(m_comments);
68−}
69−
70−void SocialPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
71−{
72− m_unitySocialPreview = std::dynamic_pointer_cast<unity::dash::SocialPreview>(unityPreview);
73− qDeleteAll(m_comments);
74− m_comments.clear();
75−
76− if (m_unitySocialPreview) {
77− for (auto unityComment: m_unitySocialPreview->GetComments()) {
78− auto comment = new SocialPreviewComment(this);
79− comment->setUnityComment(unityComment);
80− m_comments.append(comment);
81−
82− Q_EMIT previewChanged();
83− }
84− } else {
85− qWarning() << "Incorrect preview type";
86− }
87−}
plugins/Unity/socialpreview.hdeleted−63
@@ -1,63 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef SOCIALPREVIEW_H
21−#define SOCIALPREVIEW_H
22−
23−// local
24−#include "preview.h"
25−
26−// Qt
27−#include <QObject>
28−#include <QList>
29−#include <QMetaType>
30−
31−// libunity-core
32−#include <UnityCore/SocialPreview.h>
33−
34−class Q_DECL_EXPORT SocialPreview: public Preview
35−{
36− Q_OBJECT
37−
38− Q_PROPERTY(QString sender READ sender NOTIFY previewChanged)
39− Q_PROPERTY(QString content READ content NOTIFY previewChanged)
40− Q_PROPERTY(QString avatar READ avatar NOTIFY previewChanged)
41−
42−public:
43− explicit SocialPreview(QObject *parent = 0);
44−
45− QString sender() const;
46− QString content() const;
47− QString avatar() const;
48− QVariant comments();
49−
50−Q_SIGNALS:
51− void previewChanged();
52−
53−protected:
54− void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
55−
56−private:
57− unity::dash::SocialPreview::Ptr m_unitySocialPreview;
58− QList<QObject *> m_comments;
59−};
60−
61−Q_DECLARE_METATYPE(SocialPreview *)
62−
63−#endif
plugins/Unity/socialpreviewcomment.cppdeleted−63
@@ -1,63 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// local
21−#include "socialpreviewcomment.h"
22−
23−SocialPreviewComment::SocialPreviewComment(QObject *parent) :
24− QObject(parent)
25−{
26−}
27−
28−void SocialPreviewComment::setUnityComment(unity::dash::SocialPreview::CommentPtr unityComment)
29−{
30− m_unityComment = unityComment;
31−}
32−
33−QString SocialPreviewComment::id() const
34−{
35− if (m_unityComment) {
36− return QString::fromStdString(m_unityComment->id);
37− }
38− return QString();
39−}
40−
41−QString SocialPreviewComment::displayName() const
42−{
43− if (m_unityComment) {
44− return QString::fromStdString(m_unityComment->display_name);
45− }
46− return QString();
47−}
48−
49−QString SocialPreviewComment::content() const
50−{
51− if (m_unityComment) {
52− return QString::fromStdString(m_unityComment->content);
53− }
54− return QString();
55−}
56−
57−QString SocialPreviewComment::time() const
58−{
59− if (m_unityComment) {
60− return QString::fromStdString(m_unityComment->time);
61− }
62− return QString();
63−}
plugins/Unity/socialpreviewcomment.hdeleted−57
@@ -1,57 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef SOCIALPREVIEWCOMMENT_H
21−#define SOCIALPREVIEWCOMMENT_H
22−
23−// Qt
24−#include <QObject>
25−#include <QMetaType>
26−
27−// libunity-core
28−#include <UnityCore/SocialPreview.h>
29−
30−class Q_DECL_EXPORT SocialPreviewComment : public QObject
31−{
32− Q_OBJECT
33−
34− Q_PROPERTY(QString id READ id NOTIFY socialPreviewCommentChanged)
35− Q_PROPERTY(QString displayName READ displayName NOTIFY socialPreviewCommentChanged)
36− Q_PROPERTY(QString content READ content NOTIFY socialPreviewCommentChanged)
37− Q_PROPERTY(QString time READ time NOTIFY socialPreviewCommentChanged)
38−
39−public:
40− explicit SocialPreviewComment(QObject *parent = 0);
41− void setUnityComment(unity::dash::SocialPreview::CommentPtr unityComment);
42−
43− QString id() const;
44− QString displayName() const;
45− QString content() const;
46− QString time() const;
47−
48−Q_SIGNALS:
49− void socialPreviewCommentChanged();
50−
51−private:
52− unity::dash::SocialPreview::CommentPtr m_unityComment;
53−};
54−
55−Q_DECLARE_METATYPE(SocialPreviewComment *)
56−
57−#endif
plugins/Unity/unityoptionsmodel.cppdeleted−68
@@ -1,68 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// self
21−#include "unityoptionsmodel.h"
22−
23−// local
24−#include "filteroption.h"
25−
26−UnityOptionsModel::UnityOptionsModel(QObject *parent,
27− const std::vector<unity::dash::FilterOption::Ptr> options,
28− sigc::signal<void, unity::dash::FilterOption::Ptr> optionAdded,
29− sigc::signal<void, unity::dash::FilterOption::Ptr> optionRemoved,
30− bool showAllOption) :
31− GenericOptionsModel(showAllOption, parent)
32−{
33− setOptions(options, optionAdded, optionRemoved);
34−}
35−
36−void UnityOptionsModel::setOptions(const std::vector<unity::dash::FilterOption::Ptr> options,
37− sigc::signal<void, unity::dash::FilterOption::Ptr> optionAdded,
38− sigc::signal<void, unity::dash::FilterOption::Ptr> optionRemoved)
39−{
40− for (unsigned int i=0; i<options.size(); i++)
41− {
42− addOption(new FilterOption(options[i], this));
43− }
44− optionAdded.connect(sigc::mem_fun(this, &UnityOptionsModel::onOptionAdded));
45− optionRemoved.connect(sigc::mem_fun(this, &UnityOptionsModel::onOptionRemoved));
46−}
47−
48−void UnityOptionsModel::onOptionAdded(unity::dash::FilterOption::Ptr option)
49−{
50− int index = m_options.count();
51− if (index >= 0)
52− {
53− beginInsertRows(QModelIndex(), index, index);
54− addOption(new FilterOption(option, this));
55− endInsertRows();
56− }
57−}
58−
59−void UnityOptionsModel::onOptionRemoved(unity::dash::FilterOption::Ptr option)
60−{
61− auto index = indexOf(QString::fromStdString(option->id));
62− if (index >= 0)
63− {
64− beginRemoveRows(QModelIndex(), index, index);
65− removeOption(index);
66− endRemoveRows();
67− }
68−}
plugins/Unity/unityoptionsmodel.hdeleted−50
@@ -1,50 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef UNITYOPTIONSMODEL_H
21−#define UNITYOPTIONSMODEL_H
22−
23−#include "genericoptionsmodel.h"
24−
25−// libunity-core
26−#include <UnityCore/Filter.h>
27−
28−#include <sigc++/signal.h>
29−
30−class UnityOptionsModel : public GenericOptionsModel
31−{
32− Q_OBJECT
33−
34−public:
35− UnityOptionsModel(QObject *parent,
36− const std::vector<unity::dash::FilterOption::Ptr> options,
37− sigc::signal<void, unity::dash::FilterOption::Ptr> optionAdded,
38− sigc::signal<void, unity::dash::FilterOption::Ptr> optionRemoved,
39− bool showAllOption);
40−
41−private:
42− void setOptions(const std::vector<unity::dash::FilterOption::Ptr> options,
43− sigc::signal<void, unity::dash::FilterOption::Ptr> optionAdded,
44− sigc::signal<void, unity::dash::FilterOption::Ptr> optionRemoved);
45−
46− void onOptionAdded(unity::dash::FilterOption::Ptr option);
47− void onOptionRemoved(unity::dash::FilterOption::Ptr option);
48−};
49−
50−#endif // UNITYOPTIONSMODEL_H
plugins/Unity/variantutils.cppdeleted−82
@@ -1,82 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include <QUrl>
21−#include <QUrlQuery>
22−#include <QStringList>
23−
24−#include <deelistmodel.h>
25−#include "variantutils.h"
26−
27−unity::glib::HintsMap convertToHintsMap(const QHash<QString, QVariant> &val)
28−{
29− unity::glib::HintsMap hintsMap;
30− QHash<QString, QVariant>::const_iterator it = val.constBegin();
31− while (it != val.constEnd()) {
32− hintsMap[it.key().toStdString()] = DeeListModel::DataFromVariant(it.value());
33− ++it;
34− }
35− return hintsMap;
36−}
37−
38−unity::glib::HintsMap convertToHintsMap(const QVariant &var)
39−{
40− if (var.type() == QVariant::Hash) {
41− unity::glib::HintsMap hintsMap;
42− const auto hash = var.toHash();
43− return convertToHintsMap(hash);
44− }
45− return unity::glib::HintsMap();
46−}
47−
48−QVariantHash convertToQVariantHash(const unity::glib::HintsMap& var)
49−{
50− QVariantHash hash;
51− for (auto hint: var) {
52− hash.insert(QString::fromStdString(hint.first), DeeListModel::VariantForData(hint.second));
53− }
54− return hash;
55−}
56−
57−/* This will translate uris in the form of:
58− * "subscope:master.scope/sub.scope?foo=bar"
59− * into a QVariantHash that can be passed as a metadata field to scope.
60− */
61−QVariantHash subscopeUriToMetadataHash(const QString &metadata_string)
62−{
63− QUrl metadata_url(metadata_string);
64− if (metadata_url.scheme() == QLatin1String("subscope")) {
65− QString subscope_uri(metadata_url.toString(QUrl::RemoveScheme | QUrl::RemoveQuery));
66− QVariantHash new_metadata;
67− QUrlQuery query(metadata_url.query());
68− QList<QPair<QString,QString>> queryItems(query.queryItems());
69− for (auto it = queryItems.begin(); it != queryItems.end(); ++it) {
70− new_metadata[it->first] = QVariant::fromValue(it->second);
71− }
72− QStringList parts(subscope_uri.split(QChar('/')));
73− for (int i = parts.size() - 1; i >= 0; i--) {
74− QVariantHash inner;
75− inner["scope-id"] = QVariant::fromValue(parts[i]);
76− inner["content"] = QVariant::fromValue(new_metadata);
77− new_metadata = inner;
78− }
79− return new_metadata;
80− }
81− return QVariantHash();
82−}
plugins/Unity/variantutils.hdeleted−35
@@ -1,35 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef VARIANTUTILS_H
21−#define VARIANTUTILS_H
22−
23−#include <glib.h>
24−#include <QVariant>
25−
26−// libunity-core
27−#include <UnityCore/Variant.h>
28−
29−unity::glib::HintsMap convertToHintsMap(const QHash<QString, QVariant> &val);
30−unity::glib::HintsMap convertToHintsMap(const QVariant &var);
31−QVariantHash convertToQVariantHash(const unity::glib::HintsMap &var);
32−/* used in tests, so we have to export it */
33−Q_DECL_EXPORT QVariantHash subscopeUriToMetadataHash(const QString &metadata_string);
34−
35−#endif
po/ml.ponew file+240
@@ -0,0 +1,240 @@
1+# Malayalam translation for unity8
2+# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013
3+# This file is distributed under the same license as the unity8 package.
4+# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
5+#
6+msgid ""
7+msgstr ""
8+"Project-Id-Version: unity8\n"
9+"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10+"POT-Creation-Date: 2013-11-12 16:10+0100\n"
11+"PO-Revision-Date: 2013-11-23 11:44+0000\n"
12+"Last-Translator: STyM Alfazz <Unknown>\n"
13+"Language-Team: Malayalam <ml@li.org>\n"
14+"MIME-Version: 1.0\n"
15+"Content-Type: text/plain; charset=UTF-8\n"
16+"Content-Transfer-Encoding: 8bit\n"
17+"Plural-Forms: nplurals=2; plural=n != 1;\n"
18+"X-Launchpad-Export-Date: 2013-11-24 05:50+0000\n"
19+"X-Generator: Launchpad (build 16831)\n"
20+
21+#: Applications/applications.js:23
22+msgid "Phone"
23+msgstr "ഫോണ്‍"
24+
25+#: Applications/applications.js:29
26+msgid "Camera"
27+msgstr "ക്യാമറ"
28+
29+#: Applications/applications.js:35
30+msgid "Gallery"
31+msgstr "ഗ്യാലറി"
32+
33+#: Applications/applications.js:40
34+msgid "Facebook"
35+msgstr "ഫേസ്ബുക്ക്"
36+
37+#: Applications/applications.js:46
38+msgid "Browser"
39+msgstr "ബ്രൗസര്‍"
40+
41+#: Applications/applications.js:51
42+msgid "Twitter"
43+msgstr "ട്വിറ്റര്‍"
44+
45+#: Applications/applications.js:57
46+msgid "GMail"
47+msgstr "ജിമെയില്‍"
48+
49+#: Applications/applications.js:62
50+msgid "Weather"
51+msgstr "കാലാവസ്ഥ"
52+
53+#: Applications/applications.js:68
54+msgid "Notepad"
55+msgstr "നോട്പാഡ്"
56+
57+#: Applications/applications.js:74
58+msgid "Calendar"
59+msgstr "കലണ്ടര്‍"
60+
61+#: Applications/applications.js:80
62+msgid "Media Player"
63+msgstr "മീഡിയ പ്ലെയര്‍"
64+
65+#: Applications/applications.js:86
66+msgid "Evernote"
67+msgstr "എവര്‍നോട്ട്"
68+
69+#: Applications/applications.js:91
70+msgid "Map"
71+msgstr "ഭുപടം"
72+
73+#: Applications/applications.js:96
74+msgid "Pinterest"
75+msgstr "പിന്‍ട്രസ്റ്റ്"
76+
77+#: Applications/applications.js:101
78+msgid "SoundCloud"
79+msgstr "സൗണ്ട്ക്ലൗഡ്"
80+
81+#: Applications/applications.js:106
82+msgid "Wikipedia"
83+msgstr "വിക്കിപീഡിയ"
84+
85+#: Applications/applications.js:111
86+msgid "YouTube"
87+msgstr "യുട്യൂബ്"
88+
89+#: Components/EdgeDemoOverlay.qml:151
90+msgid "Skip intro"
91+msgstr "ആമുഖം ഒഴിവാക്കുക"
92+
93+#: Components/EdgeDemo.qml:112
94+msgid "Right edge"
95+msgstr "വലത് മൂല"
96+
97+#: Components/EdgeDemo.qml:113
98+msgid "Try swiping from the right edge to unlock the phone"
99+msgstr "ഫോണ്‍ അണ്‍ലോക്ക് ചെയ്യാന്‍ വലതു വശത്തുനിന്ന് സ്വൈപ് ചെയ്ത് നോക്കുക"
100+
101+#: Components/EdgeDemo.qml:144
102+msgid "Top edge"
103+msgstr "മുകള്‍ വശം"
104+
105+#: Components/EdgeDemo.qml:145
106+msgid "Try swiping from the top edge to access the indicators"
107+msgstr "സൂചകങ്ങള്‍ ലഭ്യമാക്കാന്‍ മുകള്‍ വശത്തുനിന്നും സ്വൈപ് ചെയ്യുക"
108+
109+#: Components/EdgeDemo.qml:170
110+msgid "Close"
111+msgstr "അടക്കുക"
112+
113+#: Components/EdgeDemo.qml:171
114+msgid "Swipe up again to close the settings screen"
115+msgstr "ക്രമീകരണങ്ങളുടെ സ്ക്രീന്‍ അടക്കാന്‍ മുകളിലേക്ക് സ്വൈപ് ചെയ്യുക"
116+
117+#: Components/EdgeDemo.qml:198
118+msgid "Left edge"
119+msgstr "ഇടത് വശം"
120+
121+#: Components/EdgeDemo.qml:199
122+msgid "Swipe from the left to reveal the launcher for quick access to apps"
123+msgstr ""
124+"പ്രയോഗങ്ങള്‍ പെട്ടെന്ന് ലഭ്യമാക്കുന്ന വിക്ഷേപിക ലഭ്യമാക്കാന്‍ ഇടതു വശത്ത് "
125+"നിന്നും സ്വൈപ് ചെയ്യുക"
126+
127+#: Components/EdgeDemo.qml:226
128+msgid "Well done"
129+msgstr "നന്നായി ചെയ്തിരിക്കുന്നു"
130+
131+#: Components/EdgeDemo.qml:227
132+msgid ""
133+"You have now mastered the edge gestures and can start using the "
134+"phone<br><br>Tap anywhere to start"
135+msgstr ""
136+"നിങ്ങളിപ്പോള്‍ സ്വൈപുകളും മറ്റും പഠിച്ചിരിക്കുന്നു<br><br>തുടങ്ങാന്‍ "
137+"എവിടെയെങ്കിലും ടാപ് ചെയ്യുക"
138+
139+#: Components/PageHeader.qml:345
140+msgid "Recent searches"
141+msgstr "സമീപകാല തിരയലുകള്‍"
142+
143+#. TRANSLATORS: Number of persons who rated this app
144+#. TRANSLATORS: Number of persons who rated this app/video/whatever
145+#: Dash/Apps/AppInfo.qml:73 Dash/Previews/Header.qml:93
146+#, qt-format
147+msgid "(%1)"
148+msgstr "(%1)"
149+
150+#. TRANSLATORS: Number of persons who wrote reviews for this app
151+#. TRANSLATORS: Number of persons who wrote reviews for this app/video/whatever
152+#: Dash/Apps/AppInfo.qml:85 Dash/Previews/Header.qml:105
153+#, qt-format
154+msgid "%1 review"
155+msgid_plural "%1 reviews"
156+msgstr[0] "%1 അവലോകനം"
157+msgstr[1] "%1 അവലോകനങ്ങള്‍"
158+
159+#: Dash/Apps/AppPreview.qml:135
160+msgid "Rate this"
161+msgstr "ഇത് അവലോകനം ചെയ്യുക"
162+
163+#: Dash/Previews/Reviews.qml:74
164+msgid "Add a review"
165+msgstr "ഒരു അവലോകനം ചേര്‍ക്കുക"
166+
167+#: Dash/Previews/Reviews.qml:86
168+msgid "Review"
169+msgstr "അവലോകനം"
170+
171+#: Dash/Previews/Reviews.qml:121
172+msgid "Send"
173+msgstr "അയയ്‌ക്കുക"
174+
175+#: Dash/Previews/Reviews.qml:139
176+msgid "Comments:"
177+msgstr "അഭിപ്രായങ്ങള്‍:"
178+
179+#: Greeter/Lockscreen.qml:146
180+msgid "Emergency Call"
181+msgstr "അടിയന്തിര വിളി"
182+
183+#: Greeter/PassphraseLockscreen.qml:59
184+#, qt-format
185+msgid "Hello %1"
186+msgstr "ഹലോ %1"
187+
188+#: Greeter/PassphraseLockscreen.qml:59
189+msgid "Hello"
190+msgstr "ഹലോ"
191+
192+#: Hud/HudParametrizedActionsPage.qml:132
193+msgid "Confirm"
194+msgstr "സ്ഥിരീകരിക്കുക"
195+
196+#: Hud/Hud.qml:61 Hud/Hud.qml:99 Hud/Hud.qml:372
197+msgid "Type or say a command"
198+msgstr "ഒരു ആജ്ഞ പറയുകയോ ടൈപ്പുകയോ ചെയ്യുക"
199+
200+#: Hud/Hud.qml:84
201+msgid "Loading. Please Wait..."
202+msgstr "വരുന്നു. ദയവായി കാത്തിരിക്കുക..."
203+
204+#: Hud/Hud.qml:89
205+msgid "Speak Now..."
206+msgstr "ഇപ്പോള്‍ സംസാരിക്കുക..."
207+
208+#: Hud/Hud.qml:94
209+msgid "Speaking..."
210+msgstr "സംസാരിക്കുന്നു..."
211+
212+#: Notifications/NotificationMenuItemFactory.qml:89
213+msgid "Show password"
214+msgstr "രഹസ്യവാക്ക് കാണിക്കുക"
215+
216+#: Panel/SearchIndicator.qml:27
217+msgid "Search"
218+msgstr "തിരയുക"
219+
220+#: plugins/Unity/Launcher/launcheritem.cpp:43
221+#: plugins/Unity/Launcher/launcheritem.cpp:73
222+msgid "Lock to Launcher"
223+msgstr "വിക്ഷേപികയില്‍ സ്ഥിരപ്പെടുത്തുക"
224+
225+#: plugins/Unity/Launcher/launcheritem.cpp:73
226+msgid "Unlock from Launcher"
227+msgstr "വിക്ഷേപികാ സ്ഥിരപ്പെടുത്തല്‍ ഒഴിവാക്കുക"
228+
229+#: plugins/Unity/scope.cpp:408
230+msgid "Sorry, there is nothing that matches your search."
231+msgstr "ക്ഷമിക്കണം, താങ്കളുടെ തിരച്ചിലുമായി ഒത്തുപോകുന്ന ഒന്നും തന്നെയില്ല"
232+
233+#: plugins/Unity/showallfilteroption.cpp:41
234+msgid "All"
235+msgstr "എല്ലാം"
236+
237+#: Shell.qml:441
238+#, qt-format
239+msgid "Please enter %1"
240+msgstr "ദയവായി %1 നല്‍കുക"
po/uk.po+6−6
@@ -8,15 +8,15 @@ msgstr ""
8"Project-Id-Version: unity\n"
8"Project-Id-Version: unity\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2013-11-12 16:10+0100\n"
10"POT-Creation-Date: 2013-11-12 16:10+0100\n"
11−"PO-Revision-Date: 2013-10-19 16:44+0000\n"
11+"PO-Revision-Date: 2013-11-23 12:37+0000\n"
12−"Last-Translator: Yuri Chornoivan <yurchor@gmail.com>\n"
12+"Last-Translator: Ignat Kizenko <Unknown>\n"
13"Language-Team: Ukrainian <uk@li.org>\n"
13"Language-Team: Ukrainian <uk@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
17"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
18"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
18"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
19−"X-Launchpad-Export-Date: 2013-11-19 05:59+0000\n"
19+"X-Launchpad-Export-Date: 2013-11-24 05:50+0000\n"
20"X-Generator: Launchpad (build 16831)\n"
20"X-Generator: Launchpad (build 16831)\n"
21
21
22#: Applications/applications.js:23
22#: Applications/applications.js:23
@@ -214,7 +214,7 @@ msgstr "Мовлення…"
214
214
215#: Notifications/NotificationMenuItemFactory.qml:89
215#: Notifications/NotificationMenuItemFactory.qml:89
216msgid "Show password"
216msgid "Show password"
217−msgstr ""
217+msgstr "Показати пароль"
218
218
219#: Panel/SearchIndicator.qml:27
219#: Panel/SearchIndicator.qml:27
220msgid "Search"
220msgid "Search"
@@ -223,11 +223,11 @@ msgstr "Пошук"
223#: plugins/Unity/Launcher/launcheritem.cpp:43
223#: plugins/Unity/Launcher/launcheritem.cpp:43
224#: plugins/Unity/Launcher/launcheritem.cpp:73
224#: plugins/Unity/Launcher/launcheritem.cpp:73
225msgid "Lock to Launcher"
225msgid "Lock to Launcher"
226−msgstr ""
226+msgstr "Зафіксувати на панелі запуску"
227
227
228#: plugins/Unity/Launcher/launcheritem.cpp:73
228#: plugins/Unity/Launcher/launcheritem.cpp:73
229msgid "Unlock from Launcher"
229msgid "Unlock from Launcher"
230−msgstr ""
230+msgstr "Від’єднати від панелі запуску"
231
231
232#: plugins/Unity/scope.cpp:408
232#: plugins/Unity/scope.cpp:408
233msgid "Sorry, there is nothing that matches your search."
233msgid "Sorry, there is nothing that matches your search."
run+2
@@ -42,6 +42,8 @@ done
42if $FAKE; then
42if $FAKE; then
43 export QML2_IMPORT_PATH=$PWD/builddir/tests/mocks:$PWD/builddir/plugins:$PWD/builddir/modules
43 export QML2_IMPORT_PATH=$PWD/builddir/tests/mocks:$PWD/builddir/plugins:$PWD/builddir/modules
44 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/libusermetrics:$PWD/builddir/tests/mocks/LightDM/single
44 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/libusermetrics:$PWD/builddir/tests/mocks/LightDM/single
45+else
46+ export QML2_IMPORT_PATH=`pkg-config --variable=plugindir unity-shell-api`
45fi
47fi
46
48
47if $PINLOCK; then
49if $PINLOCK; then
run_on_device+1−1
@@ -76,7 +76,7 @@ setup_adb_forwarding() {
76
76
77install_dependencies() {
77install_dependencies() {
78 exec_with_adb apt-get update
78 exec_with_adb apt-get update
79− exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs
79+ exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs unity-plugin-scopes
80}
80}
81
81
82sync_code() {
82sync_code() {
tests/autopilot/unity8/process_helpers.py+1−1
@@ -67,7 +67,7 @@ def unlock_unity(unity_proxy_obj=None):
67 main_window = MainWindow(unity_proxy_obj)
67 main_window = MainWindow(unity_proxy_obj)
68
68
69 greeter = main_window.get_greeter()
69 greeter = main_window.get_greeter()
70− if greeter is None:
70+ if greeter.created == False:
71 raise RuntimeWarning("Greeter appears to be already unlocked.")
71 raise RuntimeWarning("Greeter appears to be already unlocked.")
72 greeter.swipe()
72 greeter.swipe()
73
73
tests/mocks/Unity/CMakeLists.txt+2−3
@@ -6,7 +6,6 @@ pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
6pkg_search_module(DEEQT libdee-qt5 REQUIRED)
6pkg_search_module(DEEQT libdee-qt5 REQUIRED)
7
7
8include_directories(
8include_directories(
9− ${CMAKE_SOURCE_DIR}/plugins/Unity
10 ${CMAKE_CURRENT_BINARY_DIR}
9 ${CMAKE_CURRENT_BINARY_DIR}
11 ${Qt5Core_INCLUDE_DIRS}
10 ${Qt5Core_INCLUDE_DIRS}
12 ${Qt5Quick_INCLUDE_DIRS}
11 ${Qt5Quick_INCLUDE_DIRS}
@@ -17,8 +16,8 @@ include_directories(
17add_definitions(-DQT_NO_KEYWORDS)
16add_definitions(-DQT_NO_KEYWORDS)
18
17
19set(UnityQML_SOURCES
18set(UnityQML_SOURCES
20− ${CMAKE_SOURCE_DIR}/plugins/Unity/categoryresults.cpp
19+ categoryresults.cpp
21− ${CMAKE_SOURCE_DIR}/plugins/Unity/iconutils.cpp
20+ iconutils.cpp
22 fake_applications_scope.cpp
21 fake_applications_scope.cpp
23 fake_preview.cpp
22 fake_preview.cpp
24 fake_scope.cpp
23 fake_scope.cpp
plugins/Unity/categoryresults.cpp → tests/mocks/Unity/categoryresults.cpprenamed

The content is the same.

plugins/Unity/categoryresults.h → tests/mocks/Unity/categoryresults.hrenamed

The content is the same.

plugins/Unity/iconutils.cpp → tests/mocks/Unity/iconutils.cpprenamed

The content is the same.

plugins/Unity/iconutils.h → tests/mocks/Unity/iconutils.hrenamed

The content is the same.

tests/plugins/Ubuntu/Gestures/CMakeLists.txt+20−18
@@ -1,33 +1,34 @@
1−########## tst_DirectionalDragArea
1+include(QmlTest)
2
2
3include_directories(
3include_directories(
4 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
4 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
5 ${CMAKE_CURRENT_BINARY_DIR}
5 ${CMAKE_CURRENT_BINARY_DIR}
6 )
6 )
7
7
8−set(testCommand
9− LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
10− ${CMAKE_CURRENT_BINARY_DIR}/DirectionalDragAreaTestExec
11− -o ${CMAKE_BINARY_DIR}/DirectionalDragAreaTest.xml,xunitxml
12− -o -,txt)
13−
14−add_custom_target(testDirectionalDragArea ${testCommand})
15−add_dependencies(qmluitests testDirectionalDragArea)
16−add_dependencies(testDirectionalDragArea DirectionalDragAreaTestExec UbutunGesturesTestQmlFiles)
17−
18−add_executable(DirectionalDragAreaTestExec tst_DirectionalDragArea.cpp)
19−qt5_use_modules(DirectionalDragAreaTestExec Test Core Qml Gui Quick)
20−target_link_libraries(DirectionalDragAreaTestExec UbuntuGestureQml)
21−
22−add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
23−
24file(GLOB qmlFiles *.qml)
8file(GLOB qmlFiles *.qml)
25add_custom_target(UbuntuGesturesTestQmlFiles ALL
9add_custom_target(UbuntuGesturesTestQmlFiles ALL
26 COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
10 COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
27 DEPENDS ${qmlFiles}
11 DEPENDS ${qmlFiles}
28)
12)
29
13
30−########## other tests
14+add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
15+
16+macro(add_gesture_ui_test CLASSNAME)
17+ set(testCommand
18+ LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
19+ ${CMAKE_CURRENT_BINARY_DIR}/${CLASSNAME}TestExec
20+ -o ${CMAKE_BINARY_DIR}/${CLASSNAME}Test.xml,xunitxml
21+ -o -,txt)
22+
23+ add_custom_target(test${CLASSNAME} ${testCommand})
24+ add_dependencies(qmluitests test${CLASSNAME})
25+ add_dependencies(test${CLASSNAME} ${CLASSNAME}TestExec UbuntuGesturesTestQmlFiles)
26+
27+ add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp)
28+ qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
29+ target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
30+ add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
31+endmacro(add_gesture_ui_test)
31
32
32macro(add_gesture_test CLASSNAME)
33macro(add_gesture_test CLASSNAME)
33 set(testCommand
34 set(testCommand
@@ -43,5 +44,6 @@ macro(add_gesture_test CLASSNAME)
43 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
44 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
44endmacro(add_gesture_test)
45endmacro(add_gesture_test)
45
46
47+add_gesture_ui_test(DirectionalDragArea)
46add_gesture_test(Damper)
48add_gesture_test(Damper)
47add_gesture_test(AxisVelocityCalculator)
49add_gesture_test(AxisVelocityCalculator)
tests/plugins/Ubuntu/Gestures/GestureTest.cppnew file+54
@@ -0,0 +1,54 @@
1+/*
2+ * Copyright (C) 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 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+#include "GestureTest.h"
18+
19+#include <qpa/qwindowsysteminterface.h>
20+#include <QQmlEngine>
21+#include <QQuickView>
22+#include <QtTest>
23+
24+GestureTest::GestureTest(const QString &qmlFilename)
25+ : QObject(), m_device(nullptr), m_view(nullptr), m_qmlFilename(qmlFilename)
26+{
27+}
28+
29+void GestureTest::initTestCase()
30+{
31+ if (!m_device) {
32+ m_device = new QTouchDevice;
33+ m_device->setType(QTouchDevice::TouchScreen);
34+ QWindowSystemInterface::registerTouchDevice(m_device);
35+ }
36+}
37+
38+void GestureTest::init()
39+{
40+ m_view = new QQuickView;
41+ m_view->setResizeMode(QQuickView::SizeViewToRootObject);
42+ m_view->engine()->addImportPath(QStringLiteral(UBUNTU_GESTURES_PLUGIN_DIR));
43+ m_view->setSource(QUrl::fromLocalFile(m_qmlFilename));
44+ m_view->show();
45+ QVERIFY(QTest::qWaitForWindowExposed(m_view));
46+ QVERIFY(m_view->rootObject() != 0);
47+ qApp->processEvents();
48+}
49+
50+void GestureTest::cleanup()
51+{
52+ delete m_view;
53+ m_view = nullptr;
54+}
plugins/Unity/genericpreview.h → tests/plugins/Ubuntu/Gestures/GestureTest.hrenamed+19−19
@@ -1,9 +1,6 @@
1/*
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
3 *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
6 * the Free Software Foundation; version 3.
@@ -17,30 +14,33 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
15 */
19
16
20−#ifndef GENERICPREVIEW_H
17+#ifndef GESTURETEST_H
21−#define GENERICPREVIEW_H
18+#endif // GESTURETEST_H
22−
23−// local
24−#include "preview.h"
25
19
26−// Qt
27#include <QObject>
20#include <QObject>
28−#include <QMetaType>
29
21
30−class GenericPreview : public Preview
22+class QQuickView;
23+class QTouchDevice;
24+
25+/*
26+ The common stuff among tests come here
27+ */
28+class GestureTest : public QObject
31{
29{
32 Q_OBJECT
30 Q_OBJECT
33−
34public:
31public:
35− explicit GenericPreview(QObject *parent = 0);
32+ // \param qmlFilename name of the qml file to be loaded by the QQuickView
33+ GestureTest(const QString &qmlFilename);
36
34
37−Q_SIGNALS:
35+protected Q_SLOTS:
38− void previewChanged();
36+ void initTestCase(); // will be called before the first test function is executed
37+ virtual void init(); // called right before each and every test function is executed
38+ virtual void cleanup(); // called right after each and every test function is executed
39
39
40protected:
40protected:
41− void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
41+ QTouchDevice *m_device;
42+ QQuickView *m_view;
43+ QString m_qmlFilename;
42};
44};
43
45
44−Q_DECLARE_METATYPE(GenericPreview *)
46+#define GESTURETEST_H
45−
46−#endif
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+65−96
@@ -16,13 +16,14 @@
16
16
17#include <QtTest/QtTest>
17#include <QtTest/QtTest>
18#include <QtCore/QObject>
18#include <QtCore/QObject>
19−#include <qpa/qwindowsysteminterface.h>
20#include <QtQuick/QQuickView>
19#include <QtQuick/QQuickView>
21#include <QtQml/QQmlEngine>
20#include <QtQml/QQmlEngine>
22#include <QPointer>
21#include <QPointer>
23
22
24#include <DirectionalDragArea.h>
23#include <DirectionalDragArea.h>
25
24
25+#include "GestureTest.h"
26+
26using namespace UbuntuGestures;
27using namespace UbuntuGestures;
27
28
28class FakeTimer : public AbstractTimer
29class FakeTimer : public AbstractTimer
@@ -61,15 +62,12 @@ public:
61 qint64 m_msecsSinceReference;
62 qint64 m_msecsSinceReference;
62};
63};
63
64
64−class tst_DirectionalDragArea: public QObject
65+class tst_DirectionalDragArea: public GestureTest
65{
66{
66 Q_OBJECT
67 Q_OBJECT
67public:
68public:
68− tst_DirectionalDragArea() : device(0) { }
69+ tst_DirectionalDragArea();
69private Q_SLOTS:
70private Q_SLOTS:
70− void initTestCase(); // will be called before the first test function is executed
71− void cleanupTestCase(); // will be called after the last test function was executed.
72−
73 void init(); // called right before each and every test function is executed
71 void init(); // called right before each and every test function is executed
74 void cleanup(); // called right after each and every test function is executed
72 void cleanup(); // called right after each and every test function is executed
75
73
@@ -87,37 +85,19 @@ private Q_SLOTS:
87 void ignoreOldFinger();
85 void ignoreOldFinger();
88
86
89private:
87private:
90− QQuickView *createView();
91 void passTime(qint64 timeSpan);
88 void passTime(qint64 timeSpan);
92− QQuickView *view;
93− QTouchDevice *device;
94 FakeTimer *fakeTimer;
89 FakeTimer *fakeTimer;
95 QSharedPointer<FakeTimeSource> fakeTimeSource;
90 QSharedPointer<FakeTimeSource> fakeTimeSource;
96};
91};
97
92
98−void tst_DirectionalDragArea::initTestCase()
93+tst_DirectionalDragArea::tst_DirectionalDragArea()
99−{
94+ : GestureTest(QStringLiteral("tst_DirectionalDragArea.qml"))
100− if (!device) {
101− device = new QTouchDevice;
102− device->setType(QTouchDevice::TouchScreen);
103− QWindowSystemInterface::registerTouchDevice(device);
104− }
105−
106− view = 0;
107−}
108−
109−void tst_DirectionalDragArea::cleanupTestCase()
110{
95{
111}
96}
112
97
113void tst_DirectionalDragArea::init()
98void tst_DirectionalDragArea::init()
114{
99{
115− view = createView();
100+ GestureTest::init();
116− view->setSource(QUrl::fromLocalFile("edgeDragExample.qml"));
117− view->show();
118− QVERIFY(QTest::qWaitForWindowExposed(view));
119− QVERIFY(view->rootObject() != 0);
120− qApp->processEvents();
121
101
122 fakeTimeSource.reset(new FakeTimeSource);
102 fakeTimeSource.reset(new FakeTimeSource);
123 fakeTimer = new FakeTimer(fakeTimeSource);
103 fakeTimer = new FakeTimer(fakeTimeSource);
@@ -125,23 +105,12 @@ void tst_DirectionalDragArea::init()
125
105
126void tst_DirectionalDragArea::cleanup()
106void tst_DirectionalDragArea::cleanup()
127{
107{
128− delete view;
129− view = 0;
130−
131 delete fakeTimer;
108 delete fakeTimer;
132 fakeTimer = 0;
109 fakeTimer = 0;
133
110
134 fakeTimeSource.reset();
111 fakeTimeSource.reset();
135−}
136−
137−QQuickView *tst_DirectionalDragArea::createView()
138−{
139− QQuickView *window = new QQuickView(0);
140− window->setResizeMode(QQuickView::SizeRootObjectToView);
141− window->resize(600, 600);
142− window->engine()->addImportPath(QLatin1String(UBUNTU_GESTURES_PLUGIN_DIR));
143
112
144− return window;
113+ GestureTest::cleanup();
145}
114}
146
115
147void tst_DirectionalDragArea::passTime(qint64 timeSpan)
116void tst_DirectionalDragArea::passTime(qint64 timeSpan)
@@ -217,14 +186,14 @@ void tst_DirectionalDragArea::edgeDrag()
217 QFETCH(bool, expectGestureRecognition);
186 QFETCH(bool, expectGestureRecognition);
218
187
219 DirectionalDragArea *edgeDragArea =
188 DirectionalDragArea *edgeDragArea =
220− view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
189+ m_view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
221 QVERIFY(edgeDragArea != 0);
190 QVERIFY(edgeDragArea != 0);
222 edgeDragArea->setRecognitionTimer(fakeTimer);
191 edgeDragArea->setRecognitionTimer(fakeTimer);
223 edgeDragArea->setTimeSource(fakeTimeSource);
192 edgeDragArea->setTimeSource(fakeTimeSource);
224
193
225 QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
194 QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
226
195
227− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
196+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
228 QPointF touchPoint = initialTouchPos;
197 QPointF touchPoint = initialTouchPos;
229
198
230 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*dragDistanceFactor;
199 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*dragDistanceFactor;
@@ -235,7 +204,7 @@ void tst_DirectionalDragArea::edgeDrag()
235 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
204 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
236 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
205 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
237
206
238− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
207+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
239
208
240 QCOMPARE(draggingSpy.count(), 1);
209 QCOMPARE(draggingSpy.count(), 1);
241 QCOMPARE(edgeDragArea->dragging(), true);
210 QCOMPARE(edgeDragArea->dragging(), true);
@@ -245,13 +214,13 @@ void tst_DirectionalDragArea::edgeDrag()
245 // in order to make it easier to leave it by dragging at an angle
214 // in order to make it easier to leave it by dragging at an angle
246 // slightly bigger than the widening angle
215 // slightly bigger than the widening angle
247 touchPoint += createTouchDeviation(edgeDragArea);
216 touchPoint += createTouchDeviation(edgeDragArea);
248− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
217+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
249 }
218 }
250
219
251 for (int i = 0; i < totalMovementSteps; ++i) {
220 for (int i = 0; i < totalMovementSteps; ++i) {
252 touchPoint += touchMovement;
221 touchPoint += touchMovement;
253 passTime(movementTimeStepMs);
222 passTime(movementTimeStepMs);
254− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
223+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
255 }
224 }
256
225
257 if (expectGestureRecognition)
226 if (expectGestureRecognition)
@@ -262,7 +231,7 @@ void tst_DirectionalDragArea::edgeDrag()
262 QCOMPARE(draggingSpy.count(), 2);
231 QCOMPARE(draggingSpy.count(), 2);
263 }
232 }
264
233
265− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
234+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
266
235
267 QCOMPARE(draggingSpy.count(), 2);
236 QCOMPARE(draggingSpy.count(), 2);
268 QCOMPARE(edgeDragArea->dragging(), false);
237 QCOMPARE(edgeDragArea->dragging(), false);
@@ -326,12 +295,12 @@ void tst_DirectionalDragArea::edgeDrag_data()
326void tst_DirectionalDragArea::dragWithShortDirectionChange()
295void tst_DirectionalDragArea::dragWithShortDirectionChange()
327{
296{
328 DirectionalDragArea *edgeDragArea =
297 DirectionalDragArea *edgeDragArea =
329− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
298+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
330 QVERIFY(edgeDragArea != 0);
299 QVERIFY(edgeDragArea != 0);
331 edgeDragArea->setRecognitionTimer(fakeTimer);
300 edgeDragArea->setRecognitionTimer(fakeTimer);
332 edgeDragArea->setTimeSource(fakeTimeSource);
301 edgeDragArea->setTimeSource(fakeTimeSource);
333
302
334− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
303+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
335 QPointF touchPoint = initialTouchPos;
304 QPointF touchPoint = initialTouchPos;
336
305
337 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0;
306 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0;
@@ -341,32 +310,32 @@ void tst_DirectionalDragArea::dragWithShortDirectionChange()
341 int touchStepTimeMs = (touchStepDistance / (edgeDragArea->minSpeed() * 5.0f)) * 1000.0f;
310 int touchStepTimeMs = (touchStepDistance / (edgeDragArea->minSpeed() * 5.0f)) * 1000.0f;
342 QPointF touchMovement = dragDirectionVector * touchStepDistance;
311 QPointF touchMovement = dragDirectionVector * touchStepDistance;
343
312
344− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
313+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
345
314
346 // Move a bit in the proper direction
315 // Move a bit in the proper direction
347 for (int i=0; i < 3; ++i) {
316 for (int i=0; i < 3; ++i) {
348 touchPoint += touchMovement;
317 touchPoint += touchMovement;
349 passTime(touchStepTimeMs);
318 passTime(touchStepTimeMs);
350− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
319+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
351 }
320 }
352
321
353 // Then a sudden and small movement to the opposite direction
322 // Then a sudden and small movement to the opposite direction
354 touchPoint -= touchMovement*0.2;
323 touchPoint -= touchMovement*0.2;
355 passTime(touchStepTimeMs*0.2);
324 passTime(touchStepTimeMs*0.2);
356− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
325+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
357
326
358 // And then resume movment in the correct direction until it crosses the distance and time
327 // And then resume movment in the correct direction until it crosses the distance and time
359 // thresholds.
328 // thresholds.
360 do {
329 do {
361 touchPoint += touchMovement;
330 touchPoint += touchMovement;
362 passTime(touchStepTimeMs);
331 passTime(touchStepTimeMs);
363− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
332+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
364 } while ((touchPoint - initialTouchPos).manhattanLength() < desiredDragDistance
333 } while ((touchPoint - initialTouchPos).manhattanLength() < desiredDragDistance
365 || fakeTimeSource->m_msecsSinceReference < (edgeDragArea->compositionTime() * 1.5f));
334 || fakeTimeSource->m_msecsSinceReference < (edgeDragArea->compositionTime() * 1.5f));
366
335
367 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
336 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
368
337
369− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
338+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
370}
339}
371
340
372/*
341/*
@@ -380,7 +349,7 @@ void tst_DirectionalDragArea::minSpeed()
380 QFETCH(int, expectedStatusAfterSpeedCheck);
349 QFETCH(int, expectedStatusAfterSpeedCheck);
381
350
382 DirectionalDragArea *edgeDragArea =
351 DirectionalDragArea *edgeDragArea =
383− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
352+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
384 QVERIFY(edgeDragArea != 0);
353 QVERIFY(edgeDragArea != 0);
385 edgeDragArea->setRecognitionTimer(fakeTimer);
354 edgeDragArea->setRecognitionTimer(fakeTimer);
386 edgeDragArea->setTimeSource(fakeTimeSource);
355 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -391,7 +360,7 @@ void tst_DirectionalDragArea::minSpeed()
391
360
392 edgeDragArea->setMinSpeed(minSpeed);
361 edgeDragArea->setMinSpeed(minSpeed);
393
362
394− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
363+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
395 QPointF touchPoint = initialTouchPos;
364 QPointF touchPoint = initialTouchPos;
396
365
397 QPointF dragDirectionVector(1.0, 0.0);
366 QPointF dragDirectionVector(1.0, 0.0);
@@ -399,13 +368,13 @@ void tst_DirectionalDragArea::minSpeed()
399 qreal distanceStep = (speed / 1000.0f) * timeStepMsecs;
368 qreal distanceStep = (speed / 1000.0f) * timeStepMsecs;
400 QPointF touchMovement = dragDirectionVector * distanceStep;
369 QPointF touchMovement = dragDirectionVector * distanceStep;
401
370
402− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
371+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
403
372
404 // Move for a while to ensure our speed check is performed a couple of times
373 // Move for a while to ensure our speed check is performed a couple of times
405 for (int i=0; i < 20; ++i) {
374 for (int i=0; i < 20; ++i) {
406 touchPoint += touchMovement;
375 touchPoint += touchMovement;
407 passTime(timeStepMsecs);
376 passTime(timeStepMsecs);
408− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
377+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
409 }
378 }
410
379
411 QCOMPARE((int)edgeDragArea->status(), expectedStatusAfterSpeedCheck);
380 QCOMPARE((int)edgeDragArea->status(), expectedStatusAfterSpeedCheck);
@@ -429,7 +398,7 @@ void tst_DirectionalDragArea::minSpeed_data()
429void tst_DirectionalDragArea::recognitionTimerUsage()
398void tst_DirectionalDragArea::recognitionTimerUsage()
430{
399{
431 DirectionalDragArea *edgeDragArea =
400 DirectionalDragArea *edgeDragArea =
432− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
401+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
433 QVERIFY(edgeDragArea != 0);
402 QVERIFY(edgeDragArea != 0);
434 edgeDragArea->setRecognitionTimer(fakeTimer);
403 edgeDragArea->setRecognitionTimer(fakeTimer);
435 edgeDragArea->setTimeSource(fakeTimeSource);
404 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -439,7 +408,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
439
408
440 int timeStepMs = 5; // some arbitrary small value.
409 int timeStepMs = 5; // some arbitrary small value.
441
410
442− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
411+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
443 QPointF touchPoint = initialTouchPos;
412 QPointF touchPoint = initialTouchPos;
444
413
445 QPointF dragDirectionVector(1.0, 0.0);
414 QPointF dragDirectionVector(1.0, 0.0);
@@ -448,7 +417,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
448 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
417 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
449 QVERIFY(!fakeTimer->isRunning());
418 QVERIFY(!fakeTimer->isRunning());
450
419
451− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
420+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
452
421
453 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
422 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
454 QVERIFY(fakeTimer->isRunning());
423 QVERIFY(fakeTimer->isRunning());
@@ -461,7 +430,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
461
430
462 touchPoint += touchMovement;
431 touchPoint += touchMovement;
463 passTime(timeStepMs);
432 passTime(timeStepMs);
464− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
433+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
465 }
434 }
466
435
467 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
436 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
@@ -475,7 +444,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
475void tst_DirectionalDragArea::maxSilenceTime()
444void tst_DirectionalDragArea::maxSilenceTime()
476{
445{
477 DirectionalDragArea *edgeDragArea =
446 DirectionalDragArea *edgeDragArea =
478− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
447+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
479 QVERIFY(edgeDragArea != 0);
448 QVERIFY(edgeDragArea != 0);
480 edgeDragArea->setRecognitionTimer(fakeTimer);
449 edgeDragArea->setRecognitionTimer(fakeTimer);
481 edgeDragArea->setTimeSource(fakeTimeSource);
450 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -483,10 +452,10 @@ void tst_DirectionalDragArea::maxSilenceTime()
483 // Make sure this property is not disabled
452 // Make sure this property is not disabled
484 edgeDragArea->setMaxSilenceTime(100);
453 edgeDragArea->setMaxSilenceTime(100);
485
454
486− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
455+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
487 QPointF touchPoint = initialTouchPos;
456 QPointF touchPoint = initialTouchPos;
488
457
489− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
458+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
490
459
491 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
460 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
492 QVERIFY(fakeTimer->isRunning());
461 QVERIFY(fakeTimer->isRunning());
@@ -506,20 +475,20 @@ void tst_DirectionalDragArea::maxSilenceTime()
506void tst_DirectionalDragArea::sceneXAndX()
475void tst_DirectionalDragArea::sceneXAndX()
507{
476{
508 DirectionalDragArea *edgeDragArea =
477 DirectionalDragArea *edgeDragArea =
509− view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
478+ m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
510 QVERIFY(edgeDragArea != 0);
479 QVERIFY(edgeDragArea != 0);
511 edgeDragArea->setRecognitionTimer(fakeTimer);
480 edgeDragArea->setRecognitionTimer(fakeTimer);
512 edgeDragArea->setTimeSource(fakeTimeSource);
481 edgeDragArea->setTimeSource(fakeTimeSource);
513
482
514− QPointF touchScenePos(view->width() - (edgeDragArea->width()/2.0f), view->height()/2.0f);
483+ QPointF touchScenePos(m_view->width() - (edgeDragArea->width()/2.0f), m_view->height()/2.0f);
515
484
516− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
485+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
517
486
518 QSignalSpy touchXSpy(edgeDragArea, SIGNAL(touchXChanged(qreal)));
487 QSignalSpy touchXSpy(edgeDragArea, SIGNAL(touchXChanged(qreal)));
519 QSignalSpy touchSceneXSpy(edgeDragArea, SIGNAL(touchSceneXChanged(qreal)));
488 QSignalSpy touchSceneXSpy(edgeDragArea, SIGNAL(touchSceneXChanged(qreal)));
520
489
521− touchScenePos.rx() = view->width() / 2;
490+ touchScenePos.rx() = m_view->width() / 2;
522− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
491+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
523
492
524 QCOMPARE(touchXSpy.count(), 1);
493 QCOMPARE(touchXSpy.count(), 1);
525 QCOMPARE(touchSceneXSpy.count(), 1);
494 QCOMPARE(touchSceneXSpy.count(), 1);
@@ -534,20 +503,20 @@ void tst_DirectionalDragArea::sceneXAndX()
534void tst_DirectionalDragArea::sceneYAndY()
503void tst_DirectionalDragArea::sceneYAndY()
535{
504{
536 DirectionalDragArea *edgeDragArea =
505 DirectionalDragArea *edgeDragArea =
537− view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
506+ m_view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
538 QVERIFY(edgeDragArea != 0);
507 QVERIFY(edgeDragArea != 0);
539 edgeDragArea->setRecognitionTimer(fakeTimer);
508 edgeDragArea->setRecognitionTimer(fakeTimer);
540 edgeDragArea->setTimeSource(fakeTimeSource);
509 edgeDragArea->setTimeSource(fakeTimeSource);
541
510
542− QPointF touchScenePos(view->width()/2.0f, view->height() - (edgeDragArea->height()/2.0f));
511+ QPointF touchScenePos(m_view->width()/2.0f, m_view->height() - (edgeDragArea->height()/2.0f));
543
512
544− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
513+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
545
514
546 QSignalSpy touchYSpy(edgeDragArea, SIGNAL(touchYChanged(qreal)));
515 QSignalSpy touchYSpy(edgeDragArea, SIGNAL(touchYChanged(qreal)));
547 QSignalSpy touchSceneYSpy(edgeDragArea, SIGNAL(touchSceneYChanged(qreal)));
516 QSignalSpy touchSceneYSpy(edgeDragArea, SIGNAL(touchSceneYChanged(qreal)));
548
517
549− touchScenePos.ry() = view->height() / 2;
518+ touchScenePos.ry() = m_view->height() / 2;
550− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
519+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
551
520
552 QCOMPARE(touchYSpy.count(), 1);
521 QCOMPARE(touchYSpy.count(), 1);
553 QCOMPARE(touchSceneYSpy.count(), 1);
522 QCOMPARE(touchSceneYSpy.count(), 1);
@@ -564,27 +533,27 @@ void tst_DirectionalDragArea::sceneYAndY()
564void tst_DirectionalDragArea::twoFingerTap()
533void tst_DirectionalDragArea::twoFingerTap()
565{
534{
566 DirectionalDragArea *edgeDragArea =
535 DirectionalDragArea *edgeDragArea =
567− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
536+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
568 QVERIFY(edgeDragArea != 0);
537 QVERIFY(edgeDragArea != 0);
569 edgeDragArea->setRecognitionTimer(fakeTimer);
538 edgeDragArea->setRecognitionTimer(fakeTimer);
570 edgeDragArea->setTimeSource(fakeTimeSource);
539 edgeDragArea->setTimeSource(fakeTimeSource);
571
540
572 // Make touches evenly spaced along the edgeDragArea
541 // Make touches evenly spaced along the edgeDragArea
573− QPoint touchAPos(edgeDragArea->width()/2.0f, view->height()*0.33f);
542+ QPoint touchAPos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
574− QPoint touchBPos(edgeDragArea->width()/2.0f, view->height()*0.66f);
543+ QPoint touchBPos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
575
544
576 qint64 timeStepMsecs = 5; // some arbitrary, small value
545 qint64 timeStepMsecs = 5; // some arbitrary, small value
577
546
578 // Perform the first two-finger tap
547 // Perform the first two-finger tap
579 // NB: using move() instead of stationary() becasue in the latter you cannot provide
548 // NB: using move() instead of stationary() becasue in the latter you cannot provide
580 // the touch position and therefore it's left with some garbage numbers.
549 // the touch position and therefore it's left with some garbage numbers.
581− QTest::touchEvent(view, device)
550+ QTest::touchEvent(m_view, m_device)
582 .press(0, touchAPos);
551 .press(0, touchAPos);
583
552
584 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
553 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
585
554
586 passTime(timeStepMsecs);
555 passTime(timeStepMsecs);
587− QTest::touchEvent(view, device)
556+ QTest::touchEvent(m_view, m_device)
588 .move(0, touchAPos)
557 .move(0, touchAPos)
589 .press(1, touchBPos);
558 .press(1, touchBPos);
590
559
@@ -593,14 +562,14 @@ void tst_DirectionalDragArea::twoFingerTap()
593 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
562 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
594
563
595 passTime(timeStepMsecs);
564 passTime(timeStepMsecs);
596− QTest::touchEvent(view, device)
565+ QTest::touchEvent(m_view, m_device)
597 .release(0, touchAPos)
566 .release(0, touchAPos)
598 .move(1, touchBPos);
567 .move(1, touchBPos);
599
568
600 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
569 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
601
570
602 passTime(timeStepMsecs);
571 passTime(timeStepMsecs);
603− QTest::touchEvent(view, device)
572+ QTest::touchEvent(m_view, m_device)
604 .release(1, touchBPos);
573 .release(1, touchBPos);
605
574
606 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
575 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -608,27 +577,27 @@ void tst_DirectionalDragArea::twoFingerTap()
608 // Perform the second two-finger tap
577 // Perform the second two-finger tap
609
578
610 passTime(timeStepMsecs);
579 passTime(timeStepMsecs);
611− QTest::touchEvent(view, device)
580+ QTest::touchEvent(m_view, m_device)
612 .press(0, touchAPos);
581 .press(0, touchAPos);
613
582
614 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
583 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
615
584
616 passTime(timeStepMsecs);
585 passTime(timeStepMsecs);
617− QTest::touchEvent(view, device)
586+ QTest::touchEvent(m_view, m_device)
618 .move(0, touchAPos)
587 .move(0, touchAPos)
619 .press(1, touchBPos);
588 .press(1, touchBPos);
620
589
621 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
590 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
622
591
623 passTime(timeStepMsecs);
592 passTime(timeStepMsecs);
624− QTest::touchEvent(view, device)
593+ QTest::touchEvent(m_view, m_device)
625 .release(0, touchAPos)
594 .release(0, touchAPos)
626 .move(1, touchBPos);
595 .move(1, touchBPos);
627
596
628 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
597 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
629
598
630 passTime(timeStepMsecs);
599 passTime(timeStepMsecs);
631− QTest::touchEvent(view, device)
600+ QTest::touchEvent(m_view, m_device)
632 .release(1, touchBPos);
601 .release(1, touchBPos);
633
602
634 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
603 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -642,7 +611,7 @@ void tst_DirectionalDragArea::twoFingerTap()
642 */
611 */
643void tst_DirectionalDragArea::movingDDA()
612void tst_DirectionalDragArea::movingDDA()
644{
613{
645− QQuickItem *rightwardsLauncher = view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
614+ QQuickItem *rightwardsLauncher = m_view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
646 Q_ASSERT(rightwardsLauncher != 0);
615 Q_ASSERT(rightwardsLauncher != 0);
647
616
648 DirectionalDragArea *edgeDragArea =
617 DirectionalDragArea *edgeDragArea =
@@ -651,7 +620,7 @@ void tst_DirectionalDragArea::movingDDA()
651 edgeDragArea->setRecognitionTimer(fakeTimer);
620 edgeDragArea->setRecognitionTimer(fakeTimer);
652 edgeDragArea->setTimeSource(fakeTimeSource);
621 edgeDragArea->setTimeSource(fakeTimeSource);
653
622
654− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
623+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
655 QPointF touchPoint = initialTouchPos;
624 QPointF touchPoint = initialTouchPos;
656
625
657 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
626 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
@@ -662,7 +631,7 @@ void tst_DirectionalDragArea::movingDDA()
662 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
631 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
663 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
632 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
664
633
665− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
634+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
666
635
667 // Move it far ahead along the direction of the gesture
636 // Move it far ahead along the direction of the gesture
668 // rightwardsLauncher is a parent of our DirectionalDragArea. So moving it will move our DDA
637 // rightwardsLauncher is a parent of our DirectionalDragArea. So moving it will move our DDA
@@ -671,12 +640,12 @@ void tst_DirectionalDragArea::movingDDA()
671 for (int i = 0; i < totalMovementSteps; ++i) {
640 for (int i = 0; i < totalMovementSteps; ++i) {
672 touchPoint += touchMovement;
641 touchPoint += touchMovement;
673 passTime(movementTimeStepMs);
642 passTime(movementTimeStepMs);
674− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
643+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
675 }
644 }
676
645
677 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
646 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
678
647
679− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
648+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
680}
649}
681
650
682/*
651/*
@@ -686,16 +655,16 @@ void tst_DirectionalDragArea::movingDDA()
686void tst_DirectionalDragArea::ignoreOldFinger()
655void tst_DirectionalDragArea::ignoreOldFinger()
687{
656{
688 DirectionalDragArea *edgeDragArea =
657 DirectionalDragArea *edgeDragArea =
689− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
658+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
690 Q_ASSERT(edgeDragArea != 0);
659 Q_ASSERT(edgeDragArea != 0);
691 edgeDragArea->setRecognitionTimer(fakeTimer);
660 edgeDragArea->setRecognitionTimer(fakeTimer);
692 edgeDragArea->setTimeSource(fakeTimeSource);
661 edgeDragArea->setTimeSource(fakeTimeSource);
693
662
694 // Make touches evenly spaced along the edgeDragArea
663 // Make touches evenly spaced along the edgeDragArea
695− QPoint touch0Pos(edgeDragArea->width()/2.0f, view->height()*0.33f);
664+ QPoint touch0Pos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
696− QPoint touch1Pos(edgeDragArea->width()/2.0f, view->height()*0.66f);
665+ QPoint touch1Pos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
697
666
698− QTest::touchEvent(view, device).press(0, touch0Pos);
667+ QTest::touchEvent(m_view, m_device).press(0, touch0Pos);
699
668
700 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
669 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
701
670
@@ -712,7 +681,7 @@ void tst_DirectionalDragArea::ignoreOldFinger()
712 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
681 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
713 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
682 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
714
683
715− QTest::touchEvent(view, device)
684+ QTest::touchEvent(m_view, m_device)
716 .move(0, touch0Pos)
685 .move(0, touch0Pos)
717 .press(1, touch1Pos);
686 .press(1, touch1Pos);
718
687
@@ -721,14 +690,14 @@ void tst_DirectionalDragArea::ignoreOldFinger()
721 for (int i = 0; i < totalMovementSteps; ++i) {
690 for (int i = 0; i < totalMovementSteps; ++i) {
722 touch1Pos += touchMovement.toPoint();
691 touch1Pos += touchMovement.toPoint();
723 passTime(movementTimeStepMs);
692 passTime(movementTimeStepMs);
724− QTest::touchEvent(view, device)
693+ QTest::touchEvent(m_view, m_device)
725 .move(0, touch0Pos)
694 .move(0, touch0Pos)
726 .move(1, touch1Pos);
695 .move(1, touch1Pos);
727 }
696 }
728
697
729 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
698 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
730
699
731− QTest::touchEvent(view, device)
700+ QTest::touchEvent(m_view, m_device)
732 .move(0, touch0Pos)
701 .move(0, touch0Pos)
733 .release(1, touch1Pos);
702 .release(1, touch1Pos);
734
703
tests/plugins/Ubuntu/Gestures/edgeDragExample.qml → tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.qmlrenamed+2−2
@@ -18,8 +18,8 @@ import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19
19
20Rectangle {
20Rectangle {
21− //width: units.gu(40)
21+ width: units.gu(40)
22− //height: units.gu(71)
22+ height: units.gu(71)
23 color: "white"
23 color: "white"
24
24
25 MouseArea {
25 MouseArea {
tests/plugins/Unity/CMakeLists.txt−51
@@ -1,53 +1,2 @@
1add_subdirectory(Indicators)
1add_subdirectory(Indicators)
2add_subdirectory(Launcher)
2add_subdirectory(Launcher)
3−
4−pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0>=7.1.1)
5−pkg_check_modules(LIBUNITYPROTO REQUIRED unity-protocol-private)
6−pkg_check_modules(LIBUNITY REQUIRED unity)
7−pkg_check_modules(LIBSIGCPP REQUIRED sigc++-2.0)
8−pkg_check_modules(QTDEE REQUIRED libdee-qt5>=3.2)
9−
10−include_directories(
11− ${Unity-qml_SOURCE_DIR}
12− ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/Unity
13− ${CMAKE_CURRENT_BINARY_DIR}
14− ${LIBUNITYPROTO_INCLUDE_DIRS}
15− ${LIBUNITY_INCLUDE_DIRS}
16− ${LIBSIGCPP_INCLUDE_DIRS}
17− ${UNITYCORE_INCLUDE_DIRS}
18− ${QTDEE_INCLUDE_DIRS}
19− )
20−
21−macro(run_tests)
22− set(_test_list "")
23− foreach(_test ${ARGN})
24− set(testCommand
25− ${CMAKE_CURRENT_BINARY_DIR}/${_test}Exec
26− -o ${CMAKE_BINARY_DIR}/${_test}.xml,xunitxml
27− -o -,txt)
28− add_test(NAME test${CLASSNAME}${_test} COMMAND ${testCommand})
29− add_custom_target(${_test} ${testCommand})
30− add_executable(${_test}Exec ${_test}.cpp)
31− qt5_use_modules(${_test}Exec Test Core Qml)
32− set_tests_properties(test${CLASSNAME}${_test}
33− PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Unity:${LIBUNITYPROTO_LIBRARY_DIRS}")
34−
35− target_link_libraries(${_test}Exec
36− Unity-qml
37− ${UNITYCORE_LDFLAGS}
38− ${LIBUNITY_LDFLAGS}
39− ${LIBUNITYPROTO_LDFLAGS}
40− ${LIBSIGCPP_LDFLAGS}
41− ${QTDEE_LDFLAGS}
42− )
43−
44− set(_test_list "${_test_list};${_test}")
45− endforeach()
46−endmacro(run_tests)
47−
48−run_tests(
49− signalslisttest
50− previewbindingstest
51− filtersbindingstest
52− resultstest
53− )
tests/plugins/Unity/Indicators/indicatorsmanagertest.cpp+1−3
@@ -80,9 +80,7 @@ private Q_SLOTS:
80 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
80 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
81 QCOMPARE(props["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
81 QCOMPARE(props["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
82
82
83− QVariantMap objectPaths = props["menuObjectPaths"].toMap();
84− QCOMPARE(objectPaths["phone"].toString(), QString("/com/canonical/indicator/fake1/phone"));
83+ QCOMPARE(props["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/phone"));
85− QCOMPARE(objectPaths["desktop"].toString(), QString("/com/canonical/indicator/fake1/desktop"));
86 }
84 }
87
85
88 /*
86 /*
tests/plugins/Unity/filtersbindingstest.cppdeleted−515
@@ -1,515 +0,0 @@
1−/*
2−* Copyright (C) 2013 Canonical, Ltd.
3−*
4−* Authors:
5−* Pawel Stolowski <pawel.stolowski@canonical.com>
6−*
7−* This program is free software; you can redistribute it and/or modify
8−* it under the terms of the GNU General Public License as published by
9−* the Free Software Foundation; version 3.
10−*
11−* This program is distributed in the hope that it will be useful,
12−* but WITHOUT ANY WARRANTY; without even the implied warranty of
13−* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14−* GNU General Public License for more details.
15−*
16−* You should have received a copy of the GNU General Public License
17−* along with this program. If not, see <http://www.gnu.org/licenses/>.
18−*/
19−
20−#include "filtersbindingstest.h"
21−
22−// libunity-core
23−#include <UnityCore/Filter.h>
24−#include <UnityCore/MultiRangeFilter.h>
25−
26−// Qt
27−#include <QTest>
28−#include <QSignalSpy>
29−
30−// libunity
31−#include <unity.h>
32−
33−// local
34−#include "filter.h"
35−#include "multirangefilter.h"
36−#include "checkoptionfilter.h"
37−#include "radiooptionfilter.h"
38−#include "ratingsfilter.h"
39−#include "ratingfilteroption.h"
40−#include "genericoptionsmodel.h"
41−
42−void FiltersBindingsTest::initTestCase()
43−{
44−}
45−
46−GVariant* FiltersBindingsTest::createOptions(int numOfOptions)
47−{
48− auto vtype = g_variant_type_new("a(sssb)");
49− auto vb = g_variant_builder_new(vtype);
50− for (int i = 0; i<numOfOptions; i++) {
51− const std::string optId = "opt" + std::to_string(i);
52− const std::string optName = "Option " + std::to_string(i);
53− g_variant_builder_add(vb, "(sssb)", optId.c_str(), optName.c_str(), "", false);
54− }
55− return g_variant_builder_end(vb);
56−}
57−
58−DeeModel* FiltersBindingsTest::createFilterModel()
59−{
60− const char* filter_schema[8] = {"s", "s", "s", "s", "a{sv}", "b", "b", "b"};
61− auto model = dee_sequence_model_new();
62− dee_model_set_schema_full (DEE_MODEL(model), filter_schema, 8);
63− return model;
64−}
65−
66−void FiltersBindingsTest::createMultiRangeFilter(DeeModel *model, const std::string &id, const std::string &name, int optionCount)
67−{
68− createFilter(model, "filter-multirange", id, name, optionCount, true);
69−}
70−
71−void FiltersBindingsTest::createRadioOptionFilter(DeeModel *model, const std::string &id, const std::string &name, int optionCount)
72−{
73− createFilter(model, "filter-radiooption", id, name, optionCount, true);
74−}
75−
76−void FiltersBindingsTest::createCheckOptionFilter(DeeModel *model, const std::string &id, const std::string &name, int optionCount)
77−{
78− createFilter(model, "filter-checkoption", id, name, optionCount, true);
79−}
80−
81−void FiltersBindingsTest::createRatingsFilter(DeeModel *model, const std::string &id, const std::string &name)
82−{
83− GVariant* row[8];
84−
85− row[0] = g_variant_new_string(id.c_str());
86− row[1] = g_variant_new_string(name.c_str());
87− row[2] = g_variant_new_string(""); // icon hint
88− row[3] = g_variant_new_string("filter-ratings");
89−
90− GVariant *children[2];
91− GVariant *key1 = g_variant_new_string("show-all-button");
92− GVariant *key2 = g_variant_new_string("rating");
93− children[0] = g_variant_new_dict_entry(key1, g_variant_new_variant(g_variant_new_boolean(true)));
94− children[1] = g_variant_new_dict_entry(key2, g_variant_new_variant(g_variant_new_double(0.0f)));
95− auto fhints = g_variant_new_array(G_VARIANT_TYPE("{sv}"), children, 2);
96−
97− row[4] = fhints;
98− row[5] = g_variant_new_boolean(true); // visible
99− row[6] = g_variant_new_boolean(false); // collapsed
100− row[7] = g_variant_new_boolean(false); // filtering
101−
102− dee_model_append_row(model, row);
103−}
104−
105−void FiltersBindingsTest::createFilter(DeeModel *model, const std::string &renderer, const std::string &id, const std::string &name, int optionCount, bool showAll)
106−{
107− GVariant* row[8];
108−
109− row[0] = g_variant_new_string(id.c_str());
110− row[1] = g_variant_new_string(name.c_str());
111− row[2] = g_variant_new_string(""); // icon hint
112− row[3] = g_variant_new_string(renderer.c_str()); // renderer
113−
114− GVariant *children[2];
115− GVariant *key1 = g_variant_new_string("show-all-button");
116− GVariant *key2 = g_variant_new_string("options");
117− children[0] = g_variant_new_dict_entry(key1, g_variant_new_variant(g_variant_new_boolean(showAll)));
118− children[1] = g_variant_new_dict_entry(key2, g_variant_new_variant(createOptions(optionCount)));
119− auto fhints = g_variant_new_array(G_VARIANT_TYPE("{sv}"), children, 2);
120−
121− row[4] = fhints;
122− row[5] = g_variant_new_boolean(true); // visible
123− row[6] = g_variant_new_boolean(false); // collapsed
124− row[7] = g_variant_new_boolean(false); // filtering
125−
126− dee_model_append_row(model, row);
127−}
128−
129−void FiltersBindingsTest::testMultiRangeFilter()
130−{
131− auto model = createFilterModel();
132−
133− createMultiRangeFilter(model, "f1", "Filter1", 1);
134− createMultiRangeFilter(model, "f2", "Filter2", 2);
135− createMultiRangeFilter(model, "f3", "Filter3", 3);
136−
137− // create filter out of 1st row
138− auto iter = dee_model_get_first_iter(DEE_MODEL(model));
139− {
140− auto core_filter = unity::dash::Filter::FilterFromIter(model, iter);
141− QVERIFY(core_filter != nullptr);
142− auto bind_filter = Filter::newFromUnityFilter(core_filter);
143− auto multi_filter = dynamic_cast<MultiRangeFilter*>(bind_filter);
144− QVERIFY(multi_filter != nullptr);
145− auto options = multi_filter->options();
146− QCOMPARE(options->rowCount(), 2);
147−
148− auto idx = options->index(1);
149− QVariant id_var = options->data(idx, GenericOptionsModel::RoleId);
150− QVariant name_var = options->data(idx, GenericOptionsModel::RoleName);
151− QVariant icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
152− QVariant active_var = options->data(idx, GenericOptionsModel::RoleActive);
153−
154− QCOMPARE(id_var.toString(), QString("opt0"));
155− QCOMPARE(name_var.toString(), QString("Option 0"));
156− QCOMPARE(icon_var.toString(), QString(""));
157− QCOMPARE(active_var.toBool(), false);
158−
159− delete multi_filter;
160− }
161−
162− // create filter out of 2nd row
163− iter = dee_model_next(DEE_MODEL(model), iter);
164− {
165− auto core_filter = unity::dash::Filter::FilterFromIter(model, iter);
166− QVERIFY(core_filter != nullptr);
167− auto bind_filter = Filter::newFromUnityFilter(core_filter);
168− auto multi_filter = dynamic_cast<MultiRangeFilter*>(bind_filter);
169− QVERIFY(multi_filter != nullptr);
170− auto options = multi_filter->options();
171− QCOMPARE(options->rowCount(), 3);
172−
173− auto idx = options->index(1);
174− QVariant id_var = options->data(idx, GenericOptionsModel::RoleId);
175− QVariant name_var = options->data(idx, GenericOptionsModel::RoleName);
176− QVariant icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
177− QVariant active_var = options->data(idx, GenericOptionsModel::RoleActive);
178−
179− QCOMPARE(id_var.toString(), QString("opt0"));
180− QCOMPARE(name_var.toString(), QString("Option 0"));
181− QCOMPARE(icon_var.toString(), QString(""));
182− QCOMPARE(active_var.toBool(), false);
183−
184− AbstractFilterOption* opt1 = options->getRawOption(1);
185− QCOMPARE(opt1->id(), QString("opt0"));
186−
187− AbstractFilterOption* opt2 = options->getRawOption(2);
188− QCOMPARE(opt2->id(), QString("opt1"));
189−
190− delete multi_filter;
191− }
192−
193− // create filter out of 3nd row
194− iter = dee_model_next(DEE_MODEL(model), iter);
195− {
196− auto core_filter = unity::dash::Filter::FilterFromIter(model, iter);
197− QVERIFY(core_filter != nullptr);
198− auto bind_filter = Filter::newFromUnityFilter(core_filter);
199− auto multi_filter = dynamic_cast<MultiRangeFilter*>(bind_filter);
200− QVERIFY(multi_filter != nullptr);
201− auto options = multi_filter->options();
202− QCOMPARE(options->rowCount(), 4);
203−
204− AbstractFilterOption* showAll = options->getRawOption(0);
205− QVERIFY(showAll->id().startsWith("show_all::"));
206−
207− AbstractFilterOption* opt0 = options->getRawOption(1);
208− QCOMPARE(opt0->id(), QString("opt0"));
209−
210− AbstractFilterOption* opt1 = options->getRawOption(2);
211− QCOMPARE(opt1->id(), QString("opt1"));
212−
213− AbstractFilterOption* opt2 = options->getRawOption(3);
214− QCOMPARE(opt2->id(), QString("opt2"));
215−
216− // verify filter options are bound to correct underlying unity options
217− auto core_multi_filter = std::dynamic_pointer_cast<unity::dash::MultiRangeFilter>(core_filter);
218− QCOMPARE(QString::fromStdString(core_multi_filter->options()[0]->id()), QString("opt0"));
219− QCOMPARE(QString::fromStdString(core_multi_filter->options()[1]->id()), QString("opt1"));
220− QCOMPARE(QString::fromStdString(core_multi_filter->options()[2]->id()), QString("opt2"));
221−
222− QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
223− QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
224− QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
225−
226− // test active property changes
227− QCOMPARE(opt0->active(), false);
228−
229− opt0->setActive(true); // activate 1st option
230− QCOMPARE(opt0spy.count(), 1);
231− QCOMPARE(opt1spy.count(), 0);
232− QCOMPARE(opt2spy.count(), 0);
233− QCOMPARE(opt0->active(), true);
234− QCOMPARE(opt1->active(), false);
235− QCOMPARE(opt2->active(), false);
236−
237− opt1->setActive(true);
238− QCOMPARE(opt0spy.count(), 2);
239− QCOMPARE(opt1spy.count(), 1);
240− QCOMPARE(opt2spy.count(), 0);
241− QCOMPARE(opt0->active(), false); //1st combined option gets deactivated
242− QCOMPARE(opt1->active(), true);
243− QCOMPARE(opt2->active(), false);
244−
245− opt1->setActive(false); // and de-activate it
246− QCOMPARE(opt0spy.count(), 2);
247− QCOMPARE(opt1spy.count(), 2);
248− QCOMPARE(opt2spy.count(), 0);
249− QCOMPARE(opt0->active(), false);
250− QCOMPARE(opt1->active(), false);
251− QCOMPARE(opt2->active(), false);
252−
253− opt2->setActive(true); // activate another combined option
254− QCOMPARE(opt0spy.count(), 2);
255− QCOMPARE(opt1spy.count(), 2);
256− QCOMPARE(opt2spy.count(), 1);
257− QCOMPARE(opt0->active(), false);
258− QCOMPARE(opt1->active(), false);
259− QCOMPARE(opt2->active(), true);
260−
261− delete multi_filter;
262− }
263−}
264−
265−void FiltersBindingsTest::testCheckOptionFilter()
266−{
267− auto model = createFilterModel();
268−
269− createCheckOptionFilter(model, "f1", "Filter1", 3);
270−
271− // create filter out of 1st row
272− auto iter = dee_model_get_first_iter(DEE_MODEL(model));
273− {
274− auto core_filter = unity::dash::Filter::FilterFromIter(model, iter);
275− QVERIFY(core_filter != nullptr);
276− auto bind_filter = Filter::newFromUnityFilter(core_filter);
277− auto check_filter = dynamic_cast<CheckOptionFilter*>(bind_filter);
278− QVERIFY(check_filter != nullptr);
279− auto options = check_filter->options();
280− QCOMPARE(options->rowCount(), 4);
281−
282− QCOMPARE(check_filter->id(), QString("f1"));
283− QCOMPARE(check_filter->name(), QString("Filter1"));
284− QCOMPARE(check_filter->iconHint(), QString(""));
285− QCOMPARE(check_filter->rendererName(), QString("filter-checkoption"));
286− QCOMPARE(check_filter->visible(), true);
287− QCOMPARE(check_filter->collapsed(), false);
288− QCOMPARE(check_filter->filtering(), false);
289−
290− auto idx = options->index(1);
291− QVariant id_var = options->data(idx, GenericOptionsModel::RoleId);
292− QVariant name_var = options->data(idx, GenericOptionsModel::RoleName);
293− QVariant icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
294− QVariant active_var = options->data(idx, GenericOptionsModel::RoleActive);
295−
296− QCOMPARE(id_var.toString(), QString("opt0"));
297− QCOMPARE(name_var.toString(), QString("Option 0"));
298− QCOMPARE(icon_var.toString(), QString(""));
299− QCOMPARE(active_var.toBool(), false);
300−
301− idx = options->index(2);
302− id_var = options->data(idx, GenericOptionsModel::RoleId);
303− name_var = options->data(idx, GenericOptionsModel::RoleName);
304− icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
305− active_var = options->data(idx, GenericOptionsModel::RoleActive);
306−
307− QCOMPARE(id_var.toString(), QString("opt1"));
308− QCOMPARE(name_var.toString(), QString("Option 1"));
309− QCOMPARE(icon_var.toString(), QString(""));
310− QCOMPARE(active_var.toBool(), false);
311−
312− AbstractFilterOption* showAll = options->getRawOption(0);
313− AbstractFilterOption* opt0 = options->getRawOption(1);
314− AbstractFilterOption* opt1 = options->getRawOption(2);
315− AbstractFilterOption* opt2 = options->getRawOption(3);
316−
317− QSignalSpy showAllSpy(showAll, SIGNAL(activeChanged(bool)));
318− QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
319− QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
320− QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
321− QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
322−
323− // test active property changes
324− QCOMPARE(showAll->active(), false);
325− QCOMPARE(opt0->active(), false);
326− QCOMPARE(opt1->active(), false);
327− QCOMPARE(opt2->active(), false);
328−
329− opt0->setActive(true);
330− QCOMPARE(showAllSpy.count(), 0);
331− QCOMPARE(opt0spy.count(), 1);
332− QCOMPARE(opt1spy.count(), 0);
333− QCOMPARE(opt2spy.count(), 0);
334− QCOMPARE(showAll->active(), false);
335− QCOMPARE(opt0->active(), true);
336− QCOMPARE(opt1->active(), false);
337− QCOMPARE(opt2->active(), false);
338−
339− opt1->setActive(true);
340− QCOMPARE(showAllSpy.count(), 0);
341− QCOMPARE(opt0spy.count(), 2);
342− QCOMPARE(opt1spy.count(), 1);
343− QCOMPARE(opt2spy.count(), 0);
344− QCOMPARE(showAll->active(), false);
345− QCOMPARE(opt0->active(), false);
346− QCOMPARE(opt1->active(), true);
347− QCOMPARE(opt2->active(), false);
348−
349− QCOMPARE(dataChangedSpy.count(), 3);
350−
351− showAll->setActive(true);
352− QCOMPARE(showAllSpy.count(), 1);
353− QCOMPARE(opt0spy.count(), 2);
354− QCOMPARE(opt1spy.count(), 2);
355− QCOMPARE(opt2spy.count(), 0);
356− QCOMPARE(showAll->active(), true);
357− QCOMPARE(opt0->active(), false);
358− QCOMPARE(opt1->active(), false);
359− QCOMPARE(opt2->active(), false);
360−
361− delete check_filter;
362− }
363−}
364−
365−void FiltersBindingsTest::testRadioOptionFilter()
366−{
367− auto model = createFilterModel();
368−
369− createRadioOptionFilter(model, "f1", "Filter1", 3);
370−
371− // create filter out of 1st row
372− auto iter = dee_model_get_first_iter(DEE_MODEL(model));
373− {
374− auto core_filter = unity::dash::Filter::FilterFromIter(model, iter);
375− QVERIFY(core_filter != nullptr);
376− auto bind_filter = Filter::newFromUnityFilter(core_filter);
377− auto radio_filter = dynamic_cast<RadioOptionFilter*>(bind_filter);
378− QVERIFY(radio_filter != nullptr);
379− auto options = radio_filter->options();
380− QCOMPARE(options->rowCount(), 4);
381−
382− auto idx = options->index(0);
383− QVariant id_var = options->data(idx, GenericOptionsModel::RoleId);
384− QVariant name_var = options->data(idx, GenericOptionsModel::RoleName);
385− QVariant icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
386− QVariant active_var = options->data(idx, GenericOptionsModel::RoleActive);
387−
388− QVERIFY(id_var.toString().startsWith("show_all::"));
389− QVERIFY(name_var.toString().size() > 0);
390− QCOMPARE(icon_var.toString(), QString(""));
391− QCOMPARE(active_var.toBool(), false);
392−
393− idx = options->index(1);
394− id_var = options->data(idx, GenericOptionsModel::RoleId);
395− name_var = options->data(idx, GenericOptionsModel::RoleName);
396− icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
397− active_var = options->data(idx, GenericOptionsModel::RoleActive);
398−
399− QCOMPARE(id_var.toString(), QString("opt0"));
400− QCOMPARE(name_var.toString(), QString("Option 0"));
401− QCOMPARE(icon_var.toString(), QString(""));
402− QCOMPARE(active_var.toBool(), false);
403−
404− idx = options->index(2);
405− id_var = options->data(idx, GenericOptionsModel::RoleId);
406− name_var = options->data(idx, GenericOptionsModel::RoleName);
407− icon_var = options->data(idx, GenericOptionsModel::RoleIconHint);
408− active_var = options->data(idx, GenericOptionsModel::RoleActive);
409−
410− QCOMPARE(id_var.toString(), QString("opt1"));
411− QCOMPARE(name_var.toString(), QString("Option 1"));
412− QCOMPARE(icon_var.toString(), QString(""));
413− QCOMPARE(active_var.toBool(), false);
414−
415− AbstractFilterOption* opt0 = options->getRawOption(1);
416− AbstractFilterOption* opt1 = options->getRawOption(2);
417− AbstractFilterOption* opt2 = options->getRawOption(3);
418−
419− QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
420− QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
421− QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
422− QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
423−
424− // test active property changes
425− QCOMPARE(opt0->active(), false);
426− QCOMPARE(opt1->active(), false);
427− QCOMPARE(opt2->active(), false);
428−
429− opt0->setActive(true);
430− QCOMPARE(opt0spy.count(), 1);
431− QCOMPARE(opt1spy.count(), 0);
432− QCOMPARE(opt2spy.count(), 0);
433− QCOMPARE(opt0->active(), true);
434− QCOMPARE(opt1->active(), false);
435− QCOMPARE(opt2->active(), false);
436−
437− opt1->setActive(true);
438− QCOMPARE(opt0spy.count(), 2);
439− QCOMPARE(opt1spy.count(), 1);
440− QCOMPARE(opt2spy.count(), 0);
441− QCOMPARE(opt0->active(), false);
442− QCOMPARE(opt1->active(), true);
443− QCOMPARE(opt2->active(), false);
444−
445− QCOMPARE(dataChangedSpy.count(), 3);
446−
447− delete radio_filter;
448− }
449−}
450−
451−void FiltersBindingsTest::testRatingsFilter()
452−{
453− auto model = createFilterModel();
454−
455− createRatingsFilter(model, "f1", "Filter1");
456−
457− // create filter out of 1st row
458− auto iter = dee_model_get_first_iter(DEE_MODEL(model));
459− {
460− auto core_filter = unity::dash::Filter::FilterFromIter(model, iter);
461− QVERIFY(core_filter != nullptr);
462− auto bind_filter = Filter::newFromUnityFilter(core_filter);
463− auto rating_filter = dynamic_cast<RatingsFilter*>(bind_filter);
464− QVERIFY(rating_filter != nullptr);
465− auto options = rating_filter->options();
466− QCOMPARE(options->rowCount(), 6);
467−
468− RatingFilterOption* opt[5];
469− for (int i = 0; i<5; i++) {
470− opt[i] = dynamic_cast<RatingFilterOption *>(options->getRawOption(i+1));
471− }
472−
473− QSignalSpy opt0spy(opt[0], SIGNAL(activeChanged(bool)));
474− QSignalSpy opt4spy(opt[4], SIGNAL(activeChanged(bool)));
475− QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
476−
477− QVERIFY(qAbs(opt[0]->value() - 0.2f) <= 0.0001f);
478− QVERIFY(qAbs(opt[1]->value() - 0.4f) <= 0.0001f);
479− QVERIFY(qAbs(opt[2]->value() - 0.6f) <= 0.0001f);
480− QVERIFY(qAbs(opt[3]->value() - 0.8f) <= 0.0001f);
481− QVERIFY(qAbs(opt[4]->value() - 1.0f) <= 0.0001f);
482−
483− QVERIFY(rating_filter->rating() <= 0.0001f); // rating equals zero
484−
485− // all options initially inactive
486− for (int i=0; i<5; i++) {
487− QCOMPARE(opt[i]->active(), false);
488− }
489−
490− // verify activation for all options
491− for (int i=0; i<5; i++) {
492− opt[i]->setActive(true);
493− QCOMPARE(opt[i]->active(), true);
494− QVERIFY(rating_filter->rating() - ((i+1)*0.2f) <= 0.0001f);
495−
496− // verify that all other options are inactive
497− for (int j=0; j<5; j++) {
498− if (i != j) {
499− QCOMPARE(opt[j]->active(), false);
500− }
501− }
502− }
503−
504− QCOMPARE(opt0spy.count(), 2);
505− QCOMPARE(opt4spy.count(), 1);
506−
507− opt[4]->setActive(false);
508− QVERIFY(rating_filter->rating() <= 0.0001f); // rating equals zero
509− QCOMPARE(opt4spy.count(), 2);
510−
511− QCOMPARE(dataChangedSpy.count(), 10);
512− }
513−}
514−
515−QTEST_MAIN(FiltersBindingsTest)
tests/plugins/Unity/filtersbindingstest.hdeleted−47
@@ -1,47 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Pawel Stolowski <pawel.stolowski@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef FILTERSBINDINGSTEST_H
21−#define FILTERSBINDINGSTEST_H
22−
23−#include <QObject>
24−#include <dee.h>
25−
26−class FiltersBindingsTest : public QObject
27−{
28− Q_OBJECT
29−
30− private Q_SLOTS:
31− void initTestCase();
32− void testMultiRangeFilter();
33− void testCheckOptionFilter();
34− void testRadioOptionFilter();
35− void testRatingsFilter();
36−
37− private:
38− DeeModel* createFilterModel();
39− GVariant* createOptions(int numOfOptions);
40− void createMultiRangeFilter(DeeModel *model, const std::string &id, const std::string &name, int optionCount);
41− void createCheckOptionFilter(DeeModel *model, const std::string &id, const std::string &name, int optionCount);
42− void createRadioOptionFilter(DeeModel *model, const std::string &id, const std::string &name, int optionCount);
43− void createRatingsFilter(DeeModel *model, const std::string &id, const std::string &name);
44− void createFilter(DeeModel *model, const std::string &renderer, const std::string &id, const std::string &name, int optionCount, bool showAll);
45−};
46−
47−#endif // FILTERSBINDINGSTEST_H
tests/plugins/Unity/previewbindingstest.cppdeleted−194
@@ -1,194 +0,0 @@
1−/*
2− * Copyright (C) 2011, 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 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−#include "previewbindingstest.h"
18−#include <QTest>
19−
20−#include <UnityCore/Preview.h>
21−#include <UnityCore/GLibWrapper.h>
22−#include <UnityCore/Variant.h>
23−#include <unity-protocol.h>
24−
25−#include "genericpreview.h"
26−#include "applicationpreview.h"
27−#include "moviepreview.h"
28−#include "musicpreview.h"
29−#include "socialpreview.h"
30−#include "socialpreviewcomment.h"
31−#include "previewaction.h"
32−
33−#include <glib.h>
34−#include <glib-object.h>
35−
36−void PreviewBindingsTest::initTestCase()
37−{
38−}
39−
40−void PreviewBindingsTest::testGenericPreview()
41−{
42− auto rawPreview = (GObject *)unity_protocol_generic_preview_new();
43− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Metallica");
44− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Ride The Lightning");
45− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
46− GFile *iconFile = g_file_new_for_path("/foo.png");
47− GIcon *icon = g_file_icon_new(iconFile);
48− unity_protocol_preview_add_action(UNITY_PROTOCOL_PREVIEW(rawPreview), "1", "Action1", icon,
49− UNITY_PROTOCOL_LAYOUT_HINT_LEFT);
50− unity::glib::Object<GObject> genPrv(rawPreview);
51−
52− // create local result
53− unity::glib::HintsMap hints;
54− hints["a"] = unity::glib::Variant(g_variant_new_string("b"));
55− unity::dash::LocalResult localResult;
56− localResult.uri = "http://foo";
57− localResult.icon_hint = "xyz";
58− localResult.category_index = 1;
59− localResult.result_type = 2;
60− localResult.mimetype = "abc";
61− localResult.name = "baz";
62− localResult.comment = "qwerty";
63− localResult.dnd_uri = "zzz";
64− localResult.hints = hints;
65−
66− auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
67− corePrv->preview_result = localResult;
68−
69− auto prv = Preview::newFromUnityPreview(corePrv);
70−
71− QCOMPARE(prv != nullptr, true);
72− QCOMPARE(prv->title(), QString("Metallica"));
73− QCOMPARE(prv->subtitle(), QString("Ride The Lightning"));
74− QCOMPARE(prv->description(), QString("Lorem ipsum dolor sit amet"));
75−
76− auto actions = prv->actions().value<QList<QObject *>>();
77− QCOMPARE(actions.size(), 1);
78− auto act = dynamic_cast<PreviewAction *>(actions[0]);
79− QVERIFY(act != nullptr);
80− QCOMPARE(act->id(), QString("1"));
81− QCOMPARE(act->displayName(), QString("Action1"));
82− QCOMPARE(act->iconHint(), QString("/foo.png"));
83−
84− Result* res = prv->result().value<Result*>();
85− QCOMPARE(res->uri(), QString("http://foo"));
86− QCOMPARE(res->iconHint(), QString("xyz"));
87− QCOMPARE(res->categoryIndex(), 1u);
88− QCOMPARE(res->resultType(), 2u);
89− QCOMPARE(res->mimeType(), QString("abc"));
90− QCOMPARE(res->title(), QString("baz"));
91− QCOMPARE(res->dndUri(), QString("zzz"));
92− QCOMPARE(res->metadata().toHash()["a"].toString(), QString("b"));
93−
94− g_object_unref(icon);
95− g_object_unref(iconFile);
96−}
97−
98−void PreviewBindingsTest::testApplicationPreview()
99−{
100− auto rawPreview = (GObject *)unity_protocol_application_preview_new();
101− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Firefox");
102− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Web Browser");
103− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
104− unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(rawPreview), "GPL");
105− unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(rawPreview), 0.5f);
106− unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(rawPreview), 4);
107− unity::glib::Object<GObject> genPrv(rawPreview);
108−
109− auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
110− auto prv = Preview::newFromUnityPreview(corePrv);
111− auto appPrv = dynamic_cast<ApplicationPreview*>(prv);
112−
113− QCOMPARE(appPrv != nullptr, true);
114− QCOMPARE(appPrv->title(), QString("Firefox"));
115− QCOMPARE(appPrv->subtitle(), QString("Web Browser"));
116− QCOMPARE(appPrv->description(), QString("Lorem ipsum dolor sit amet"));
117− QCOMPARE(appPrv->license(), QString("GPL"));
118− QCOMPARE(appPrv->rating(), 0.5f);
119− QCOMPARE(appPrv->numRatings(), unsigned (4));
120−}
121−
122−void PreviewBindingsTest::testMoviePreview()
123−{
124− auto rawPreview = (GObject *)unity_protocol_movie_preview_new();
125− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Blade Runner");
126− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Ridley Scott");
127− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
128− unity_protocol_movie_preview_set_year(UNITY_PROTOCOL_MOVIE_PREVIEW(rawPreview), "1982");
129− unity::glib::Object<GObject> genPrv(rawPreview);
130−
131− auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
132− auto prv = Preview::newFromUnityPreview(corePrv);
133− auto moviePrv = dynamic_cast<MoviePreview*>(prv);
134−
135− QCOMPARE(moviePrv != nullptr, true);
136− QCOMPARE(moviePrv->title(), QString("Blade Runner"));
137− QCOMPARE(moviePrv->subtitle(), QString("Ridley Scott"));
138− QCOMPARE(moviePrv->description(), QString("Lorem ipsum dolor sit amet"));
139− QCOMPARE(moviePrv->year(), QString("1982"));
140−}
141−
142−void PreviewBindingsTest::testMusicPreview()
143−{
144− auto rawPreview = (GObject *)unity_protocol_music_preview_new();
145− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Metallica");
146− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Death Magnetic");
147− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
148− unity::glib::Object<GObject> genPrv(rawPreview);
149−
150− auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
151− auto prv = Preview::newFromUnityPreview(corePrv);
152− auto musicPrv = dynamic_cast<MusicPreview*>(prv);
153−
154− QCOMPARE(musicPrv != nullptr, true);
155− QCOMPARE(musicPrv->title(), QString("Metallica"));
156− QCOMPARE(musicPrv->subtitle(), QString("Death Magnetic"));
157− QCOMPARE(musicPrv->description(), QString("Lorem ipsum dolor sit amet"));
158−}
159−
160−void PreviewBindingsTest::testSocialPreview()
161−{
162− GFile *iconFile = g_file_new_for_path("/foo.png");
163− GIcon *icon = g_file_icon_new(iconFile);
164−
165− auto rawPreview = (GObject *)unity_protocol_social_preview_new();
166− unity_protocol_social_preview_set_sender(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), "John");
167− unity_protocol_social_preview_set_avatar(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), icon);
168− unity_protocol_social_preview_set_content(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
169− unity_protocol_social_preview_add_comment(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), "1", "comment1", "Ubuntu", "2013-07-04 14:10");
170− unity::glib::Object<GObject> genPrv(rawPreview);
171−
172− auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
173− auto prv = Preview::newFromUnityPreview(corePrv);
174− auto socialPrv = dynamic_cast<SocialPreview*>(prv);
175−
176− QCOMPARE(socialPrv != nullptr, true);
177− QCOMPARE(socialPrv->sender(), QString("John"));
178− QCOMPARE(socialPrv->content(), QString("Lorem ipsum dolor sit amet"));
179− QCOMPARE(socialPrv->avatar(), QString("/foo.png"));
180−
181− auto comments = socialPrv->comments().value<QList<QObject *>>();
182− QCOMPARE(comments.size(), 1);
183− auto cmt = dynamic_cast<SocialPreviewComment *>(comments[0]);
184− QVERIFY(cmt != nullptr);
185− QCOMPARE(cmt->id(), QString("1"));
186− QCOMPARE(cmt->displayName(), QString("comment1"));
187− QCOMPARE(cmt->content(), QString("Ubuntu"));
188− QCOMPARE(cmt->time(), QString("2013-07-04 14:10"));
189−
190− g_object_unref(icon);
191− g_object_unref(iconFile);
192−}
193−
194−QTEST_MAIN(PreviewBindingsTest)
tests/plugins/Unity/previewbindingstest.hdeleted−35
@@ -1,35 +0,0 @@
1−/*
2− * Copyright (C) 2011, 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 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 PREVIEWBINDINGSTEST_H
18−#define PREVIEWBINDINGSTEST_H
19−
20−#include <QObject>
21−
22−class PreviewBindingsTest : public QObject
23−{
24− Q_OBJECT
25−
26− private Q_SLOTS:
27− void initTestCase();
28− void testGenericPreview();
29− void testApplicationPreview();
30− void testMoviePreview();
31− void testMusicPreview();
32− void testSocialPreview();
33−};
34−
35−#endif
tests/plugins/Unity/resultstest.cppdeleted−248
@@ -1,248 +0,0 @@
1−/*
2− * Copyright (C) 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 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− * Authors:
17− * Michal Hruby <michal.hruby@canonical.com>
18− */
19−
20−#include <QTest>
21−#include <dee.h>
22−#include <glib.h>
23−
24−#include "resultstest.h"
25−#include "categoryresults.h"
26−#include "variantutils.h"
27−
28−static DeeModel* createBackendModel()
29−{
30− auto model = dee_sequence_model_new();
31− dee_model_set_schema(model, "s", "s", "u", "u", "s", "s", "s", "s", "a{sv}", NULL);
32−
33− return model;
34−}
35−
36−void ResultsTest::testAllColumns()
37−{
38− auto deeModel = createBackendModel();
39− GVariantBuilder builder;
40− g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
41− g_variant_builder_add(&builder, "{sv}", "metadata-field", g_variant_new_string("foo"));
42− dee_model_append (deeModel,
43− "test:uri",
44− "themed-icon",
45− 4,
46− 0,
47− "application/octet-stream",
48− "Test",
49− "Comment",
50− "test:dnd-uri",
51− g_variant_builder_end(&builder));
52−
53− CategoryResults* results = new CategoryResults(this);
54− results->setModel(deeModel);
55−
56− auto index = results->index(0, 0); // there's just one result
57− QCOMPARE(index.data(CategoryResults::Roles::RoleUri).toString(), QString("test:uri"));
58− QCOMPARE(index.data(CategoryResults::Roles::RoleIconHint).toString(), QString("image://theme/themed-icon"));
59− QCOMPARE(index.data(CategoryResults::Roles::RoleCategory).toInt(), 4);
60− QCOMPARE(index.data(CategoryResults::Roles::RoleMimetype).toString(), QString("application/octet-stream"));
61− QCOMPARE(index.data(CategoryResults::Roles::RoleTitle).toString(), QString("Test"));
62− QCOMPARE(index.data(CategoryResults::Roles::RoleComment).toString(), QString("Comment"));
63− QCOMPARE(index.data(CategoryResults::Roles::RoleDndUri).toString(), QString("test:dnd-uri"));
64− auto metadata = index.data(CategoryResults::Roles::RoleMetadata).toHash();
65− QCOMPARE(metadata["metadata-field"].toString(), QString("foo"));
66−}
67−
68−void ResultsTest::testIconColumn_data()
69−{
70− QTest::addColumn<QString>("uri");
71− QTest::addColumn<QString>("giconString");
72− QTest::addColumn<QString>("result");
73−
74− QTest::newRow("unspecified") << "test:uri" << "" << "";
75− QTest::newRow("absolute path") << "test:uri" << "/usr/share/icons/example.png" << "/usr/share/icons/example.png";
76− QTest::newRow("file uri") << "test:uri" << "file:///usr/share/icons/example.png" << "file:///usr/share/icons/example.png";
77− QTest::newRow("http uri") << "test:uri" << "http://images.ubuntu.com/example.jpg" << "http://images.ubuntu.com/example.jpg";
78− QTest::newRow("image uri") << "test:uri" << "image://thumbnail/with/arguments?passed_to=ImageProvider" << "image://thumbnail/with/arguments?passed_to=ImageProvider";
79− QTest::newRow("themed icon") << "test:uri" << "accessories-other" << "image://theme/accessories-other";
80− QTest::newRow("fileicon") << "test:uri" << ". GFileIcon http://example.org/resource.gif" << "http://example.org/resource.gif";
81− QTest::newRow("themedicon") << "test:uri" << ". GThemedIcon accessories-other accessories generic" << "image://theme/accessories-other,accessories,generic";
82− QTest::newRow("annotatedicon") << "test:uri" << ". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'.%20GThemedIcon%20accessories-other%20accessories%20generic'%3E%7D" << "image://theme/accessories-other,accessories,generic";
83− QTest::newRow("thumbnailer icon") << "file:///usr/share/samples/video/foo.avi" << "" << "image://thumbnailer//usr/share/samples/video/foo.avi";
84−}
85−
86−void ResultsTest::testIconColumn()
87−{
88− QFETCH(QString, uri);
89− QFETCH(QString, giconString);
90− QFETCH(QString, result);
91− auto deeModel = createBackendModel();
92− dee_model_append (deeModel,
93− uri.toLocal8Bit().constData(),
94− giconString.toLocal8Bit().constData(),
95− 0,
96− 0,
97− "application/octet-stream",
98− "Test",
99− "",
100− "test:dnd-uri",
101− g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0));
102−
103− CategoryResults* results = new CategoryResults(this);
104− results->setModel(deeModel);
105−
106− auto index = results->index(0, 0); // there's just one result
107− auto transformedIcon = index.data(CategoryResults::Roles::RoleIconHint).toString();
108− QCOMPARE(transformedIcon, result);
109−}
110−
111−class GVariantWrapper
112−{
113−public:
114− GVariantWrapper() : variant(NULL) {}
115− GVariantWrapper(GVariant* v) {
116− variant = v ? g_variant_ref_sink(v) : NULL;
117− }
118− GVariantWrapper(const GVariantWrapper& other) {
119− variant = other.variant ? g_variant_ref(other.variant) : NULL;
120− }
121− ~GVariantWrapper() {
122− if (variant) g_variant_unref(variant);
123− }
124−
125− GVariant* variant;
126−};
127−
128−Q_DECLARE_METATYPE(GVariantWrapper)
129−
130−void ResultsTest::testSpecialIcons_data()
131−{
132− QTest::addColumn<QString>("uri");
133− QTest::addColumn<GVariantWrapper>("metadata");
134− QTest::addColumn<QString>("result");
135−
136− GVariant *inner;
137− GVariantBuilder builder, inner_builder;
138−
139− g_variant_builder_init(&inner_builder, G_VARIANT_TYPE_VARDICT);
140− g_variant_builder_add(&inner_builder, "{sv}", "artist", g_variant_new_string("U2"));
141− g_variant_builder_add(&inner_builder, "{sv}", "album", g_variant_new_string("War"));
142−
143− g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
144− g_variant_builder_add(&builder, "{sv}", "content", g_variant_builder_end(&inner_builder));
145−
146− QTest::newRow("simple") << "file:///foo.mp3" << GVariantWrapper(g_variant_builder_end(&builder)) << "image://albumart/artist=U2&album=War";
147−
148− g_variant_builder_init(&inner_builder, G_VARIANT_TYPE_VARDICT);
149− g_variant_builder_add(&inner_builder, "{sv}", "artist", g_variant_new_string("U2"));
150− g_variant_builder_add(&inner_builder, "{sv}", "album", g_variant_new_string("War/Joshua tree"));
151− inner = g_variant_builder_end(&inner_builder);
152−
153− g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
154− g_variant_builder_add(&builder, "{sv}", "content", inner);
155−
156− QTest::newRow("with-slash") << "file:///foo.mp3" << GVariantWrapper(g_variant_builder_end(&builder)) << "image://albumart/artist=U2&album=War/Joshua tree";
157−
158− g_variant_builder_init(&inner_builder, G_VARIANT_TYPE_VARDICT);
159− g_variant_builder_add(&inner_builder, "{sv}", "artist", g_variant_new_string("U2"));
160− g_variant_builder_add(&inner_builder, "{sv}", "album", g_variant_new_string("War"));
161− inner = g_variant_builder_end(&inner_builder);
162−
163− g_variant_builder_init(&inner_builder, G_VARIANT_TYPE_VARDICT);
164− g_variant_builder_add(&inner_builder, "{sv}", "content", inner);
165−
166− g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
167− g_variant_builder_add(&builder, "{sv}", "content", g_variant_builder_end(&inner_builder));
168−
169− QTest::newRow("nested") << "file:///foo.mp3" << GVariantWrapper(g_variant_builder_end(&builder)) << "image://albumart/artist=U2&album=War";
170−}
171−
172−void ResultsTest::testSpecialIcons()
173−{
174− QFETCH(QString, uri);
175− QFETCH(GVariantWrapper, metadata);
176− QFETCH(QString, result);
177− auto deeModel = createBackendModel();
178− dee_model_append (deeModel,
179− uri.toLocal8Bit().constData(),
180− "",
181− 0,
182− 0,
183− "audio/mp3",
184− "Test",
185− "",
186− uri.toLocal8Bit().constData(),
187− metadata.variant);
188−
189− CategoryResults* results = new CategoryResults(this);
190− results->setModel(deeModel);
191−
192− auto index = results->index(0, 0); // there's just one result
193− auto transformedIcon = index.data(CategoryResults::Roles::RoleIconHint).toString();
194− QCOMPARE(transformedIcon, result);
195−}
196−
197−void ResultsTest::testMetadataOverride_data()
198−{
199− QTest::addColumn<QString>("uri");
200− QTest::addColumn<QVariantHash>("result");
201−
202− QVariantHash expected_result;
203− QVariantHash inner_hash;
204−
205− expected_result = QVariantHash();
206− expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
207− expected_result["content"] = QVariant::fromValue(QVariantHash());
208−
209− QTest::newRow("single scope") << "subscope:applications.scope" << expected_result;
210−
211− expected_result = QVariantHash();
212− expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
213− inner_hash = QVariantHash();
214− inner_hash["foo"] = QVariant::fromValue(QString("bar"));
215− inner_hash["qoo"] = QVariant::fromValue(QString("baz"));
216− expected_result["content"] = QVariant::fromValue(inner_hash);
217−
218− QTest::newRow("single scope with data") << "subscope:applications.scope?foo=bar&qoo=baz" << expected_result;
219−
220− expected_result = QVariantHash();
221− inner_hash = QVariantHash();
222− inner_hash["scope-id"] = QVariant::fromValue(QString("applications-local.scope"));
223− inner_hash["content"] = QVariant::fromValue(QVariantHash());
224− expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
225− expected_result["content"] = QVariant::fromValue(inner_hash);
226− QTest::newRow("master scope") << "subscope:applications.scope/applications-local.scope" << expected_result;
227−
228− expected_result = QVariantHash();
229− expected_result["foo"] = QVariant::fromValue(QString("baz"));
230− expected_result["qoo"] = QVariant::fromValue(QString("baz"));
231− inner_hash = QVariantHash();
232− inner_hash["scope-id"] = QVariant::fromValue(QString("applications-local.scope"));
233− inner_hash["content"] = QVariant::fromValue(expected_result);
234− expected_result = QVariantHash();
235− expected_result["scope-id"] = QVariant::fromValue(QString("applications.scope"));
236− expected_result["content"] = QVariant::fromValue(inner_hash);
237− QTest::newRow("nested with data") << "subscope:applications.scope/applications-local.scope?foo=baz&qoo=baz" << expected_result;
238−}
239−
240−void ResultsTest::testMetadataOverride()
241−{
242− QFETCH(QString, uri);
243− QFETCH(QVariantHash, result);
244−
245− QCOMPARE(subscopeUriToMetadataHash(uri), result);
246−}
247−
248−QTEST_MAIN(ResultsTest)
tests/plugins/Unity/resultstest.hdeleted−39
@@ -1,39 +0,0 @@
1−/*
2− * Copyright (C) 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 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− * Authors:
17− * Michal Hruby <michal.hruby@canonical.com>
18− */
19−
20−#ifndef RESULTSTEST_H
21−#define RESULTSTEST_H
22−
23−#include <QObject>
24−
25−class ResultsTest : public QObject
26−{
27− Q_OBJECT
28−
29− private Q_SLOTS:
30− void testAllColumns();
31− void testIconColumn_data();
32− void testIconColumn();
33− void testSpecialIcons_data();
34− void testSpecialIcons();
35− void testMetadataOverride_data();
36− void testMetadataOverride();
37−};
38−
39−#endif
tests/plugins/Unity/signalslisttest.cppdeleted−57
@@ -1,57 +0,0 @@
1−/*
2− * Copyright (C) 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 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−// local
18−#include "signalslisttest.h"
19−#include "signalslist.h"
20−
21−// Qt
22−#include <QTest>
23−
24−class TestSource
25−{
26− public:
27− TestSource(): m_count(0) {}
28− void update()
29− {
30− countChanged(++m_count);
31− }
32−
33− sigc::signal<void, int> countChanged;
34− int m_count;
35−};
36−
37−void SignalsListTest::testSignalsList()
38−{
39− TestSource src;
40− SignalsList signals;
41− int counter = -1;
42−
43− signals << src.countChanged.connect([&counter](int val) {
44− counter = val;
45− });
46−
47− src.update();
48− QCOMPARE(counter, 1);
49− src.update();
50− QCOMPARE(counter, 2);
51−
52− signals.disconnectAll();
53− src.update();
54− QCOMPARE(counter, 2);
55−}
56−
57−QTEST_MAIN(SignalsListTest)
tests/plugins/Unity/signalslisttest.hdeleted−30
@@ -1,30 +0,0 @@
1−/*
2− * Copyright (C) 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 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 SIGNALSLISTTEST_H
18−#define SIGNALSLISTTEST_H
19−
20−#include <QObject>
21−
22−class SignalsListTest : public QObject
23−{
24− Q_OBJECT
25−
26− private Q_SLOTS:
27− void testSignalsList();
28−};
29−
30−#endif // SIGNALSLISTTEST_H
tests/qmltests/Components/tst_PageHeader.qml+1
@@ -214,6 +214,7 @@ Item {
214 scope: scopeMock
214 scope: scopeMock
215
215
216 searchEntryEnabled: true
216 searchEntryEnabled: true
217+ searchHistory: SearchHistoryModel {}
217 text: "%^$%^%^&%^&%^$%GHR%"
218 text: "%^$%^%^&%^&%^$%GHR%"
218 }
219 }
219
220
tests/qmltests/Dash/tst_Dash.qml+5−1
@@ -102,11 +102,15 @@ Item {
102 console.log("Not testing " + data.tag + ": not visible");
102 console.log("Not testing " + data.tag + ": not visible");
103 return;
103 return;
104 }
104 }
105+ var dashContentList = findChild(dash, "dashContentList");
106+
105 dash.showScopeOnLoaded = data.tag
107 dash.showScopeOnLoaded = data.tag
106 scopes.clear();
108 scopes.clear();
109+ tryCompare(dashContentList, "count", 0);
107 scopes.load();
110 scopes.load();
111+ tryCompare(scopes, "loaded", true);
112+ tryCompare(dashContentList, "count", 4);
108
113
109− var dashContentList = findChild(dash, "dashContentList");
110 verify(dashContentList != undefined);
114 verify(dashContentList != undefined);
111 tryCompare(dashContentList, "currentIndex", data.visualIndex);
115 tryCompare(dashContentList, "currentIndex", data.visualIndex);
112 }
116 }
tests/qmltests/Dash/tst_DashContent.qml+15−14
@@ -26,8 +26,6 @@ Item {
26 width: units.gu(40)
26 width: units.gu(40)
27 height: units.gu(80)
27 height: units.gu(80)
28
28
29− property ListModel searchHistory: ListModel {}
30−
31 Item {
29 Item {
32 // Fake. Make a few components less noisy
30 // Fake. Make a few components less noisy
33 id: greeter
31 id: greeter
@@ -60,6 +58,7 @@ Item {
60 scopes : scopesModel
58 scopes : scopesModel
61
59
62 scopeMapper : scopeDelegateMapper
60 scopeMapper : scopeDelegateMapper
61+ searchHistory: ListModel {}
63 }
62 }
64
63
65 ScopeDelegateMapper {
64 ScopeDelegateMapper {
@@ -125,13 +124,6 @@ Item {
125
124
126 var dashContentList = findChild(dashContent, "dashContentList");
125 var dashContentList = findChild(dashContent, "dashContentList");
127 verify(dashContentList != undefined);
126 verify(dashContentList != undefined);
128− // TODO For Qt 5.2 remove this wait
129− // and the tryCompare and see if it still crashes when
130− // looping the test
131− wait(1000);
132− if (dashContentList.currentItem !== null) {
133− tryCompare(dashContentList.currentItem, "moving", false);
134− }
135 scopesModel.clear();
127 scopesModel.clear();
136 // wait for dash to empty scopes.
128 // wait for dash to empty scopes.
137 tryCompare(dashContentList, "count", 0);
129 tryCompare(dashContentList, "count", 0);
@@ -249,18 +241,27 @@ Item {
249 tryCompare(scopesModel.get(2), "isActive", data.active2);
241 tryCompare(scopesModel.get(2), "isActive", data.active2);
250 }
242 }
251
243
252− function test_hswipe_disabled_vswipe() {
244+ function checkFlickMovingAndNotInteractive()
245+ {
253 var dashContentList = findChild(dashContent, "dashContentList");
246 var dashContentList = findChild(dashContent, "dashContentList");
254
247
255− tryCompare(dashContentList, "interactive", true);
248+ if (dashContentList.currentItem.moving && !dashContentList.interactive)
249+ return true;
256
250
257 var startX = dashContentList.width/2;
251 var startX = dashContentList.width/2;
258 var startY = dashContentList.height/2;
252 var startY = dashContentList.height/2;
259− touchFlick(dashContentList, startX, startY, startX, startY - units.gu(80));
253+ touchFlick(dashContentList, startX, startY, startX, startY - units.gu(40));
254+
255+ return dashContentList.currentItem.moving && !dashContentList.interactive;
256+ }
260
257
261− tryCompare(dashContentList.currentItem, "moving", true);
262
258
259+ function test_hswipe_disabled_vswipe() {
260+ var dashContentList = findChild(dashContent, "dashContentList");
261+
263− compare(dashContentList.interactive, false);
262+ tryCompare(dashContentList, "interactive", true);
263+
264+ tryCompareFunction(checkFlickMovingAndNotInteractive, true);
264 }
265 }
265 }
266 }
266}
267}
tests/qmltests/Greeter/tst_Lockscreen.qml+45−17
@@ -41,7 +41,7 @@ Rectangle {
41 target: lockscreen
41 target: lockscreen
42
42
43 onEmergencyCall: emergencyCheckBox.checked = true
43 onEmergencyCall: emergencyCheckBox.checked = true
44− onUnlocked: unlockedCheckBox.checked = true
44+ onEntered: enteredLabel.text = passphrase
45 }
45 }
46
46
47 Connections {
47 Connections {
@@ -99,12 +99,11 @@ Rectangle {
99 anchors.verticalCenter: parent.verticalCenter
99 anchors.verticalCenter: parent.verticalCenter
100 }
100 }
101 Row {
101 Row {
102− CheckBox {
102+ Label {
103− id: unlockedCheckBox
103+ text: "Entered:"
104 }
104 }
105 Label {
105 Label {
106− text: "Unlocked signal"
106+ id: enteredLabel
107− anchors.verticalCenter: parent.verticalCenter
108 }
107 }
109 }
108 }
110 Button {
109 Button {
@@ -176,16 +175,16 @@ Rectangle {
176
175
177 function test_unlock_data() {
176 function test_unlock_data() {
178 return [
177 return [
179− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true, pinLength: 4},
178+ {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", pinLength: 4},
180− {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", unlockedSignal: true, pinLength: -1},
179+ {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", pinLength: -1},
181− {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", unlockedSignal: false, pinLength: 4},
180+ {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", pinLength: 4},
182− {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", unlockedSignal: false, pinLength: -1},
181+ {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", pinLength: -1},
183− {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true, pinLength: -1},
182+ {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", pinLength: -1},
184 ]
183 ]
185 }
184 }
186
185
187 function test_unlock(data) {
186 function test_unlock(data) {
188− unlockedCheckBox.checked = false
187+ enteredLabel.text = ""
189 pinLengthTextField.text = data.pinLength
188 pinLengthTextField.text = data.pinLength
190 LightDM.Greeter.authenticate(data.username)
189 LightDM.Greeter.authenticate(data.username)
191 waitForRendering(lockscreen)
190 waitForRendering(lockscreen)
@@ -206,14 +205,43 @@ Rectangle {
206 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
205 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
207 }
206 }
208 }
207 }
208+ tryCompare(enteredLabel, "text", data.password)
209+ }
210+
211+ function test_clear_data() {
212+ return [
213+ {tag: "animated PIN", animation: true, alphanumeric: false},
214+ {tag: "not animated PIN", animation: false, alphanumeric: false},
215+ {tag: "animated passphrase", animation: true, alphanumeric: true},
216+ {tag: "not animated passphrase", animation: false, alphanumeric: true}
217+ ];
218+ }
219+
220+ function test_clear(data) {
221+ pinPadCheckBox.checked = data.alphanumeric
222+ waitForRendering(lockscreen)
209
223
210− tryCompare(unlockedCheckBox, "checked", data.unlockedSignal)
224+ var inputField = findChild(lockscreen, "pinentryField")
211− if (!data.unlockedSignal) {
225+ if (data.alphanumeric) {
212− // make sure the input is cleared on wrong input
226+ mouseClick(inputField, units.gu(1), units.gu(1))
213− tryCompareFunction(function() {return inputField.text.length == 0}, true)
227+ typeString("1")
214 } else {
228 } else {
215− tryCompareFunction(function() {return inputField.text.length > 0}, true)
229+ var button = findChild(lockscreen, "pinPadButton1")
230+ mouseClick(button, units.gu(1), units.gu(1))
216 }
231 }
232+
233+ var animation = findInvisibleChild(lockscreen, "wrongPasswordAnimation")
234+
235+ tryCompare(inputField, "text", "1")
236+
237+ lockscreen.clear(data.animation)
238+ tryCompare(inputField, "text", "")
239+
240+ wait(0) // Trigger event loop to make sure the animation would start running
241+ compare(animation.running, data.animation)
242+
243+ // wait for animation to finish to not disturb other tests
244+ tryCompare(animation, "running", false)
217 }
245 }
218
246
219 function test_backspace_data() {
247 function test_backspace_data() {
@@ -224,7 +252,7 @@ Rectangle {
224 }
252 }
225
253
226 function test_backspace(data) {
254 function test_backspace(data) {
227− LightDM.Greeter.authenticate("has-pin");
255+ pinPadCheckBox.checked = false
228 pinLengthTextField.text = data.pinLength
256 pinLengthTextField.text = data.pinLength
229 waitForRendering(lockscreen);
257 waitForRendering(lockscreen);
230
258
tests/qmltests/Notifications/tst_Notifications.qml+56
@@ -76,6 +76,20 @@ Row {
76 mockModel.append(n)
76 mockModel.append(n)
77 }
77 }
78
78
79+ function addEphemeralNonShapedIconNotification() {
80+ var n = {
81+ type: Notification.Ephemeral,
82+ hints: {"x-canonical-non-shaped-icon": "true"},
83+ summary: "Contacts",
84+ body: "Synchronised contacts-database with cloud-storage.",
85+ icon: "../graphics/applicationIcons/contacts-app.png",
86+ secondaryIcon: "",
87+ actions: []
88+ }
89+
90+ mockModel.append(n)
91+ }
92+
79 function addEphemeralIconSummaryNotification() {
93 function addEphemeralIconSummaryNotification() {
80 var n = {
94 var n = {
81 type: Notification.Ephemeral,
95 type: Notification.Ephemeral,
@@ -156,6 +170,12 @@ Row {
156 onClicked: addEphemeralNotification()
170 onClicked: addEphemeralNotification()
157 }
171 }
158
172
173+ Button {
174+ width: parent.width
175+ text: "add an non-shaped-icon-summary-body"
176+ onClicked: addEphemeralNonShapedIconNotification()
177+ }
178+
159 Button {
179 Button {
160 width: parent.width
180 width: parent.width
161 text: "add an icon-summary"
181 text: "add an icon-summary"
@@ -206,6 +226,8 @@ Row {
206 bodyVisible: true,
226 bodyVisible: true,
207 interactiveAreaEnabled: false,
227 interactiveAreaEnabled: false,
208 iconVisible: true,
228 iconVisible: true,
229+ shapedIcon: true,
230+ nonShapedIcon: false,
209 secondaryIconVisible: true,
231 secondaryIconVisible: true,
210 buttonRowVisible: true,
232 buttonRowVisible: true,
211 buttonTinted: true
233 buttonTinted: true
@@ -223,6 +245,8 @@ Row {
223 bodyVisible: false,
245 bodyVisible: false,
224 interactiveAreaEnabled: false,
246 interactiveAreaEnabled: false,
225 iconVisible: false,
247 iconVisible: false,
248+ shapedIcon: false,
249+ nonShapedIcon: false,
226 secondaryIconVisible: true,
250 secondaryIconVisible: true,
227 buttonRowVisible: false,
251 buttonRowVisible: false,
228 buttonTinted: false
252 buttonTinted: false
@@ -240,6 +264,8 @@ Row {
240 bodyVisible: false,
264 bodyVisible: false,
241 interactiveAreaEnabled: false,
265 interactiveAreaEnabled: false,
242 iconVisible: false,
266 iconVisible: false,
267+ shapedIcon: false,
268+ nonShapedIcon: false,
243 secondaryIconVisible: true,
269 secondaryIconVisible: true,
244 buttonRowVisible: false,
270 buttonRowVisible: false,
245 buttonTinted: false
271 buttonTinted: false
@@ -257,6 +283,8 @@ Row {
257 bodyVisible: true,
283 bodyVisible: true,
258 interactiveAreaEnabled: true,
284 interactiveAreaEnabled: true,
259 iconVisible: true,
285 iconVisible: true,
286+ shapedIcon: true,
287+ nonShapedIcon: false,
260 secondaryIconVisible: false,
288 secondaryIconVisible: false,
261 buttonRowVisible: false,
289 buttonRowVisible: false,
262 buttonTinted: false
290 buttonTinted: false
@@ -275,6 +303,8 @@ Row {
275 bodyVisible: true,
303 bodyVisible: true,
276 interactiveAreaEnabled: false,
304 interactiveAreaEnabled: false,
277 iconVisible: true,
305 iconVisible: true,
306+ shapedIcon: true,
307+ nonShapedIcon: false,
278 secondaryIconVisible: false,
308 secondaryIconVisible: false,
279 buttonRowVisible: true,
309 buttonRowVisible: true,
280 buttonTinted: false
310 buttonTinted: false
@@ -292,9 +322,31 @@ Row {
292 bodyVisible: true,
322 bodyVisible: true,
293 interactiveAreaEnabled: false,
323 interactiveAreaEnabled: false,
294 iconVisible: true,
324 iconVisible: true,
325+ shapedIcon: true,
326+ nonShapedIcon: false,
295 secondaryIconVisible: true,
327 secondaryIconVisible: true,
296 buttonRowVisible: false,
328 buttonRowVisible: false,
297 buttonTinted: false
329 buttonTinted: false
330+ },
331+ {
332+ tag: "Ephemeral notification with non-shaped icon",
333+ type: Notification.Ephemeral,
334+ hints: {"x-canonical-private-button-tint": "false",
335+ "x-canonical-non-shaped-icon": "true"},
336+ summary: "Contacts",
337+ body: "Synchronised contacts-database with cloud-storage.",
338+ icon: "../graphics/applicationIcons/contacts-app.png",
339+ secondaryIcon: "",
340+ actions: [],
341+ summaryVisible: true,
342+ bodyVisible: true,
343+ interactiveAreaEnabled: false,
344+ iconVisible: true,
345+ shapedIcon: false,
346+ nonShapedIcon: true,
347+ secondaryIconVisible: false,
348+ buttonRowVisible: false,
349+ buttonTinted: false
298 }
350 }
299 ]
351 ]
300 }
352 }
@@ -330,6 +382,8 @@ Row {
330 verify(notification !== undefined, "notification wasn't found");
382 verify(notification !== undefined, "notification wasn't found");
331
383
332 var icon = findChild(notification, "icon")
384 var icon = findChild(notification, "icon")
385+ var shapedIcon = findChild(notification, "shapedIcon")
386+ var nonShapedIcon = findChild(notification, "nonShapedIcon")
333 var interactiveArea = findChild(notification, "interactiveArea")
387 var interactiveArea = findChild(notification, "interactiveArea")
334 var secondaryIcon = findChild(notification, "secondaryIcon")
388 var secondaryIcon = findChild(notification, "secondaryIcon")
335 var summaryLabel = findChild(notification, "summaryLabel")
389 var summaryLabel = findChild(notification, "summaryLabel")
@@ -338,6 +392,8 @@ Row {
338 waitForRendering(buttonRow)
392 waitForRendering(buttonRow)
339
393
340 compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
394 compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
395+ compare(shapedIcon.visible, data.shapedIcon, "shaped-icon visibility is incorrect")
396+ compare(nonShapedIcon.visible, data.nonShapedIcon, "non-shaped-icon visibility is incorrect")
341 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
397 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
342
398
343 if(data.interactiveAreaEnabled) {
399 if(data.interactiveAreaEnabled) {