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

Proposed by Paweł Stołowski
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 208
Merged at revision: 214
Proposed branch: lp:~stolowski/unity-api/filters-iface
Merge into: lp:unity-api
Prerequisite: lp:~stolowski/unity-api/license-check
Diff against target: 1125 lines (+760/-49)
19 files modified
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 (+43/-22)
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 (+29/-17)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h (+8/-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
Unity8 CI Bot continuous-integration Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+277807@code.launchpad.net

This proposal supersedes a proposal from 2015-03-13.

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

> 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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

> 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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

> 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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

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

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Should we remove the altNav* from here too?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Looks good to me.

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

Method for resetting filters to defaults

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

Merged trunk

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

Merged trunk

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

Merged trunk

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

Merged trunk

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

Merged trunk

207. By Paweł Stołowski

Bump

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Approve (continuous-integration)
208. 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
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:208
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-1-ci/24/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/597
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/620
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/638
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/638
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/634
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/634/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/634
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/634/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/634
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/634/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/634
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/634/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/634
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/634/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/634
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/634/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-1-ci/24/rebuild

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

Looks good to me.

review: Approve
209. By Paweł Stołowski

Merged trunk

210. By Paweł Stołowski

Bump

211. By Paweł Stołowski

No changelog change:

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/unity/shell/scopes/CMakeLists.txt'
2--- include/unity/shell/scopes/CMakeLists.txt 2016-02-18 15:46:46 +0000
3+++ include/unity/shell/scopes/CMakeLists.txt 2016-03-11 12:01:26 +0000
4@@ -7,7 +7,7 @@
5
6 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
7
8-set(VERSION 10)
9+set(VERSION 11)
10 set(PKGCONFIG_NAME "unity-shell-scopes")
11 set(PKGCONFIG_DESCRIPTION "Unity shell Scopes APIs")
12 set(PKGCONFIG_REQUIRES "Qt5Core")
13
14=== added file 'include/unity/shell/scopes/FilterBaseInterface.h'
15--- include/unity/shell/scopes/FilterBaseInterface.h 1970-01-01 00:00:00 +0000
16+++ include/unity/shell/scopes/FilterBaseInterface.h 2016-03-11 12:01:26 +0000
17@@ -0,0 +1,60 @@
18+/*
19+ * Copyright (C) 2015 Canonical, Ltd.
20+ *
21+ * This program is free software; you can redistribute it and/or modify
22+ * it under the terms of the GNU General Public License as published by
23+ * the Free Software Foundation; version 3.
24+ *
25+ * This program is distributed in the hope that it will be useful,
26+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
27+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+ * GNU General Public License for more details.
29+ *
30+ * You should have received a copy of the GNU General Public License
31+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
32+ */
33+
34+#ifndef UNITY_SHELL_SCOPES_FILTERBASEINTERHACE_H
35+#define UNITY_SHELL_SCOPES_FILTERBASEINTERHACE_H
36+
37+#include "FiltersInterface.h"
38+#include <QObject>
39+
40+namespace unity
41+{
42+namespace shell
43+{
44+namespace scopes
45+{
46+
47+class UNITY_API FilterBaseInterface : public QObject
48+{
49+ Q_OBJECT
50+
51+ public:
52+
53+ Q_PROPERTY(QString filterId READ filterId CONSTANT)
54+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
55+ Q_PROPERTY(unity::shell::scopes::FiltersInterface::FilterType filterType READ filterType CONSTANT)
56+
57+ virtual QString filterId() const = 0;
58+ virtual QString title() const = 0;
59+ virtual FiltersInterface::FilterType filterType() const = 0;
60+ virtual QString filterTag() const = 0;
61+
62+ Q_SIGNALS:
63+ void titleChanged();
64+
65+ protected:
66+ /// @cond
67+ explicit FilterBaseInterface(QObject* parent = 0) : QObject(parent) {}
68+ /// @endcond
69+};
70+
71+}
72+}
73+}
74+
75+Q_DECLARE_METATYPE(unity::shell::scopes::FilterBaseInterface*)
76+
77+#endif
78
79=== added file 'include/unity/shell/scopes/FiltersInterface.h'
80--- include/unity/shell/scopes/FiltersInterface.h 1970-01-01 00:00:00 +0000
81+++ include/unity/shell/scopes/FiltersInterface.h 2016-03-11 12:01:26 +0000
82@@ -0,0 +1,74 @@
83+/*
84+ * Copyright (C) 2015 Canonical, Ltd.
85+ *
86+ * This program is free software; you can redistribute it and/or modify
87+ * it under the terms of the GNU General Public License as published by
88+ * the Free Software Foundation; version 3.
89+ *
90+ * This program is distributed in the hope that it will be useful,
91+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
92+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+ * GNU General Public License for more details.
94+ *
95+ * You should have received a copy of the GNU General Public License
96+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
97+ */
98+
99+#ifndef UNITY_SHELL_SCOPES_FILTERSINTERFACE_H
100+#define UNITY_SHELL_SCOPES_FILTERSINTERFACE_H
101+
102+#include <unity/SymbolExport.h>
103+
104+#include <QAbstractListModel>
105+
106+namespace unity
107+{
108+namespace shell
109+{
110+namespace scopes
111+{
112+
113+class UNITY_API FiltersInterface : public QAbstractListModel
114+{
115+ Q_OBJECT
116+
117+ Q_ENUMS(Roles)
118+ Q_ENUMS(FilterType)
119+
120+public:
121+ enum Roles {
122+ RoleFilterId = Qt::UserRole + 1,
123+ RoleFilterType,
124+ RoleFilter
125+ };
126+
127+ enum FilterType {
128+ Invalid,
129+ OptionSelectorFilter,
130+ RangeInputFilter
131+ // TODO add remaining filters
132+ };
133+
134+ QHash<int, QByteArray> roleNames() const override
135+ {
136+ QHash<int, QByteArray> roles;
137+ roles[RoleFilterId] = "id";
138+ roles[RoleFilterType] = "type";
139+ roles[RoleFilter] = "filter";
140+ return roles;
141+ }
142+
143+protected:
144+ /// @cond
145+ explicit FiltersInterface(QObject* parent = 0) : QAbstractListModel(parent) {}
146+ /// @endcond
147+};
148+
149+}
150+
151+}
152+}
153+
154+Q_DECLARE_METATYPE(unity::shell::scopes::FiltersInterface*)
155+
156+#endif
157
158=== modified file 'include/unity/shell/scopes/NavigationInterface.h'
159--- include/unity/shell/scopes/NavigationInterface.h 2014-08-04 13:58:53 +0000
160+++ include/unity/shell/scopes/NavigationInterface.h 2016-03-11 12:01:26 +0000
161@@ -94,6 +94,7 @@
162 enum Roles {
163 RoleNavigationId,
164 RoleLabel,
165+ RoleAllLabel,
166 RoleHasChildren,
167 RoleIsActive
168 };
169@@ -113,6 +114,7 @@
170 QHash<int, QByteArray> roles;
171 roles[RoleNavigationId] = "navigationId";
172 roles[RoleLabel] = "label";
173+ roles[RoleAllLabel] = "allLabel";
174 roles[RoleHasChildren] = "hasChildren";
175 roles[RoleIsActive] = "isActive";
176 return roles;
177
178=== added file 'include/unity/shell/scopes/OptionSelectorFilterInterface.h'
179--- include/unity/shell/scopes/OptionSelectorFilterInterface.h 1970-01-01 00:00:00 +0000
180+++ include/unity/shell/scopes/OptionSelectorFilterInterface.h 2016-03-11 12:01:26 +0000
181@@ -0,0 +1,67 @@
182+/*
183+ * Copyright (C) 2015 Canonical, Ltd.
184+ *
185+ * This program is free software; you can redistribute it and/or modify
186+ * it under the terms of the GNU General Public License as published by
187+ * the Free Software Foundation; version 3.
188+ *
189+ * This program is distributed in the hope that it will be useful,
190+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
191+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
192+ * GNU General Public License for more details.
193+ *
194+ * You should have received a copy of the GNU General Public License
195+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
196+ */
197+
198+#ifndef UNITY_SHELL_SCOPES_OPTIONSELECTORFILTERINTERFACE_H
199+#define UNITY_SHELL_SCOPES_OPTIONSELECTORFILTERINTERFACE_H
200+
201+#include <unity/SymbolExport.h>
202+
203+#include "FilterBaseInterface.h"
204+#include "OptionSelectorOptionsInterface.h"
205+
206+namespace unity
207+{
208+namespace shell
209+{
210+namespace scopes
211+{
212+
213+class UNITY_API OptionSelectorFilterInterface : public FilterBaseInterface
214+{
215+ Q_OBJECT
216+
217+public:
218+ Q_PROPERTY(QString label READ label NOTIFY labelChanged)
219+ Q_PROPERTY(bool multiSelect READ multiSelect NOTIFY multiSelectChanged)
220+ Q_PROPERTY(unity::shell::scopes::OptionSelectorOptionsInterface* options READ options CONSTANT)
221+
222+ FiltersInterface::FilterType filterType() const override
223+ {
224+ return FiltersInterface::OptionSelectorFilter;
225+ }
226+
227+ virtual QString label() const = 0;
228+ virtual bool multiSelect() const = 0;
229+ virtual OptionSelectorOptionsInterface* options() const = 0;
230+
231+Q_SIGNALS:
232+ void labelChanged(const QString&);
233+ void multiSelectChanged(bool);
234+
235+protected:
236+ /// @cond
237+ explicit OptionSelectorFilterInterface(QObject* parent = 0) : FilterBaseInterface(parent) {}
238+ /// @endcond
239+};
240+
241+}
242+
243+}
244+}
245+
246+Q_DECLARE_METATYPE(unity::shell::scopes::OptionSelectorFilterInterface*)
247+
248+#endif
249
250=== added file 'include/unity/shell/scopes/OptionSelectorOptionsInterface.h'
251--- include/unity/shell/scopes/OptionSelectorOptionsInterface.h 1970-01-01 00:00:00 +0000
252+++ include/unity/shell/scopes/OptionSelectorOptionsInterface.h 2016-03-11 12:01:26 +0000
253@@ -0,0 +1,66 @@
254+/*
255+ * Copyright (C) 2015 Canonical, Ltd.
256+ *
257+ * This program is free software; you can redistribute it and/or modify
258+ * it under the terms of the GNU General Public License as published by
259+ * the Free Software Foundation; version 3.
260+ *
261+ * This program is distributed in the hope that it will be useful,
262+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
263+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
264+ * GNU General Public License for more details.
265+ *
266+ * You should have received a copy of the GNU General Public License
267+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
268+ */
269+
270+#ifndef UNITY_SHELL_SCOPES_OPTIONSELECTOROPTIONSINTERFACE_H
271+#define UNITY_SHELL_SCOPES_OPTIONSELECTOROPTIONSINTERFACE_H
272+
273+#include <unity/SymbolExport.h>
274+#include <QAbstractListModel>
275+
276+namespace unity
277+{
278+namespace shell
279+{
280+namespace scopes
281+{
282+
283+class UNITY_API OptionSelectorOptionsInterface : public QAbstractListModel
284+{
285+ Q_OBJECT
286+
287+ Q_ENUMS(OptionRoles)
288+
289+public:
290+ enum Roles {
291+ RoleOptionId = Qt::UserRole + 1,
292+ RoleOptionLabel,
293+ RoleOptionChecked
294+ };
295+
296+ Q_INVOKABLE virtual void setChecked(int index, bool checked) = 0;
297+
298+ QHash<int, QByteArray> roleNames() const override
299+ {
300+ QHash<int, QByteArray> roles;
301+ roles[RoleOptionId] = "id";
302+ roles[RoleOptionLabel] = "label";
303+ roles[RoleOptionChecked] = "checked";
304+ return roles;
305+ }
306+
307+protected:
308+ /// @cond
309+ explicit OptionSelectorOptionsInterface(QObject* parent = 0) : QAbstractListModel(parent) {}
310+ /// @endcond
311+};
312+
313+}
314+}
315+}
316+
317+Q_DECLARE_METATYPE(unity::shell::scopes::OptionSelectorOptionsInterface*)
318+
319+#endif
320
321=== modified file 'include/unity/shell/scopes/ScopeInterface.h'
322--- include/unity/shell/scopes/ScopeInterface.h 2016-02-18 15:46:46 +0000
323+++ include/unity/shell/scopes/ScopeInterface.h 2016-03-11 12:01:26 +0000
324@@ -33,6 +33,8 @@
325 class PreviewModelInterface;
326 class NavigationInterface;
327 class SettingsModelInterface;
328+class FiltersInterface;
329+class FilterBaseInterface;
330
331 /**
332 * @brief Object representing scope instance, which exposes model(s) with results.
333@@ -98,6 +100,11 @@
334 Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)
335
336 /**
337+ * @brief
338+ */
339+ Q_PROPERTY(unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter READ primaryNavigationFilter NOTIFY primaryNavigationFilterChanged)
340+
341+ /**
342 * @brief Current search query.
343 *
344 * Writing to this property issues a new search to the scope.
345@@ -134,16 +141,6 @@
346 Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)
347
348 /**
349- * @brief String specifying currently selected sort order
350- */
351- Q_PROPERTY(QString currentAltNavigationId READ currentAltNavigationId NOTIFY currentAltNavigationIdChanged)
352-
353- /**
354- * @brief Boolean specifying whether current query has sort order.
355- */
356- Q_PROPERTY(bool hasAltNavigation READ hasAltNavigation NOTIFY hasAltNavigationChanged)
357-
358- /**
359 * @brief VariantMap with customization properties
360 */
361 Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)
362@@ -153,6 +150,21 @@
363 */
364 Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)
365
366+ /**
367+ * @brief Filters model for the scope.
368+ */
369+ Q_PROPERTY(unity::shell::scopes::FiltersInterface* filters READ filters NOTIFY filtersChanged)
370+
371+ /**
372+ * @brief Label for the currently active top level navigation (department or primary filter).
373+ */
374+ Q_PROPERTY(QString primaryNavigationTag READ primaryNavigationTag NOTIFY primaryNavigationTagChanged)
375+
376+ /**
377+ * @brief The number of currently selected filters.
378+ */
379+ Q_PROPERTY(int activeFiltersCount READ activeFiltersCount NOTIFY activeFiltersCountChanged)
380+
381 protected:
382 /// @cond
383 explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
384@@ -182,16 +194,18 @@
385 virtual bool favorite() const = 0;
386 virtual CategoriesInterface* categories() const = 0;
387 virtual SettingsModelInterface* settings() const = 0;
388+ virtual FilterBaseInterface* primaryNavigationFilter() const = 0;
389 virtual QString searchQuery() const = 0;
390 virtual QString noResultsHint() const = 0;
391 virtual QString formFactor() const = 0;
392 virtual bool isActive() const = 0;
393 virtual QString currentNavigationId() const = 0;
394 virtual bool hasNavigation() const = 0;
395- virtual QString currentAltNavigationId() const = 0;
396- virtual bool hasAltNavigation() const = 0;
397 virtual Status status() const = 0;
398 virtual QVariantMap customizations() const = 0;
399+ virtual FiltersInterface* filters() const = 0;
400+ virtual QString primaryNavigationTag() const = 0;
401+ virtual int activeFiltersCount() const = 0;
402
403 /* setters */
404 virtual void setSearchQuery(const QString& search_query) = 0;
405@@ -230,14 +244,9 @@
406 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;
407
408 /**
409- * @brief Get a NavigationInterface instance for the passed altNavigationId.
410- */
411- Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& altNavigationId) = 0;
412-
413- /**
414- * @brief Request change to the current navigation or altNavigation id.
415- */
416- Q_INVOKABLE virtual void setNavigationState(QString const& navId, bool altNavigation) = 0;
417+ * @brief Request change to the current navigation id.
418+ */
419+ Q_INVOKABLE virtual void setNavigationState(QString const& navId) = 0;
420
421 /**
422 * @brief Execute canned query.
423@@ -250,6 +259,16 @@
424 Q_INVOKABLE virtual void refresh() = 0;
425
426 /**
427+ * @brief Reset primary navigation filter and its tag in the search bar.
428+ */
429+ Q_INVOKABLE virtual void resetPrimaryNavigationTag() = 0;
430+
431+ /**
432+ * @brief Reset filters to default values.
433+ */
434+ Q_INVOKABLE virtual void resetFilters() = 0;
435+
436+ /*
437 * @brief Method used to activate an action of a result.
438 */
439 Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) = 0;
440@@ -273,11 +292,13 @@
441 void isActiveChanged();
442 void hasNavigationChanged();
443 void currentNavigationIdChanged();
444- void hasAltNavigationChanged();
445- void currentAltNavigationIdChanged();
446 void customizationsChanged();
447 void statusChanged();
448 void detailsChanged();
449+ void filtersChanged();
450+ void primaryNavigationTagChanged();
451+ void activeFiltersCountChanged();
452+ void primaryNavigationFilterChanged();
453 // @endcond
454
455 // signals triggered by activate(..) or preview(..) requests.
456
457=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt'
458--- test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2016-02-11 14:00:36 +0000
459+++ test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2016-03-11 12:01:26 +0000
460@@ -19,7 +19,14 @@
461 Mocks/MockScope.cpp
462 Mocks/MockScopes.cpp
463 Mocks/MockSettingsModel.cpp
464+ Mocks/MockFiltersModel.cpp
465+ Mocks/MockOptionSelectorFilter.cpp
466+ Mocks/MockSelectorOptions.cpp
467 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/CategoriesInterface.h
468+ ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/FiltersInterface.h
469+ ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/FilterBaseInterface.h
470+ ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/OptionSelectorFilterInterface.h
471+ ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/OptionSelectorOptionsInterface.h
472 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/NavigationInterface.h
473 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h
474 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h
475
476=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp'
477--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp 2014-08-04 13:58:53 +0000
478+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp 2016-03-11 12:01:26 +0000
479@@ -79,6 +79,8 @@
480 return "child";
481 case RoleLabel:
482 return "Child Clothes";
483+ case RoleAllLabel:
484+ return "All Child Clothes";
485 case RoleHasChildren:
486 return true;
487 case RoleIsActive:
488
489=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp'
490--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp 1970-01-01 00:00:00 +0000
491+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.cpp 2016-03-11 12:01:26 +0000
492@@ -0,0 +1,51 @@
493+/*
494+ * Copyright (C) 2015 Canonical, Ltd.
495+ *
496+ * This program is free software; you can redistribute it and/or modify
497+ * it under the terms of the GNU General Public License as published by
498+ * the Free Software Foundation; version 3.
499+ *
500+ * This program is distributed in the hope that it will be useful,
501+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
502+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
503+ * GNU General Public License for more details.
504+ *
505+ * You should have received a copy of the GNU General Public License
506+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
507+ */
508+
509+#include "MockFiltersModel.h"
510+#include "MockOptionSelectorFilter.h"
511+
512+MockFiltersModel::MockFiltersModel(unity::shell::scopes::ScopeInterface *parent)
513+ : unity::shell::scopes::FiltersInterface(parent)
514+{
515+ MockOptionSelectorFilter *f = new MockOptionSelectorFilter("f1", "Filter 1", false, this);
516+ m_filters.append(f); // owned by parent, so no need to manage it
517+}
518+
519+QVariant MockFiltersModel::data(const QModelIndex& index, int role) const
520+{
521+ if (index.row() >= 0 && index.row() < m_filters.count())
522+ {
523+ auto filter = m_filters.at(index.row());
524+ switch (role)
525+ {
526+ case Qt::DisplayRole:
527+ case unity::shell::scopes::FiltersInterface::RoleFilterId:
528+ return QVariant(filter->filterId());
529+ case unity::shell::scopes::FiltersInterface::RoleFilterType:
530+ return QVariant(static_cast<int>(filter->filterType()));
531+ case unity::shell::scopes::FiltersInterface::RoleFilter:
532+ return QVariant::fromValue(filter);
533+ default:
534+ return QVariant();
535+ }
536+ }
537+ return QVariant();
538+}
539+
540+int MockFiltersModel::rowCount(const QModelIndex&) const
541+{
542+ return m_filters.count();
543+}
544
545=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h'
546--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h 1970-01-01 00:00:00 +0000
547+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockFiltersModel.h 2016-03-11 12:01:26 +0000
548@@ -0,0 +1,40 @@
549+/*
550+ * Copyright (C) 2015 Canonical, Ltd.
551+ *
552+ * This program is free software; you can redistribute it and/or modify
553+ * it under the terms of the GNU General Public License as published by
554+ * the Free Software Foundation; version 3.
555+ *
556+ * This program is distributed in the hope that it will be useful,
557+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
558+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
559+ * GNU General Public License for more details.
560+ *
561+ * You should have received a copy of the GNU General Public License
562+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
563+ */
564+
565+#ifndef MOCKFILTERS_H
566+#define MOCKFILTERS_H
567+
568+#include <unity/shell/scopes/FiltersInterface.h>
569+#include <unity/shell/scopes/FilterBaseInterface.h>
570+#include <unity/shell/scopes/ScopeInterface.h>
571+
572+#include <QList>
573+
574+class MockFiltersModel : public unity::shell::scopes::FiltersInterface
575+{
576+ Q_OBJECT
577+
578+public:
579+ explicit MockFiltersModel(unity::shell::scopes::ScopeInterface *parent = 0);
580+
581+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
582+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
583+
584+private:
585+ QList<unity::shell::scopes::FilterBaseInterface*> m_filters;
586+};
587+
588+#endif // MOCKDEPARTMENT_H
589
590=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp'
591--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp 1970-01-01 00:00:00 +0000
592+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.cpp 2016-03-11 12:01:26 +0000
593@@ -0,0 +1,57 @@
594+/*
595+ * Copyright (C) 2015 Canonical, Ltd.
596+ *
597+ * This program is free software; you can redistribute it and/or modify
598+ * it under the terms of the GNU General Public License as published by
599+ * the Free Software Foundation; version 3.
600+ *
601+ * This program is distributed in the hope that it will be useful,
602+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
603+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
604+ * GNU General Public License for more details.
605+ *
606+ * You should have received a copy of the GNU General Public License
607+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
608+ */
609+
610+#include "MockOptionSelectorFilter.h"
611+
612+MockOptionSelectorFilter::MockOptionSelectorFilter(const QString &id, const QString &title, const QString &label, bool multi, QObject *parent)
613+ : unity::shell::scopes::OptionSelectorFilterInterface(parent),
614+ m_id(id),
615+ m_title(title),
616+ m_label(label),
617+ m_multiSelect(multi),
618+ m_options(new MockSelectorOptions(2, this))
619+{
620+}
621+
622+QString MockOptionSelectorFilter::filterId() const
623+{
624+ return m_id;
625+}
626+
627+QString MockOptionSelectorFilter::title() const
628+{
629+ return m_title;
630+}
631+
632+QString MockOptionSelectorFilter::label() const
633+{
634+ return m_label;
635+}
636+
637+bool MockOptionSelectorFilter::multiSelect() const
638+{
639+ return m_multiSelect;
640+}
641+
642+unity::shell::scopes::OptionSelectorOptionsInterface* MockOptionSelectorFilter::options() const
643+{
644+ return m_options;
645+}
646+
647+QString MockOptionSelectorFilter::filterTag() const
648+{
649+ return "";
650+}
651
652=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h'
653--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h 1970-01-01 00:00:00 +0000
654+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockOptionSelectorFilter.h 2016-03-11 12:01:26 +0000
655@@ -0,0 +1,45 @@
656+/*
657+ * Copyright (C) 2015 Canonical, Ltd.
658+ *
659+ * This program is free software; you can redistribute it and/or modify
660+ * it under the terms of the GNU General Public License as published by
661+ * the Free Software Foundation; version 3.
662+ *
663+ * This program is distributed in the hope that it will be useful,
664+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
665+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
666+ * GNU General Public License for more details.
667+ *
668+ * You should have received a copy of the GNU General Public License
669+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
670+ */
671+
672+#ifndef MOCKOPTIONSELECTORFILTER_H
673+#define MOCKOPTIONSELECTORFILTER_H
674+
675+#include <unity/shell/scopes/OptionSelectorFilterInterface.h>
676+#include <unity/shell/scopes/FiltersInterface.h>
677+#include "MockSelectorOptions.h"
678+
679+class MockOptionSelectorFilter : public unity::shell::scopes::OptionSelectorFilterInterface
680+{
681+ Q_OBJECT
682+
683+public:
684+ MockOptionSelectorFilter(const QString &id, const QString& title, const QString &label, bool multi, QObject *parent = 0);
685+ QString filterId() const override;
686+ QString title() const override;
687+ QString label() const override;
688+ bool multiSelect() const override;
689+ unity::shell::scopes::OptionSelectorOptionsInterface* options() const override;
690+ QString filterTag() const override;
691+
692+private:
693+ QString m_id;
694+ QString m_title;
695+ QString m_label;
696+ bool m_multiSelect;
697+ MockSelectorOptions *m_options;
698+};
699+
700+#endif
701
702=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp'
703--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2016-02-18 15:46:46 +0000
704+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2016-03-11 12:01:26 +0000
705@@ -19,6 +19,7 @@
706 #include "MockPreviewModel.h"
707 #include "MockDepartment.h"
708 #include "MockSettingsModel.h"
709+#include "MockFiltersModel.h"
710
711 MockScope::MockScope(QObject* parent) : MockScope(QString(), QString(), parent)
712 {
713@@ -34,6 +35,7 @@
714 , m_previewRendererName("preview-generic")
715 , m_categories(new MockCategories(20, this))
716 , m_settings(new MockSettingsModel(this))
717+ , m_filters(new MockFiltersModel(this))
718 {
719 }
720
721@@ -69,10 +71,6 @@
722 return m_currentDepartmentId;
723 }
724
725-QString MockScope::currentAltNavigationId() const {
726- return m_currentAltDepartmentId;
727-}
728-
729 bool MockScope::searchInProgress() const {
730 return m_searching;
731 }
732@@ -89,6 +87,14 @@
733 return m_settings;
734 }
735
736+unity::shell::scopes::FiltersInterface* MockScope::filters() const {
737+ return m_filters;
738+}
739+
740+unity::shell::scopes::FilterBaseInterface* MockScope::primaryNavigationFilter() const {
741+ return nullptr;
742+}
743+
744 QString MockScope::noResultsHint() const {
745 return m_noResultsHint;
746 }
747@@ -109,10 +115,6 @@
748 return m_hasNavigation;
749 }
750
751-bool MockScope::hasAltNavigation() const {
752- return m_hasAltNavigation;
753-}
754-
755 QVariantMap MockScope::customizations() const {
756 return m_customizations;
757 }
758@@ -193,17 +195,9 @@
759 return new MockDepartment();
760 }
761
762-unity::shell::scopes::NavigationInterface* MockScope::getAltNavigation(QString const& navigationId)
763-{
764- Q_UNUSED(navigationId);
765-
766- return new MockDepartment();
767-}
768-
769-void MockScope::setNavigationState(QString const& navId, bool altNavigation)
770+void MockScope::setNavigationState(QString const& navId)
771 {
772 Q_UNUSED(navId);
773- Q_UNUSED(altNavigation);
774 }
775
776 void MockScope::cancelActivation()
777@@ -223,3 +217,21 @@
778 void MockScope::refresh()
779 {
780 }
781+
782+QString MockScope::primaryNavigationTag() const
783+{
784+ return "";
785+}
786+
787+void MockScope::resetPrimaryNavigationTag()
788+{
789+}
790+
791+void MockScope::resetFilters()
792+{
793+}
794+
795+int MockScope::activeFiltersCount() const
796+{
797+ return 0;
798+}
799
800=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h'
801--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2016-02-18 15:46:46 +0000
802+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2016-03-11 12:01:26 +0000
803@@ -39,16 +39,18 @@
804 bool activationInProgress() const override;
805 unity::shell::scopes::CategoriesInterface* categories() const override;
806 unity::shell::scopes::SettingsModelInterface* settings() const override;
807+ unity::shell::scopes::FiltersInterface* filters() const override;
808+ unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter() const override;
809 QString searchQuery() const override;
810 QString noResultsHint() const override;
811 QString formFactor() const override;
812 bool isActive() const override;
813 bool hasNavigation() const override;
814 QString currentNavigationId() const override;
815- bool hasAltNavigation() const override;
816- QString currentAltNavigationId() const override;
817 QVariantMap customizations() const override;
818 Status status() const override;
819+ QString primaryNavigationTag() const override;
820+ int activeFiltersCount() const override;
821
822 /* setters */
823 void setName(const QString& name);
824@@ -64,10 +66,11 @@
825 Q_INVOKABLE void cancelActivation() override;
826 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
827 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& departmentId) override;
828- Q_INVOKABLE unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& departmentId) override;
829- Q_INVOKABLE void setNavigationState(QString const& navId, bool altNavigation) override;
830+ Q_INVOKABLE void setNavigationState(QString const& navId) override;
831 Q_INVOKABLE void performQuery(QString const& cannedQuery) override;
832 Q_INVOKABLE void refresh() override;
833+ Q_INVOKABLE void resetPrimaryNavigationTag() override;
834+ Q_INVOKABLE void resetFilters() override;
835
836 protected:
837 QString m_id;
838@@ -78,18 +81,17 @@
839 QString m_noResultsHint;
840 QString m_formFactor;
841 QString m_currentDepartmentId;
842- QString m_currentAltDepartmentId;
843 bool m_favorite;
844 bool m_searching;
845 bool m_isActive;
846 bool m_hasNavigation;
847- bool m_hasAltNavigation;
848 QVariantMap m_customizations;
849
850 QString m_previewRendererName;
851
852 unity::shell::scopes::CategoriesInterface* m_categories;
853 unity::shell::scopes::SettingsModelInterface* m_settings;
854+ unity::shell::scopes::FiltersInterface* m_filters;
855 };
856
857 #endif
858
859=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp'
860--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp 1970-01-01 00:00:00 +0000
861+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.cpp 2016-03-11 12:01:26 +0000
862@@ -0,0 +1,53 @@
863+/*
864+ * Copyright (C) 2015 Canonical, Ltd.
865+ *
866+ * This program is free software; you can redistribute it and/or modify
867+ * it under the terms of the GNU General Public License as published by
868+ * the Free Software Foundation; version 3.
869+ *
870+ * This program is distributed in the hope that it will be useful,
871+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
872+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
873+ * GNU General Public License for more details.
874+ *
875+ * You should have received a copy of the GNU General Public License
876+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
877+ */
878+
879+#include "MockSelectorOptions.h"
880+
881+MockSelectorOptions::MockSelectorOptions(int num, QObject *parent)
882+ : unity::shell::scopes::OptionSelectorOptionsInterface(parent),
883+ m_numOfOptions(num)
884+{
885+}
886+
887+QVariant MockSelectorOptions::data(const QModelIndex& index, int role) const
888+{
889+ if (index.row() >= 0 && index.row() < m_numOfOptions)
890+ {
891+ switch (role)
892+ {
893+ case unity::shell::scopes::OptionSelectorOptionsInterface::RoleOptionId:
894+ return QVariant(QString("option") + QString::number(index.row()));
895+ case Qt::DisplayRole:
896+ case unity::shell::scopes::OptionSelectorOptionsInterface::RoleOptionLabel:
897+ return QVariant(QString("Option") + QString::number(index.row()));
898+ case unity::shell::scopes::OptionSelectorOptionsInterface::RoleOptionChecked:
899+ return QVariant(false);
900+ default:
901+ return QVariant();
902+ }
903+ }
904+ return QVariant();
905+}
906+
907+int MockSelectorOptions::rowCount(const QModelIndex&) const
908+{
909+ return m_numOfOptions;
910+}
911+
912+void MockSelectorOptions::setChecked(int, bool)
913+{
914+ qFatal("Using un-implemented setChecked() method");
915+}
916
917=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h'
918--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h 1970-01-01 00:00:00 +0000
919+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockSelectorOptions.h 2016-03-11 12:01:26 +0000
920@@ -0,0 +1,36 @@
921+/*
922+ * Copyright (C) 2015 Canonical, Ltd.
923+ *
924+ * This program is free software; you can redistribute it and/or modify
925+ * it under the terms of the GNU General Public License as published by
926+ * the Free Software Foundation; version 3.
927+ *
928+ * This program is distributed in the hope that it will be useful,
929+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
930+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
931+ * GNU General Public License for more details.
932+ *
933+ * You should have received a copy of the GNU General Public License
934+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
935+ */
936+
937+#ifndef MOCKOPTIONSELECTOROPTIONS_H
938+#define MOCKOPTIONSELECTOROPTIONS_H
939+
940+#include <unity/shell/scopes/OptionSelectorOptionsInterface.h>
941+
942+class MockSelectorOptions : public unity::shell::scopes::OptionSelectorOptionsInterface
943+{
944+ Q_OBJECT
945+
946+public:
947+ MockSelectorOptions(int num = 2, QObject *parent = 0);
948+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
949+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
950+ void setChecked(int index, bool checked) override;
951+
952+private:
953+ int m_numOfOptions;
954+};
955+
956+#endif
957
958=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp'
959--- test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2016-02-11 14:00:36 +0000
960+++ test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2016-03-11 12:01:26 +0000
961@@ -25,6 +25,10 @@
962 #include "PreviewModelInterface.h"
963 #include "PreviewWidgetModelInterface.h"
964 #include "SettingsModelInterface.h"
965+#include "FiltersInterface.h"
966+#include "FilterBaseInterface.h"
967+#include "OptionSelectorOptionsInterface.h"
968+#include "OptionSelectorFilterInterface.h"
969 #include "Mocks/MockScopes.h"
970 #include "Mocks/MockScope.h"
971
972@@ -38,4 +42,8 @@
973 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");
974 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
975 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create new Settings in QML. Get them from Scope instance.");
976+ qmlRegisterUncreatableType<unity::shell::scopes::FilterBaseInterface>(uri, 0, 2, "FilterBase", "Can't create new Filter in QML. Get them from Filters instance.");
977+ qmlRegisterUncreatableType<unity::shell::scopes::FiltersInterface>(uri, 0, 2, "Filters", "Can't create new Filters in QML. Get them from Scope instance.");
978+ qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create new OptionSelectorOptions in QML. Get them from OptionSelectorFilter instance.");
979+ qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorFilterInterface>(uri, 0, 2, "OptionSelectorFilter", "Can't create new OptionSelectorFilter in QML. Get them from Scope instance.");
980 }
981
982=== modified file 'test/qmltest/unity/shell/scopes/tst_Scopes.qml'
983--- test/qmltest/unity/shell/scopes/tst_Scopes.qml 2016-02-11 14:06:46 +0000
984+++ test/qmltest/unity/shell/scopes/tst_Scopes.qml 2016-03-11 12:01:26 +0000
985@@ -122,14 +122,13 @@
986 { tag: "Item.properties[favorite]", constant: "favorite", type: "boolean" },
987 { tag: "Item.properties[shortcut]", constant: "shortcut", type: "string" },
988 { tag: "Item.properties[categories]", constant: "categories", type: "object" },
989+ { tag: "Item.properties[filters]", constant: "filters", type: "object" },
990 { tag: "Item.properties[searchQuery]", constant: "searchQuery", type: "string" },
991 { tag: "Item.properties[noResultsHint]", constant: "noResultsHint", type: "string" },
992 { tag: "Item.properties[formFactor]", constant: "formFactor", type: "string" },
993 { tag: "Item.properties[isActive]", constant: "isActive", type: "boolean" },
994 { tag: "Item.properties[currentNavigationId]", constant: "currentNavigationId", type: "string" },
995 { tag: "Item.properties[hasNavigation]", constant: "hasNavigation", type: "boolean" },
996- { tag: "Item.properties[currentAltNavigationId]", constant: "currentAltNavigationId", type: "string" },
997- { tag: "Item.properties[hasAltNavigation]", constant: "hasAltNavigation", type: "boolean" },
998 { tag: "Item.properties[customizations]", constant: "customizations", type: "object" },
999 { tag: "Item.properties[status]", constant: "status", type: "number" }
1000 ];
1001@@ -156,7 +155,6 @@
1002 { tag: "Model.methods[performQuery]", method: "performQuery" },
1003 { tag: "Model.methods[refresh]", method: "refresh" },
1004 { tag: "Model.methods[getNavigation]", method: "getNavigation" },
1005- { tag: "Model.methods[getAltNavigation]", method: "getAltNavigation" },
1006 { tag: "Model.methods[setNavigationState]", method: "setNavigationState" },
1007 ];
1008 }
1009@@ -169,6 +167,116 @@
1010 }
1011
1012 Verifier {
1013+ id: filtersVerifier
1014+
1015+ Repeater {
1016+ id: filtersRepeater
1017+ model: root.scope.filters
1018+ delegate: Item {
1019+ property var roles: model
1020+ }
1021+ }
1022+
1023+ function test_filters(data) {
1024+ object = filtersRepeater.model;
1025+ name = "Filters";
1026+ verifyData(data);
1027+ }
1028+
1029+ function test_filters_data() {
1030+ return [
1031+ { tag: "Filters[object]", type: "object" },
1032+ { tag: "Filters[FiltersInterface]", type: "unity::shell::scopes::FiltersInterface" },
1033+ ];
1034+ }
1035+
1036+ function test_filters_roles(data) {
1037+ object = filtersRepeater.itemAt(0).roles;
1038+ name = "Filters";
1039+ verifyData(data);
1040+ }
1041+
1042+ function test_filters_roles_data() {
1043+ return [
1044+ { tag: "Model.roles[id]", role: "id", type: "string" },
1045+ { tag: "Model.roles[type]", role: "type", type: "number" },
1046+ { tag: "Model.roles[filter]", role: "filter", type: "unity::shell::scopes::FilterBaseInterface" },
1047+ ];
1048+ }
1049+ }
1050+
1051+ Verifier {
1052+ id: optionSelectorFilterVerifier
1053+
1054+ function test_option_selector_filter(data) {
1055+ object = filtersRepeater.itemAt(0).roles.filter;
1056+ name = "Filter";
1057+ verifyData(data);
1058+ }
1059+
1060+ function test_option_selector_filter_data() {
1061+ return [
1062+ { tag: "Filter[object]", type: "object" },
1063+ { tag: "Filter[OptionSelectorFilterInterface]", type: "unity::shell::scopes::OptionSelectorFilterInterface" },
1064+ ];
1065+ }
1066+
1067+ function test_option_selector_filter_properties_data() {
1068+ return [
1069+ { tag: "Filter.properties[filterId]", constant: "filterId", type: "string" },
1070+ { tag: "Filter.properties[label]", constant: "label", type: "string" },
1071+ { tag: "Filter.properties[multiSelect]", constant: "multiSelect", type: "boolean" },
1072+ { tag: "Filter.properties[options]", constant: "options", type: "object" },
1073+ ];
1074+ }
1075+
1076+ function test_option_selector_filter_properties(data) {
1077+ object = filtersRepeater.itemAt(0).roles.filter;
1078+ name = "Filter";
1079+ verifyData(data);
1080+ }
1081+
1082+ function test_options_data() {
1083+ return [
1084+ { tag: "Options[object]", type: "object" },
1085+ { tag: "Options[OptionSelectorOptionsInterface]", type: "unity::shell::scopes::OptionSelectorOptionsInterface" },
1086+ ];
1087+ }
1088+
1089+ function test_options(data) {
1090+ object = filtersRepeater.itemAt(0).roles.filter.options;
1091+ name = "Options";
1092+ verifyData(data);
1093+ }
1094+ }
1095+
1096+ Verifier {
1097+ id: optionSelectorFilterOptionsVerifier
1098+
1099+ Repeater {
1100+ id: optionsRepeater
1101+ model: filtersRepeater.count > 0 ? filtersRepeater.itemAt(0).roles.filter.options : undefined
1102+ delegate: Item {
1103+ property var roles: model
1104+ }
1105+ }
1106+
1107+ function test_option_selector_filter_options_roles_data() {
1108+ return [
1109+ { tag: "Model.roles[id]", role: "id", type: "string" },
1110+ { tag: "Model.roles[label]", role: "label", type: "string" },
1111+ { tag: "Model.roles[checked]", role: "checked", type: "boolean" },
1112+ ];
1113+ }
1114+
1115+ function test_option_selector_filter_options_roles(data) {
1116+ object = optionsRepeater.itemAt(0).roles;
1117+ name = "Options";
1118+ verifyData(data);
1119+ }
1120+ }
1121+
1122+ Verifier {
1123 id: categoriesVerifier
1124
1125 Repeater {

Subscribers

People subscribed via source and target branches

to all changes: