Merge lp:~stolowski/unity-scopes-shell/manage-dash-rtm into lp:unity-scopes-shell/rtm-14.09
- manage-dash-rtm
- Merge into rtm-14.09
Proposed by
Paweł Stołowski
Status: | Merged |
---|---|
Approved by: | Michał Sawicz |
Approved revision: | 136 |
Merged at revision: | 136 |
Proposed branch: | lp:~stolowski/unity-scopes-shell/manage-dash-rtm |
Merge into: | lp:unity-scopes-shell/rtm-14.09 |
Diff against target: |
614 lines (+257/-59) 14 files modified
debian/control (+4/-3) src/Unity/CMakeLists.txt (+2/-2) src/Unity/overviewcategories.cpp (+15/-10) src/Unity/overviewcategories.h (+5/-4) src/Unity/overviewresults.cpp (+57/-4) src/Unity/overviewresults.h (+4/-1) src/Unity/overviewscope.cpp (+38/-28) src/Unity/overviewscope.h (+3/-0) src/Unity/scopes.cpp (+55/-2) src/Unity/scopes.h (+2/-1) tests/CMakeLists.txt (+1/-1) tests/data/mock-scope-departments/mock-scope-departments.ini.in (+1/-0) tests/favoritestest.cpp (+65/-1) tests/overviewtest.cpp (+5/-2) |
To merge this branch: | bzr merge lp:~stolowski/unity-scopes-shell/manage-dash-rtm |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michał Sawicz | Approve | ||
Review via email: mp+244117@code.launchpad.net |
Commit message
Support for Manage Dash as per latest designs (cherry-picked from trunk rev. 173).
Description of the change
Support for Manage Dash as per latest designs (cherry-picked from trunk rev. 173).
To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) : | # |
review:
Needs Fixing
Revision history for this message
Michał Sawicz (saviq) : | # |
- 137. By Paweł Stołowski
-
Merged rtm-14.09
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-10-22 15:48:29 +0000 |
3 | +++ debian/control 2014-12-16 16:01:50 +0000 |
4 | @@ -3,8 +3,8 @@ |
5 | Section: libs |
6 | Build-Depends: cmake, |
7 | debhelper (>= 9), |
8 | - libunity-api-dev (>= 7.88), |
9 | - libunity-scopes-dev (>= 0.6.8~), |
10 | + libunity-api-dev (>= 7.94~), |
11 | + libunity-scopes-dev (>= 0.6.9~), |
12 | libgsettings-qt-dev (>= 0.1), |
13 | libqtdbustest1-dev (>= 0.2), |
14 | libqtdbusmock1-dev (>= 0.2), |
15 | @@ -37,7 +37,8 @@ |
16 | unity-scopes-impl-0, |
17 | unity-scopes-impl-1, |
18 | unity-scopes-impl-4, |
19 | -Breaks: unity8-private (<< 7.84) |
20 | +Breaks: unity8-private (<< 7.84), |
21 | + unity8 (<< 8.02) |
22 | Replaces: unity8-private (<< 7.84) |
23 | Description: QML plugin for Scopes |
24 | Plugin to integrate scopes with the Unity shell |
25 | |
26 | === modified file 'src/Unity/CMakeLists.txt' |
27 | --- src/Unity/CMakeLists.txt 2014-10-22 15:48:29 +0000 |
28 | +++ src/Unity/CMakeLists.txt 2014-12-16 16:01:50 +0000 |
29 | @@ -2,8 +2,8 @@ |
30 | include(Plugins) |
31 | |
32 | # Dependencies |
33 | -pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=4) |
34 | -pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.6.8) |
35 | +pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=5) |
36 | +pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.6.9) |
37 | pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt) |
38 | pkg_check_modules(UBUNTU_LOCATION_SERVICE REQUIRED ubuntu-location-service) |
39 | pkg_check_modules(ONLINE_ACCOUNTS_CLIENT REQUIRED OnlineAccountsClient) |
40 | |
41 | === modified file 'src/Unity/overviewcategories.cpp' |
42 | --- src/Unity/overviewcategories.cpp 2014-08-18 09:15:12 +0000 |
43 | +++ src/Unity/overviewcategories.cpp 2014-12-16 16:01:50 +0000 |
44 | @@ -52,11 +52,11 @@ |
45 | : scopes_ng::Categories(parent) |
46 | , m_isSurfacing(true) |
47 | { |
48 | - m_allScopes.reset(new OverviewResultsModel(this)); |
49 | + m_otherScopes.reset(new OverviewResultsModel(this)); |
50 | m_favoriteScopes.reset(new OverviewResultsModel(this)); |
51 | |
52 | m_surfaceCategories.append(QSharedPointer<ScopesCategoryData>(new ScopesCategoryData("favorites", CATEGORY_JSON))); |
53 | - m_surfaceCategories.append(QSharedPointer<ScopesCategoryData>(new ScopesCategoryData("all", CATEGORY_JSON))); |
54 | + m_surfaceCategories.append(QSharedPointer<ScopesCategoryData>(new ScopesCategoryData("other", CATEGORY_JSON))); |
55 | } |
56 | |
57 | OverviewCategories::~OverviewCategories() |
58 | @@ -72,9 +72,9 @@ |
59 | } |
60 | } |
61 | |
62 | -void OverviewCategories::setAllScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes) |
63 | +void OverviewCategories::setOtherScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName) |
64 | { |
65 | - m_allScopes->setResults(scopes); |
66 | + m_otherScopes->setResults(scopes, scopeIdToName); |
67 | |
68 | if (!m_isSurfacing) return; |
69 | |
70 | @@ -85,9 +85,9 @@ |
71 | dataChanged(changedIndex, changedIndex, roles); |
72 | } |
73 | |
74 | -void OverviewCategories::setFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes) |
75 | +void OverviewCategories::setFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName) |
76 | { |
77 | - m_favoriteScopes->setResults(scopes); |
78 | + m_favoriteScopes->setResults(scopes, scopeIdToName); |
79 | |
80 | if (!m_isSurfacing) return; |
81 | |
82 | @@ -98,9 +98,14 @@ |
83 | dataChanged(changedIndex, changedIndex, roles); |
84 | } |
85 | |
86 | -void OverviewCategories::updateFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes) |
87 | -{ |
88 | - m_favoriteScopes->setResults(scopes); |
89 | +void OverviewCategories::updateOtherScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName) |
90 | +{ |
91 | + m_otherScopes->setResults(scopes, scopeIdToName); |
92 | +} |
93 | + |
94 | +void OverviewCategories::updateFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName) |
95 | +{ |
96 | + m_favoriteScopes->setResults(scopes, scopeIdToName); |
97 | } |
98 | |
99 | int OverviewCategories::rowCount(const QModelIndex& parent) const |
100 | @@ -120,7 +125,7 @@ |
101 | } |
102 | |
103 | ScopesCategoryData* catData = m_surfaceCategories.at(index.row()).data(); |
104 | - OverviewResultsModel* results = index.row() == 0 ? m_favoriteScopes.data() : m_allScopes.data(); |
105 | + OverviewResultsModel* results = index.row() == 0 ? m_favoriteScopes.data() : m_otherScopes.data(); |
106 | |
107 | switch (role) { |
108 | case RoleCategoryId: |
109 | |
110 | === modified file 'src/Unity/overviewcategories.h' |
111 | --- src/Unity/overviewcategories.h 2014-08-18 09:15:12 +0000 |
112 | +++ src/Unity/overviewcategories.h 2014-12-16 16:01:50 +0000 |
113 | @@ -44,15 +44,16 @@ |
114 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
115 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
116 | |
117 | - void setAllScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes); |
118 | - void setFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes); |
119 | - void updateFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes); |
120 | + void setOtherScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName); |
121 | + void setFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName); |
122 | + void updateOtherScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName); |
123 | + void updateFavoriteScopes(const QList<unity::scopes::ScopeMetadata::SPtr>& scopes, const QMap<QString, QString>& scopeIdToName); |
124 | |
125 | private: |
126 | bool m_isSurfacing; |
127 | |
128 | QList<QSharedPointer<ScopesCategoryData>> m_surfaceCategories; |
129 | - QScopedPointer<OverviewResultsModel> m_allScopes; |
130 | + QScopedPointer<OverviewResultsModel> m_otherScopes; |
131 | QScopedPointer<OverviewResultsModel> m_favoriteScopes; |
132 | }; |
133 | |
134 | |
135 | === modified file 'src/Unity/overviewresults.cpp' |
136 | --- src/Unity/overviewresults.cpp 2014-08-25 09:51:13 +0000 |
137 | +++ src/Unity/overviewresults.cpp 2014-12-16 16:01:50 +0000 |
138 | @@ -67,19 +67,25 @@ |
139 | { |
140 | } |
141 | |
142 | -void OverviewResultsModel::setResults(const QList<unity::scopes::ScopeMetadata::SPtr>& results) |
143 | +void OverviewResultsModel::setResults(const QList<unity::scopes::ScopeMetadata::SPtr>& results, const QMap<QString, QString>& scopeIdToName) |
144 | { |
145 | if (m_results.empty()) { |
146 | beginResetModel(); |
147 | m_results = results; |
148 | + for (auto const newRes: results) |
149 | + { |
150 | + updateChildScopes(newRes, scopeIdToName); |
151 | + } |
152 | + |
153 | endResetModel(); |
154 | Q_EMIT countChanged(); |
155 | return; |
156 | } |
157 | |
158 | - QSet<QString> newResult; |
159 | + int pos = 0; |
160 | + QMap<QString, int> newResult; |
161 | for (auto const res: results) { |
162 | - newResult.insert(QString::fromStdString(res->scope_id())); |
163 | + newResult[QString::fromStdString(res->scope_id())] = pos++; |
164 | } |
165 | |
166 | // itearate over old results, remove rows that are not present in new results |
167 | @@ -105,6 +111,7 @@ |
168 | row = 0; |
169 | for (auto const newRes: results) |
170 | { |
171 | + updateChildScopes(newRes, scopeIdToName); |
172 | if (!oldResult.contains(QString::fromStdString(newRes->scope_id()))) |
173 | { |
174 | beginInsertRows(QModelIndex(), row, row); |
175 | @@ -113,9 +120,49 @@ |
176 | } |
177 | ++row; |
178 | } |
179 | + |
180 | + // iterate over results, move rows if positions changes |
181 | + for (int i = 0; i<m_results.size(); ) |
182 | + { |
183 | + auto scope_meta = m_results.at(i); |
184 | + const QString id = QString::fromStdString(scope_meta->scope_id()); |
185 | + if (newResult.contains(id)) { |
186 | + pos = newResult[id]; |
187 | + if (pos != i) { |
188 | + beginMoveRows(QModelIndex(), i, i, QModelIndex(), pos + (pos > i ? 1 : 0)); |
189 | + m_results.move(i, pos); |
190 | + endMoveRows(); |
191 | + continue; |
192 | + } |
193 | + } |
194 | + i++; |
195 | + } |
196 | + |
197 | Q_EMIT countChanged(); |
198 | } |
199 | |
200 | +void OverviewResultsModel::updateChildScopes(const unity::scopes::ScopeMetadata::SPtr& scopeMetadata, const QMap<QString, QString>& scopeIdToName) |
201 | +{ |
202 | + auto const children = scopeMetadata->child_scope_ids(); |
203 | + if (children.size()) |
204 | + { |
205 | + // iterate over child scope ids, join their display names and insert into m_childScopes for current scope |
206 | + QStringList childNames; |
207 | + for (auto const& id: children) |
208 | + { |
209 | + auto it = scopeIdToName.find(QString::fromStdString(id)); |
210 | + if (it != scopeIdToName.end()) |
211 | + { |
212 | + childNames << *it; |
213 | + } |
214 | + } |
215 | + if (!childNames.empty()) |
216 | + { |
217 | + m_childScopes[QString::fromStdString(scopeMetadata->scope_id())] = childNames.join(", "); |
218 | + } |
219 | + } |
220 | +} |
221 | + |
222 | QString OverviewResultsModel::categoryId() const |
223 | { |
224 | return QString(); |
225 | @@ -190,8 +237,14 @@ |
226 | } |
227 | return QString::fromStdString(art); |
228 | } |
229 | - case RoleSubtitle: |
230 | + case RoleSubtitle: { |
231 | + auto it = m_childScopes.find(QString::fromStdString(metadata->scope_id())); |
232 | + if (it != m_childScopes.end()) |
233 | + { |
234 | + return *it; |
235 | + } |
236 | return QVariant(); |
237 | + } |
238 | case RoleMascot: |
239 | return QVariant(); |
240 | case RoleEmblem: |
241 | |
242 | === modified file 'src/Unity/overviewresults.h' |
243 | --- src/Unity/overviewresults.h 2014-07-18 10:23:07 +0000 |
244 | +++ src/Unity/overviewresults.h 2014-12-16 16:01:50 +0000 |
245 | @@ -25,6 +25,7 @@ |
246 | #include <unity/scopes/ScopeMetadata.h> |
247 | |
248 | #include <QHash> |
249 | +#include <QMap> |
250 | |
251 | namespace scopes_ng { |
252 | |
253 | @@ -39,7 +40,7 @@ |
254 | |
255 | explicit OverviewResultsModel(QObject* parent = 0); |
256 | |
257 | - void setResults(const QList<unity::scopes::ScopeMetadata::SPtr>& results); |
258 | + void setResults(const QList<unity::scopes::ScopeMetadata::SPtr>& results, const QMap<QString, QString>& scopeIdToName); |
259 | |
260 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
261 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
262 | @@ -54,7 +55,9 @@ |
263 | Q_INVOKABLE int scopeIndex(const QString& scopeId) const; |
264 | |
265 | private: |
266 | + void updateChildScopes(const unity::scopes::ScopeMetadata::SPtr& scopeMetadata, const QMap<QString, QString>& scopeIdToName); |
267 | QList<unity::scopes::ScopeMetadata::SPtr> m_results; |
268 | + QMap<QString, QString> m_childScopes; |
269 | }; |
270 | |
271 | } // namespace scopes_ng |
272 | |
273 | === modified file 'src/Unity/overviewscope.cpp' |
274 | --- src/Unity/overviewscope.cpp 2014-09-30 12:40:03 +0000 |
275 | +++ src/Unity/overviewscope.cpp 2014-12-16 16:01:50 +0000 |
276 | @@ -65,30 +65,13 @@ |
277 | return; |
278 | } |
279 | |
280 | - QMap<QString, scopes::ScopeMetadata::SPtr> allMetadata = m_scopesInstance->getAllMetadata(); |
281 | + QMap<QString, QString> scopeIdToName; |
282 | QList<scopes::ScopeMetadata::SPtr> favorites; |
283 | - Q_FOREACH(QString id, m_scopesInstance->getFavoriteIds()) { |
284 | - auto it = allMetadata.find(id); |
285 | - if (it != allMetadata.end()) { |
286 | - favorites.append(it.value()); |
287 | - } |
288 | - } |
289 | - |
290 | - QList<ScopeInfo> scopes; |
291 | - Q_FOREACH(scopes::ScopeMetadata::SPtr const& metadata, allMetadata.values()) { |
292 | - if (metadata->invisible()) continue; |
293 | - scopes.append(ScopeInfo(metadata)); |
294 | - } |
295 | - qSort(scopes.begin(), scopes.end()); |
296 | - |
297 | - QList<scopes::ScopeMetadata::SPtr> allScopes; |
298 | - Q_FOREACH(ScopeInfo const& info, scopes) { |
299 | - allScopes << info.data; |
300 | - } |
301 | - |
302 | - // FIXME: filter invisible scopes? |
303 | - categories->setAllScopes(allScopes); |
304 | - categories->setFavoriteScopes(favorites); |
305 | + QList<scopes::ScopeMetadata::SPtr> otherScopes; |
306 | + processFavorites(m_scopesInstance->getFavoriteIds(), favorites, otherScopes, scopeIdToName); |
307 | + |
308 | + categories->setFavoriteScopes(favorites, scopeIdToName); |
309 | + categories->setOtherScopes(otherScopes, scopeIdToName); |
310 | |
311 | // Metadata has changed, invalidate the search results |
312 | invalidateResults(); |
313 | @@ -109,25 +92,52 @@ |
314 | } |
315 | } |
316 | |
317 | -void OverviewScope::updateFavorites(const QStringList& favorites) |
318 | +void OverviewScope::processFavorites(const QStringList& favs, QList<scopes::ScopeMetadata::SPtr>& favorites, QList<scopes::ScopeMetadata::SPtr>& otherScopes, QMap<QString, QString>& scopeIdToName) |
319 | { |
320 | - QList<scopes::ScopeMetadata::SPtr> favs; |
321 | auto allMetadata = m_scopesInstance->getAllMetadata(); |
322 | - for (auto const id: favorites) |
323 | + |
324 | + for (auto m: allMetadata) |
325 | + { |
326 | + scopeIdToName[QString::fromStdString(m->scope_id())] = QString::fromStdString(m->display_name()); |
327 | + } |
328 | + |
329 | + for (auto const id: favs) |
330 | { |
331 | auto it = allMetadata.find(id); |
332 | if (it != allMetadata.end()) { |
333 | - favs.append(it.value()); |
334 | + favorites.append(it.value()); |
335 | + allMetadata.erase(it); |
336 | } |
337 | } |
338 | |
339 | + QList<ScopeInfo> scopes; |
340 | + Q_FOREACH(scopes::ScopeMetadata::SPtr const& metadata, allMetadata.values()) { |
341 | + if (metadata->invisible()) |
342 | + continue; |
343 | + scopes.append(ScopeInfo(metadata)); |
344 | + } |
345 | + qSort(scopes.begin(), scopes.end()); |
346 | + |
347 | + Q_FOREACH(ScopeInfo const& info, scopes) { |
348 | + otherScopes << info.data; |
349 | + } |
350 | +} |
351 | + |
352 | +void OverviewScope::updateFavorites(const QStringList& favs) |
353 | +{ |
354 | OverviewCategories* categories = qobject_cast<OverviewCategories*>(m_categories.data()); |
355 | if (!categories) { |
356 | qWarning("Unable to cast m_categories to OverviewCategories"); |
357 | return; |
358 | } |
359 | |
360 | - categories->updateFavoriteScopes(favs); |
361 | + QMap<QString, QString> scopeIdToName; |
362 | + QList<scopes::ScopeMetadata::SPtr> favorites; |
363 | + QList<scopes::ScopeMetadata::SPtr> otherScopes; |
364 | + processFavorites(favs, favorites, otherScopes, scopeIdToName); |
365 | + |
366 | + categories->updateFavoriteScopes(favorites, scopeIdToName); |
367 | + categories->updateOtherScopes(otherScopes, scopeIdToName); |
368 | } |
369 | |
370 | void OverviewScope::dispatchSearch() |
371 | |
372 | === modified file 'src/Unity/overviewscope.h' |
373 | --- src/Unity/overviewscope.h 2014-08-13 15:46:55 +0000 |
374 | +++ src/Unity/overviewscope.h 2014-12-16 16:01:50 +0000 |
375 | @@ -44,6 +44,9 @@ |
376 | |
377 | private Q_SLOTS: |
378 | void metadataChanged(); |
379 | + |
380 | +private: |
381 | + void processFavorites(const QStringList& favs, QList<unity::scopes::ScopeMetadata::SPtr>& favorites, QList<unity::scopes::ScopeMetadata::SPtr>& otherScopes, QMap<QString, QString>& scopeIdToName); |
382 | }; |
383 | |
384 | } // namespace scopes_ng |
385 | |
386 | === modified file 'src/Unity/scopes.cpp' |
387 | --- src/Unity/scopes.cpp 2014-12-10 16:45:40 +0000 |
388 | +++ src/Unity/scopes.cpp 2014-12-16 16:01:50 +0000 |
389 | @@ -390,17 +390,20 @@ |
390 | // notify about scopes model changes accordingly. |
391 | if (m_dashSettings) { |
392 | QStringList newFavorites; |
393 | - QSet<QString> favScopesLut; |
394 | + QMap<QString, int> favScopesLut; |
395 | for (auto const& fv: m_dashSettings->get("favoriteScopes").toList()) |
396 | { |
397 | + int pos = 0; |
398 | try |
399 | { |
400 | auto const query = unity::scopes::CannedQuery::from_uri(fv.toString().toStdString()); |
401 | const QString id = QString::fromStdString(query.scope_id()); |
402 | + |
403 | if (m_cachedMetadata.find(id) != m_cachedMetadata.end()) |
404 | { |
405 | newFavorites.push_back(id); |
406 | - favScopesLut.insert(id); |
407 | + pos = newFavorites.size() - 1; |
408 | + favScopesLut[id] = pos; |
409 | } |
410 | else |
411 | { |
412 | @@ -471,6 +474,23 @@ |
413 | ++row; |
414 | ++favIt; |
415 | } |
416 | + |
417 | + // iterate over results, move rows if positions changes |
418 | + for (int i = 0; i<m_scopes.size(); ) |
419 | + { |
420 | + auto scope = m_scopes.at(i); |
421 | + const QString id = scope->id(); |
422 | + if (favScopesLut.contains(id)) { |
423 | + int pos = favScopesLut[id]; |
424 | + if (pos != i) { |
425 | + beginMoveRows(QModelIndex(), i, i, QModelIndex(), pos + (pos > i ? 1 : 0)); |
426 | + m_scopes.move(i, pos); |
427 | + endMoveRows(); |
428 | + continue; |
429 | + } |
430 | + } |
431 | + i++; |
432 | + } |
433 | } |
434 | } |
435 | |
436 | @@ -618,6 +638,39 @@ |
437 | } |
438 | } |
439 | |
440 | +void Scopes::moveFavoriteTo(QString const& scopeId, int index) |
441 | +{ |
442 | + if (m_dashSettings) |
443 | + { |
444 | + QStringList cannedQueries; |
445 | + bool found = false; |
446 | + |
447 | + int i = 0; |
448 | + for (auto const& fav: m_favoriteScopes) |
449 | + { |
450 | + if (fav == scopeId) { |
451 | + if (index == i) |
452 | + return; // same position |
453 | + found = true; |
454 | + } else { |
455 | + const QString query = "scope://" + fav; |
456 | + cannedQueries.push_back(query); |
457 | + } |
458 | + |
459 | + ++i; |
460 | + } |
461 | + |
462 | + if (found) { |
463 | + // insert scopeId at new position |
464 | + const QString query = "scope://" + scopeId; |
465 | + cannedQueries.insert(index, query); |
466 | + // update gsettings entry |
467 | + // note: this will trigger notification, so that new favorites are processed by processFavoriteScopes |
468 | + m_dashSettings->set("favoriteScopes", QVariant(cannedQueries)); |
469 | + } |
470 | + } |
471 | +} |
472 | + |
473 | QMap<QString, unity::scopes::ScopeMetadata::SPtr> Scopes::getAllMetadata() const |
474 | { |
475 | return m_cachedMetadata; |
476 | |
477 | === modified file 'src/Unity/scopes.h' |
478 | --- src/Unity/scopes.h 2014-11-05 16:47:40 +0000 |
479 | +++ src/Unity/scopes.h 2014-12-16 16:01:50 +0000 |
480 | @@ -61,7 +61,8 @@ |
481 | unity::scopes::ScopeMetadata::SPtr getCachedMetadata(QString const& scopeId) const; |
482 | QMap<QString, unity::scopes::ScopeMetadata::SPtr> getAllMetadata() const; |
483 | QStringList getFavoriteIds() const; |
484 | - void setFavorite(QString const& scopeId, bool value); |
485 | + Q_INVOKABLE void setFavorite(QString const& scopeId, bool value) override; |
486 | + Q_INVOKABLE void moveFavoriteTo(QString const& scopeId, int index) override; |
487 | |
488 | void refreshScopeMetadata(); |
489 | |
490 | |
491 | === modified file 'tests/CMakeLists.txt' |
492 | --- tests/CMakeLists.txt 2014-09-15 12:03:13 +0000 |
493 | +++ tests/CMakeLists.txt 2014-12-16 16:01:50 +0000 |
494 | @@ -1,4 +1,4 @@ |
495 | -pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=3) |
496 | +pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=5) |
497 | pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.6.2) |
498 | pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt) |
499 | pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1>=0.2 REQUIRED) |
500 | |
501 | === modified file 'tests/data/mock-scope-departments/mock-scope-departments.ini.in' |
502 | --- tests/data/mock-scope-departments/mock-scope-departments.ini.in 2014-06-02 14:36:07 +0000 |
503 | +++ tests/data/mock-scope-departments/mock-scope-departments.ini.in 2014-12-16 16:01:50 +0000 |
504 | @@ -6,3 +6,4 @@ |
505 | SearchHint = mock-departments.SearchHint |
506 | HotKey = mock-departments.HotKey |
507 | Author = mock-departments.Author |
508 | +ChildScopes = mock-scope-double-nav;mock-scope |
509 | |
510 | === modified file 'tests/favoritestest.cpp' |
511 | --- tests/favoritestest.cpp 2014-09-29 14:25:10 +0000 |
512 | +++ tests/favoritestest.cpp 2014-12-16 16:01:50 +0000 |
513 | @@ -146,6 +146,70 @@ |
514 | QTRY_COMPARE(results->rowCount(), 0); |
515 | } |
516 | |
517 | + void testFavoritesReordering() |
518 | + { |
519 | + QStringList favs; |
520 | + favs << "scope://mock-scope-departments" << "scope://mock-scope-double-nav" << "scope://mock-scope"; |
521 | + setFavouriteScopes(favs); |
522 | + |
523 | + // should have one scope now |
524 | + QTRY_COMPARE(m_scopes->rowCount(), 3); |
525 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(0))->id(), QString("mock-scope-departments")); |
526 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(1))->id(), QString("mock-scope-double-nav")); |
527 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(2))->id(), QString("mock-scope")); |
528 | + |
529 | + { |
530 | + QSignalSpy spy(m_scopes.data(), SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int))); |
531 | + m_scopes->moveFavoriteTo("mock-scope", 1); |
532 | + |
533 | + // check new positions |
534 | + QTRY_COMPARE(spy.count(), 1); |
535 | + |
536 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(0))->id(), QString("mock-scope-departments")); |
537 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(1))->id(), QString("mock-scope")); |
538 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(2))->id(), QString("mock-scope-double-nav")); |
539 | + |
540 | + // check overview model |
541 | + auto categories = m_overviewScope->categories(); |
542 | + QVERIFY(categories->rowCount() > 0); |
543 | + QCOMPARE(categories->data(categories->index(0), Categories::Roles::RoleCategoryId), QVariant(QString("favorites"))); |
544 | + |
545 | + QVariant results_var = categories->data(categories->index(0), Categories::Roles::RoleResults); |
546 | + QVERIFY(results_var.canConvert<OverviewResultsModel*>()); |
547 | + OverviewResultsModel* results = results_var.value<OverviewResultsModel*>(); |
548 | + QTRY_COMPARE(results->rowCount(), 3); |
549 | + |
550 | + QTRY_COMPARE(results->data(results->index(0), OverviewResultsModel::RoleScopeId), QVariant(QString("mock-scope-departments"))); |
551 | + QTRY_COMPARE(results->data(results->index(1), OverviewResultsModel::RoleScopeId), QVariant(QString("mock-scope"))); |
552 | + QTRY_COMPARE(results->data(results->index(2), OverviewResultsModel::RoleScopeId), QVariant(QString("mock-scope-double-nav"))); |
553 | + } |
554 | + { |
555 | + QSignalSpy spy(m_scopes.data(), SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int))); |
556 | + m_scopes->moveFavoriteTo("mock-scope", 2); |
557 | + |
558 | + // check new positions |
559 | + QTRY_COMPARE(spy.count(), 1); |
560 | + |
561 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(0))->id(), QString("mock-scope-departments")); |
562 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(1))->id(), QString("mock-scope-double-nav")); |
563 | + QTRY_COMPARE(qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(2))->id(), QString("mock-scope")); |
564 | + |
565 | + // check overview model |
566 | + auto categories = m_overviewScope->categories(); |
567 | + QVERIFY(categories->rowCount() > 0); |
568 | + QCOMPARE(categories->data(categories->index(0), Categories::Roles::RoleCategoryId), QVariant(QString("favorites"))); |
569 | + |
570 | + QVariant results_var = categories->data(categories->index(0), Categories::Roles::RoleResults); |
571 | + QVERIFY(results_var.canConvert<OverviewResultsModel*>()); |
572 | + OverviewResultsModel* results = results_var.value<OverviewResultsModel*>(); |
573 | + QTRY_COMPARE(results->rowCount(), 3); |
574 | + |
575 | + QTRY_COMPARE(results->data(results->index(0), OverviewResultsModel::RoleScopeId), QVariant(QString("mock-scope-departments"))); |
576 | + QTRY_COMPARE(results->data(results->index(1), OverviewResultsModel::RoleScopeId), QVariant(QString("mock-scope-double-nav"))); |
577 | + QTRY_COMPARE(results->data(results->index(2), OverviewResultsModel::RoleScopeId), QVariant(QString("mock-scope"))); |
578 | + } |
579 | + } |
580 | + |
581 | void testGSettingsUpdates() |
582 | { |
583 | QStringList favs; |
584 | @@ -157,7 +221,7 @@ |
585 | auto scope1 = qobject_cast<scopes_ng::Scope*>(m_scopes->getScope(QString("mock-scope-departments"))); |
586 | QVERIFY(scope1 != nullptr); |
587 | |
588 | - // un-facorite one scope |
589 | + // un-favorite one scope |
590 | scope1->setFavorite(false); |
591 | QTRY_COMPARE(getFavoriteScopes().size(), 1); |
592 | QCOMPARE(getFavoriteScopes().at(0), QString("scope://mock-scope-double-nav")); |
593 | |
594 | === modified file 'tests/overviewtest.cpp' |
595 | --- tests/overviewtest.cpp 2014-08-14 09:45:50 +0000 |
596 | +++ tests/overviewtest.cpp 2014-12-16 16:01:50 +0000 |
597 | @@ -108,12 +108,15 @@ |
598 | auto categories = m_scope->categories(); |
599 | QVERIFY(categories->rowCount() > 0); |
600 | QCOMPARE(categories->data(categories->index(0), Categories::Roles::RoleCategoryId), QVariant(QString("favorites"))); |
601 | - QCOMPARE(categories->data(categories->index(1), Categories::Roles::RoleCategoryId), QVariant(QString("all"))); |
602 | + QCOMPARE(categories->data(categories->index(1), Categories::Roles::RoleCategoryId), QVariant(QString("other"))); |
603 | |
604 | QVariant results_var = categories->data(categories->index(0), Categories::Roles::RoleResults); |
605 | QVERIFY(results_var.canConvert<OverviewResultsModel*>()); |
606 | OverviewResultsModel* results = results_var.value<OverviewResultsModel*>(); |
607 | - QVERIFY(results->rowCount() > 0); |
608 | + QVERIFY(results->rowCount() == 2); |
609 | + |
610 | + QCOMPARE(results->data(results->index(0), OverviewResultsModel::Roles::RoleTitle), QVariant(QString("mock-departments.DisplayName"))); |
611 | + QCOMPARE(results->data(results->index(0), OverviewResultsModel::Roles::RoleSubtitle), QVariant(QString("mock-double-nav.DisplayName, mock.DisplayName"))); |
612 | } |
613 | |
614 | void testPreview() |
As per upstream changes.