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
=== modified file 'include/unity/shell/scopes/CMakeLists.txt'
--- include/unity/shell/scopes/CMakeLists.txt 2016-02-18 15:46:46 +0000
+++ include/unity/shell/scopes/CMakeLists.txt 2016-03-11 12:01:26 +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 10)10set(VERSION 11)
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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-02-18 15:46:46 +0000
+++ include/unity/shell/scopes/ScopeInterface.h 2016-03-11 12:01:26 +0000
@@ -33,6 +33,8 @@
33class PreviewModelInterface;33class PreviewModelInterface;
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.
@@ -98,6 +100,11 @@
98 Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)100 Q_PROPERTY(unity::shell::scopes::SettingsModelInterface* settings READ settings NOTIFY settingsChanged)
99101
100 /**102 /**
103 * @brief
104 */
105 Q_PROPERTY(unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter READ primaryNavigationFilter NOTIFY primaryNavigationFilterChanged)
106
107 /**
101 * @brief Current search query.108 * @brief Current search query.
102 *109 *
103 * Writing to this property issues a new search to the scope.110 * Writing to this property issues a new search to the scope.
@@ -134,16 +141,6 @@
134 Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)141 Q_PROPERTY(bool hasNavigation READ hasNavigation NOTIFY hasNavigationChanged)
135142
136 /**143 /**
137 * @brief String specifying currently selected sort order
138 */
139 Q_PROPERTY(QString currentAltNavigationId READ currentAltNavigationId NOTIFY currentAltNavigationIdChanged)
140
141 /**
142 * @brief Boolean specifying whether current query has sort order.
143 */
144 Q_PROPERTY(bool hasAltNavigation READ hasAltNavigation NOTIFY hasAltNavigationChanged)
145
146 /**
147 * @brief VariantMap with customization properties144 * @brief VariantMap with customization properties
148 */145 */
149 Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)146 Q_PROPERTY(QVariantMap customizations READ customizations NOTIFY customizationsChanged)
@@ -153,6 +150,21 @@
153 */150 */
154 Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)151 Q_PROPERTY(unity::shell::scopes::ScopeInterface::Status status READ status NOTIFY statusChanged)
155152
153 /**
154 * @brief Filters model for the scope.
155 */
156 Q_PROPERTY(unity::shell::scopes::FiltersInterface* filters READ filters NOTIFY filtersChanged)
157
158 /**
159 * @brief Label for the currently active top level navigation (department or primary filter).
160 */
161 Q_PROPERTY(QString primaryNavigationTag READ primaryNavigationTag NOTIFY primaryNavigationTagChanged)
162
163 /**
164 * @brief The number of currently selected filters.
165 */
166 Q_PROPERTY(int activeFiltersCount READ activeFiltersCount NOTIFY activeFiltersCountChanged)
167
156protected:168protected:
157 /// @cond169 /// @cond
158 explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }170 explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
@@ -182,16 +194,18 @@
182 virtual bool favorite() const = 0;194 virtual bool favorite() const = 0;
183 virtual CategoriesInterface* categories() const = 0;195 virtual CategoriesInterface* categories() const = 0;
184 virtual SettingsModelInterface* settings() const = 0;196 virtual SettingsModelInterface* settings() const = 0;
197 virtual FilterBaseInterface* primaryNavigationFilter() const = 0;
185 virtual QString searchQuery() const = 0;198 virtual QString searchQuery() const = 0;
186 virtual QString noResultsHint() const = 0;199 virtual QString noResultsHint() const = 0;
187 virtual QString formFactor() const = 0;200 virtual QString formFactor() const = 0;
188 virtual bool isActive() const = 0;201 virtual bool isActive() const = 0;
189 virtual QString currentNavigationId() const = 0;202 virtual QString currentNavigationId() const = 0;
190 virtual bool hasNavigation() const = 0;203 virtual bool hasNavigation() const = 0;
191 virtual QString currentAltNavigationId() const = 0;
192 virtual bool hasAltNavigation() const = 0;
193 virtual Status status() const = 0;204 virtual Status status() const = 0;
194 virtual QVariantMap customizations() const = 0;205 virtual QVariantMap customizations() const = 0;
206 virtual FiltersInterface* filters() const = 0;
207 virtual QString primaryNavigationTag() const = 0;
208 virtual int activeFiltersCount() const = 0;
195209
196 /* setters */210 /* setters */
197 virtual void setSearchQuery(const QString& search_query) = 0;211 virtual void setSearchQuery(const QString& search_query) = 0;
@@ -230,14 +244,9 @@
230 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;244 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) = 0;
231245
232 /**246 /**
233 * @brief Get a NavigationInterface instance for the passed altNavigationId.247 * @brief Request change to the current navigation id.
234 */248 */
235 Q_INVOKABLE virtual unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& altNavigationId) = 0;249 Q_INVOKABLE virtual void setNavigationState(QString const& navId) = 0;
236
237 /**
238 * @brief Request change to the current navigation or altNavigation id.
239 */
240 Q_INVOKABLE virtual void setNavigationState(QString const& navId, bool altNavigation) = 0;
241250
242 /**251 /**
243 * @brief Execute canned query.252 * @brief Execute canned query.
@@ -250,6 +259,16 @@
250 Q_INVOKABLE virtual void refresh() = 0;259 Q_INVOKABLE virtual void refresh() = 0;
251260
252 /**261 /**
262 * @brief Reset primary navigation filter and its tag in the search bar.
263 */
264 Q_INVOKABLE virtual void resetPrimaryNavigationTag() = 0;
265
266 /**
267 * @brief Reset filters to default values.
268 */
269 Q_INVOKABLE virtual void resetFilters() = 0;
270
271 /*
253 * @brief Method used to activate an action of a result.272 * @brief Method used to activate an action of a result.
254 */273 */
255 Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) = 0;274 Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) = 0;
@@ -273,11 +292,13 @@
273 void isActiveChanged();292 void isActiveChanged();
274 void hasNavigationChanged();293 void hasNavigationChanged();
275 void currentNavigationIdChanged();294 void currentNavigationIdChanged();
276 void hasAltNavigationChanged();
277 void currentAltNavigationIdChanged();
278 void customizationsChanged();295 void customizationsChanged();
279 void statusChanged();296 void statusChanged();
280 void detailsChanged();297 void detailsChanged();
298 void filtersChanged();
299 void primaryNavigationTagChanged();
300 void activeFiltersCountChanged();
301 void primaryNavigationFilterChanged();
281 // @endcond302 // @endcond
282303
283 // signals triggered by activate(..) or preview(..) requests.304 // signals triggered by activate(..) or preview(..) requests.
284305
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt'
--- test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2016-02-11 14:00:36 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2016-03-11 12:01:26 +0000
@@ -19,7 +19,14 @@
19 Mocks/MockScope.cpp19 Mocks/MockScope.cpp
20 Mocks/MockScopes.cpp20 Mocks/MockScopes.cpp
21 Mocks/MockSettingsModel.cpp21 Mocks/MockSettingsModel.cpp
22 Mocks/MockFiltersModel.cpp
23 Mocks/MockOptionSelectorFilter.cpp
24 Mocks/MockSelectorOptions.cpp
22 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/CategoriesInterface.h25 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/CategoriesInterface.h
26 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/FiltersInterface.h
27 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/FilterBaseInterface.h
28 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/OptionSelectorFilterInterface.h
29 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/OptionSelectorOptionsInterface.h
23 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/NavigationInterface.h30 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/NavigationInterface.h
24 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h31 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h
25 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h32 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h
2633
=== 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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-02-18 15:46:46 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2016-03-11 12:01:26 +0000
@@ -19,6 +19,7 @@
19#include "MockPreviewModel.h"19#include "MockPreviewModel.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}
@@ -89,6 +87,14 @@
89 return m_settings;87 return m_settings;
90}88}
9189
90unity::shell::scopes::FiltersInterface* MockScope::filters() const {
91 return m_filters;
92}
93
94unity::shell::scopes::FilterBaseInterface* MockScope::primaryNavigationFilter() const {
95 return nullptr;
96}
97
92QString MockScope::noResultsHint() const {98QString MockScope::noResultsHint() const {
93 return m_noResultsHint;99 return m_noResultsHint;
94}100}
@@ -109,10 +115,6 @@
109 return m_hasNavigation;115 return m_hasNavigation;
110}116}
111117
112bool MockScope::hasAltNavigation() const {
113 return m_hasAltNavigation;
114}
115
116QVariantMap MockScope::customizations() const {118QVariantMap MockScope::customizations() const {
117 return m_customizations;119 return m_customizations;
118}120}
@@ -193,17 +195,9 @@
193 return new MockDepartment();195 return new MockDepartment();
194}196}
195197
196unity::shell::scopes::NavigationInterface* MockScope::getAltNavigation(QString const& navigationId)198void MockScope::setNavigationState(QString const& navId)
197{
198 Q_UNUSED(navigationId);
199
200 return new MockDepartment();
201}
202
203void MockScope::setNavigationState(QString const& navId, bool altNavigation)
204{199{
205 Q_UNUSED(navId);200 Q_UNUSED(navId);
206 Q_UNUSED(altNavigation);
207}201}
208202
209void MockScope::cancelActivation()203void MockScope::cancelActivation()
@@ -223,3 +217,21 @@
223void MockScope::refresh()217void MockScope::refresh()
224{218{
225}219}
220
221QString MockScope::primaryNavigationTag() const
222{
223 return "";
224}
225
226void MockScope::resetPrimaryNavigationTag()
227{
228}
229
230void MockScope::resetFilters()
231{
232}
233
234int MockScope::activeFiltersCount() const
235{
236 return 0;
237}
226238
=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h'
--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2016-02-18 15:46:46 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2016-03-11 12:01:26 +0000
@@ -39,16 +39,18 @@
39 bool activationInProgress() const override;39 bool activationInProgress() const override;
40 unity::shell::scopes::CategoriesInterface* categories() const override;40 unity::shell::scopes::CategoriesInterface* categories() const override;
41 unity::shell::scopes::SettingsModelInterface* settings() const override;41 unity::shell::scopes::SettingsModelInterface* settings() const override;
42 unity::shell::scopes::FiltersInterface* filters() const override;
43 unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter() const override;
42 QString searchQuery() const override;44 QString searchQuery() const override;
43 QString noResultsHint() const override;45 QString noResultsHint() const override;
44 QString formFactor() const override;46 QString formFactor() const override;
45 bool isActive() const override;47 bool isActive() const override;
46 bool hasNavigation() const override;48 bool hasNavigation() const override;
47 QString currentNavigationId() const override;49 QString currentNavigationId() const override;
48 bool hasAltNavigation() const override;
49 QString currentAltNavigationId() const override;
50 QVariantMap customizations() const override;50 QVariantMap customizations() const override;
51 Status status() const override;51 Status status() const override;
52 QString primaryNavigationTag() const override;
53 int activeFiltersCount() const override;
5254
53 /* setters */55 /* setters */
54 void setName(const QString& name);56 void setName(const QString& name);
@@ -64,10 +66,11 @@
64 Q_INVOKABLE void cancelActivation() override;66 Q_INVOKABLE void cancelActivation() override;
65 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;67 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
66 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& departmentId) override;68 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& departmentId) override;
67 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& departmentId) override;69 Q_INVOKABLE void setNavigationState(QString const& navId) override;
68 Q_INVOKABLE void setNavigationState(QString const& navId, bool altNavigation) override;
69 Q_INVOKABLE void performQuery(QString const& cannedQuery) override;70 Q_INVOKABLE void performQuery(QString const& cannedQuery) override;
70 Q_INVOKABLE void refresh() override;71 Q_INVOKABLE void refresh() override;
72 Q_INVOKABLE void resetPrimaryNavigationTag() override;
73 Q_INVOKABLE void resetFilters() override;
7174
72protected:75protected:
73 QString m_id;76 QString m_id;
@@ -78,18 +81,17 @@
78 QString m_noResultsHint;81 QString m_noResultsHint;
79 QString m_formFactor;82 QString m_formFactor;
80 QString m_currentDepartmentId;83 QString m_currentDepartmentId;
81 QString m_currentAltDepartmentId;
82 bool m_favorite;84 bool m_favorite;
83 bool m_searching;85 bool m_searching;
84 bool m_isActive;86 bool m_isActive;
85 bool m_hasNavigation;87 bool m_hasNavigation;
86 bool m_hasAltNavigation;
87 QVariantMap m_customizations;88 QVariantMap m_customizations;
8889
89 QString m_previewRendererName;90 QString m_previewRendererName;
9091
91 unity::shell::scopes::CategoriesInterface* m_categories;92 unity::shell::scopes::CategoriesInterface* m_categories;
92 unity::shell::scopes::SettingsModelInterface* m_settings;93 unity::shell::scopes::SettingsModelInterface* m_settings;
94 unity::shell::scopes::FiltersInterface* m_filters;
93};95};
9496
95#endif97#endif
9698
=== 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 2016-03-11 12:01:26 +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 2016-03-11 12:01:26 +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 2016-02-11 14:00:36 +0000
+++ test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2016-03-11 12:01:26 +0000
@@ -25,6 +25,10 @@
25#include "PreviewModelInterface.h"25#include "PreviewModelInterface.h"
26#include "PreviewWidgetModelInterface.h"26#include "PreviewWidgetModelInterface.h"
27#include "SettingsModelInterface.h"27#include "SettingsModelInterface.h"
28#include "FiltersInterface.h"
29#include "FilterBaseInterface.h"
30#include "OptionSelectorOptionsInterface.h"
31#include "OptionSelectorFilterInterface.h"
28#include "Mocks/MockScopes.h"32#include "Mocks/MockScopes.h"
29#include "Mocks/MockScope.h"33#include "Mocks/MockScope.h"
3034
@@ -38,4 +42,8 @@
38 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");42 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");
39 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");43 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
40 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create new Settings in QML. Get them from Scope instance.");44 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create new Settings in QML. Get them from Scope instance.");
45 qmlRegisterUncreatableType<unity::shell::scopes::FilterBaseInterface>(uri, 0, 2, "FilterBase", "Can't create new Filter in QML. Get them from Filters instance.");
46 qmlRegisterUncreatableType<unity::shell::scopes::FiltersInterface>(uri, 0, 2, "Filters", "Can't create new Filters in QML. Get them from Scope instance.");
47 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create new OptionSelectorOptions in QML. Get them from OptionSelectorFilter instance.");
48 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorFilterInterface>(uri, 0, 2, "OptionSelectorFilter", "Can't create new OptionSelectorFilter in QML. Get them from Scope instance.");
41}49}
4250
=== modified file 'test/qmltest/unity/shell/scopes/tst_Scopes.qml'
--- test/qmltest/unity/shell/scopes/tst_Scopes.qml 2016-02-11 14:06:46 +0000
+++ test/qmltest/unity/shell/scopes/tst_Scopes.qml 2016-03-11 12:01:26 +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: