Merge lp:~unity-team/unity-scopes-shell/sort-order into lp:unity-scopes-shell
- sort-order
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 153 |
Merged at revision: | 123 |
Proposed branch: | lp:~unity-team/unity-scopes-shell/sort-order |
Merge into: | lp:unity-scopes-shell |
Diff against target: |
1749 lines (+780/-169) 24 files modified
debian/changelog (+6/-0) debian/control (+2/-3) src/Unity/CMakeLists.txt (+2/-2) src/Unity/collectors.cpp (+37/-3) src/Unity/collectors.h (+9/-5) src/Unity/department.cpp (+28/-13) src/Unity/department.h (+12/-6) src/Unity/departmentnode.cpp (+57/-1) src/Unity/departmentnode.h (+8/-0) src/Unity/overviewscope.cpp (+0/-5) src/Unity/overviewscope.h (+0/-1) src/Unity/plugin.cpp (+1/-1) src/Unity/scope.cpp (+231/-80) src/Unity/scope.h (+27/-8) src/Unity/scopes.cpp (+6/-2) src/Unity/scopes.h (+1/-0) tests/data/CMakeLists.txt (+1/-0) tests/data/mock-scope-double-nav/CMakeLists.txt (+16/-0) tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp (+214/-0) tests/data/mock-scope-double-nav/mock-scope-double-nav.ini.in (+8/-0) tests/departmentstest.cpp (+106/-29) tests/previewtest.cpp (+3/-3) tests/resultstest.cpp (+3/-5) tests/settingsendtoendtest.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~unity-team/unity-scopes-shell/sort-order |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Pete Woods (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Review via email: mp+229190@code.launchpad.net |
Commit message
Implemented alt navigation as per shell interface v4.
Description of the change
Implemented alt navigation as per shell interface v4.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 145. By Michal Hruby
-
Drop support for impl-2 and 3, as the interfaces changed
- 146. By Michal Hruby
-
Compile with very latest unity-api
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:146
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 147. By Michal Hruby
-
Update for the latest interface
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:147
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 148. By Michal Hruby
-
Update tests
- 149. By Michal Hruby
-
Merge with drop-appid branch
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:149
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 150. By Michal Hruby
-
Implement refresh method
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:150
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 151. By Michal Hruby
-
Reset filter state on non-empty queries
- 152. By Michal Hruby
-
Merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:152
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Pete Woods (pete-woods) wrote : | # |
Conflicts with trunk
- 153. By Michal Hruby
-
Merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:153
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Pete Woods (pete-woods) : | # |
Michal Hruby (mhr3) : | # |
Pete Woods (pete-woods) : | # |
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2014-08-05 16:42:48 +0000 | |||
3 | +++ debian/changelog 2014-08-06 08:35:31 +0000 | |||
4 | @@ -1,3 +1,9 @@ | |||
5 | 1 | unity-scopes-shell (0.5.3-0ubuntu1) UNRELEASED; urgency=medium | ||
6 | 2 | |||
7 | 3 | * Implemented shell interface version 4 | ||
8 | 4 | |||
9 | 5 | -- Michal Hruby <michal.hruby@canonical.com> Fri, 01 Aug 2014 11:08:43 +0100 | ||
10 | 6 | |||
11 | 1 | unity-scopes-shell (0.5.2+14.10.20140805.1-0ubuntu1) utopic; urgency=low | 7 | unity-scopes-shell (0.5.2+14.10.20140805.1-0ubuntu1) utopic; urgency=low |
12 | 2 | 8 | ||
13 | 3 | [ Pete Woods ] | 9 | [ Pete Woods ] |
14 | 4 | 10 | ||
15 | === modified file 'debian/control' | |||
16 | --- debian/control 2014-08-01 10:25:41 +0000 | |||
17 | +++ debian/control 2014-08-06 08:35:31 +0000 | |||
18 | @@ -3,7 +3,7 @@ | |||
19 | 3 | Section: libs | 3 | Section: libs |
20 | 4 | Build-Depends: cmake, | 4 | Build-Depends: cmake, |
21 | 5 | debhelper (>= 9), | 5 | debhelper (>= 9), |
23 | 6 | libunity-api-dev (>= 7.87), | 6 | libunity-api-dev (>= 7.88), |
24 | 7 | libunity-scopes-dev (>= 0.6.0~), | 7 | libunity-scopes-dev (>= 0.6.0~), |
25 | 8 | libgsettings-qt-dev (>= 0.1), | 8 | libgsettings-qt-dev (>= 0.1), |
26 | 9 | libqtdbustest1-dev (>= 0.2), | 9 | libqtdbustest1-dev (>= 0.2), |
27 | @@ -34,8 +34,7 @@ | |||
28 | 34 | Provides: unity-scopes-impl, | 34 | Provides: unity-scopes-impl, |
29 | 35 | unity-scopes-impl-0, | 35 | unity-scopes-impl-0, |
30 | 36 | unity-scopes-impl-1, | 36 | unity-scopes-impl-1, |
33 | 37 | unity-scopes-impl-2, | 37 | unity-scopes-impl-4, |
32 | 38 | unity-scopes-impl-3, | ||
34 | 39 | Breaks: unity8-private (<< 7.84) | 38 | Breaks: unity8-private (<< 7.84) |
35 | 40 | Replaces: unity8-private (<< 7.84) | 39 | Replaces: unity8-private (<< 7.84) |
36 | 41 | Description: QML plugin for Scopes | 40 | Description: QML plugin for Scopes |
37 | 42 | 41 | ||
38 | === modified file 'src/Unity/CMakeLists.txt' | |||
39 | --- src/Unity/CMakeLists.txt 2014-08-01 10:25:41 +0000 | |||
40 | +++ src/Unity/CMakeLists.txt 2014-08-06 08:35:31 +0000 | |||
41 | @@ -2,7 +2,7 @@ | |||
42 | 2 | include(Plugins) | 2 | include(Plugins) |
43 | 3 | 3 | ||
44 | 4 | # Dependencies | 4 | # Dependencies |
46 | 5 | pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=3) | 5 | pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=4) |
47 | 6 | pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.6.0) | 6 | pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.6.0) |
48 | 7 | pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt) | 7 | pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt) |
49 | 8 | pkg_check_modules(U1DB REQUIRED libu1db-qt5) | 8 | pkg_check_modules(U1DB REQUIRED libu1db-qt5) |
50 | @@ -41,7 +41,7 @@ | |||
51 | 41 | # We need these headers here so moc runs and we get the moc-stuff | 41 | # We need these headers here so moc runs and we get the moc-stuff |
52 | 42 | # compiled in, otherwise we miss some symbols | 42 | # compiled in, otherwise we miss some symbols |
53 | 43 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h | 43 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h |
55 | 44 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/DepartmentInterface.h | 44 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h |
56 | 45 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h | 45 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h |
57 | 46 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h | 46 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h |
58 | 47 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h | 47 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h |
59 | 48 | 48 | ||
60 | === modified file 'src/Unity/collectors.cpp' | |||
61 | --- src/Unity/collectors.cpp 2014-08-01 10:34:32 +0000 | |||
62 | +++ src/Unity/collectors.cpp 2014-08-06 08:35:31 +0000 | |||
63 | @@ -93,7 +93,19 @@ | |||
64 | 93 | m_rootDepartment = department; | 93 | m_rootDepartment = department; |
65 | 94 | } | 94 | } |
66 | 95 | 95 | ||
68 | 96 | Status collect(QList<scopes::CategorisedResult::SPtr>& out_results, scopes::Department::SCPtr& out_rootDepartment) | 96 | void setSortOrder(scopes::OptionSelectorFilter::SCPtr const& sortOrder) |
69 | 97 | { | ||
70 | 98 | QMutexLocker locker(&m_mutex); | ||
71 | 99 | m_sortOrderFilter = sortOrder; | ||
72 | 100 | } | ||
73 | 101 | |||
74 | 102 | void setFilterState(scopes::FilterState const& state) | ||
75 | 103 | { | ||
76 | 104 | QMutexLocker locker(&m_mutex); | ||
77 | 105 | m_filterState = state; | ||
78 | 106 | } | ||
79 | 107 | |||
80 | 108 | Status collect(QList<scopes::CategorisedResult::SPtr>& out_results, scopes::Department::SCPtr& out_rootDepartment, scopes::OptionSelectorFilter::SCPtr& out_sortOrder, scopes::FilterState& out_filterState) | ||
81 | 97 | { | 109 | { |
82 | 98 | Status status; | 110 | Status status; |
83 | 99 | 111 | ||
84 | @@ -106,12 +118,17 @@ | |||
85 | 106 | m_results.swap(out_results); | 118 | m_results.swap(out_results); |
86 | 107 | out_rootDepartment = m_rootDepartment; | 119 | out_rootDepartment = m_rootDepartment; |
87 | 108 | 120 | ||
88 | 121 | out_sortOrder = m_sortOrderFilter; | ||
89 | 122 | out_filterState = m_filterState; | ||
90 | 123 | |||
91 | 109 | return status; | 124 | return status; |
92 | 110 | } | 125 | } |
93 | 111 | 126 | ||
94 | 112 | private: | 127 | private: |
95 | 113 | QList<scopes::CategorisedResult::SPtr> m_results; | 128 | QList<scopes::CategorisedResult::SPtr> m_results; |
96 | 114 | scopes::Department::SCPtr m_rootDepartment; | 129 | scopes::Department::SCPtr m_rootDepartment; |
97 | 130 | scopes::OptionSelectorFilter::SCPtr m_sortOrderFilter; | ||
98 | 131 | scopes::FilterState m_filterState; | ||
99 | 115 | }; | 132 | }; |
100 | 116 | 133 | ||
101 | 117 | class PreviewDataCollector: public CollectorBase | 134 | class PreviewDataCollector: public CollectorBase |
102 | @@ -222,10 +239,10 @@ | |||
103 | 222 | return m_collector->msecsSinceStart(); | 239 | return m_collector->msecsSinceStart(); |
104 | 223 | } | 240 | } |
105 | 224 | 241 | ||
107 | 225 | CollectorBase::Status PushEvent::collectSearchResults(QList<scopes::CategorisedResult::SPtr>& out_results, scopes::Department::SCPtr& rootDepartment) | 242 | CollectorBase::Status PushEvent::collectSearchResults(QList<scopes::CategorisedResult::SPtr>& out_results, scopes::Department::SCPtr& rootDepartment, scopes::OptionSelectorFilter::SCPtr& sortOrder, scopes::FilterState& filterState) |
108 | 226 | { | 243 | { |
109 | 227 | auto collector = std::dynamic_pointer_cast<SearchDataCollector>(m_collector); | 244 | auto collector = std::dynamic_pointer_cast<SearchDataCollector>(m_collector); |
111 | 228 | return collector->collect(out_results, rootDepartment); | 245 | return collector->collect(out_results, rootDepartment, sortOrder, filterState); |
112 | 229 | } | 246 | } |
113 | 230 | 247 | ||
114 | 231 | CollectorBase::Status PushEvent::collectPreviewData(scopes::ColumnLayoutList& out_columns, scopes::PreviewWidgetList& out_widgets, QHash<QString, QVariant>& out_data) | 248 | CollectorBase::Status PushEvent::collectPreviewData(scopes::ColumnLayoutList& out_columns, scopes::PreviewWidgetList& out_widgets, QHash<QString, QVariant>& out_data) |
115 | @@ -287,6 +304,23 @@ | |||
116 | 287 | m_collector->setDepartment(department); | 304 | m_collector->setDepartment(department); |
117 | 288 | } | 305 | } |
118 | 289 | 306 | ||
119 | 307 | void SearchResultReceiver::push(scopes::Filters const& filters, scopes::FilterState const& state) | ||
120 | 308 | { | ||
121 | 309 | for (auto it = filters.begin(); it != filters.end(); ++it) { | ||
122 | 310 | scopes::FilterBase::SCPtr filter = *it; | ||
123 | 311 | if (filter->display_hints() == scopes::FilterBase::DisplayHints::Primary) { | ||
124 | 312 | scopes::OptionSelectorFilter::SCPtr option_filter = std::dynamic_pointer_cast<const scopes::OptionSelectorFilter>(filter); | ||
125 | 313 | if (!option_filter) { | ||
126 | 314 | continue; | ||
127 | 315 | } else { | ||
128 | 316 | m_collector->setSortOrder(option_filter); | ||
129 | 317 | break; | ||
130 | 318 | } | ||
131 | 319 | } | ||
132 | 320 | } | ||
133 | 321 | m_collector->setFilterState(state); | ||
134 | 322 | } | ||
135 | 323 | |||
136 | 290 | // this might be called from any thread (might be main, might be any other thread) | 324 | // this might be called from any thread (might be main, might be any other thread) |
137 | 291 | void SearchResultReceiver::finished(scopes::CompletionDetails const& details) | 325 | void SearchResultReceiver::finished(scopes::CompletionDetails const& details) |
138 | 292 | { | 326 | { |
139 | 293 | 327 | ||
140 | === modified file 'src/Unity/collectors.h' | |||
141 | --- src/Unity/collectors.h 2014-08-01 10:34:32 +0000 | |||
142 | +++ src/Unity/collectors.h 2014-08-06 08:35:31 +0000 | |||
143 | @@ -27,12 +27,15 @@ | |||
144 | 27 | #include <QElapsedTimer> | 27 | #include <QElapsedTimer> |
145 | 28 | 28 | ||
146 | 29 | #include <unity/scopes/ActivationListenerBase.h> | 29 | #include <unity/scopes/ActivationListenerBase.h> |
148 | 30 | #include <unity/scopes/SearchListenerBase.h> | 30 | #include <unity/scopes/ActivationResponse.h> |
149 | 31 | #include <unity/scopes/CategorisedResult.h> | ||
150 | 32 | #include <unity/scopes/FilterBase.h> | ||
151 | 33 | #include <unity/scopes/FilterState.h> | ||
152 | 34 | #include <unity/scopes/OptionSelectorFilter.h> | ||
153 | 31 | #include <unity/scopes/PreviewListenerBase.h> | 35 | #include <unity/scopes/PreviewListenerBase.h> |
155 | 32 | #include <unity/scopes/CategorisedResult.h> | 36 | #include <unity/scopes/PreviewWidget.h> |
156 | 33 | #include <unity/scopes/QueryCtrl.h> | 37 | #include <unity/scopes/QueryCtrl.h> |
159 | 34 | #include <unity/scopes/PreviewWidget.h> | 38 | #include <unity/scopes/SearchListenerBase.h> |
158 | 35 | #include <unity/scopes/ActivationResponse.h> | ||
160 | 36 | 39 | ||
161 | 37 | namespace scopes_ng | 40 | namespace scopes_ng |
162 | 38 | { | 41 | { |
163 | @@ -73,7 +76,7 @@ | |||
164 | 73 | PushEvent(Type event_type, std::shared_ptr<CollectorBase> collector); | 76 | PushEvent(Type event_type, std::shared_ptr<CollectorBase> collector); |
165 | 74 | Type type(); | 77 | Type type(); |
166 | 75 | 78 | ||
168 | 76 | CollectorBase::Status collectSearchResults(QList<std::shared_ptr<unity::scopes::CategorisedResult>>& out_results, unity::scopes::Department::SCPtr& out_rootDepartment); | 79 | CollectorBase::Status collectSearchResults(QList<std::shared_ptr<unity::scopes::CategorisedResult>>& out_results, unity::scopes::Department::SCPtr& out_rootDepartment, unity::scopes::OptionSelectorFilter::SCPtr& out_sortOrder, unity::scopes::FilterState& out_filterState); |
169 | 77 | CollectorBase::Status collectPreviewData(unity::scopes::ColumnLayoutList& out_columns, unity::scopes::PreviewWidgetList& out_widgets, QHash<QString, QVariant>& out_data); | 80 | CollectorBase::Status collectPreviewData(unity::scopes::ColumnLayoutList& out_columns, unity::scopes::PreviewWidgetList& out_widgets, QHash<QString, QVariant>& out_data); |
170 | 78 | CollectorBase::Status collectActivationResponse(std::shared_ptr<unity::scopes::ActivationResponse>& out_response, std::shared_ptr<unity::scopes::Result>& out_result); | 81 | CollectorBase::Status collectActivationResponse(std::shared_ptr<unity::scopes::ActivationResponse>& out_response, std::shared_ptr<unity::scopes::Result>& out_result); |
171 | 79 | 82 | ||
172 | @@ -105,6 +108,7 @@ | |||
173 | 105 | public: | 108 | public: |
174 | 106 | virtual void push(unity::scopes::CategorisedResult result) override; | 109 | virtual void push(unity::scopes::CategorisedResult result) override; |
175 | 107 | virtual void push(unity::scopes::Department::SCPtr const& department) override; | 110 | virtual void push(unity::scopes::Department::SCPtr const& department) override; |
176 | 111 | virtual void push(unity::scopes::Filters const& filters, unity::scopes::FilterState const& state) override; | ||
177 | 108 | virtual void finished(unity::scopes::CompletionDetails const& details) override; | 112 | virtual void finished(unity::scopes::CompletionDetails const& details) override; |
178 | 109 | 113 | ||
179 | 110 | SearchResultReceiver(QObject* receiver); | 114 | SearchResultReceiver(QObject* receiver); |
180 | 111 | 115 | ||
181 | === modified file 'src/Unity/department.cpp' | |||
182 | --- src/Unity/department.cpp 2014-06-12 11:34:44 +0000 | |||
183 | +++ src/Unity/department.cpp 2014-08-06 08:35:31 +0000 | |||
184 | @@ -19,16 +19,22 @@ | |||
185 | 19 | 19 | ||
186 | 20 | #include "department.h" | 20 | #include "department.h" |
187 | 21 | 21 | ||
188 | 22 | #include <unity/scopes/OptionSelectorFilter.h> | ||
189 | 23 | |||
190 | 22 | namespace scopes_ng | 24 | namespace scopes_ng |
191 | 23 | { | 25 | { |
192 | 24 | 26 | ||
193 | 25 | using namespace unity; | 27 | using namespace unity; |
194 | 26 | 28 | ||
195 | 27 | Department::Department(QObject* parent) : | 29 | Department::Department(QObject* parent) : |
200 | 28 | unity::shell::scopes::DepartmentInterface(parent), | 30 | unity::shell::scopes::NavigationInterface(parent), |
201 | 29 | m_loaded(false), | 31 | m_loaded(false), m_isRoot(false), m_hidden(false), m_isFilter(false) |
202 | 30 | m_isRoot(false) | 32 | { |
203 | 31 | { | 33 | } |
204 | 34 | |||
205 | 35 | void Department::setScopeId(QString const& scopeId) | ||
206 | 36 | { | ||
207 | 37 | m_scopeId = scopeId; | ||
208 | 32 | } | 38 | } |
209 | 33 | 39 | ||
210 | 34 | void Department::loadFromDepartmentNode(DepartmentNode* treeNode) | 40 | void Department::loadFromDepartmentNode(DepartmentNode* treeNode) |
211 | @@ -37,14 +43,17 @@ | |||
212 | 37 | qWarning("Tried to set null DepartmentNode!"); | 43 | qWarning("Tried to set null DepartmentNode!"); |
213 | 38 | return; | 44 | return; |
214 | 39 | } | 45 | } |
216 | 40 | m_departmentId = treeNode->id(); | 46 | m_navigationId = treeNode->id(); |
217 | 47 | m_filterId = treeNode->filterId(); | ||
218 | 41 | m_label = treeNode->label(); | 48 | m_label = treeNode->label(); |
219 | 42 | m_allLabel = treeNode->allLabel(); | 49 | m_allLabel = treeNode->allLabel(); |
220 | 43 | m_loaded = !treeNode->isLeaf() && treeNode->childCount() > 0; | 50 | m_loaded = !treeNode->isLeaf() && treeNode->childCount() > 0; |
221 | 44 | m_isRoot = treeNode->isRoot(); | 51 | m_isRoot = treeNode->isRoot(); |
222 | 52 | m_hidden = treeNode->hidden(); | ||
223 | 53 | m_isFilter = treeNode->isFilter(); | ||
224 | 45 | 54 | ||
225 | 46 | DepartmentNode* parentNode = treeNode->parent(); | 55 | DepartmentNode* parentNode = treeNode->parent(); |
227 | 47 | m_parentDepartmentId = parentNode ? parentNode->id() : ""; | 56 | m_parentNavigationId = parentNode ? parentNode->id() : ""; |
228 | 48 | m_parentLabel = parentNode ? parentNode->label() : ""; | 57 | m_parentLabel = parentNode ? parentNode->label() : ""; |
229 | 49 | 58 | ||
230 | 50 | beginResetModel(); | 59 | beginResetModel(); |
231 | @@ -61,14 +70,15 @@ | |||
232 | 61 | 70 | ||
233 | 62 | endResetModel(); | 71 | endResetModel(); |
234 | 63 | 72 | ||
236 | 64 | Q_EMIT departmentIdChanged(); | 73 | Q_EMIT navigationIdChanged(); |
237 | 65 | Q_EMIT labelChanged(); | 74 | Q_EMIT labelChanged(); |
238 | 66 | Q_EMIT allLabelChanged(); | 75 | Q_EMIT allLabelChanged(); |
240 | 67 | Q_EMIT parentDepartmentIdChanged(); | 76 | Q_EMIT parentNavigationIdChanged(); |
241 | 68 | Q_EMIT parentLabelChanged(); | 77 | Q_EMIT parentLabelChanged(); |
242 | 69 | Q_EMIT loadedChanged(); | 78 | Q_EMIT loadedChanged(); |
243 | 70 | Q_EMIT countChanged(); | 79 | Q_EMIT countChanged(); |
244 | 71 | Q_EMIT isRootChanged(); | 80 | Q_EMIT isRootChanged(); |
245 | 81 | Q_EMIT hiddenChanged(); | ||
246 | 72 | } | 82 | } |
247 | 73 | 83 | ||
248 | 74 | void Department::markSubdepartmentActive(QString const& subdepartmentId) | 84 | void Department::markSubdepartmentActive(QString const& subdepartmentId) |
249 | @@ -100,7 +110,7 @@ | |||
250 | 100 | { | 110 | { |
251 | 101 | SubdepartmentData* data = m_subdepartments[index.row()].data(); | 111 | SubdepartmentData* data = m_subdepartments[index.row()].data(); |
252 | 102 | switch (role) { | 112 | switch (role) { |
254 | 103 | case RoleDepartmentId: return data->id; | 113 | case RoleNavigationId: return data->id; |
255 | 104 | case RoleLabel: return data->label; | 114 | case RoleLabel: return data->label; |
256 | 105 | case RoleHasChildren: return data->hasChildren; | 115 | case RoleHasChildren: return data->hasChildren; |
257 | 106 | case RoleIsActive: return data->isActive; | 116 | case RoleIsActive: return data->isActive; |
258 | @@ -114,9 +124,9 @@ | |||
259 | 114 | return m_subdepartments.size(); | 124 | return m_subdepartments.size(); |
260 | 115 | } | 125 | } |
261 | 116 | 126 | ||
263 | 117 | QString Department::departmentId() const | 127 | QString Department::navigationId() const |
264 | 118 | { | 128 | { |
266 | 119 | return m_departmentId; | 129 | return m_navigationId; |
267 | 120 | } | 130 | } |
268 | 121 | 131 | ||
269 | 122 | QString Department::label() const | 132 | QString Department::label() const |
270 | @@ -129,9 +139,9 @@ | |||
271 | 129 | return m_allLabel; | 139 | return m_allLabel; |
272 | 130 | } | 140 | } |
273 | 131 | 141 | ||
275 | 132 | QString Department::parentDepartmentId() const | 142 | QString Department::parentNavigationId() const |
276 | 133 | { | 143 | { |
278 | 134 | return m_parentDepartmentId; | 144 | return m_parentNavigationId; |
279 | 135 | } | 145 | } |
280 | 136 | 146 | ||
281 | 137 | QString Department::parentLabel() const | 147 | QString Department::parentLabel() const |
282 | @@ -149,6 +159,11 @@ | |||
283 | 149 | return m_isRoot; | 159 | return m_isRoot; |
284 | 150 | } | 160 | } |
285 | 151 | 161 | ||
286 | 162 | bool Department::hidden() const | ||
287 | 163 | { | ||
288 | 164 | return m_hidden; | ||
289 | 165 | } | ||
290 | 166 | |||
291 | 152 | int Department::count() const | 167 | int Department::count() const |
292 | 153 | { | 168 | { |
293 | 154 | return rowCount(); | 169 | return rowCount(); |
294 | 155 | 170 | ||
295 | === modified file 'src/Unity/department.h' | |||
296 | --- src/Unity/department.h 2014-06-12 11:34:44 +0000 | |||
297 | +++ src/Unity/department.h 2014-08-06 08:35:31 +0000 | |||
298 | @@ -21,7 +21,7 @@ | |||
299 | 21 | #ifndef NG_DEPARTMENT_H | 21 | #ifndef NG_DEPARTMENT_H |
300 | 22 | #define NG_DEPARTMENT_H | 22 | #define NG_DEPARTMENT_H |
301 | 23 | 23 | ||
303 | 24 | #include <unity/shell/scopes/DepartmentInterface.h> | 24 | #include <unity/shell/scopes/NavigationInterface.h> |
304 | 25 | 25 | ||
305 | 26 | #include <QString> | 26 | #include <QString> |
306 | 27 | #include <QSharedPointer> | 27 | #include <QSharedPointer> |
307 | @@ -44,37 +44,43 @@ | |||
308 | 44 | bool isActive; | 44 | bool isActive; |
309 | 45 | }; | 45 | }; |
310 | 46 | 46 | ||
312 | 47 | class Q_DECL_EXPORT Department : public unity::shell::scopes::DepartmentInterface | 47 | class Q_DECL_EXPORT Department : public unity::shell::scopes::NavigationInterface |
313 | 48 | { | 48 | { |
314 | 49 | Q_OBJECT | 49 | Q_OBJECT |
315 | 50 | 50 | ||
316 | 51 | public: | 51 | public: |
317 | 52 | explicit Department(QObject* parent = 0); | 52 | explicit Department(QObject* parent = 0); |
318 | 53 | void setScopeId(QString const& scopeId); | ||
319 | 53 | void loadFromDepartmentNode(DepartmentNode* treeNode); | 54 | void loadFromDepartmentNode(DepartmentNode* treeNode); |
320 | 54 | void markSubdepartmentActive(QString const& subdepartmentId); | 55 | void markSubdepartmentActive(QString const& subdepartmentId); |
321 | 55 | 56 | ||
322 | 56 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | 57 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
323 | 57 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 58 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
324 | 58 | 59 | ||
326 | 59 | QString departmentId() const override; | 60 | QString navigationId() const override; |
327 | 60 | QString label() const override; | 61 | QString label() const override; |
328 | 61 | QString allLabel() const override; | 62 | QString allLabel() const override; |
330 | 62 | QString parentDepartmentId() const override; | 63 | QString parentNavigationId() const override; |
331 | 63 | QString parentLabel() const override; | 64 | QString parentLabel() const override; |
332 | 64 | bool loaded() const override; | 65 | bool loaded() const override; |
333 | 65 | bool isRoot() const override; | 66 | bool isRoot() const override; |
334 | 67 | bool hidden() const override; | ||
335 | 66 | int count() const override; | 68 | int count() const override; |
336 | 67 | 69 | ||
337 | 68 | Q_SIGNALS: | 70 | Q_SIGNALS: |
338 | 69 | 71 | ||
339 | 70 | private: | 72 | private: |
341 | 71 | QString m_departmentId; | 73 | QString m_navigationId; |
342 | 74 | QString m_scopeId; | ||
343 | 75 | QString m_filterId; | ||
344 | 72 | QString m_label; | 76 | QString m_label; |
345 | 73 | QString m_allLabel; | 77 | QString m_allLabel; |
347 | 74 | QString m_parentDepartmentId; | 78 | QString m_parentNavigationId; |
348 | 75 | QString m_parentLabel; | 79 | QString m_parentLabel; |
349 | 76 | bool m_loaded; | 80 | bool m_loaded; |
350 | 77 | bool m_isRoot; | 81 | bool m_isRoot; |
351 | 82 | bool m_hidden; | ||
352 | 83 | bool m_isFilter; | ||
353 | 78 | 84 | ||
354 | 79 | QList<QSharedPointer<SubdepartmentData>> m_subdepartments; | 85 | QList<QSharedPointer<SubdepartmentData>> m_subdepartments; |
355 | 80 | }; | 86 | }; |
356 | 81 | 87 | ||
357 | === modified file 'src/Unity/departmentnode.cpp' | |||
358 | --- src/Unity/departmentnode.cpp 2014-05-28 07:04:50 +0000 | |||
359 | +++ src/Unity/departmentnode.cpp 2014-08-06 08:35:31 +0000 | |||
360 | @@ -24,7 +24,11 @@ | |||
361 | 24 | 24 | ||
362 | 25 | using namespace unity; | 25 | using namespace unity; |
363 | 26 | 26 | ||
365 | 27 | DepartmentNode::DepartmentNode(DepartmentNode* parent) : m_parent(parent), m_isRoot(false) | 27 | DepartmentNode::DepartmentNode(DepartmentNode* parent) |
366 | 28 | : m_parent(parent) | ||
367 | 29 | , m_isRoot(false) | ||
368 | 30 | , m_hidden(false) | ||
369 | 31 | , m_isFilter(false) | ||
370 | 28 | { | 32 | { |
371 | 29 | } | 33 | } |
372 | 30 | 34 | ||
373 | @@ -39,6 +43,8 @@ | |||
374 | 39 | m_label = QString::fromStdString(dep->label()); | 43 | m_label = QString::fromStdString(dep->label()); |
375 | 40 | m_allLabel = QString::fromStdString(dep->alternate_label()); | 44 | m_allLabel = QString::fromStdString(dep->alternate_label()); |
376 | 41 | m_hasSubdepartments = dep->has_subdepartments(); | 45 | m_hasSubdepartments = dep->has_subdepartments(); |
377 | 46 | m_hidden = false; | ||
378 | 47 | m_isFilter = false; | ||
379 | 42 | 48 | ||
380 | 43 | clearChildren(); | 49 | clearChildren(); |
381 | 44 | 50 | ||
382 | @@ -50,6 +56,41 @@ | |||
383 | 50 | } | 56 | } |
384 | 51 | } | 57 | } |
385 | 52 | 58 | ||
386 | 59 | void DepartmentNode::initializeForFilter(scopes::OptionSelectorFilter::SCPtr const& filter) | ||
387 | 60 | { | ||
388 | 61 | auto children = filter->options(); | ||
389 | 62 | m_id = QString(""); // this is root (which we shouldn't show really) | ||
390 | 63 | m_filterId = QString::fromStdString(filter->id()); | ||
391 | 64 | m_label = QString::fromStdString(filter->label()); | ||
392 | 65 | m_allLabel = QString(); | ||
393 | 66 | m_hasSubdepartments = !children.empty(); | ||
394 | 67 | m_isRoot = true; | ||
395 | 68 | m_hidden = true; | ||
396 | 69 | m_isFilter = true; | ||
397 | 70 | |||
398 | 71 | clearChildren(); | ||
399 | 72 | |||
400 | 73 | for (auto it = children.begin(); it != children.end(); ++it) { | ||
401 | 74 | DepartmentNode* subdep = new DepartmentNode(this); | ||
402 | 75 | subdep->initializeForFilterOption(*it, m_filterId); | ||
403 | 76 | this->appendChild(subdep); | ||
404 | 77 | } | ||
405 | 78 | } | ||
406 | 79 | |||
407 | 80 | void DepartmentNode::initializeForFilterOption(scopes::FilterOption::SCPtr const& option, QString const& filterId) | ||
408 | 81 | { | ||
409 | 82 | m_id = QString::fromStdString(option->id()); | ||
410 | 83 | m_filterId = filterId; | ||
411 | 84 | m_label = QString::fromStdString(option->label()); | ||
412 | 85 | m_allLabel = QString(); | ||
413 | 86 | m_hasSubdepartments = false; | ||
414 | 87 | m_isRoot = false; | ||
415 | 88 | m_hidden = false; | ||
416 | 89 | m_isFilter = true; | ||
417 | 90 | |||
418 | 91 | clearChildren(); | ||
419 | 92 | } | ||
420 | 93 | |||
421 | 53 | void DepartmentNode::setIsRoot(bool isRoot) | 94 | void DepartmentNode::setIsRoot(bool isRoot) |
422 | 54 | { | 95 | { |
423 | 55 | m_isRoot = isRoot; | 96 | m_isRoot = isRoot; |
424 | @@ -60,6 +101,16 @@ | |||
425 | 60 | return m_isRoot; | 101 | return m_isRoot; |
426 | 61 | } | 102 | } |
427 | 62 | 103 | ||
428 | 104 | bool DepartmentNode::hidden() const | ||
429 | 105 | { | ||
430 | 106 | return m_hidden; | ||
431 | 107 | } | ||
432 | 108 | |||
433 | 109 | bool DepartmentNode::isFilter() const | ||
434 | 110 | { | ||
435 | 111 | return m_isFilter; | ||
436 | 112 | } | ||
437 | 113 | |||
438 | 63 | DepartmentNode* DepartmentNode::findNodeById(QString const& id) | 114 | DepartmentNode* DepartmentNode::findNodeById(QString const& id) |
439 | 64 | { | 115 | { |
440 | 65 | if (id == m_id) return this; | 116 | if (id == m_id) return this; |
441 | @@ -87,6 +138,11 @@ | |||
442 | 87 | return m_allLabel; | 138 | return m_allLabel; |
443 | 88 | } | 139 | } |
444 | 89 | 140 | ||
445 | 141 | QString DepartmentNode::filterId() const | ||
446 | 142 | { | ||
447 | 143 | return m_filterId; | ||
448 | 144 | } | ||
449 | 145 | |||
450 | 90 | bool DepartmentNode::hasSubdepartments() const | 146 | bool DepartmentNode::hasSubdepartments() const |
451 | 91 | { | 147 | { |
452 | 92 | return m_hasSubdepartments; | 148 | return m_hasSubdepartments; |
453 | 93 | 149 | ||
454 | === modified file 'src/Unity/departmentnode.h' | |||
455 | --- src/Unity/departmentnode.h 2014-05-28 07:04:50 +0000 | |||
456 | +++ src/Unity/departmentnode.h 2014-08-06 08:35:31 +0000 | |||
457 | @@ -38,6 +38,7 @@ | |||
458 | 38 | ~DepartmentNode(); | 38 | ~DepartmentNode(); |
459 | 39 | 39 | ||
460 | 40 | void initializeForDepartment(unity::scopes::Department::SCPtr const& dep); | 40 | void initializeForDepartment(unity::scopes::Department::SCPtr const& dep); |
461 | 41 | void initializeForFilter(unity::scopes::OptionSelectorFilter::SCPtr const& filter); | ||
462 | 41 | DepartmentNode* findNodeById(QString const& id); | 42 | DepartmentNode* findNodeById(QString const& id); |
463 | 42 | 43 | ||
464 | 43 | QString id() const; | 44 | QString id() const; |
465 | @@ -45,6 +46,8 @@ | |||
466 | 45 | QString allLabel() const; | 46 | QString allLabel() const; |
467 | 46 | bool hasSubdepartments() const; | 47 | bool hasSubdepartments() const; |
468 | 47 | bool isRoot() const; | 48 | bool isRoot() const; |
469 | 49 | bool hidden() const; | ||
470 | 50 | bool isFilter() const; | ||
471 | 48 | 51 | ||
472 | 49 | void setIsRoot(bool isRoot); | 52 | void setIsRoot(bool isRoot); |
473 | 50 | 53 | ||
474 | @@ -53,17 +56,22 @@ | |||
475 | 53 | bool isLeaf() const; | 56 | bool isLeaf() const; |
476 | 54 | QList<DepartmentNode*> childNodes() const; | 57 | QList<DepartmentNode*> childNodes() const; |
477 | 55 | DepartmentNode* parent() const; | 58 | DepartmentNode* parent() const; |
478 | 59 | QString filterId() const; | ||
479 | 56 | 60 | ||
480 | 57 | private: | 61 | private: |
481 | 58 | void clearChildren(); | 62 | void clearChildren(); |
482 | 63 | void initializeForFilterOption(unity::scopes::FilterOption::SCPtr const&, QString const&); | ||
483 | 59 | 64 | ||
484 | 60 | DepartmentNode* m_parent; | 65 | DepartmentNode* m_parent; |
485 | 61 | QList<DepartmentNode*> m_children; | 66 | QList<DepartmentNode*> m_children; |
486 | 62 | QString m_id; | 67 | QString m_id; |
487 | 63 | QString m_label; | 68 | QString m_label; |
488 | 64 | QString m_allLabel; | 69 | QString m_allLabel; |
489 | 70 | QString m_filterId; | ||
490 | 65 | bool m_hasSubdepartments; | 71 | bool m_hasSubdepartments; |
491 | 66 | bool m_isRoot; | 72 | bool m_isRoot; |
492 | 73 | bool m_hidden; | ||
493 | 74 | bool m_isFilter; | ||
494 | 67 | }; | 75 | }; |
495 | 68 | 76 | ||
496 | 69 | } // namespace scopes_ng | 77 | } // namespace scopes_ng |
497 | 70 | 78 | ||
498 | === modified file 'src/Unity/overviewscope.cpp' | |||
499 | --- src/Unity/overviewscope.cpp 2014-07-23 12:32:48 +0000 | |||
500 | +++ src/Unity/overviewscope.cpp 2014-08-06 08:35:31 +0000 | |||
501 | @@ -96,11 +96,6 @@ | |||
502 | 96 | return QString("scopes"); | 96 | return QString("scopes"); |
503 | 97 | } | 97 | } |
504 | 98 | 98 | ||
505 | 99 | bool OverviewScope::visible() const | ||
506 | 100 | { | ||
507 | 101 | return false; | ||
508 | 102 | } | ||
509 | 103 | |||
510 | 104 | scopes::ScopeProxy OverviewScope::proxy_for_result(scopes::Result::SPtr const& result) const | 99 | scopes::ScopeProxy OverviewScope::proxy_for_result(scopes::Result::SPtr const& result) const |
511 | 105 | { | 100 | { |
512 | 106 | try { | 101 | try { |
513 | 107 | 102 | ||
514 | === modified file 'src/Unity/overviewscope.h' | |||
515 | --- src/Unity/overviewscope.h 2014-07-18 17:10:39 +0000 | |||
516 | +++ src/Unity/overviewscope.h 2014-08-06 08:35:31 +0000 | |||
517 | @@ -35,7 +35,6 @@ | |||
518 | 35 | 35 | ||
519 | 36 | /* getters */ | 36 | /* getters */ |
520 | 37 | QString id() const override; | 37 | QString id() const override; |
521 | 38 | bool visible() const override; | ||
522 | 39 | 38 | ||
523 | 40 | void dispatchSearch() override; | 39 | void dispatchSearch() override; |
524 | 41 | 40 | ||
525 | 42 | 41 | ||
526 | === modified file 'src/Unity/plugin.cpp' | |||
527 | --- src/Unity/plugin.cpp 2014-06-11 17:08:34 +0000 | |||
528 | +++ src/Unity/plugin.cpp 2014-08-06 08:35:31 +0000 | |||
529 | @@ -41,7 +41,7 @@ | |||
530 | 41 | // new Scopes classes | 41 | // new Scopes classes |
531 | 42 | qmlRegisterType<scopes_ng::Scopes>(uri, 0, 2, "Scopes"); | 42 | qmlRegisterType<scopes_ng::Scopes>(uri, 0, 2, "Scopes"); |
532 | 43 | qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML. Get them from Scopes instance."); | 43 | qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML. Get them from Scopes instance."); |
534 | 44 | qmlRegisterUncreatableType<unity::shell::scopes::DepartmentInterface>(uri, 0, 2, "Department", "Can't create Department object in QML. Get them from Scope instance."); | 44 | qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML. Get them from Scope instance."); |
535 | 45 | qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML. Get them from Scope instance."); | 45 | qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML. Get them from Scope instance."); |
536 | 46 | qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create Settings object in QML. Get them from Scope instance."); | 46 | qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", "Can't create Settings object in QML. Get them from Scope instance."); |
537 | 47 | qmlRegisterUncreatableType<scopes_ng::ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create new ResultsModel in QML. Get them from Categories instance."); | 47 | qmlRegisterUncreatableType<scopes_ng::ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create new ResultsModel in QML. Get them from Categories instance."); |
538 | 48 | 48 | ||
539 | === modified file 'src/Unity/scope.cpp' | |||
540 | --- src/Unity/scope.cpp 2014-08-05 16:24:32 +0000 | |||
541 | +++ src/Unity/scope.cpp 2014-08-06 08:35:31 +0000 | |||
542 | @@ -47,6 +47,8 @@ | |||
543 | 47 | #include <libintl.h> | 47 | #include <libintl.h> |
544 | 48 | 48 | ||
545 | 49 | #include <unity/scopes/ListenerBase.h> | 49 | #include <unity/scopes/ListenerBase.h> |
546 | 50 | #include <unity/scopes/CannedQuery.h> | ||
547 | 51 | #include <unity/scopes/OptionSelectorFilter.h> | ||
548 | 50 | #include <unity/scopes/CategorisedResult.h> | 52 | #include <unity/scopes/CategorisedResult.h> |
549 | 51 | #include <unity/scopes/QueryCtrl.h> | 53 | #include <unity/scopes/QueryCtrl.h> |
550 | 52 | #include <unity/scopes/PreviewWidget.h> | 54 | #include <unity/scopes/PreviewWidget.h> |
551 | @@ -70,9 +72,11 @@ | |||
552 | 70 | , m_searchInProgress(false) | 72 | , m_searchInProgress(false) |
553 | 71 | , m_resultsDirty(false) | 73 | , m_resultsDirty(false) |
554 | 72 | , m_delayedClear(false) | 74 | , m_delayedClear(false) |
556 | 73 | , m_hasDepartments(false) | 75 | , m_hasNavigation(false) |
557 | 76 | , m_hasAltNavigation(false) | ||
558 | 74 | , m_searchController(new CollectionController) | 77 | , m_searchController(new CollectionController) |
559 | 75 | , m_activationController(new CollectionController) | 78 | , m_activationController(new CollectionController) |
560 | 79 | , m_status(Status::Okay) | ||
561 | 76 | { | 80 | { |
562 | 77 | m_categories.reset(new Categories(this)); | 81 | m_categories.reset(new Categories(this)); |
563 | 78 | 82 | ||
564 | @@ -99,13 +103,17 @@ | |||
565 | 99 | CollectorBase::Status status; | 103 | CollectorBase::Status status; |
566 | 100 | QList<std::shared_ptr<scopes::CategorisedResult>> results; | 104 | QList<std::shared_ptr<scopes::CategorisedResult>> results; |
567 | 101 | scopes::Department::SCPtr rootDepartment; | 105 | scopes::Department::SCPtr rootDepartment; |
568 | 106 | scopes::OptionSelectorFilter::SCPtr sortOrderFilter; | ||
569 | 107 | scopes::FilterState filterState; | ||
570 | 102 | 108 | ||
572 | 103 | status = pushEvent->collectSearchResults(results, rootDepartment); | 109 | status = pushEvent->collectSearchResults(results, rootDepartment, sortOrderFilter, filterState); |
573 | 104 | if (status == CollectorBase::Status::CANCELLED) { | 110 | if (status == CollectorBase::Status::CANCELLED) { |
574 | 105 | return; | 111 | return; |
575 | 106 | } | 112 | } |
576 | 107 | 113 | ||
577 | 108 | m_rootDepartment = rootDepartment; | 114 | m_rootDepartment = rootDepartment; |
578 | 115 | m_sortOrderFilter = sortOrderFilter; | ||
579 | 116 | m_receivedFilterState = filterState; | ||
580 | 109 | 117 | ||
581 | 110 | if (m_cachedResults.empty()) { | 118 | if (m_cachedResults.empty()) { |
582 | 111 | m_cachedResults.swap(results); | 119 | m_cachedResults.swap(results); |
583 | @@ -126,6 +134,7 @@ | |||
584 | 126 | flushUpdates(); | 134 | flushUpdates(); |
585 | 127 | 135 | ||
586 | 128 | setSearchInProgress(false); | 136 | setSearchInProgress(false); |
587 | 137 | setStatus(status == CollectorBase::Status::FINISHED ? Status::Okay : Status::Unknown); | ||
588 | 129 | 138 | ||
589 | 130 | // Don't schedule a refresh if the query suffered an error | 139 | // Don't schedule a refresh if the query suffered an error |
590 | 131 | if (status == CollectorBase::Status::FINISHED) { | 140 | if (status == CollectorBase::Status::FINISHED) { |
591 | @@ -226,9 +235,13 @@ | |||
592 | 226 | } | 235 | } |
593 | 227 | 236 | ||
594 | 228 | if (scope != nullptr) { | 237 | if (scope != nullptr) { |
597 | 229 | // TODO: change filters? | 238 | scope->setCurrentNavigationId(departmentId); |
598 | 230 | scope->setCurrentDepartmentId(departmentId); | 239 | scope->setFilterState(query.filter_state()); |
599 | 231 | scope->setSearchQuery(searchString); | 240 | scope->setSearchQuery(searchString); |
600 | 241 | // FIXME: implement better way to do multiple changes to search props and dispatch single search | ||
601 | 242 | if (!scope->searchInProgress()) { | ||
602 | 243 | scope->invalidateResults(); | ||
603 | 244 | } | ||
604 | 232 | if (scope != this) Q_EMIT gotoScope(scopeId); | 245 | if (scope != this) Q_EMIT gotoScope(scopeId); |
605 | 233 | } else { | 246 | } else { |
606 | 234 | // create temp dash page | 247 | // create temp dash page |
607 | @@ -237,7 +250,8 @@ | |||
608 | 237 | scope = new scopes_ng::Scope(this); | 250 | scope = new scopes_ng::Scope(this); |
609 | 238 | scope->setScopeData(*meta_sptr); | 251 | scope->setScopeData(*meta_sptr); |
610 | 239 | scope->setScopesInstance(m_scopesInstance); | 252 | scope->setScopesInstance(m_scopesInstance); |
612 | 240 | scope->setCurrentDepartmentId(departmentId); | 253 | scope->setCurrentNavigationId(departmentId); |
613 | 254 | scope->setFilterState(query.filter_state()); | ||
614 | 241 | scope->setSearchQuery(searchString); | 255 | scope->setSearchQuery(searchString); |
615 | 242 | m_tempScopes.insert(scope); | 256 | m_tempScopes.insert(scope); |
616 | 243 | Q_EMIT openScope(scope); | 257 | Q_EMIT openScope(scope); |
617 | @@ -263,6 +277,9 @@ | |||
618 | 263 | m_clearTimer.stop(); | 277 | m_clearTimer.stop(); |
619 | 264 | } | 278 | } |
620 | 265 | 279 | ||
621 | 280 | if (m_status != Status::Okay) { | ||
622 | 281 | setStatus(Status::Okay); | ||
623 | 282 | } | ||
624 | 266 | processResultSet(m_cachedResults); // clears the result list | 283 | processResultSet(m_cachedResults); // clears the result list |
625 | 267 | 284 | ||
626 | 268 | // process departments | 285 | // process departments |
627 | @@ -289,25 +306,7 @@ | |||
628 | 289 | m_departmentTree->setIsRoot(true); | 306 | m_departmentTree->setIsRoot(true); |
629 | 290 | 307 | ||
630 | 291 | // update corresponding models | 308 | // update corresponding models |
650 | 292 | QString activeDepartment(m_currentDepartmentId); | 309 | updateNavigationModels(m_departmentTree.data(), m_departmentModels, m_currentNavigationId); |
632 | 293 | node = m_departmentTree->findNodeById(activeDepartment); | ||
633 | 294 | DepartmentNode* parentNode = nullptr; | ||
634 | 295 | if (node != nullptr) { | ||
635 | 296 | auto it = m_departmentModels.find(activeDepartment); | ||
636 | 297 | while (it != m_departmentModels.end() && it.key() == activeDepartment) { | ||
637 | 298 | it.value()->loadFromDepartmentNode(node); | ||
638 | 299 | ++it; | ||
639 | 300 | } | ||
640 | 301 | // if this node is a leaf, we need to update models for the parent | ||
641 | 302 | parentNode = node->isLeaf() ? node->parent() : nullptr; | ||
642 | 303 | } | ||
643 | 304 | if (parentNode != nullptr) { | ||
644 | 305 | auto it = m_departmentModels.find(parentNode->id()); | ||
645 | 306 | while (it != m_departmentModels.end() && it.key() == parentNode->id()) { | ||
646 | 307 | it.value()->markSubdepartmentActive(activeDepartment); | ||
647 | 308 | ++it; | ||
648 | 309 | } | ||
649 | 310 | } | ||
651 | 311 | } else { | 310 | } else { |
652 | 312 | m_departmentTree.reset(new DepartmentNode); | 311 | m_departmentTree.reset(new DepartmentNode); |
653 | 313 | m_departmentTree->initializeForDepartment(m_rootDepartment); | 312 | m_departmentTree->initializeForDepartment(m_rootDepartment); |
654 | @@ -320,17 +319,80 @@ | |||
655 | 320 | m_lastRootDepartment = m_rootDepartment; | 319 | m_lastRootDepartment = m_rootDepartment; |
656 | 321 | 320 | ||
657 | 322 | bool containsDepartments = m_rootDepartment.get() != nullptr; | 321 | bool containsDepartments = m_rootDepartment.get() != nullptr; |
659 | 323 | // design decision - no departments when doing searches | 322 | // design decision - no navigation when doing searches |
660 | 324 | containsDepartments &= m_searchQuery.isEmpty(); | 323 | containsDepartments &= m_searchQuery.isEmpty(); |
661 | 325 | 324 | ||
670 | 326 | if (containsDepartments != m_hasDepartments) { | 325 | if (containsDepartments != m_hasNavigation) { |
671 | 327 | m_hasDepartments = containsDepartments; | 326 | m_hasNavigation = containsDepartments; |
672 | 328 | Q_EMIT hasDepartmentsChanged(); | 327 | Q_EMIT hasNavigationChanged(); |
673 | 329 | } | 328 | } |
674 | 330 | 329 | ||
675 | 331 | if (!containsDepartments && !m_currentDepartmentId.isEmpty()) { | 330 | if (!containsDepartments && !m_currentNavigationId.isEmpty()) { |
676 | 332 | m_currentDepartmentId = ""; | 331 | m_currentNavigationId = ""; |
677 | 333 | Q_EMIT currentDepartmentIdChanged(); | 332 | Q_EMIT currentNavigationIdChanged(); |
678 | 333 | } | ||
679 | 334 | |||
680 | 335 | // process the alt navigation (sort order filter) | ||
681 | 336 | QString currentAltNav(m_currentAltNavigationId); | ||
682 | 337 | |||
683 | 338 | if (m_sortOrderFilter && m_sortOrderFilter != m_lastSortOrderFilter) { | ||
684 | 339 | // build the nodes | ||
685 | 340 | m_altNavTree.reset(new DepartmentNode); | ||
686 | 341 | m_altNavTree->initializeForFilter(m_sortOrderFilter); | ||
687 | 342 | |||
688 | 343 | if (m_sortOrderFilter->has_active_option(m_receivedFilterState)) { | ||
689 | 344 | auto active_options = m_sortOrderFilter->active_options(m_receivedFilterState); | ||
690 | 345 | scopes::FilterOption::SCPtr active_option = *active_options.begin(); | ||
691 | 346 | if (active_option) { | ||
692 | 347 | currentAltNav = QString::fromStdString(active_option->id()); | ||
693 | 348 | } | ||
694 | 349 | } | ||
695 | 350 | } | ||
696 | 351 | |||
697 | 352 | m_lastSortOrderFilter = m_sortOrderFilter; | ||
698 | 353 | |||
699 | 354 | bool containsAltNav = m_sortOrderFilter.get() != nullptr; | ||
700 | 355 | // design decision - no navigation when doing searches | ||
701 | 356 | containsAltNav &= m_searchQuery.isEmpty(); | ||
702 | 357 | |||
703 | 358 | if (containsAltNav != m_hasAltNavigation) { | ||
704 | 359 | m_hasAltNavigation = containsAltNav; | ||
705 | 360 | Q_EMIT hasAltNavigationChanged(); | ||
706 | 361 | } | ||
707 | 362 | |||
708 | 363 | if (!containsAltNav && !m_currentAltNavigationId.isEmpty()) { | ||
709 | 364 | m_currentAltNavigationId = ""; | ||
710 | 365 | Q_EMIT currentAltNavigationIdChanged(); | ||
711 | 366 | } | ||
712 | 367 | |||
713 | 368 | if (containsAltNav && currentAltNav != m_currentAltNavigationId) { | ||
714 | 369 | m_currentAltNavigationId = currentAltNav; | ||
715 | 370 | Q_EMIT currentAltNavigationIdChanged(); | ||
716 | 371 | |||
717 | 372 | // update the alt navigation models | ||
718 | 373 | updateNavigationModels(m_altNavTree.data(), m_altNavModels, m_currentAltNavigationId); | ||
719 | 374 | } | ||
720 | 375 | } | ||
721 | 376 | |||
722 | 377 | void Scope::updateNavigationModels(DepartmentNode* rootNode, QMultiMap<QString, Department*>& navigationModels, QString const& activeNavigation) | ||
723 | 378 | { | ||
724 | 379 | DepartmentNode* parentNode = nullptr; | ||
725 | 380 | DepartmentNode* node = rootNode->findNodeById(activeNavigation); | ||
726 | 381 | if (node != nullptr) { | ||
727 | 382 | auto it = navigationModels.find(activeNavigation); | ||
728 | 383 | while (it != navigationModels.end() && it.key() == activeNavigation) { | ||
729 | 384 | it.value()->loadFromDepartmentNode(node); | ||
730 | 385 | ++it; | ||
731 | 386 | } | ||
732 | 387 | // if this node is a leaf, we need to update models for the parent | ||
733 | 388 | parentNode = node->isLeaf() ? node->parent() : nullptr; | ||
734 | 389 | } | ||
735 | 390 | if (parentNode != nullptr) { | ||
736 | 391 | auto it = navigationModels.find(parentNode->id()); | ||
737 | 392 | while (it != navigationModels.end() && it.key() == parentNode->id()) { | ||
738 | 393 | it.value()->markSubdepartmentActive(activeNavigation); | ||
739 | 394 | ++it; | ||
740 | 395 | } | ||
741 | 334 | } | 396 | } |
742 | 335 | } | 397 | } |
743 | 336 | 398 | ||
744 | @@ -494,12 +556,25 @@ | |||
745 | 494 | } | 556 | } |
746 | 495 | } | 557 | } |
747 | 496 | 558 | ||
754 | 497 | void Scope::setCurrentDepartmentId(QString const& id) | 559 | void Scope::setStatus(shell::scopes::ScopeInterface::Status status) |
755 | 498 | { | 560 | { |
756 | 499 | if (m_currentDepartmentId != id) { | 561 | if (m_status != status) { |
757 | 500 | m_currentDepartmentId = id; | 562 | m_status = status; |
758 | 501 | Q_EMIT currentDepartmentIdChanged(); | 563 | Q_EMIT statusChanged(); |
759 | 502 | } | 564 | } |
760 | 565 | } | ||
761 | 566 | |||
762 | 567 | void Scope::setCurrentNavigationId(QString const& id) | ||
763 | 568 | { | ||
764 | 569 | if (m_currentNavigationId != id) { | ||
765 | 570 | m_currentNavigationId = id; | ||
766 | 571 | Q_EMIT currentNavigationIdChanged(); | ||
767 | 572 | } | ||
768 | 573 | } | ||
769 | 574 | |||
770 | 575 | void Scope::setFilterState(scopes::FilterState const& filterState) | ||
771 | 576 | { | ||
772 | 577 | m_filterState = filterState; | ||
773 | 503 | } | 578 | } |
774 | 504 | 579 | ||
775 | 505 | void Scope::dispatchSearch() | 580 | void Scope::dispatchSearch() |
776 | @@ -554,7 +629,7 @@ | |||
777 | 554 | scopes::SearchListenerBase::SPtr listener(new SearchResultReceiver(this)); | 629 | scopes::SearchListenerBase::SPtr listener(new SearchResultReceiver(this)); |
778 | 555 | m_searchController->setListener(listener); | 630 | m_searchController->setListener(listener); |
779 | 556 | try { | 631 | try { |
781 | 557 | scopes::QueryCtrlProxy controller = m_proxy->search(m_searchQuery.toStdString(), m_currentDepartmentId.toStdString(), scopes::FilterState(), meta, listener); | 632 | scopes::QueryCtrlProxy controller = m_proxy->search(m_searchQuery.toStdString(), m_currentNavigationId.toStdString(), m_filterState, meta, listener); |
782 | 558 | m_searchController->setController(controller); | 633 | m_searchController->setController(controller); |
783 | 559 | } catch (std::exception& e) { | 634 | } catch (std::exception& e) { |
784 | 560 | qWarning("Caught an error from create_query(): %s", e.what()); | 635 | qWarning("Caught an error from create_query(): %s", e.what()); |
785 | @@ -652,9 +727,13 @@ | |||
786 | 652 | return m_searchInProgress; | 727 | return m_searchInProgress; |
787 | 653 | } | 728 | } |
788 | 654 | 729 | ||
792 | 655 | bool Scope::visible() const | 730 | unity::shell::scopes::ScopeInterface::Status Scope::status() const |
793 | 656 | { | 731 | { |
794 | 657 | // FIXME: get from scope config | 732 | return m_status; |
795 | 733 | } | ||
796 | 734 | |||
797 | 735 | bool Scope::favorite() const | ||
798 | 736 | { | ||
799 | 658 | return true; | 737 | return true; |
800 | 659 | } | 738 | } |
801 | 660 | 739 | ||
802 | @@ -689,42 +768,86 @@ | |||
803 | 689 | } | 768 | } |
804 | 690 | */ | 769 | */ |
805 | 691 | 770 | ||
807 | 692 | unity::shell::scopes::DepartmentInterface* Scope::getDepartment(QString const& departmentId) | 771 | unity::shell::scopes::NavigationInterface* Scope::getNavigation(QString const& navId) |
808 | 693 | { | 772 | { |
809 | 694 | if (!m_departmentTree) return nullptr; | 773 | if (!m_departmentTree) return nullptr; |
810 | 695 | 774 | ||
822 | 696 | DepartmentNode* node = m_departmentTree->findNodeById(departmentId); | 775 | DepartmentNode* node = m_departmentTree->findNodeById(navId); |
823 | 697 | if (!node) return nullptr; | 776 | if (!node) return nullptr; |
824 | 698 | 777 | ||
825 | 699 | Department* departmentModel = new Department; | 778 | Department* navModel = new Department; |
826 | 700 | departmentModel->loadFromDepartmentNode(node); | 779 | navModel->setScopeId(this->id()); |
827 | 701 | 780 | navModel->loadFromDepartmentNode(node); | |
828 | 702 | m_departmentModels.insert(departmentId, departmentModel); | 781 | navModel->markSubdepartmentActive(m_currentNavigationId); |
829 | 703 | m_inverseDepartments.insert(departmentModel, departmentId); | 782 | |
830 | 704 | QObject::connect(departmentModel, &QObject::destroyed, this, &Scope::departmentModelDestroyed); | 783 | // sharing m_inverseDepartments with getAltNavigation |
831 | 705 | 784 | m_departmentModels.insert(navId, navModel); | |
832 | 706 | return departmentModel; | 785 | m_inverseDepartments.insert(navModel, navId); |
833 | 786 | QObject::connect(navModel, &QObject::destroyed, this, &Scope::departmentModelDestroyed); | ||
834 | 787 | |||
835 | 788 | return navModel; | ||
836 | 789 | } | ||
837 | 790 | |||
838 | 791 | unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& navId) | ||
839 | 792 | { | ||
840 | 793 | if (!m_altNavTree) return nullptr; | ||
841 | 794 | |||
842 | 795 | DepartmentNode* node = m_altNavTree->findNodeById(navId); | ||
843 | 796 | if (!node) return nullptr; | ||
844 | 797 | |||
845 | 798 | Department* navModel = new Department; | ||
846 | 799 | navModel->setScopeId(this->id()); | ||
847 | 800 | navModel->loadFromDepartmentNode(node); | ||
848 | 801 | navModel->markSubdepartmentActive(m_currentAltNavigationId); | ||
849 | 802 | |||
850 | 803 | // sharing m_inverseDepartments with getNavigation | ||
851 | 804 | m_altNavModels.insert(navId, navModel); | ||
852 | 805 | m_inverseDepartments.insert(navModel, navId); | ||
853 | 806 | QObject::connect(navModel, &QObject::destroyed, this, &Scope::departmentModelDestroyed); | ||
854 | 807 | |||
855 | 808 | return navModel; | ||
856 | 809 | } | ||
857 | 810 | |||
858 | 811 | QString Scope::buildQuery(QString const& scopeId, QString const& searchQuery, QString const& departmentId, QString const& primaryFilterId, QString const& primaryOptionId) | ||
859 | 812 | { | ||
860 | 813 | scopes::CannedQuery q(scopeId.toStdString()); | ||
861 | 814 | q.set_query_string(searchQuery.toStdString()); | ||
862 | 815 | q.set_department_id(departmentId.toStdString()); | ||
863 | 816 | |||
864 | 817 | if (!primaryFilterId.isEmpty() && !primaryOptionId.isEmpty()) { | ||
865 | 818 | scopes::FilterState filter_state; | ||
866 | 819 | scopes::OptionSelectorFilter::update_state(filter_state, primaryFilterId.toStdString(), primaryOptionId.toStdString(), true); | ||
867 | 820 | q.set_filter_state(filter_state); | ||
868 | 821 | } | ||
869 | 822 | |||
870 | 823 | return QString::fromStdString(q.to_uri()); | ||
871 | 824 | } | ||
872 | 825 | |||
873 | 826 | void Scope::setNavigationState(QString const& navId, bool altNavigation) | ||
874 | 827 | { | ||
875 | 828 | QString primaryFilterId; | ||
876 | 829 | if (m_sortOrderFilter) { | ||
877 | 830 | primaryFilterId = QString::fromStdString(m_sortOrderFilter->id()); | ||
878 | 831 | } | ||
879 | 832 | if (!altNavigation) { | ||
880 | 833 | // switch current department id | ||
881 | 834 | performQuery(buildQuery(id(), m_searchQuery, navId, primaryFilterId, m_currentAltNavigationId)); | ||
882 | 835 | } else { | ||
883 | 836 | // switch current primary filter | ||
884 | 837 | performQuery(buildQuery(id(), m_searchQuery, m_currentNavigationId, primaryFilterId, navId)); | ||
885 | 838 | } | ||
886 | 707 | } | 839 | } |
887 | 708 | 840 | ||
888 | 709 | void Scope::departmentModelDestroyed(QObject* obj) | 841 | void Scope::departmentModelDestroyed(QObject* obj) |
889 | 710 | { | 842 | { |
907 | 711 | scopes_ng::Department* department = reinterpret_cast<scopes_ng::Department*>(obj); | 843 | scopes_ng::Department* navigation = reinterpret_cast<scopes_ng::Department*>(obj); |
908 | 712 | 844 | ||
909 | 713 | auto it = m_inverseDepartments.find(department); | 845 | auto it = m_inverseDepartments.find(navigation); |
910 | 714 | if (it == m_inverseDepartments.end()) return; | 846 | if (it == m_inverseDepartments.end()) return; |
911 | 715 | 847 | ||
912 | 716 | m_departmentModels.remove(it.value(), department); | 848 | m_departmentModels.remove(it.value(), navigation); |
913 | 717 | m_inverseDepartments.erase(it); | 849 | m_altNavModels.remove(it.value(), navigation); |
914 | 718 | } | 850 | m_inverseDepartments.erase(it); |
898 | 719 | |||
899 | 720 | void Scope::loadDepartment(QString const& departmentId) | ||
900 | 721 | { | ||
901 | 722 | if (departmentId != m_currentDepartmentId) { | ||
902 | 723 | m_currentDepartmentId = departmentId; | ||
903 | 724 | Q_EMIT currentDepartmentIdChanged(); | ||
904 | 725 | |||
905 | 726 | dispatchSearch(); | ||
906 | 727 | } | ||
915 | 728 | } | 851 | } |
916 | 729 | 852 | ||
917 | 730 | void Scope::performQuery(QString const& cannedQuery) | 853 | void Scope::performQuery(QString const& cannedQuery) |
918 | @@ -737,6 +860,12 @@ | |||
919 | 737 | } | 860 | } |
920 | 738 | } | 861 | } |
921 | 739 | 862 | ||
922 | 863 | void Scope::refresh() | ||
923 | 864 | { | ||
924 | 865 | // shell has to specifically call this, maybe we should ignore the active flag here and just call dispatchSearch | ||
925 | 866 | invalidateResults(); | ||
926 | 867 | } | ||
927 | 868 | |||
928 | 740 | QString Scope::searchQuery() const | 869 | QString Scope::searchQuery() const |
929 | 741 | { | 870 | { |
930 | 742 | return m_searchQuery; | 871 | return m_searchQuery; |
931 | @@ -757,14 +886,24 @@ | |||
932 | 757 | return m_isActive; | 886 | return m_isActive; |
933 | 758 | } | 887 | } |
934 | 759 | 888 | ||
943 | 760 | QString Scope::currentDepartmentId() const | 889 | QString Scope::currentNavigationId() const |
944 | 761 | { | 890 | { |
945 | 762 | return m_currentDepartmentId; | 891 | return m_currentNavigationId; |
946 | 763 | } | 892 | } |
947 | 764 | 893 | ||
948 | 765 | bool Scope::hasDepartments() const | 894 | bool Scope::hasNavigation() const |
949 | 766 | { | 895 | { |
950 | 767 | return m_hasDepartments; | 896 | return m_hasNavigation; |
951 | 897 | } | ||
952 | 898 | |||
953 | 899 | QString Scope::currentAltNavigationId() const | ||
954 | 900 | { | ||
955 | 901 | return m_currentAltNavigationId; | ||
956 | 902 | } | ||
957 | 903 | |||
958 | 904 | bool Scope::hasAltNavigation() const | ||
959 | 905 | { | ||
960 | 906 | return m_hasAltNavigation; | ||
961 | 768 | } | 907 | } |
962 | 769 | 908 | ||
963 | 770 | QVariantMap Scope::customizations() const | 909 | QVariantMap Scope::customizations() const |
964 | @@ -783,6 +922,11 @@ | |||
965 | 783 | if (m_searchQuery.isNull() || search_query != m_searchQuery) { | 922 | if (m_searchQuery.isNull() || search_query != m_searchQuery) { |
966 | 784 | m_searchQuery = search_query; | 923 | m_searchQuery = search_query; |
967 | 785 | 924 | ||
968 | 925 | // atm only empty query can have a filter state | ||
969 | 926 | if (!m_searchQuery.isEmpty()) { | ||
970 | 927 | m_filterState = scopes::FilterState(); | ||
971 | 928 | } | ||
972 | 929 | |||
973 | 786 | // FIXME: use a timeout | 930 | // FIXME: use a timeout |
974 | 787 | invalidateResults(); | 931 | invalidateResults(); |
975 | 788 | 932 | ||
976 | @@ -828,6 +972,13 @@ | |||
977 | 828 | } | 972 | } |
978 | 829 | } | 973 | } |
979 | 830 | 974 | ||
980 | 975 | void Scope::setFavorite(const bool value) | ||
981 | 976 | { | ||
982 | 977 | Q_UNUSED(value); | ||
983 | 978 | |||
984 | 979 | qWarning("Unimplemented: %s", __func__); | ||
985 | 980 | } | ||
986 | 981 | |||
987 | 831 | void Scope::activate(QVariant const& result_var) | 982 | void Scope::activate(QVariant const& result_var) |
988 | 832 | { | 983 | { |
989 | 833 | if (!result_var.canConvert<std::shared_ptr<scopes::Result>>()) { | 984 | if (!result_var.canConvert<std::shared_ptr<scopes::Result>>()) { |
990 | 834 | 985 | ||
991 | === modified file 'src/Unity/scope.h' | |||
992 | --- src/Unity/scope.h 2014-07-31 11:08:50 +0000 | |||
993 | +++ src/Unity/scope.h 2014-08-06 08:35:31 +0000 | |||
994 | @@ -116,17 +116,20 @@ | |||
995 | 116 | QString iconHint() const override; | 116 | QString iconHint() const override; |
996 | 117 | QString description() const override; | 117 | QString description() const override; |
997 | 118 | QString searchHint() const override; | 118 | QString searchHint() const override; |
999 | 119 | bool visible() const override; | 119 | bool favorite() const override; |
1000 | 120 | QString shortcut() const override; | 120 | QString shortcut() const override; |
1001 | 121 | bool searchInProgress() const override; | 121 | bool searchInProgress() const override; |
1002 | 122 | unity::shell::scopes::ScopeInterface::Status status() const override; | ||
1003 | 122 | unity::shell::scopes::CategoriesInterface* categories() const override; | 123 | unity::shell::scopes::CategoriesInterface* categories() const override; |
1004 | 123 | unity::shell::scopes::SettingsModelInterface* settings() const override; | 124 | unity::shell::scopes::SettingsModelInterface* settings() const override; |
1005 | 124 | QString searchQuery() const override; | 125 | QString searchQuery() const override; |
1006 | 125 | QString noResultsHint() const override; | 126 | QString noResultsHint() const override; |
1007 | 126 | QString formFactor() const override; | 127 | QString formFactor() const override; |
1008 | 127 | bool isActive() const override; | 128 | bool isActive() const override; |
1011 | 128 | QString currentDepartmentId() const override; | 129 | QString currentNavigationId() const override; |
1012 | 129 | bool hasDepartments() const override; | 130 | bool hasNavigation() const override; |
1013 | 131 | QString currentAltNavigationId() const override; | ||
1014 | 132 | bool hasAltNavigation() const override; | ||
1015 | 130 | QVariantMap customizations() const override; | 133 | QVariantMap customizations() const override; |
1016 | 131 | 134 | ||
1017 | 132 | /* setters */ | 135 | /* setters */ |
1018 | @@ -134,14 +137,17 @@ | |||
1019 | 134 | void setNoResultsHint(const QString& hint) override; | 137 | void setNoResultsHint(const QString& hint) override; |
1020 | 135 | void setFormFactor(const QString& form_factor) override; | 138 | void setFormFactor(const QString& form_factor) override; |
1021 | 136 | void setActive(const bool) override; | 139 | void setActive(const bool) override; |
1022 | 140 | void setFavorite(const bool) override; | ||
1023 | 137 | 141 | ||
1024 | 138 | Q_INVOKABLE void activate(QVariant const& result) override; | 142 | Q_INVOKABLE void activate(QVariant const& result) override; |
1025 | 139 | Q_INVOKABLE unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result) override; | 143 | Q_INVOKABLE unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result) override; |
1026 | 140 | Q_INVOKABLE void cancelActivation() override; | 144 | Q_INVOKABLE void cancelActivation() override; |
1027 | 141 | Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override; | 145 | Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override; |
1030 | 142 | Q_INVOKABLE unity::shell::scopes::DepartmentInterface* getDepartment(QString const& id) override; | 146 | Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& id) override; |
1031 | 143 | Q_INVOKABLE void loadDepartment(QString const& id) override; | 147 | Q_INVOKABLE unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& id) override; |
1032 | 148 | Q_INVOKABLE void setNavigationState(QString const& navId, bool altNavigation) override; | ||
1033 | 144 | Q_INVOKABLE void performQuery(QString const& cannedQuery) override; | 149 | Q_INVOKABLE void performQuery(QString const& cannedQuery) override; |
1034 | 150 | Q_INVOKABLE void refresh() override; | ||
1035 | 145 | 151 | ||
1036 | 146 | void setScopeData(unity::scopes::ScopeMetadata const& data); | 152 | void setScopeData(unity::scopes::ScopeMetadata const& data); |
1037 | 147 | void handleActivation(std::shared_ptr<unity::scopes::ActivationResponse> const&, unity::scopes::Result::SPtr const&); | 153 | void handleActivation(std::shared_ptr<unity::scopes::ActivationResponse> const&, unity::scopes::Result::SPtr const&); |
1038 | @@ -164,6 +170,7 @@ | |||
1039 | 164 | 170 | ||
1040 | 165 | protected: | 171 | protected: |
1041 | 166 | void setSearchInProgress(bool searchInProgress); | 172 | void setSearchInProgress(bool searchInProgress); |
1042 | 173 | void setStatus(unity::shell::scopes::ScopeInterface::Status status); | ||
1043 | 167 | void invalidateLastSearch(); | 174 | void invalidateLastSearch(); |
1044 | 168 | virtual void dispatchSearch(); | 175 | virtual void dispatchSearch(); |
1045 | 169 | 176 | ||
1046 | @@ -173,9 +180,12 @@ | |||
1047 | 173 | QPointer<Scopes> m_scopesInstance; | 180 | QPointer<Scopes> m_scopesInstance; |
1048 | 174 | 181 | ||
1049 | 175 | private: | 182 | private: |
1050 | 183 | static void updateNavigationModels(DepartmentNode* rootNode, QMultiMap<QString, Department*>& navigationModels, QString const& activeNavigation); | ||
1051 | 184 | static QString buildQuery(QString const& scopeId, QString const& searchQuery, QString const& departmentId, QString const& primaryFilterId, QString const& primaryOptionId); | ||
1052 | 176 | void setScopesInstance(Scopes*); | 185 | void setScopesInstance(Scopes*); |
1053 | 177 | void startTtlTimer(); | 186 | void startTtlTimer(); |
1055 | 178 | void setCurrentDepartmentId(QString const& id); | 187 | void setCurrentNavigationId(QString const& id); |
1056 | 188 | void setFilterState(unity::scopes::FilterState const& filterState); | ||
1057 | 179 | void processSearchChunk(PushEvent* pushEvent); | 189 | void processSearchChunk(PushEvent* pushEvent); |
1058 | 180 | void executeCannedQuery(unity::scopes::CannedQuery const& query, bool allowDelayedActivation); | 190 | void executeCannedQuery(unity::scopes::CannedQuery const& query, bool allowDelayedActivation); |
1059 | 181 | 191 | ||
1060 | @@ -187,13 +197,15 @@ | |||
1061 | 187 | QString m_searchQuery; | 197 | QString m_searchQuery; |
1062 | 188 | QString m_noResultsHint; | 198 | QString m_noResultsHint; |
1063 | 189 | QString m_formFactor; | 199 | QString m_formFactor; |
1065 | 190 | QString m_currentDepartmentId; | 200 | QString m_currentNavigationId; |
1066 | 201 | QString m_currentAltNavigationId; | ||
1067 | 191 | QVariantMap m_customizations; | 202 | QVariantMap m_customizations; |
1068 | 192 | bool m_isActive; | 203 | bool m_isActive; |
1069 | 193 | bool m_searchInProgress; | 204 | bool m_searchInProgress; |
1070 | 194 | bool m_resultsDirty; | 205 | bool m_resultsDirty; |
1071 | 195 | bool m_delayedClear; | 206 | bool m_delayedClear; |
1073 | 196 | bool m_hasDepartments; | 207 | bool m_hasNavigation; |
1074 | 208 | bool m_hasAltNavigation; | ||
1075 | 197 | 209 | ||
1076 | 198 | std::unique_ptr<CollectionController> m_searchController; | 210 | std::unique_ptr<CollectionController> m_searchController; |
1077 | 199 | std::unique_ptr<CollectionController> m_activationController; | 211 | std::unique_ptr<CollectionController> m_activationController; |
1078 | @@ -202,15 +214,22 @@ | |||
1079 | 202 | std::shared_ptr<unity::scopes::ActivationResponse> m_delayedActivation; | 214 | std::shared_ptr<unity::scopes::ActivationResponse> m_delayedActivation; |
1080 | 203 | unity::scopes::Department::SCPtr m_rootDepartment; | 215 | unity::scopes::Department::SCPtr m_rootDepartment; |
1081 | 204 | unity::scopes::Department::SCPtr m_lastRootDepartment; | 216 | unity::scopes::Department::SCPtr m_lastRootDepartment; |
1082 | 217 | unity::scopes::OptionSelectorFilter::SCPtr m_sortOrderFilter; | ||
1083 | 218 | unity::scopes::OptionSelectorFilter::SCPtr m_lastSortOrderFilter; | ||
1084 | 219 | unity::scopes::FilterState m_filterState; | ||
1085 | 220 | unity::scopes::FilterState m_receivedFilterState; | ||
1086 | 221 | unity::shell::scopes::ScopeInterface::Status m_status; | ||
1087 | 205 | QGSettings* m_settings; | 222 | QGSettings* m_settings; |
1088 | 206 | QScopedPointer<SettingsModel> m_settingsModel; | 223 | QScopedPointer<SettingsModel> m_settingsModel; |
1089 | 207 | QSharedPointer<DepartmentNode> m_departmentTree; | 224 | QSharedPointer<DepartmentNode> m_departmentTree; |
1090 | 225 | QSharedPointer<DepartmentNode> m_altNavTree; | ||
1091 | 208 | QTimer m_aggregatorTimer; | 226 | QTimer m_aggregatorTimer; |
1092 | 209 | QTimer m_clearTimer; | 227 | QTimer m_clearTimer; |
1093 | 210 | QTimer m_invalidateTimer; | 228 | QTimer m_invalidateTimer; |
1094 | 211 | QList<std::shared_ptr<unity::scopes::CategorisedResult>> m_cachedResults; | 229 | QList<std::shared_ptr<unity::scopes::CategorisedResult>> m_cachedResults; |
1095 | 212 | QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes; | 230 | QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes; |
1096 | 213 | QMultiMap<QString, Department*> m_departmentModels; | 231 | QMultiMap<QString, Department*> m_departmentModels; |
1097 | 232 | QMultiMap<QString, Department*> m_altNavModels; | ||
1098 | 214 | QMap<Department*, QString> m_inverseDepartments; | 233 | QMap<Department*, QString> m_inverseDepartments; |
1099 | 215 | QMetaObject::Connection m_metadataConnection; | 234 | QMetaObject::Connection m_metadataConnection; |
1100 | 216 | LocationService::Ptr m_locationService; | 235 | LocationService::Ptr m_locationService; |
1101 | 217 | 236 | ||
1102 | === modified file 'src/Unity/scopes.cpp' | |||
1103 | --- src/Unity/scopes.cpp 2014-07-31 11:08:50 +0000 | |||
1104 | +++ src/Unity/scopes.cpp 2014-08-06 08:35:31 +0000 | |||
1105 | @@ -130,6 +130,11 @@ | |||
1106 | 130 | return m_scopes.count(); | 130 | return m_scopes.count(); |
1107 | 131 | } | 131 | } |
1108 | 132 | 132 | ||
1109 | 133 | int Scopes::count() const | ||
1110 | 134 | { | ||
1111 | 135 | return m_scopes.count(); | ||
1112 | 136 | } | ||
1113 | 137 | |||
1114 | 133 | void Scopes::populateScopes() | 138 | void Scopes::populateScopes() |
1115 | 134 | { | 139 | { |
1116 | 135 | auto thread = new ScopeListWorker; | 140 | auto thread = new ScopeListWorker; |
1117 | @@ -198,6 +203,7 @@ | |||
1118 | 198 | 203 | ||
1119 | 199 | m_loaded = true; | 204 | m_loaded = true; |
1120 | 200 | Q_EMIT loadedChanged(); | 205 | Q_EMIT loadedChanged(); |
1121 | 206 | Q_EMIT countChanged(); | ||
1122 | 201 | Q_EMIT overviewScopeChanged(); | 207 | Q_EMIT overviewScopeChanged(); |
1123 | 202 | Q_EMIT metadataRefreshed(); | 208 | Q_EMIT metadataRefreshed(); |
1124 | 203 | 209 | ||
1125 | @@ -249,8 +255,6 @@ | |||
1126 | 249 | return QVariant::fromValue(scope); | 255 | return QVariant::fromValue(scope); |
1127 | 250 | case Scopes::RoleId: | 256 | case Scopes::RoleId: |
1128 | 251 | return QString(scope->id()); | 257 | return QString(scope->id()); |
1129 | 252 | case Scopes::RoleVisible: | ||
1130 | 253 | return QVariant::fromValue(scope->visible()); | ||
1131 | 254 | case Scopes::RoleTitle: | 258 | case Scopes::RoleTitle: |
1132 | 255 | return QString(scope->name()); | 259 | return QString(scope->name()); |
1133 | 256 | default: | 260 | default: |
1134 | 257 | 261 | ||
1135 | === modified file 'src/Unity/scopes.h' | |||
1136 | --- src/Unity/scopes.h 2014-07-31 11:08:50 +0000 | |||
1137 | +++ src/Unity/scopes.h 2014-08-06 08:35:31 +0000 | |||
1138 | @@ -62,6 +62,7 @@ | |||
1139 | 62 | void refreshScopeMetadata(); | 62 | void refreshScopeMetadata(); |
1140 | 63 | 63 | ||
1141 | 64 | bool loaded() const override; | 64 | bool loaded() const override; |
1142 | 65 | int count() const override; | ||
1143 | 65 | unity::shell::scopes::ScopeInterface* overviewScope() const override; | 66 | unity::shell::scopes::ScopeInterface* overviewScope() const override; |
1144 | 66 | 67 | ||
1145 | 67 | LocationService::Ptr locationService() const; | 68 | LocationService::Ptr locationService() const; |
1146 | 68 | 69 | ||
1147 | === modified file 'tests/data/CMakeLists.txt' | |||
1148 | --- tests/data/CMakeLists.txt 2014-07-22 13:49:50 +0000 | |||
1149 | +++ tests/data/CMakeLists.txt 2014-08-06 08:35:31 +0000 | |||
1150 | @@ -1,5 +1,6 @@ | |||
1151 | 1 | add_subdirectory(mock-scope) | 1 | add_subdirectory(mock-scope) |
1152 | 2 | add_subdirectory(mock-scope-departments) | 2 | add_subdirectory(mock-scope-departments) |
1153 | 3 | add_subdirectory(mock-scope-double-nav) | ||
1154 | 3 | add_subdirectory(mock-scope-ttl) | 4 | add_subdirectory(mock-scope-ttl) |
1155 | 4 | add_subdirectory(scopes) | 5 | add_subdirectory(scopes) |
1156 | 5 | 6 | ||
1157 | 6 | 7 | ||
1158 | === added directory 'tests/data/mock-scope-double-nav' | |||
1159 | === added file 'tests/data/mock-scope-double-nav/CMakeLists.txt' | |||
1160 | --- tests/data/mock-scope-double-nav/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1161 | +++ tests/data/mock-scope-double-nav/CMakeLists.txt 2014-08-06 08:35:31 +0000 | |||
1162 | @@ -0,0 +1,16 @@ | |||
1163 | 1 | include(FindPkgConfig) | ||
1164 | 2 | pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.4.0) | ||
1165 | 3 | |||
1166 | 4 | set(SCOPES_BIN_DIR ${SCOPESLIB_LIBDIR}) | ||
1167 | 5 | |||
1168 | 6 | include_directories(${SCOPESLIB_INCLUDE_DIRS}) | ||
1169 | 7 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
1170 | 8 | |||
1171 | 9 | set(SCOPE_SOURCES | ||
1172 | 10 | mock-scope-double-nav.cpp | ||
1173 | 11 | ) | ||
1174 | 12 | |||
1175 | 13 | add_library(mock-scope-double-nav MODULE ${SCOPE_SOURCES}) | ||
1176 | 14 | target_link_libraries(mock-scope-double-nav ${SCOPESLIB_LDFLAGS}) | ||
1177 | 15 | |||
1178 | 16 | configure_file(mock-scope-double-nav.ini.in mock-scope-double-nav.ini) | ||
1179 | 0 | 17 | ||
1180 | === added file 'tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp' | |||
1181 | --- tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp 1970-01-01 00:00:00 +0000 | |||
1182 | +++ tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp 2014-08-06 08:35:31 +0000 | |||
1183 | @@ -0,0 +1,214 @@ | |||
1184 | 1 | /* | ||
1185 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
1186 | 3 | * | ||
1187 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1188 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1189 | 6 | * published by the Free Software Foundation. | ||
1190 | 7 | * | ||
1191 | 8 | * This program is distributed in the hope that it will be useful, | ||
1192 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1193 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1194 | 11 | * GNU Lesser General Public License for more details. | ||
1195 | 12 | * | ||
1196 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1197 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1198 | 15 | * | ||
1199 | 16 | * Authored by: Pete Woods <pete.woods@canonical.com> | ||
1200 | 17 | */ | ||
1201 | 18 | |||
1202 | 19 | #include <unity/scopes/CategorisedResult.h> | ||
1203 | 20 | #include <unity/scopes/OptionSelectorFilter.h> | ||
1204 | 21 | #include <unity/scopes/ScopeBase.h> | ||
1205 | 22 | #include <unity/scopes/SearchReply.h> | ||
1206 | 23 | |||
1207 | 24 | #include <iostream> | ||
1208 | 25 | #include <thread> | ||
1209 | 26 | #include <atomic> | ||
1210 | 27 | #include <sstream> | ||
1211 | 28 | |||
1212 | 29 | #define EXPORT __attribute__ ((visibility ("default"))) | ||
1213 | 30 | |||
1214 | 31 | using namespace std; | ||
1215 | 32 | using namespace unity::scopes; | ||
1216 | 33 | |||
1217 | 34 | class MyQuery : public SearchQueryBase | ||
1218 | 35 | { | ||
1219 | 36 | public: | ||
1220 | 37 | MyQuery(CannedQuery const& query, SearchMetadata const& metadata) : | ||
1221 | 38 | SearchQueryBase(query, metadata), | ||
1222 | 39 | department_id_(query.department_id()) | ||
1223 | 40 | { | ||
1224 | 41 | } | ||
1225 | 42 | |||
1226 | 43 | ~MyQuery() | ||
1227 | 44 | { | ||
1228 | 45 | } | ||
1229 | 46 | |||
1230 | 47 | virtual void cancelled() override | ||
1231 | 48 | { | ||
1232 | 49 | } | ||
1233 | 50 | |||
1234 | 51 | static Department::SPtr create_root_dep(CannedQuery const& query) | ||
1235 | 52 | { | ||
1236 | 53 | Department::SPtr child_dep; | ||
1237 | 54 | Department::SPtr root_dep; | ||
1238 | 55 | root_dep = Department::create("", query, "All departments"); | ||
1239 | 56 | |||
1240 | 57 | child_dep = Department::create("books", query, "Books"); | ||
1241 | 58 | child_dep->set_has_subdepartments(); | ||
1242 | 59 | root_dep->add_subdepartment(child_dep); | ||
1243 | 60 | |||
1244 | 61 | child_dep = Department::create("movies", query, "Movies, TV, Music"); | ||
1245 | 62 | child_dep->set_has_subdepartments(); | ||
1246 | 63 | root_dep->add_subdepartment(child_dep); | ||
1247 | 64 | |||
1248 | 65 | child_dep = Department::create("electronics", query, "Electronics"); | ||
1249 | 66 | child_dep->set_has_subdepartments(); | ||
1250 | 67 | root_dep->add_subdepartment(child_dep); | ||
1251 | 68 | |||
1252 | 69 | child_dep = Department::create("home", query, "Home, Garden & DIY"); | ||
1253 | 70 | child_dep->set_has_subdepartments(); | ||
1254 | 71 | root_dep->add_subdepartment(child_dep); | ||
1255 | 72 | |||
1256 | 73 | child_dep = Department::create("toys", query, "Toys, Children & Baby"); | ||
1257 | 74 | child_dep->set_has_subdepartments(); | ||
1258 | 75 | root_dep->add_subdepartment(child_dep); | ||
1259 | 76 | |||
1260 | 77 | return root_dep; | ||
1261 | 78 | } | ||
1262 | 79 | |||
1263 | 80 | static Department::SPtr get_department_by_id(Department::SPtr root_dep, std::string const& dep_id) | ||
1264 | 81 | { | ||
1265 | 82 | auto children = root_dep->subdepartments(); | ||
1266 | 83 | for (auto it = children.begin(); it != children.end(); ++it) | ||
1267 | 84 | { | ||
1268 | 85 | if ((*it)->id() == dep_id) return const_pointer_cast<Department>(*it); | ||
1269 | 86 | } | ||
1270 | 87 | return Department::SPtr(); | ||
1271 | 88 | } | ||
1272 | 89 | |||
1273 | 90 | virtual void run(SearchReplyProxy const& reply) override | ||
1274 | 91 | { | ||
1275 | 92 | Department::SPtr child_dep; | ||
1276 | 93 | Department::SPtr root_dep; | ||
1277 | 94 | Department::SPtr active_dep; | ||
1278 | 95 | |||
1279 | 96 | root_dep = create_root_dep(query()); | ||
1280 | 97 | |||
1281 | 98 | if (department_id_.compare(0, 5, "books") == 0) | ||
1282 | 99 | { | ||
1283 | 100 | active_dep = get_department_by_id(root_dep, "books"); | ||
1284 | 101 | child_dep = Department::create("books-kindle", query(), "Kindle Books"); | ||
1285 | 102 | active_dep->add_subdepartment(child_dep); | ||
1286 | 103 | |||
1287 | 104 | child_dep = Department::create("books-study", query(), "Books for Study"); | ||
1288 | 105 | active_dep->add_subdepartment(child_dep); | ||
1289 | 106 | |||
1290 | 107 | child_dep = Department::create("books-audio", query(), "Audiobooks"); | ||
1291 | 108 | active_dep->add_subdepartment(child_dep); | ||
1292 | 109 | } | ||
1293 | 110 | |||
1294 | 111 | if (department_id_.compare(0, 4, "home") == 0) | ||
1295 | 112 | { | ||
1296 | 113 | active_dep = get_department_by_id(root_dep, "home"); | ||
1297 | 114 | child_dep = Department::create("home-garden", query(), "Garden & Outdoors"); | ||
1298 | 115 | active_dep->add_subdepartment(child_dep); | ||
1299 | 116 | |||
1300 | 117 | child_dep = Department::create("home-furniture", query(), "Homeware & Furniture"); | ||
1301 | 118 | active_dep->add_subdepartment(child_dep); | ||
1302 | 119 | |||
1303 | 120 | child_dep = Department::create("home-kitchen", query(), "Kitchen & Dining"); | ||
1304 | 121 | active_dep->add_subdepartment(child_dep); | ||
1305 | 122 | } | ||
1306 | 123 | |||
1307 | 124 | if (department_id_.compare(0, 4, "toys") == 0) | ||
1308 | 125 | { | ||
1309 | 126 | active_dep = get_department_by_id(root_dep, "toys"); | ||
1310 | 127 | child_dep = Department::create("toys-games", query(), "Toys & Games"); | ||
1311 | 128 | active_dep->add_subdepartment(child_dep); | ||
1312 | 129 | |||
1313 | 130 | child_dep = Department::create("toys-baby", query(), "Baby"); | ||
1314 | 131 | active_dep->add_subdepartment(child_dep); | ||
1315 | 132 | } | ||
1316 | 133 | |||
1317 | 134 | // provide only partial tree for this leaf | ||
1318 | 135 | if (department_id_ == "toys-games") | ||
1319 | 136 | { | ||
1320 | 137 | root_dep = Department::create("", query(), "All departments"); | ||
1321 | 138 | child_dep = Department::create("toys", query(), "Toys, Children & Baby"); | ||
1322 | 139 | root_dep->add_subdepartment(child_dep); | ||
1323 | 140 | active_dep = Department::create("toys-games", query(), "Toys & Games"); | ||
1324 | 141 | child_dep->add_subdepartment(active_dep); | ||
1325 | 142 | } | ||
1326 | 143 | |||
1327 | 144 | reply->register_departments(root_dep); | ||
1328 | 145 | |||
1329 | 146 | // add sort order filter | ||
1330 | 147 | OptionSelectorFilter::UPtr sort_order_filter = OptionSelectorFilter::create("sort-order", "Sort Order"); | ||
1331 | 148 | sort_order_filter->set_display_hints(FilterBase::Primary); | ||
1332 | 149 | sort_order_filter->add_option("featured", "Featured"); | ||
1333 | 150 | sort_order_filter->add_option("top", "Most popular"); | ||
1334 | 151 | sort_order_filter->add_option("best", "Best sellers"); | ||
1335 | 152 | Filters filters; | ||
1336 | 153 | filters.push_back(std::move(sort_order_filter)); | ||
1337 | 154 | |||
1338 | 155 | FilterState state; | ||
1339 | 156 | FilterState initial_filter_state(query().filter_state()); | ||
1340 | 157 | if (initial_filter_state.has_filter("sort-order")) { | ||
1341 | 158 | state = initial_filter_state; | ||
1342 | 159 | } else { | ||
1343 | 160 | // default option | ||
1344 | 161 | OptionSelectorFilter::update_state(state, "sort-order", "featured", true); | ||
1345 | 162 | } | ||
1346 | 163 | |||
1347 | 164 | reply->push(filters, state); | ||
1348 | 165 | |||
1349 | 166 | auto cat1 = reply->register_category("cat1", "Category 1", ""); | ||
1350 | 167 | CategorisedResult res1(cat1); | ||
1351 | 168 | res1.set_uri("test:uri"); | ||
1352 | 169 | res1.set_title("result for: \"" + query().query_string() + "\""); | ||
1353 | 170 | reply->push(res1); | ||
1354 | 171 | } | ||
1355 | 172 | |||
1356 | 173 | protected: | ||
1357 | 174 | string department_id_; | ||
1358 | 175 | }; | ||
1359 | 176 | |||
1360 | 177 | class MyScope : public ScopeBase | ||
1361 | 178 | { | ||
1362 | 179 | public: | ||
1363 | 180 | MyScope() | ||
1364 | 181 | { | ||
1365 | 182 | } | ||
1366 | 183 | |||
1367 | 184 | virtual SearchQueryBase::UPtr search(CannedQuery const& q, SearchMetadata const& metadata) override | ||
1368 | 185 | { | ||
1369 | 186 | return SearchQueryBase::UPtr(new MyQuery(q, metadata)); | ||
1370 | 187 | } | ||
1371 | 188 | |||
1372 | 189 | virtual PreviewQueryBase::UPtr preview(Result const&, ActionMetadata const&) override | ||
1373 | 190 | { | ||
1374 | 191 | return nullptr; | ||
1375 | 192 | } | ||
1376 | 193 | }; | ||
1377 | 194 | |||
1378 | 195 | extern "C" | ||
1379 | 196 | { | ||
1380 | 197 | |||
1381 | 198 | EXPORT | ||
1382 | 199 | unity::scopes::ScopeBase* | ||
1383 | 200 | // cppcheck-suppress unusedFunction | ||
1384 | 201 | UNITY_SCOPE_CREATE_FUNCTION() | ||
1385 | 202 | { | ||
1386 | 203 | return new MyScope; | ||
1387 | 204 | } | ||
1388 | 205 | |||
1389 | 206 | EXPORT | ||
1390 | 207 | void | ||
1391 | 208 | // cppcheck-suppress unusedFunction | ||
1392 | 209 | UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope_base) | ||
1393 | 210 | { | ||
1394 | 211 | delete scope_base; | ||
1395 | 212 | } | ||
1396 | 213 | |||
1397 | 214 | } | ||
1398 | 0 | 215 | ||
1399 | === added file 'tests/data/mock-scope-double-nav/mock-scope-double-nav.ini.in' | |||
1400 | --- tests/data/mock-scope-double-nav/mock-scope-double-nav.ini.in 1970-01-01 00:00:00 +0000 | |||
1401 | +++ tests/data/mock-scope-double-nav/mock-scope-double-nav.ini.in 2014-08-06 08:35:31 +0000 | |||
1402 | @@ -0,0 +1,8 @@ | |||
1403 | 1 | [ScopeConfig] | ||
1404 | 2 | DisplayName = mock-double-nav.DisplayName | ||
1405 | 3 | Description = mock-double-nav.Description | ||
1406 | 4 | Art = /mock-double-nav.Art | ||
1407 | 5 | Icon = /mock-double-nav.Icon | ||
1408 | 6 | SearchHint = mock-double-nav.SearchHint | ||
1409 | 7 | HotKey = mock-double-nav.HotKey | ||
1410 | 8 | Author = mock-double-nav.Author | ||
1411 | 0 | 9 | ||
1412 | === modified file 'tests/departmentstest.cpp' | |||
1413 | --- tests/departmentstest.cpp 2014-07-18 16:35:52 +0000 | |||
1414 | +++ tests/departmentstest.cpp 2014-08-06 08:35:31 +0000 | |||
1415 | @@ -48,6 +48,7 @@ | |||
1416 | 48 | private: | 48 | private: |
1417 | 49 | QScopedPointer<Scopes> m_scopes; | 49 | QScopedPointer<Scopes> m_scopes; |
1418 | 50 | Scope* m_scope; | 50 | Scope* m_scope; |
1419 | 51 | Scope* m_scope_navs; | ||
1420 | 51 | QScopedPointer<RegistrySpawner> m_registry; | 52 | QScopedPointer<RegistrySpawner> m_registry; |
1421 | 52 | 53 | ||
1422 | 53 | private Q_SLOTS: | 54 | private Q_SLOTS: |
1423 | @@ -78,6 +79,10 @@ | |||
1424 | 78 | m_scope = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope-departments"))); | 79 | m_scope = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope-departments"))); |
1425 | 79 | QVERIFY(m_scope != nullptr); | 80 | QVERIFY(m_scope != nullptr); |
1426 | 80 | m_scope->setActive(true); | 81 | m_scope->setActive(true); |
1427 | 82 | |||
1428 | 83 | m_scope_navs = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope-double-nav"))); | ||
1429 | 84 | QVERIFY(m_scope_navs != nullptr); | ||
1430 | 85 | m_scope_navs->setActive(true); | ||
1431 | 81 | } | 86 | } |
1432 | 82 | 87 | ||
1433 | 83 | void cleanup() | 88 | void cleanup() |
1434 | @@ -90,37 +95,40 @@ | |||
1435 | 90 | { | 95 | { |
1436 | 91 | performSearch(m_scope, QString("foo")); | 96 | performSearch(m_scope, QString("foo")); |
1437 | 92 | 97 | ||
1439 | 93 | QCOMPARE(m_scope->hasDepartments(), false); | 98 | QCOMPARE(m_scope->hasNavigation(), false); |
1440 | 99 | QCOMPARE(m_scope->hasAltNavigation(), false); | ||
1441 | 94 | } | 100 | } |
1442 | 95 | 101 | ||
1443 | 96 | void testRootDepartment() | 102 | void testRootDepartment() |
1444 | 97 | { | 103 | { |
1445 | 98 | performSearch(m_scope, QString("")); | 104 | performSearch(m_scope, QString("")); |
1446 | 99 | 105 | ||
1450 | 100 | QCOMPARE(m_scope->hasDepartments(), true); | 106 | QCOMPARE(m_scope->hasNavigation(), true); |
1451 | 101 | QCOMPARE(m_scope->currentDepartmentId(), QString("")); | 107 | QCOMPARE(m_scope->hasAltNavigation(), false); |
1452 | 102 | QScopedPointer<DepartmentInterface> departmentModel(m_scope->getDepartment(m_scope->currentDepartmentId())); | 108 | QCOMPARE(m_scope->currentNavigationId(), QString("")); |
1453 | 109 | QScopedPointer<NavigationInterface> departmentModel(m_scope->getNavigation(m_scope->currentNavigationId())); | ||
1454 | 103 | QVERIFY(departmentModel != nullptr); | 110 | QVERIFY(departmentModel != nullptr); |
1455 | 104 | 111 | ||
1457 | 105 | QVERIFY(departmentModel->departmentId().isEmpty()); | 112 | QVERIFY(departmentModel->navigationId().isEmpty()); |
1458 | 106 | QCOMPARE(departmentModel->label(), QString("All departments")); | 113 | QCOMPARE(departmentModel->label(), QString("All departments")); |
1459 | 107 | QCOMPARE(departmentModel->allLabel(), QString("")); | 114 | QCOMPARE(departmentModel->allLabel(), QString("")); |
1461 | 108 | QCOMPARE(departmentModel->parentDepartmentId(), QString()); | 115 | QCOMPARE(departmentModel->parentNavigationId(), QString()); |
1462 | 109 | QCOMPARE(departmentModel->parentLabel(), QString()); | 116 | QCOMPARE(departmentModel->parentLabel(), QString()); |
1463 | 110 | QCOMPARE(departmentModel->loaded(), true); | 117 | QCOMPARE(departmentModel->loaded(), true); |
1464 | 111 | QCOMPARE(departmentModel->isRoot(), true); | 118 | QCOMPARE(departmentModel->isRoot(), true); |
1465 | 119 | QCOMPARE(departmentModel->hidden(), false); | ||
1466 | 112 | 120 | ||
1467 | 113 | QCOMPARE(departmentModel->rowCount(), 5); | 121 | QCOMPARE(departmentModel->rowCount(), 5); |
1468 | 114 | QModelIndex idx; | 122 | QModelIndex idx; |
1469 | 115 | 123 | ||
1470 | 116 | idx = departmentModel->index(0); | 124 | idx = departmentModel->index(0); |
1472 | 117 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleDepartmentId), QVariant(QString("books"))); | 125 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleNavigationId), QVariant(QString("books"))); |
1473 | 118 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleLabel), QVariant(QString("Books"))); | 126 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleLabel), QVariant(QString("Books"))); |
1474 | 119 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleHasChildren), QVariant(true)); | 127 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleHasChildren), QVariant(true)); |
1475 | 120 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleIsActive), QVariant(false)); | 128 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleIsActive), QVariant(false)); |
1476 | 121 | 129 | ||
1477 | 122 | idx = departmentModel->index(4); | 130 | idx = departmentModel->index(4); |
1479 | 123 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleDepartmentId), QVariant(QString("toys"))); | 131 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleNavigationId), QVariant(QString("toys"))); |
1480 | 124 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleLabel), QVariant(QString("Toys, Children & Baby"))); | 132 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleLabel), QVariant(QString("Toys, Children & Baby"))); |
1481 | 125 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleHasChildren), QVariant(true)); | 133 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleHasChildren), QVariant(true)); |
1482 | 126 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleIsActive), QVariant(false)); | 134 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleIsActive), QVariant(false)); |
1483 | @@ -130,23 +138,23 @@ | |||
1484 | 130 | { | 138 | { |
1485 | 131 | performSearch(m_scope, QString("")); | 139 | performSearch(m_scope, QString("")); |
1486 | 132 | 140 | ||
1489 | 133 | QCOMPARE(m_scope->currentDepartmentId(), QString("")); | 141 | QCOMPARE(m_scope->currentNavigationId(), QString("")); |
1490 | 134 | QScopedPointer<DepartmentInterface> departmentModel(m_scope->getDepartment(QString("toys"))); | 142 | QScopedPointer<NavigationInterface> departmentModel(m_scope->getNavigation(QString("toys"))); |
1491 | 135 | QVERIFY(departmentModel != nullptr); | 143 | QVERIFY(departmentModel != nullptr); |
1492 | 136 | 144 | ||
1493 | 137 | QSignalSpy spy(departmentModel.data(), SIGNAL(loadedChanged())); | 145 | QSignalSpy spy(departmentModel.data(), SIGNAL(loadedChanged())); |
1494 | 138 | 146 | ||
1496 | 139 | QCOMPARE(departmentModel->departmentId(), QString("toys")); | 147 | QCOMPARE(departmentModel->navigationId(), QString("toys")); |
1497 | 140 | QCOMPARE(departmentModel->label(), QString("Toys, Children & Baby")); | 148 | QCOMPARE(departmentModel->label(), QString("Toys, Children & Baby")); |
1498 | 141 | QCOMPARE(departmentModel->allLabel(), QString("")); | 149 | QCOMPARE(departmentModel->allLabel(), QString("")); |
1500 | 142 | QCOMPARE(departmentModel->parentDepartmentId(), QString("")); | 150 | QCOMPARE(departmentModel->parentNavigationId(), QString("")); |
1501 | 143 | QCOMPARE(departmentModel->parentLabel(), QString("All departments")); | 151 | QCOMPARE(departmentModel->parentLabel(), QString("All departments")); |
1502 | 144 | QCOMPARE(departmentModel->loaded(), false); | 152 | QCOMPARE(departmentModel->loaded(), false); |
1503 | 145 | QCOMPARE(departmentModel->isRoot(), false); | 153 | QCOMPARE(departmentModel->isRoot(), false); |
1504 | 146 | 154 | ||
1505 | 147 | QCOMPARE(departmentModel->rowCount(), 0); | 155 | QCOMPARE(departmentModel->rowCount(), 0); |
1506 | 148 | 156 | ||
1508 | 149 | m_scope->loadDepartment(QString("toys")); | 157 | m_scope->setNavigationState(departmentModel->navigationId(), false); |
1509 | 150 | QVERIFY(spy.wait()); | 158 | QVERIFY(spy.wait()); |
1510 | 151 | 159 | ||
1511 | 152 | QCOMPARE(departmentModel->rowCount(), 2); | 160 | QCOMPARE(departmentModel->rowCount(), 2); |
1512 | @@ -158,16 +166,18 @@ | |||
1513 | 158 | { | 166 | { |
1514 | 159 | performSearch(m_scope, QString("")); | 167 | performSearch(m_scope, QString("")); |
1515 | 160 | 168 | ||
1517 | 161 | QCOMPARE(m_scope->currentDepartmentId(), QString("")); | 169 | QCOMPARE(m_scope->currentNavigationId(), QString("")); |
1518 | 162 | QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged())); | 170 | QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged())); |
1520 | 163 | m_scope->loadDepartment(QString("books")); | 171 | QScopedPointer<NavigationInterface> navModel(m_scope->getNavigation(QString("books"))); |
1521 | 172 | m_scope->setNavigationState(navModel->navigationId(), false); | ||
1522 | 164 | QVERIFY(spy.wait()); | 173 | QVERIFY(spy.wait()); |
1523 | 165 | QCOMPARE(m_scope->searchInProgress(), false); | 174 | QCOMPARE(m_scope->searchInProgress(), false); |
1525 | 166 | QScopedPointer<DepartmentInterface> departmentModel(m_scope->getDepartment(QString("books"))); | 175 | QScopedPointer<NavigationInterface> departmentModel(m_scope->getNavigation(QString("books"))); |
1526 | 167 | QCOMPARE(departmentModel->isRoot(), false); | 176 | QCOMPARE(departmentModel->isRoot(), false); |
1527 | 168 | 177 | ||
1528 | 178 | navModel.reset(m_scope->getNavigation(QString("books-audio"))); | ||
1529 | 169 | // this is a leaf department, so activating it should update the parent model | 179 | // this is a leaf department, so activating it should update the parent model |
1531 | 170 | m_scope->loadDepartment(QString("books-audio")); | 180 | m_scope->setNavigationState(navModel->navigationId(), false); |
1532 | 171 | QVERIFY(spy.wait()); | 181 | QVERIFY(spy.wait()); |
1533 | 172 | QCOMPARE(m_scope->searchInProgress(), false); | 182 | QCOMPARE(m_scope->searchInProgress(), false); |
1534 | 173 | QCOMPARE(departmentModel->isRoot(), false); | 183 | QCOMPARE(departmentModel->isRoot(), false); |
1535 | @@ -175,7 +185,7 @@ | |||
1536 | 175 | bool foundAudiobooks = false; | 185 | bool foundAudiobooks = false; |
1537 | 176 | for (int i = 0; i < departmentModel->rowCount(); i++) { | 186 | for (int i = 0; i < departmentModel->rowCount(); i++) { |
1538 | 177 | QModelIndex idx(departmentModel->index(i)); | 187 | QModelIndex idx(departmentModel->index(i)); |
1540 | 178 | QVariant data = departmentModel->data(idx, Department::Roles::RoleDepartmentId); | 188 | QVariant data = departmentModel->data(idx, Department::Roles::RoleNavigationId); |
1541 | 179 | if (data.toString() == QString("books-audio")) { | 189 | if (data.toString() == QString("books-audio")) { |
1542 | 180 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleIsActive).toBool(), true); | 190 | QCOMPARE(departmentModel->data(idx, Department::Roles::RoleIsActive).toBool(), true); |
1543 | 181 | foundAudiobooks = true; | 191 | foundAudiobooks = true; |
1544 | @@ -188,16 +198,17 @@ | |||
1545 | 188 | { | 198 | { |
1546 | 189 | performSearch(m_scope, QString("")); | 199 | performSearch(m_scope, QString("")); |
1547 | 190 | 200 | ||
1549 | 191 | QCOMPARE(m_scope->currentDepartmentId(), QString("")); | 201 | QCOMPARE(m_scope->currentNavigationId(), QString("")); |
1550 | 192 | QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged())); | 202 | QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged())); |
1552 | 193 | m_scope->loadDepartment(QString("books")); | 203 | QScopedPointer<NavigationInterface> navModel(m_scope->getNavigation(QString("books"))); |
1553 | 204 | m_scope->setNavigationState(navModel->navigationId(), false); | ||
1554 | 194 | QVERIFY(spy.wait()); | 205 | QVERIFY(spy.wait()); |
1555 | 195 | QCOMPARE(m_scope->searchInProgress(), false); | 206 | QCOMPARE(m_scope->searchInProgress(), false); |
1557 | 196 | QScopedPointer<DepartmentInterface> departmentModel(m_scope->getDepartment(QString("books"))); | 207 | QScopedPointer<NavigationInterface> departmentModel(m_scope->getNavigation(QString("books"))); |
1558 | 197 | QCOMPARE(departmentModel->isRoot(), false); | 208 | QCOMPARE(departmentModel->isRoot(), false); |
1559 | 198 | 209 | ||
1560 | 199 | // get the root again without actually loading the department | 210 | // get the root again without actually loading the department |
1562 | 200 | departmentModel.reset(m_scope->getDepartment(departmentModel->parentDepartmentId())); | 211 | departmentModel.reset(m_scope->getNavigation(departmentModel->parentNavigationId())); |
1563 | 201 | QCOMPARE(departmentModel->isRoot(), true); | 212 | QCOMPARE(departmentModel->isRoot(), true); |
1564 | 202 | QEXPECT_FAIL("", "We have the department in cache, to it kind of is loaded", Continue); | 213 | QEXPECT_FAIL("", "We have the department in cache, to it kind of is loaded", Continue); |
1565 | 203 | QCOMPARE(departmentModel->loaded(), false); | 214 | QCOMPARE(departmentModel->loaded(), false); |
1566 | @@ -205,32 +216,98 @@ | |||
1567 | 205 | 216 | ||
1568 | 206 | void testIncompleteTreeOnLeaf() | 217 | void testIncompleteTreeOnLeaf() |
1569 | 207 | { | 218 | { |
1571 | 208 | QScopedPointer<DepartmentInterface> departmentModel; | 219 | QScopedPointer<NavigationInterface> navModel; |
1572 | 220 | QScopedPointer<NavigationInterface> departmentModel; | ||
1573 | 209 | performSearch(m_scope, QString("")); | 221 | performSearch(m_scope, QString("")); |
1574 | 210 | 222 | ||
1577 | 211 | QCOMPARE(m_scope->currentDepartmentId(), QString("")); | 223 | QCOMPARE(m_scope->currentNavigationId(), QString("")); |
1578 | 212 | QCOMPARE(m_scope->hasDepartments(), true); | 224 | QCOMPARE(m_scope->hasNavigation(), true); |
1579 | 213 | 225 | ||
1580 | 214 | QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged())); | 226 | QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged())); |
1582 | 215 | m_scope->loadDepartment(QString("toys")); | 227 | navModel.reset(m_scope->getNavigation(QString("toys"))); |
1583 | 228 | m_scope->setNavigationState(navModel->navigationId(), false); | ||
1584 | 216 | QVERIFY(spy.wait()); | 229 | QVERIFY(spy.wait()); |
1585 | 217 | QCOMPARE(m_scope->searchInProgress(), false); | 230 | QCOMPARE(m_scope->searchInProgress(), false); |
1586 | 218 | 231 | ||
1588 | 219 | departmentModel.reset(m_scope->getDepartment(QString("toys"))); | 232 | departmentModel.reset(m_scope->getNavigation(QString("toys"))); |
1589 | 220 | QCOMPARE(departmentModel->isRoot(), false); | 233 | QCOMPARE(departmentModel->isRoot(), false); |
1590 | 221 | QCOMPARE(departmentModel->rowCount(), 2); | 234 | QCOMPARE(departmentModel->rowCount(), 2); |
1591 | 222 | 235 | ||
1593 | 223 | m_scope->loadDepartment(QString("toys-games")); | 236 | navModel.reset(m_scope->getNavigation(QString("toys-games"))); |
1594 | 237 | m_scope->setNavigationState(navModel->navigationId(), false); | ||
1595 | 224 | QVERIFY(spy.wait()); | 238 | QVERIFY(spy.wait()); |
1596 | 225 | QCOMPARE(m_scope->searchInProgress(), false); | 239 | QCOMPARE(m_scope->searchInProgress(), false); |
1597 | 226 | 240 | ||
1598 | 227 | // after getting the parent department model, it should still have | 241 | // after getting the parent department model, it should still have |
1599 | 228 | // all the leaves, even though the leaf served just itself | 242 | // all the leaves, even though the leaf served just itself |
1601 | 229 | departmentModel.reset(m_scope->getDepartment(QString("toys"))); | 243 | departmentModel.reset(m_scope->getNavigation(QString("toys"))); |
1602 | 230 | QCOMPARE(departmentModel->isRoot(), false); | 244 | QCOMPARE(departmentModel->isRoot(), false); |
1603 | 231 | QCOMPARE(departmentModel->rowCount(), 2); | 245 | QCOMPARE(departmentModel->rowCount(), 2); |
1604 | 232 | } | 246 | } |
1605 | 233 | 247 | ||
1606 | 248 | void testDoubleNavigation() | ||
1607 | 249 | { | ||
1608 | 250 | performSearch(m_scope_navs, QString("")); | ||
1609 | 251 | |||
1610 | 252 | QCOMPARE(m_scope_navs->hasNavigation(), true); | ||
1611 | 253 | QCOMPARE(m_scope_navs->hasAltNavigation(), true); | ||
1612 | 254 | QCOMPARE(m_scope_navs->currentNavigationId(), QString("")); | ||
1613 | 255 | QCOMPARE(m_scope_navs->currentAltNavigationId(), QString("featured")); | ||
1614 | 256 | QScopedPointer<NavigationInterface> departmentModel(m_scope_navs->getNavigation(m_scope_navs->currentNavigationId())); | ||
1615 | 257 | QVERIFY(departmentModel != nullptr); | ||
1616 | 258 | |||
1617 | 259 | QVERIFY(!m_scope_navs->currentAltNavigationId().isEmpty()); | ||
1618 | 260 | QScopedPointer<NavigationInterface> sortOrderModel(m_scope_navs->getAltNavigation("")); | ||
1619 | 261 | QVERIFY(sortOrderModel != nullptr); | ||
1620 | 262 | |||
1621 | 263 | QCOMPARE(sortOrderModel->navigationId(), QString("")); | ||
1622 | 264 | QCOMPARE(sortOrderModel->label(), QString("Sort Order")); | ||
1623 | 265 | QCOMPARE(sortOrderModel->allLabel(), QString("")); | ||
1624 | 266 | QCOMPARE(sortOrderModel->parentNavigationId(), QString()); | ||
1625 | 267 | QCOMPARE(sortOrderModel->parentLabel(), QString()); | ||
1626 | 268 | QCOMPARE(sortOrderModel->loaded(), true); | ||
1627 | 269 | QCOMPARE(sortOrderModel->isRoot(), true); | ||
1628 | 270 | QCOMPARE(sortOrderModel->hidden(), true); | ||
1629 | 271 | |||
1630 | 272 | QCOMPARE(sortOrderModel->rowCount(), 3); | ||
1631 | 273 | QModelIndex idx; | ||
1632 | 274 | |||
1633 | 275 | idx = sortOrderModel->index(0); | ||
1634 | 276 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleNavigationId), QVariant(QString("featured"))); | ||
1635 | 277 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleLabel), QVariant(QString("Featured"))); | ||
1636 | 278 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleHasChildren), QVariant(false)); | ||
1637 | 279 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleIsActive), QVariant(true)); | ||
1638 | 280 | |||
1639 | 281 | idx = sortOrderModel->index(2); | ||
1640 | 282 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleNavigationId), QVariant(QString("best"))); | ||
1641 | 283 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleLabel), QVariant(QString("Best sellers"))); | ||
1642 | 284 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleHasChildren), QVariant(false)); | ||
1643 | 285 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleIsActive), QVariant(false)); | ||
1644 | 286 | } | ||
1645 | 287 | |||
1646 | 288 | void testDoubleNavChangeActive() | ||
1647 | 289 | { | ||
1648 | 290 | performSearch(m_scope_navs, QString("")); | ||
1649 | 291 | |||
1650 | 292 | QCOMPARE(m_scope_navs->currentAltNavigationId(), QString("featured")); | ||
1651 | 293 | QScopedPointer<NavigationInterface> sortOrderModel(m_scope_navs->getAltNavigation("")); | ||
1652 | 294 | QVERIFY(sortOrderModel != nullptr); | ||
1653 | 295 | QCOMPARE(sortOrderModel->loaded(), true); | ||
1654 | 296 | QCOMPARE(sortOrderModel->rowCount(), 3); | ||
1655 | 297 | |||
1656 | 298 | QModelIndex idx(sortOrderModel->index(1)); | ||
1657 | 299 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleNavigationId), QVariant(QString("top"))); | ||
1658 | 300 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleIsActive), QVariant(false)); | ||
1659 | 301 | |||
1660 | 302 | // perform a query for the other navigation | ||
1661 | 303 | QSignalSpy spy(m_scope_navs, SIGNAL(searchInProgressChanged())); | ||
1662 | 304 | m_scope_navs->setNavigationState("top", true); | ||
1663 | 305 | QVERIFY(spy.wait()); | ||
1664 | 306 | |||
1665 | 307 | // the model should be updated | ||
1666 | 308 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleNavigationId), QVariant(QString("top"))); | ||
1667 | 309 | QCOMPARE(sortOrderModel->data(idx, Department::Roles::RoleIsActive), QVariant(true)); | ||
1668 | 310 | } | ||
1669 | 234 | }; | 311 | }; |
1670 | 235 | 312 | ||
1671 | 236 | QTEST_GUILESS_MAIN(DepartmentsTest) | 313 | QTEST_GUILESS_MAIN(DepartmentsTest) |
1672 | 237 | 314 | ||
1673 | === modified file 'tests/previewtest.cpp' | |||
1674 | --- tests/previewtest.cpp 2014-08-05 12:10:41 +0000 | |||
1675 | +++ tests/previewtest.cpp 2014-08-06 08:35:31 +0000 | |||
1676 | @@ -67,14 +67,14 @@ | |||
1677 | 67 | QVERIFY(spy.wait()); | 67 | QVERIFY(spy.wait()); |
1678 | 68 | QCOMPARE(m_scopes->loaded(), true); | 68 | QCOMPARE(m_scopes->loaded(), true); |
1679 | 69 | // should have at least one scope now | 69 | // should have at least one scope now |
1681 | 70 | QCOMPARE(m_scopes->rowCount(), 4); | 70 | QVERIFY(m_scopes->rowCount() > 1); |
1682 | 71 | 71 | ||
1683 | 72 | QVariant scope_var = m_scopes->data(m_scopes->index(0), Scopes::Roles::RoleScope); | 72 | QVariant scope_var = m_scopes->data(m_scopes->index(0), Scopes::Roles::RoleScope); |
1684 | 73 | QVERIFY(scope_var.canConvert<Scope*>()); | 73 | QVERIFY(scope_var.canConvert<Scope*>()); |
1685 | 74 | 74 | ||
1686 | 75 | // get scope proxy | 75 | // get scope proxy |
1689 | 76 | m_scope = scope_var.value<Scope*>(); | 76 | m_scope = m_scopes->getScopeById("mock-scope"); |
1690 | 77 | QCOMPARE(m_scope->id(), QString("mock-scope")); | 77 | QVERIFY(m_scope != nullptr); |
1691 | 78 | m_scope->setActive(true); | 78 | m_scope->setActive(true); |
1692 | 79 | } | 79 | } |
1693 | 80 | 80 | ||
1694 | 81 | 81 | ||
1695 | === modified file 'tests/resultstest.cpp' | |||
1696 | --- tests/resultstest.cpp 2014-07-31 13:04:20 +0000 | |||
1697 | +++ tests/resultstest.cpp 2014-08-06 08:35:31 +0000 | |||
1698 | @@ -112,15 +112,15 @@ | |||
1699 | 112 | QVERIFY(spy.wait()); | 112 | QVERIFY(spy.wait()); |
1700 | 113 | QCOMPARE(m_scopes->loaded(), true); | 113 | QCOMPARE(m_scopes->loaded(), true); |
1701 | 114 | // should have at least one scope now | 114 | // should have at least one scope now |
1703 | 115 | QCOMPARE(m_scopes->rowCount(), 4); | 115 | QVERIFY(m_scopes->rowCount() > 1); |
1704 | 116 | 116 | ||
1705 | 117 | // get scope proxy | 117 | // get scope proxy |
1707 | 118 | m_scope = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope"))); | 118 | m_scope = qobject_cast<scopes_ng::Scope*>(m_scopes->getScopeById(QString("mock-scope"))); |
1708 | 119 | QVERIFY(m_scope != nullptr); | 119 | QVERIFY(m_scope != nullptr); |
1709 | 120 | m_scope->setActive(true); | 120 | m_scope->setActive(true); |
1710 | 121 | 121 | ||
1711 | 122 | // get scope proxy for TTL scope | 122 | // get scope proxy for TTL scope |
1713 | 123 | m_scope_ttl = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope-ttl"))); | 123 | m_scope_ttl = qobject_cast<scopes_ng::Scope*>(m_scopes->getScopeById(QString("mock-scope-ttl"))); |
1714 | 124 | QVERIFY(m_scope != nullptr); | 124 | QVERIFY(m_scope != nullptr); |
1715 | 125 | m_scope_ttl->setActive(true); | 125 | m_scope_ttl->setActive(true); |
1716 | 126 | } | 126 | } |
1717 | @@ -177,7 +177,6 @@ | |||
1718 | 177 | QCOMPARE(m_scope->description(), QString("mock.Description")); | 177 | QCOMPARE(m_scope->description(), QString("mock.Description")); |
1719 | 178 | QCOMPARE(m_scope->searchHint(), QString("mock.SearchHint")); | 178 | QCOMPARE(m_scope->searchHint(), QString("mock.SearchHint")); |
1720 | 179 | QCOMPARE(m_scope->shortcut(), QString("mock.HotKey")); | 179 | QCOMPARE(m_scope->shortcut(), QString("mock.HotKey")); |
1721 | 180 | QCOMPARE(m_scope->visible(), true); | ||
1722 | 181 | QCOMPARE(m_scope->searchQuery(), QString()); | 180 | QCOMPARE(m_scope->searchQuery(), QString()); |
1723 | 182 | 181 | ||
1724 | 183 | QVariantMap customizations(m_scope->customizations()); | 182 | QVariantMap customizations(m_scope->customizations()); |
1725 | @@ -199,7 +198,6 @@ | |||
1726 | 199 | QCOMPARE(m_scope_ttl->description(), QString("mock-ttl.Description")); | 198 | QCOMPARE(m_scope_ttl->description(), QString("mock-ttl.Description")); |
1727 | 200 | QCOMPARE(m_scope_ttl->searchHint(), QString()); | 199 | QCOMPARE(m_scope_ttl->searchHint(), QString()); |
1728 | 201 | QCOMPARE(m_scope_ttl->shortcut(), QString()); | 200 | QCOMPARE(m_scope_ttl->shortcut(), QString()); |
1729 | 202 | QCOMPARE(m_scope_ttl->visible(), true); | ||
1730 | 203 | QCOMPARE(m_scope_ttl->searchQuery(), QString()); | 201 | QCOMPARE(m_scope_ttl->searchQuery(), QString()); |
1731 | 204 | } | 202 | } |
1732 | 205 | 203 | ||
1733 | 206 | 204 | ||
1734 | === modified file 'tests/settingsendtoendtest.cpp' | |||
1735 | --- tests/settingsendtoendtest.cpp 2014-08-05 16:41:02 +0000 | |||
1736 | +++ tests/settingsendtoendtest.cpp 2014-08-06 08:35:31 +0000 | |||
1737 | @@ -61,10 +61,10 @@ | |||
1738 | 61 | QVERIFY(spy.wait()); | 61 | QVERIFY(spy.wait()); |
1739 | 62 | QCOMPARE(m_scopes->loaded(), true); | 62 | QCOMPARE(m_scopes->loaded(), true); |
1740 | 63 | // should have at least one scope now | 63 | // should have at least one scope now |
1742 | 64 | QCOMPARE(m_scopes->rowCount(), 4); | 64 | QVERIFY(m_scopes->rowCount() > 1); |
1743 | 65 | 65 | ||
1744 | 66 | // get scope proxy | 66 | // get scope proxy |
1746 | 67 | m_scope = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope"))); | 67 | m_scope = m_scopes->getScopeById("mock-scope"); |
1747 | 68 | QVERIFY(m_scope != nullptr); | 68 | QVERIFY(m_scope != nullptr); |
1748 | 69 | m_scope->setActive(true); | 69 | m_scope->setActive(true); |
1749 | 70 | } | 70 | } |
FAILED: Continuous integration, rev:144 jenkins. qa.ubuntu. com/job/ unity-scopes- shell-ci/ 179/ jenkins. qa.ubuntu. com/job/ unity-scopes- shell-utopic- amd64-ci/ 76/console jenkins. qa.ubuntu. com/job/ unity-scopes- shell-utopic- armhf-ci/ 76/console jenkins. qa.ubuntu. com/job/ unity-scopes- shell-utopic- i386-ci/ 76/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- scopes- shell-ci/ 179/rebuild
http://