Merge lp:~stolowski/unity-scopes-shell/feeds into lp:unity-scopes-shell

Proposed by kevin gunn
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 174
Merged at revision: 173
Proposed branch: lp:~stolowski/unity-scopes-shell/feeds
Merge into: lp:unity-scopes-shell
Diff against target: 594 lines (+254/-57)
13 files modified
debian/control (+2/-2)
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/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/feeds
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Pete Woods (community) Approve
Review via email: mp+239396@code.launchpad.net

Commit message

Support for Manage Dash as per latest designs.

To post a comment you must log in.
170. By Paweł Stołowski on 2014-11-18

Merged trunk.

171. By Paweł Stołowski on 2014-11-21

Merged trunk

Pete Woods (pete-woods) :
review: Approve
172. By Paweł Stołowski on 2014-12-02

Merged trunk

173. By Paweł Stołowski on 2014-12-02

Require scopes api 0.6.9 (debian/control already got updated).

174. By Paweł Stołowski on 2014-12-03

Bump required package version of unity-api

Marcus Tomlinson (marcustomlinson) wrote :

+1

review: Approve

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

Subscribers

People subscribed via source and target branches

to all changes: