Merge lp:~stolowski/unity-api/filters-iface into lp:unity-api

Proposed by Paweł Stołowski
Status: Superseded
Proposed branch: lp:~stolowski/unity-api/filters-iface
Merge into: lp:unity-api
Diff against target: 1158 lines (+763/-49)
22 files modified
debian/changelog (+7/-0)
debian/control (+1/-0)
include/unity/shell/scopes/CMakeLists.txt (+1/-1)
include/unity/shell/scopes/FilterBaseInterface.h (+60/-0)
include/unity/shell/scopes/FiltersInterface.h (+74/-0)
include/unity/shell/scopes/NavigationInterface.h (+2/-0)
include/unity/shell/scopes/OptionSelectorFilterInterface.h (+67/-0)
include/unity/shell/scopes/OptionSelectorOptionsInterface.h (+66/-0)
include/unity/shell/scopes/ScopeInterface.h (+38/-22)
test/copyright/check_copyright.sh (+5/-0)
test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt (+7/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp (+2/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp (+51/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h (+40/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp (+57/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h (+45/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp (+25/-17)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h (+7/-6)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp (+53/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h (+36/-0)
test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp (+8/-0)
test/qmltest/unity/shell/scopes/tst_Scopes.qml (+111/-3)
To merge this branch: bzr merge lp:~stolowski/unity-api/filters-iface
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+252890@code.launchpad.net

This proposal has been superseded by a proposal from 2015-11-18.

Commit message

Base interfaces for filters.

Description of the change

Base interfaces for filters.

NOTE: Decided no to land yet till designs are closer to be finalized.

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :

I'd say we need to rename the id property to filterId, QML doesn't like people taking the id keyword

Q_PROPERTY(OptionSelectorOptionsInterface* options READ options) needs a changed signal, otherwise QML will complain when i bind it to a property

review: Needs Fixing
Revision history for this message
Paweł Stołowski (stolowski) wrote :

> I'd say we need to rename the id property to filterId, QML doesn't like people
> taking the id keyword
>
> Q_PROPERTY(OptionSelectorOptionsInterface* options READ options) needs a
> changed signal, otherwise QML will complain when i bind it to a property

Ok, done.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Actually i was wrong about the NOTIFY signal what it needed was a CONSTANT marker as do need it both of
 Q_PROPERTY(QString filterId READ filterId)
 Q_PROPERTY(QString filterType READ filterType)

Sorry i didn't realize before

review: Needs Fixing
Revision history for this message
Paweł Stołowski (stolowski) wrote :

> Actually i was wrong about the NOTIFY signal what it needed was a CONSTANT
> marker as do need it both of
> Q_PROPERTY(QString filterId READ filterId)
> Q_PROPERTY(QString filterType READ filterType)
>
> Sorry i didn't realize before

No problem, updated.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Also make filterType property be an enum instead of a string as discussed on IRC?

review: Needs Fixing
Revision history for this message
Paweł Stołowski (stolowski) wrote :

> Also make filterType property be an enum instead of a string as discussed on
> IRC?

Right.. thanks for catching it! Fixed.

Revision history for this message
Albert Astals Cid (aacid) wrote :

New a few more Verifier { } added to tst_Scopes.qml to verify the mocks you created are actually returning the stuff it should

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

The Verifiers have been added, can't remember anything else more that i wanted fixed nor can see on checking the code.

review: Approve
Revision history for this message
Albert Astals Cid (aacid) wrote :

Back to needs review since lots of things happened since may :D

Revision history for this message
Albert Astals Cid (aacid) wrote :

You forgot a
>>>>>>> MERGE-SOURCE
in the changelog file

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Should we remove the altNav* from here too?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
194. By Paweł Stołowski

Merged all-label-role

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
195. By Paweł Stołowski

Removed unused alt nav properties/methods

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
196. By Paweł Stołowski

Fully-qualified filterType property

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
197. By Paweł Stołowski

Merged trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good to me.

review: Approve
198. By Paweł Stołowski

Merged trunk

199. By Paweł Stołowski

Merged license-check

200. By Paweł Stołowski

Added title to filter base

201. By Paweł Stołowski

Method for resetting filters to defaults

202. By Paweł Stołowski

Merged trunk

203. By Paweł Stołowski

Merged trunk

204. By Paweł Stołowski

Merged trunk

205. By Paweł Stołowski

Merged trunk

206. By Paweł Stołowski

Merged trunk

207. By Paweł Stołowski

Bump

208. By Paweł Stołowski

Merged trunk

209. By Paweł Stołowski

Merged trunk

210. By Paweł Stołowski

Bump

211. By Paweł Stołowski

No changelog change:

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-11-02 11:23:43 +0000
+++ debian/changelog 2015-11-17 14:58:53 +0000
@@ -1,3 +1,10 @@
1unity-api (7.103+15.10.20150903-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Added Filters interface.
4 * Added allLabel role to the scopes NavigationInterface.
5
6 -- Pawel Stolowski <pawel.stolowski@canonical.com> Mon, 28 Sep 2015 11:16:45 +0200
7
1unity-api (7.102+16.04.20151102-0ubuntu1) xenial; urgency=medium8unity-api (7.102+16.04.20151102-0ubuntu1) xenial; urgency=medium
29
3 [ Nick Dedekind ]10 [ Nick Dedekind ]
411
=== modified file 'debian/control'
--- debian/control 2015-07-20 09:35:04 +0000
+++ debian/control 2015-11-17 14:58:53 +0000
@@ -4,6 +4,7 @@
4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5Build-Depends: cmake,5Build-Depends: cmake,
6 debhelper (>= 9),6 debhelper (>= 9),
7 devscripts,
7 doxygen,8 doxygen,
8# To allow cross-compiling to work, we append :native9# To allow cross-compiling to work, we append :native
9# to g++-4.9 so we don't try to run armhf g++10# to g++-4.9 so we don't try to run armhf g++
1011
=== modified file 'include/unity/shell/scopes/CMakeLists.txt'
--- include/unity/shell/scopes/CMakeLists.txt 2015-09-15 09:15:11 +0000
+++ include/unity/shell/scopes/CMakeLists.txt 2015-11-17 14:58:53 +0000
@@ -7,7 +7,7 @@
77
8set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)8set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
99
10set(VERSION 7)10set(VERSION 8)
11set(PKGCONFIG_NAME "unity-shell-scopes")11set(PKGCONFIG_NAME "unity-shell-scopes")
12set(PKGCONFIG_DESCRIPTION "Unity shell Scopes APIs")12set(PKGCONFIG_DESCRIPTION "Unity shell Scopes APIs")
13set(PKGCONFIG_REQUIRES "Qt5Core")13set(PKGCONFIG_REQUIRES "Qt5Core")
1414
=== added file 'include/unity/shell/scopes/FilterBaseInterface.h'
--- include/unity/shell/scopes/FilterBaseInterface.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/scopes/FilterBaseInterface.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_SCOPES_FILTERBASEINTERHACE_H
18#define UNITY_SHELL_SCOPES_FILTERBASEINTERHACE_H
19
20#include "FiltersInterface.h"
21#include <QObject>
22
23namespace unity
24{
25namespace shell
26{
27namespace scopes
28{
29
30class UNITY_API FilterBaseInterface : public QObject
31{
32 Q_OBJECT
33
34 public:
35
36 Q_PROPERTY(QString filterId READ filterId CONSTANT)
37 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
38 Q_PROPERTY(unity::shell::scopes::FiltersInterface::FilterType filterType READ filterType CONSTANT)
39
40 virtual QString filterId() const = 0;
41 virtual QString title() const = 0;
42 virtual FiltersInterface::FilterType filterType() const = 0;
43 virtual QString filterTag() const = 0;
44
45 Q_SIGNALS:
46 void titleChanged();
47
48 protected:
49 /// @cond
50 explicit FilterBaseInterface(QObject* parent = 0) : QObject(parent) {}
51 /// @endcond
52};
53
54}
55}
56}
57
58Q_DECLARE_METATYPE(unity::shell::scopes::FilterBaseInterface*)
59
60#endif
061
=== added file 'include/unity/shell/scopes/FiltersInterface.h'
--- include/unity/shell/scopes/FiltersInterface.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/scopes/FiltersInterface.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_SCOPES_FILTERSINTERFACE_H
18#define UNITY_SHELL_SCOPES_FILTERSINTERFACE_H
19
20#include <unity/SymbolExport.h>
21
22#include <QAbstractListModel>
23
24namespace unity
25{
26namespace shell
27{
28namespace scopes
29{
30
31class UNITY_API FiltersInterface : public QAbstractListModel
32{
33 Q_OBJECT
34
35 Q_ENUMS(Roles)
36 Q_ENUMS(FilterType)
37
38public:
39 enum Roles {
40 RoleFilterId = Qt::UserRole + 1,
41 RoleFilterType,
42 RoleFilter
43 };
44
45 enum FilterType {
46 Invalid,
47 OptionSelectorFilter,
48 RangeInputFilter
49 // TODO add remaining filters
50 };
51
52 QHash<int, QByteArray> roleNames() const override
53 {
54 QHash<int, QByteArray> roles;
55 roles[RoleFilterId] = "id";
56 roles[RoleFilterType] = "type";
57 roles[RoleFilter] = "filter";
58 return roles;
59 }
60
61protected:
62 /// @cond
63 explicit FiltersInterface(QObject* parent = 0) : QAbstractListModel(parent) {}
64 /// @endcond
65};
66
67}
68
69}
70}
71
72Q_DECLARE_METATYPE(unity::shell::scopes::FiltersInterface*)
73
74#endif
075
=== modified file 'include/unity/shell/scopes/NavigationInterface.h'
--- include/unity/shell/scopes/NavigationInterface.h 2014-08-04 13:58:53 +0000
+++ include/unity/shell/scopes/NavigationInterface.h 2015-11-17 14:58:53 +0000
@@ -94,6 +94,7 @@
94 enum Roles {94 enum Roles {
95 RoleNavigationId,95 RoleNavigationId,
96 RoleLabel,96 RoleLabel,
97 RoleAllLabel,
97 RoleHasChildren,98 RoleHasChildren,
98 RoleIsActive99 RoleIsActive
99 };100 };
@@ -113,6 +114,7 @@
113 QHash<int, QByteArray> roles;114 QHash<int, QByteArray> roles;
114 roles[RoleNavigationId] = "navigationId";115 roles[RoleNavigationId] = "navigationId";
115 roles[RoleLabel] = "label";116 roles[RoleLabel] = "label";
117 roles[RoleAllLabel] = "allLabel";
116 roles[RoleHasChildren] = "hasChildren";118 roles[RoleHasChildren] = "hasChildren";
117 roles[RoleIsActive] = "isActive";119 roles[RoleIsActive] = "isActive";
118 return roles;120 return roles;
119121
=== added file 'include/unity/shell/scopes/OptionSelectorFilterInterface.h'
--- include/unity/shell/scopes/OptionSelectorFilterInterface.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/scopes/OptionSelectorFilterInterface.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_SCOPES_OPTIONSELECTORFILTERINTERFACE_H
18#define UNITY_SHELL_SCOPES_OPTIONSELECTORFILTERINTERFACE_H
19
20#include <unity/SymbolExport.h>
21
22#include "FilterBaseInterface.h"
23#include "OptionSelectorOptionsInterface.h"
24
25namespace unity
26{
27namespace shell
28{
29namespace scopes
30{
31
32class UNITY_API OptionSelectorFilterInterface : public FilterBaseInterface
33{
34 Q_OBJECT
35
36public:
37 Q_PROPERTY(QString label READ label NOTIFY labelChanged)
38 Q_PROPERTY(bool multiSelect READ multiSelect NOTIFY multiSelectChanged)
39 Q_PROPERTY(unity::shell::scopes::OptionSelectorOptionsInterface* options READ options CONSTANT)
40
41 FiltersInterface::FilterType filterType() const override
42 {
43 return FiltersInterface::OptionSelectorFilter;
44 }
45
46 virtual QString label() const = 0;
47 virtual bool multiSelect() const = 0;
48 virtual OptionSelectorOptionsInterface* options() const = 0;
49
50Q_SIGNALS:
51 void labelChanged(const QString&);
52 void multiSelectChanged(bool);
53
54protected:
55 /// @cond
56 explicit OptionSelectorFilterInterface(QObject* parent = 0) : FilterBaseInterface(parent) {}
57 /// @endcond
58};
59
60}
61
62}
63}
64
65Q_DECLARE_METATYPE(unity::shell::scopes::OptionSelectorFilterInterface*)
66
67#endif
068
=== added file 'include/unity/shell/scopes/OptionSelectorOptionsInterface.h'
--- include/unity/shell/scopes/OptionSelectorOptionsInterface.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/scopes/OptionSelectorOptionsInterface.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_SCOPES_OPTIONSELECTOROPTIONSINTERFACE_H
18#define UNITY_SHELL_SCOPES_OPTIONSELECTOROPTIONSINTERFACE_H
19
20#include <unity/SymbolExport.h>
21#include <QAbstractListModel>
22
23namespace unity
24{
25namespace shell
26{
27namespace scopes
28{
29
30class UNITY_API OptionSelectorOptionsInterface : public QAbstractListModel
31{
32 Q_OBJECT
33
34 Q_ENUMS(OptionRoles)
35
36public:
37 enum Roles {
38 RoleOptionId = Qt::UserRole + 1,
39 RoleOptionLabel,
40 RoleOptionChecked
41 };
42
43 Q_INVOKABLE virtual void setChecked(int index, bool checked) = 0;
44
45 QHash<int, QByteArray> roleNames() const override
46 {
47 QHash<int, QByteArray> roles;
48 roles[RoleOptionId] = "id";
49 roles[RoleOptionLabel] = "label";
50 roles[RoleOptionChecked] = "checked";
51 return roles;
52 }
53
54protected:
55 /// @cond
56 explicit OptionSelectorOptionsInterface(QObject* parent = 0) : QAbstractListModel(parent) {}
57 /// @endcond
58};
59
60}
61}
62}
63
64Q_DECLARE_METATYPE(unity::shell::scopes::OptionSelectorOptionsInterface*)
65
66#endif
067
=== modified file 'include/unity/shell/scopes/ScopeInterface.h'
--- include/unity/shell/scopes/ScopeInterface.h 2015-09-15 09:15:11 +0000
+++ include/unity/shell/scopes/ScopeInterface.h 2015-11-17 14:58:53 +0000
@@ -33,6 +33,8 @@
33class PreviewStackInterface;33class PreviewStackInterface;
34class NavigationInterface;34class NavigationInterface;
35class SettingsModelInterface;35class SettingsModelInterface;
36class FiltersInterface;
37class FilterBaseInterface;
3638
37/**39/**
38 * @brief Object representing scope instance, which exposes model(s) with results.40 * @brief Object representing scope instance, which exposes model(s) with results.
@@ -93,6 +95,11 @@
93 Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)95 Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)
9496
95 /**97 /**
98 * @brief
99 */
100 Q_PROPERTY(unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter READ primaryNavigationFilter NOTIFY primaryNavigationFilterChanged)
101
102 /**
96 * @brief Current search query.103 * @brief Current search query.
97 *104 *
98 * Writing to this property issues a new search to the scope.105 * Writing to this property issues a new search to the scope.
@@ -129,16 +136,6 @@
129 Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)136 Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)
130137
131 /**138 /**
132 * @brief String specifying currently selected sort order
133 */
134 Q_PROPERTY(QString currentAltNavigationId READ currentAltNavigationId NOTIFY currentAltNavigationIdChanged)
135
136 /**
137 * @brief Boolean specifying whether current query has sort order.
138 */
139 Q_PROPERTY(bool hasAltNavigation READ hasAltNavigation NOTIFY hasAltNavigationChanged)
140
141 /**
142 * @brief VariantMap with customization properties139 * @brief VariantMap with customization properties
143 */140 */
144 Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)141 Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)
@@ -148,6 +145,21 @@
148 */145 */
149 Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)146 Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)
150147
148 /**
149 * @brief Filters model for the scope.
150 */
151 Q_PROPERTY(unity::shell::scopes::FiltersInterface* filters READ filters NOTIFY filtersChanged)
152
153 /**
154 * @brief Label for the currently active top level navigation (department or primary filter).
155 */
156 Q_PROPERTY(QString primaryNavigationTag READ primaryNavigationTag NOTIFY primaryNavigationTagChanged)
157
158 /**
159 * @brief The number of currently selected filters.
160 */
161 Q_PROPERTY(int activeFiltersCount READ activeFiltersCount NOTIFY activeFiltersCountChanged)
162
151protected:163protected:
152 /// @cond164 /// @cond
153 explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }165 explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
@@ -176,16 +188,18 @@
176 virtual bool favorite() const = 0;188 virtual bool favorite() const = 0;
177 virtual CategoriesInterface* categories() const = 0;189 virtual CategoriesInterface* categories() const = 0;
178 virtual SettingsModelInterface* settings() const = 0;190 virtual SettingsModelInterface* settings() const = 0;
191 virtual FilterBaseInterface* primaryNavigationFilter() const = 0;
179 virtual QString searchQuery() const = 0;192 virtual QString searchQuery() const = 0;
180 virtual QString noResultsHint() const = 0;193 virtual QString noResultsHint() const = 0;
181 virtual QString formFactor() const = 0;194 virtual QString formFactor() const = 0;
182 virtual bool isActive() const = 0;195 virtual bool isActive() const = 0;
183 virtual QString currentNavigationId() const = 0;196 virtual QString currentNavigationId() const = 0;
184 virtual bool hasNavigation() const = 0;197 virtual bool hasNavigation() const = 0;
185 virtual QString currentAltNavigationId() const = 0;
186 virtual bool hasAltNavigation() const = 0;
187 virtual Status status() const = 0;198 virtual Status status() const = 0;
188 virtual QVariantMap customizations() const = 0;199 virtual QVariantMap customizations() const = 0;
200 virtual FiltersInterface* filters() const = 0;
201 virtual QString primaryNavigationTag() const = 0;
202 virtual int activeFiltersCount() const = 0;
189203
190 /* setters */204 /* setters */
191 virtual void setSearchQuery(const QString& search_query) = 0;205 virtual void setSearchQuery(const QString& search_query) = 0;
@@ -224,14 +238,9 @@
224 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;238 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;
225239
226 /**240 /**
227 * @brief Get a NavigationInterface instance for the passed altNavigationId.241 * @brief Request change to the current navigation id.
228 */242 */
229 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& altNavigationId) = 0;243 Q_INVOKABLE virtual void setNavigationState(QString const& navId) = 0;
230
231 /**
232 * @brief Request change to the current navigation or altNavigation id.
233 */
234 Q_INVOKABLE virtual void setNavigationState(QString const& navId, bool altNavigation) = 0;
235244
236 /**245 /**
237 * @brief Execute canned query.246 * @brief Execute canned query.
@@ -243,6 +252,11 @@
243 */252 */
244 Q_INVOKABLE virtual void refresh() = 0;253 Q_INVOKABLE virtual void refresh() = 0;
245254
255 /**
256 * @brief Reset primary navigation filter and its tag in the search bar.
257 */
258 Q_INVOKABLE virtual void resetPrimaryNavigationTag() = 0;
259
246Q_SIGNALS:260Q_SIGNALS:
247 // @cond261 // @cond
248 void idChanged();262 void idChanged();
@@ -261,11 +275,13 @@
261 void isActiveChanged();275 void isActiveChanged();
262 void hasNavigationChanged();276 void hasNavigationChanged();
263 void currentNavigationIdChanged();277 void currentNavigationIdChanged();
264 void hasAltNavigationChanged();
265 void currentAltNavigationIdChanged();
266 void customizationsChanged();278 void customizationsChanged();
267 void statusChanged();279 void statusChanged();
268 void detailsChanged();280 void detailsChanged();
281 void filtersChanged();
282 void primaryNavigationTagChanged();
283 void activeFiltersCountChanged();
284 void primaryNavigationFilterChanged();
269 // @endcond285 // @endcond
270286
271 // signals triggered by activate(..) or preview(..) requests.287 // signals triggered by activate(..) or preview(..) requests.
272288
=== modified file 'test/copyright/check_copyright.sh'
--- test/copyright/check_copyright.sh 2013-06-26 23:47:34 +0000
+++ test/copyright/check_copyright.sh 2015-11-17 14:58:53 +0000
@@ -33,6 +33,11 @@
33[ $# -lt 1 ] && usage33[ $# -lt 1 ] && usage
34[ $# -gt 2 ] && usage34[ $# -gt 2 ] && usage
3535
36
37# TODO: Temporary hack to work around broken licensecheck on xenial. Remove this once that is fixed.
38distro=$(lsb_release -c -s)
39[ "$distro" = "xenial" ] && exit 0
40
36ignore_pat="\\.sci$|CMakeFiles"41ignore_pat="\\.sci$|CMakeFiles"
3742
38#43#
3944
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt'
--- test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2014-07-25 15:17:40 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2015-11-17 14:58:53 +0000
@@ -20,7 +20,14 @@
20 Mocks/MockScope.cpp20 Mocks/MockScope.cpp
21 Mocks/MockScopes.cpp21 Mocks/MockScopes.cpp
22 Mocks/MockSettingsModel.cpp22 Mocks/MockSettingsModel.cpp
23 Mocks/MockFiltersModel.cpp
24 Mocks/MockOptionSelectorFilter.cpp
25 Mocks/MockSelectorOptions.cpp
23 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/CategoriesInterface.h26 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/CategoriesInterface.h
27 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/FiltersInterface.h
28 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/FilterBaseInterface.h
29 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/OptionSelectorFilterInterface.h
30 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/OptionSelectorOptionsInterface.h
24 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/NavigationInterface.h31 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/NavigationInterface.h
25 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h32 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h
26 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h33 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h
2734
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp 2014-08-04 13:58:53 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp 2015-11-17 14:58:53 +0000
@@ -79,6 +79,8 @@
79 return "child";79 return "child";
80 case RoleLabel:80 case RoleLabel:
81 return "Child Clothes";81 return "Child Clothes";
82 case RoleAllLabel:
83 return "All Child Clothes";
82 case RoleHasChildren:84 case RoleHasChildren:
83 return true;85 return true;
84 case RoleIsActive:86 case RoleIsActive:
8587
=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp 1970-01-01 00:00:00 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp 2015-11-17 14:58:53 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2015 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 "MockFiltersModel.h"
18#include "MockOptionSelectorFilter.h"
19
20MockFiltersModel::MockFiltersModel(unity::shell::scopes::ScopeInterface *parent)
21 : unity::shell::scopes::FiltersInterface(parent)
22{
23 MockOptionSelectorFilter *f = new MockOptionSelectorFilter("f1", "Filter 1", false, this);
24 m_filters.append(f); // owned by parent, so no need to manage it
25}
26
27QVariant MockFiltersModel::data(const QModelIndex& index, int role) const
28{
29 if (index.row() >= 0 && index.row() < m_filters.count())
30 {
31 auto filter = m_filters.at(index.row());
32 switch (role)
33 {
34 case Qt::DisplayRole:
35 case unity::shell::scopes::FiltersInterface::RoleFilterId:
36 return QVariant(filter->filterId());
37 case unity::shell::scopes::FiltersInterface::RoleFilterType:
38 return QVariant(static_cast<int>(filter->filterType()));
39 case unity::shell::scopes::FiltersInterface::RoleFilter:
40 return QVariant::fromValue(filter);
41 default:
42 return QVariant();
43 }
44 }
45 return QVariant();
46}
47
48int MockFiltersModel::rowCount(const QModelIndex&) const
49{
50 return m_filters.count();
51}
052
=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h 1970-01-01 00:00:00 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2015 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 MOCKFILTERS_H
18#define MOCKFILTERS_H
19
20#include <unity/shell/scopes/FiltersInterface.h>
21#include <unity/shell/scopes/FilterBaseInterface.h>
22#include <unity/shell/scopes/ScopeInterface.h>
23
24#include <QList>
25
26class MockFiltersModel : public unity::shell::scopes::FiltersInterface
27{
28 Q_OBJECT
29
30public:
31 explicit MockFiltersModel(unity::shell::scopes::ScopeInterface *parent = 0);
32
33 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
34 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
35
36private:
37 QList<unity::shell::scopes::FilterBaseInterface*> m_filters;
38};
39
40#endif // MOCKDEPARTMENT_H
041
=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp 1970-01-01 00:00:00 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp 2015-11-17 14:58:53 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright (C) 2015 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 "MockOptionSelectorFilter.h"
18
19MockOptionSelectorFilter::MockOptionSelectorFilter(const QString &id, const QString &title, const QString &label, bool multi, QObject *parent)
20 : unity::shell::scopes::OptionSelectorFilterInterface(parent),
21 m_id(id),
22 m_title(title),
23 m_label(label),
24 m_multiSelect(multi),
25 m_options(new MockSelectorOptions(2, this))
26{
27}
28
29QString MockOptionSelectorFilter::filterId() const
30{
31 return m_id;
32}
33
34QString MockOptionSelectorFilter::title() const
35{
36 return m_title;
37}
38
39QString MockOptionSelectorFilter::label() const
40{
41 return m_label;
42}
43
44bool MockOptionSelectorFilter::multiSelect() const
45{
46 return m_multiSelect;
47}
48
49unity::shell::scopes::OptionSelectorOptionsInterface* MockOptionSelectorFilter::options() const
50{
51 return m_options;
52}
53
54QString MockOptionSelectorFilter::filterTag() const
55{
56 return "";
57}
058
=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h 1970-01-01 00:00:00 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2015 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 MOCKOPTIONSELECTORFILTER_H
18#define MOCKOPTIONSELECTORFILTER_H
19
20#include <unity/shell/scopes/OptionSelectorFilterInterface.h>
21#include <unity/shell/scopes/FiltersInterface.h>
22#include "MockSelectorOptions.h"
23
24class MockOptionSelectorFilter : public unity::shell::scopes::OptionSelectorFilterInterface
25{
26 Q_OBJECT
27
28public:
29 MockOptionSelectorFilter(const QString &id, const QString& title, const QString &label, bool multi, QObject *parent = 0);
30 QString filterId() const override;
31 QString title() const override;
32 QString label() const override;
33 bool multiSelect() const override;
34 unity::shell::scopes::OptionSelectorOptionsInterface* options() const override;
35 QString filterTag() const override;
36
37private:
38 QString m_id;
39 QString m_title;
40 QString m_label;
41 bool m_multiSelect;
42 MockSelectorOptions *m_options;
43};
44
45#endif
046
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2015-09-15 09:15:11 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2015-11-17 14:58:53 +0000
@@ -19,6 +19,7 @@
19#include "MockPreviewStack.h"19#include "MockPreviewStack.h"
20#include "MockDepartment.h"20#include "MockDepartment.h"
21#include "MockSettingsModel.h"21#include "MockSettingsModel.h"
22#include "MockFiltersModel.h"
2223
23MockScope::MockScope(QObject* parent) : MockScope(QString(), QString(), parent)24MockScope::MockScope(QObject* parent) : MockScope(QString(), QString(), parent)
24{25{
@@ -34,6 +35,7 @@
34 , m_previewRendererName("preview-generic")35 , m_previewRendererName("preview-generic")
35 , m_categories(new MockCategories(20, this))36 , m_categories(new MockCategories(20, this))
36 , m_settings(new MockSettingsModel(this))37 , m_settings(new MockSettingsModel(this))
38 , m_filters(new MockFiltersModel(this))
37{39{
38}40}
3941
@@ -69,10 +71,6 @@
69 return m_currentDepartmentId;71 return m_currentDepartmentId;
70}72}
7173
72QString MockScope::currentAltNavigationId() const {
73 return m_currentAltDepartmentId;
74}
75
76bool MockScope::searchInProgress() const {74bool MockScope::searchInProgress() const {
77 return m_searching;75 return m_searching;
78}76}
@@ -85,6 +83,14 @@
85 return m_settings;83 return m_settings;
86}84}
8785
86unity::shell::scopes::FiltersInterface* MockScope::filters() const {
87 return m_filters;
88}
89
90unity::shell::scopes::FilterBaseInterface* MockScope::primaryNavigationFilter() const {
91 return nullptr;
92}
93
88QString MockScope::noResultsHint() const {94QString MockScope::noResultsHint() const {
89 return m_noResultsHint;95 return m_noResultsHint;
90}96}
@@ -105,10 +111,6 @@
105 return m_hasNavigation;111 return m_hasNavigation;
106}112}
107113
108bool MockScope::hasAltNavigation() const {
109 return m_hasAltNavigation;
110}
111
112QVariantMap MockScope::customizations() const {114QVariantMap MockScope::customizations() const {
113 return m_customizations;115 return m_customizations;
114}116}
@@ -182,17 +184,9 @@
182 return new MockDepartment();184 return new MockDepartment();
183}185}
184186
185unity::shell::scopes::NavigationInterface* MockScope::getAltNavigation(QString const& navigationId)187void MockScope::setNavigationState(QString const& navId)
186{
187 Q_UNUSED(navigationId);
188
189 return new MockDepartment();
190}
191
192void MockScope::setNavigationState(QString const& navId, bool altNavigation)
193{188{
194 Q_UNUSED(navId);189 Q_UNUSED(navId);
195 Q_UNUSED(altNavigation);
196}190}
197191
198void MockScope::cancelActivation()192void MockScope::cancelActivation()
@@ -212,3 +206,17 @@
212void MockScope::refresh()206void MockScope::refresh()
213{207{
214}208}
209
210QString MockScope::primaryNavigationTag() const
211{
212 return "";
213}
214
215void MockScope::resetPrimaryNavigationTag()
216{
217}
218
219int MockScope::activeFiltersCount() const
220{
221 return 0;
222}
215223
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2015-09-15 09:15:11 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2015-11-17 14:58:53 +0000
@@ -38,16 +38,18 @@
38 bool searchInProgress() const override;38 bool searchInProgress() const override;
39 unity::shell::scopes::CategoriesInterface* categories() const override;39 unity::shell::scopes::CategoriesInterface* categories() const override;
40 unity::shell::scopes::SettingsModelInterface* settings() const override;40 unity::shell::scopes::SettingsModelInterface* settings() const override;
41 unity::shell::scopes::FiltersInterface* filters() const override;
42 unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter() const override;
41 QString searchQuery() const override;43 QString searchQuery() const override;
42 QString noResultsHint() const override;44 QString noResultsHint() const override;
43 QString formFactor() const override;45 QString formFactor() const override;
44 bool isActive() const override;46 bool isActive() const override;
45 bool hasNavigation() const override;47 bool hasNavigation() const override;
46 QString currentNavigationId() const override;48 QString currentNavigationId() const override;
47 bool hasAltNavigation() const override;
48 QString currentAltNavigationId() const override;
49 QVariantMap customizations() const override;49 QVariantMap customizations() const override;
50 Status status() const override;50 Status status() const override;
51 QString primaryNavigationTag() const override;
52 int activeFiltersCount() const override;
5153
52 /* setters */54 /* setters */
53 void setName(const QString& name);55 void setName(const QString& name);
@@ -62,10 +64,10 @@
62 Q_INVOKABLE void cancelActivation() override;64 Q_INVOKABLE void cancelActivation() override;
63 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;65 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
64 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& departmentId) override;66 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& departmentId) override;
65 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& departmentId) override;67 Q_INVOKABLE void setNavigationState(QString const& navId) override;
66 Q_INVOKABLE void setNavigationState(QString const& navId, bool altNavigation) override;
67 Q_INVOKABLE void performQuery(QString const& cannedQuery) override;68 Q_INVOKABLE void performQuery(QString const& cannedQuery) override;
68 Q_INVOKABLE void refresh() override;69 Q_INVOKABLE void refresh() override;
70 Q_INVOKABLE void resetPrimaryNavigationTag() override;
6971
70protected:72protected:
71 QString m_id;73 QString m_id;
@@ -76,18 +78,17 @@
76 QString m_noResultsHint;78 QString m_noResultsHint;
77 QString m_formFactor;79 QString m_formFactor;
78 QString m_currentDepartmentId;80 QString m_currentDepartmentId;
79 QString m_currentAltDepartmentId;
80 bool m_favorite;81 bool m_favorite;
81 bool m_searching;82 bool m_searching;
82 bool m_isActive;83 bool m_isActive;
83 bool m_hasNavigation;84 bool m_hasNavigation;
84 bool m_hasAltNavigation;
85 QVariantMap m_customizations;85 QVariantMap m_customizations;
8686
87 QString m_previewRendererName;87 QString m_previewRendererName;
8888
89 unity::shell::scopes::CategoriesInterface* m_categories;89 unity::shell::scopes::CategoriesInterface* m_categories;
90 unity::shell::scopes::SettingsModelInterface* m_settings;90 unity::shell::scopes::SettingsModelInterface* m_settings;
91 unity::shell::scopes::FiltersInterface* m_filters;
91};92};
9293
93#endif94#endif
9495
=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp 1970-01-01 00:00:00 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp 2015-11-17 14:58:53 +0000
@@ -0,0 +1,53 @@
1/*
2 * Copyright (C) 2015 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 "MockSelectorOptions.h"
18
19MockSelectorOptions::MockSelectorOptions(int num, QObject *parent)
20 : unity::shell::scopes::OptionSelectorOptionsInterface(parent),
21 m_numOfOptions(num)
22{
23}
24
25QVariant MockSelectorOptions::data(const QModelIndex& index, int role) const
26{
27 if (index.row() >= 0 && index.row() < m_numOfOptions)
28 {
29 switch (role)
30 {
31 case unity::shell::scopes::OptionSelectorOptionsInterface::RoleOptionId:
32 return QVariant(QString("option") + QString::number(index.row()));
33 case Qt::DisplayRole:
34 case unity::shell::scopes::OptionSelectorOptionsInterface::RoleOptionLabel:
35 return QVariant(QString("Option") + QString::number(index.row()));
36 case unity::shell::scopes::OptionSelectorOptionsInterface::RoleOptionChecked:
37 return QVariant(false);
38 default:
39 return QVariant();
40 }
41 }
42 return QVariant();
43}
44
45int MockSelectorOptions::rowCount(const QModelIndex&) const
46{
47 return m_numOfOptions;
48}
49
50void MockSelectorOptions::setChecked(int, bool)
51{
52 qFatal("Using un-implemented setChecked() method");
53}
054
=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h 1970-01-01 00:00:00 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h 2015-11-17 14:58:53 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2015 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 MOCKOPTIONSELECTOROPTIONS_H
18#define MOCKOPTIONSELECTOROPTIONS_H
19
20#include <unity/shell/scopes/OptionSelectorOptionsInterface.h>
21
22class MockSelectorOptions : public unity::shell::scopes::OptionSelectorOptionsInterface
23{
24 Q_OBJECT
25
26public:
27 MockSelectorOptions(int num = 2, QObject *parent = 0);
28 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
29 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
30 void setChecked(int index, bool checked) override;
31
32private:
33 int m_numOfOptions;
34};
35
36#endif
037
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp'
--- test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2014-07-25 15:17:40 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2015-11-17 14:58:53 +0000
@@ -26,6 +26,10 @@
26#include "PreviewWidgetModelInterface.h"26#include "PreviewWidgetModelInterface.h"
27#include "PreviewStackInterface.h"27#include "PreviewStackInterface.h"
28#include "SettingsModelInterface.h"28#include "SettingsModelInterface.h"
29#include "FiltersInterface.h"
30#include "FilterBaseInterface.h"
31#include "OptionSelectorOptionsInterface.h"
32#include "OptionSelectorFilterInterface.h"
29#include "Mocks/MockScopes.h"33#include "Mocks/MockScopes.h"
30#include "Mocks/MockScope.h"34#include "Mocks/MockScope.h"
3135
@@ -40,4 +44,8 @@
40 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");44 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
41 qmlRegisterUncreatableType<unity::shell::scopes::PreviewStackInterface>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");45 qmlRegisterUncreatableType<unity::shell::scopes::PreviewStackInterface>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
42 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create new Settings in QML. Get them from Scope instance.");46 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create new Settings in QML. Get them from Scope instance.");
47 qmlRegisterUncreatableType<unity::shell::scopes::FilterBaseInterface>(uri, 0, 2, "FilterBase", "Can't create new Filter in QML. Get them from Filters instance.");
48 qmlRegisterUncreatableType<unity::shell::scopes::FiltersInterface>(uri, 0, 2, "Filters", "Can't create new Filters in QML. Get them from Scope instance.");
49 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create new OptionSelectorOptions in QML. Get them from OptionSelectorFilter instance.");
50 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorFilterInterface>(uri, 0, 2, "OptionSelectorFilter", "Can't create new OptionSelectorFilter in QML. Get them from Scope instance.");
43}51}
4452
=== modified file 'test/qmltest/unity/shell/scopes/tst_Scopes.qml'
--- test/qmltest/unity/shell/scopes/tst_Scopes.qml 2015-09-15 09:15:11 +0000
+++ test/qmltest/unity/shell/scopes/tst_Scopes.qml 2015-11-17 14:58:53 +0000
@@ -122,14 +122,13 @@
122 { tag: "Item.properties[favorite]", constant: "favorite", type: "boolean" },122 { tag: "Item.properties[favorite]", constant: "favorite", type: "boolean" },
123 { tag: "Item.properties[shortcut]", constant: "shortcut", type: "string" },123 { tag: "Item.properties[shortcut]", constant: "shortcut", type: "string" },
124 { tag: "Item.properties[categories]", constant: "categories", type: "object" },124 { tag: "Item.properties[categories]", constant: "categories", type: "object" },
125 { tag: "Item.properties[filters]", constant: "filters", type: "object" },
125 { tag: "Item.properties[searchQuery]", constant: "searchQuery", type: "string" },126 { tag: "Item.properties[searchQuery]", constant: "searchQuery", type: "string" },
126 { tag: "Item.properties[noResultsHint]", constant: "noResultsHint", type: "string" },127 { tag: "Item.properties[noResultsHint]", constant: "noResultsHint", type: "string" },
127 { tag: "Item.properties[formFactor]", constant: "formFactor", type: "string" },128 { tag: "Item.properties[formFactor]", constant: "formFactor", type: "string" },
128 { tag: "Item.properties[isActive]", constant: "isActive", type: "boolean" },129 { tag: "Item.properties[isActive]", constant: "isActive", type: "boolean" },
129 { tag: "Item.properties[currentNavigationId]", constant: "currentNavigationId", type: "string" },130 { tag: "Item.properties[currentNavigationId]", constant: "currentNavigationId", type: "string" },
130 { tag: "Item.properties[hasNavigation]", constant: "hasNavigation", type: "boolean" },131 { tag: "Item.properties[hasNavigation]", constant: "hasNavigation", type: "boolean" },
131 { tag: "Item.properties[currentAltNavigationId]", constant: "currentAltNavigationId", type: "string" },
132 { tag: "Item.properties[hasAltNavigation]", constant: "hasAltNavigation", type: "boolean" },
133 { tag: "Item.properties[customizations]", constant: "customizations", type: "object" },132 { tag: "Item.properties[customizations]", constant: "customizations", type: "object" },
134 { tag: "Item.properties[status]", constant: "status", type: "number" }133 { tag: "Item.properties[status]", constant: "status", type: "number" }
135 ];134 ];
@@ -156,7 +155,6 @@
156 { tag: "Model.methods[performQuery]", method: "performQuery" },155 { tag: "Model.methods[performQuery]", method: "performQuery" },
157 { tag: "Model.methods[refresh]", method: "refresh" },156 { tag: "Model.methods[refresh]", method: "refresh" },
158 { tag: "Model.methods[getNavigation]", method: "getNavigation" },157 { tag: "Model.methods[getNavigation]", method: "getNavigation" },
159 { tag: "Model.methods[getAltNavigation]", method: "getAltNavigation" },
160 { tag: "Model.methods[setNavigationState]", method: "setNavigationState" },158 { tag: "Model.methods[setNavigationState]", method: "setNavigationState" },
161 ];159 ];
162 }160 }
@@ -169,6 +167,116 @@
169 }167 }
170168
171 Verifier {169 Verifier {
170 id: filtersVerifier
171
172 Repeater {
173 id: filtersRepeater
174 model: root.scope.filters
175 delegate: Item {
176 property var roles: model
177 }
178 }
179
180 function test_filters(data) {
181 object = filtersRepeater.model;
182 name = "Filters";
183 verifyData(data);
184 }
185
186 function test_filters_data() {
187 return [
188 { tag: "Filters[object]", type: "object" },
189 { tag: "Filters[FiltersInterface]", type: "unity::shell::scopes::FiltersInterface" },
190 ];
191 }
192
193 function test_filters_roles(data) {
194 object = filtersRepeater.itemAt(0).roles;
195 name = "Filters";
196 verifyData(data);
197 }
198
199 function test_filters_roles_data() {
200 return [
201 { tag: "Model.roles[id]", role: "id", type: "string" },
202 { tag: "Model.roles[type]", role: "type", type: "number" },
203 { tag: "Model.roles[filter]", role: "filter", type: "unity::shell::scopes::FilterBaseInterface" },
204 ];
205 }
206 }
207
208 Verifier {
209 id: optionSelectorFilterVerifier
210
211 function test_option_selector_filter(data) {
212 object = filtersRepeater.itemAt(0).roles.filter;
213 name = "Filter";
214 verifyData(data);
215 }
216
217 function test_option_selector_filter_data() {
218 return [
219 { tag: "Filter[object]", type: "object" },
220 { tag: "Filter[OptionSelectorFilterInterface]", type: "unity::shell::scopes::OptionSelectorFilterInterface" },
221 ];
222 }
223
224 function test_option_selector_filter_properties_data() {
225 return [
226 { tag: "Filter.properties[filterId]", constant: "filterId", type: "string" },
227 { tag: "Filter.properties[label]", constant: "label", type: "string" },
228 { tag: "Filter.properties[multiSelect]", constant: "multiSelect", type: "boolean" },
229 { tag: "Filter.properties[options]", constant: "options", type: "object" },
230 ];
231 }
232
233 function test_option_selector_filter_properties(data) {
234 object = filtersRepeater.itemAt(0).roles.filter;
235 name = "Filter";
236 verifyData(data);
237 }
238
239 function test_options_data() {
240 return [
241 { tag: "Options[object]", type: "object" },
242 { tag: "Options[OptionSelectorOptionsInterface]", type: "unity::shell::scopes::OptionSelectorOptionsInterface" },
243 ];
244 }
245
246 function test_options(data) {
247 object = filtersRepeater.itemAt(0).roles.filter.options;
248 name = "Options";
249 verifyData(data);
250 }
251 }
252
253 Verifier {
254 id: optionSelectorFilterOptionsVerifier
255
256 Repeater {
257 id: optionsRepeater
258 model: filtersRepeater.count > 0 ? filtersRepeater.itemAt(0).roles.filter.options : undefined
259 delegate: Item {
260 property var roles: model
261 }
262 }
263
264 function test_option_selector_filter_options_roles_data() {
265 return [
266 { tag: "Model.roles[id]", role: "id", type: "string" },
267 { tag: "Model.roles[label]", role: "label", type: "string" },
268 { tag: "Model.roles[checked]", role: "checked", type: "boolean" },
269 ];
270 }
271
272 function test_option_selector_filter_options_roles(data) {
273 object = optionsRepeater.itemAt(0).roles;
274 name = "Options";
275 verifyData(data);
276 }
277 }
278
279 Verifier {
172 id: categoriesVerifier280 id: categoriesVerifier
173281
174 Repeater {282 Repeater {

Subscribers

People subscribed via source and target branches

to all changes: