Merge lp:~stolowski/unity-scopes-shell/fix-1374481 into lp:unity-scopes-shell

Proposed by Paweł Stołowski
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 163
Merged at revision: 160
Proposed branch: lp:~stolowski/unity-scopes-shell/fix-1374481
Merge into: lp:unity-scopes-shell
Diff against target: 230 lines (+45/-15)
6 files modified
src/Unity/scope.cpp (+8/-0)
src/Unity/scope.h (+2/-0)
src/Unity/scopes.cpp (+17/-13)
src/Unity/scopes.h (+1/-2)
tests/departmentstest.cpp (+8/-0)
tests/resultstest.cpp (+9/-0)
To merge this branch: bzr merge lp:~stolowski/unity-scopes-shell/fix-1374481
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marcus Tomlinson (community) Approve
Review via email: mp+238445@code.launchpad.net

Commit message

Don't query all favorite scopes on startup - query only next two scopes following current active.

Description of the change

Don't query all favorite scopes on startup - query only next two scopes following current active.

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looks good, just one small issue:

98 + qDebug() << "Pre-populating scope" << scope->id();

Missing a space before the scope id in this message. (E.g. "Pre-populating scopecom.ubuntu.scopes.youtube")

review: Needs Fixing
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> Looks good, just one small issue:
>
> 98 + qDebug() << "Pre-populating scope" <<
> scope->id();
>
> Missing a space before the scope id in this message. (E.g. "Pre-populating
> scopecom.ubuntu.scopes.youtube")

Sorry ignore that one.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Unity/scope.cpp'
2--- src/Unity/scope.cpp 2014-10-10 09:26:35 +0000
3+++ src/Unity/scope.cpp 2014-10-15 14:11:46 +0000
4@@ -80,6 +80,7 @@
5 , m_hasNavigation(false)
6 , m_hasAltNavigation(false)
7 , m_favorite(false)
8+ , m_initialQueryDone(false)
9 , m_searchController(new CollectionController)
10 , m_activationController(new CollectionController)
11 , m_status(Status::Okay)
12@@ -635,6 +636,8 @@
13
14 void Scope::dispatchSearch()
15 {
16+ m_initialQueryDone = true;
17+
18 invalidateLastSearch();
19 m_delayedClear = true;
20 m_clearTimer.start(CLEAR_TIMEOUT);
21@@ -1283,4 +1286,9 @@
22 return service_enabled;
23 }
24
25+bool Scope::initialQueryDone() const
26+{
27+ return m_initialQueryDone;
28+}
29+
30 } // namespace scopes_ng
31
32=== modified file 'src/Unity/scope.h'
33--- src/Unity/scope.h 2014-10-10 05:20:19 +0000
34+++ src/Unity/scope.h 2014-10-15 14:11:46 +0000
35@@ -162,6 +162,7 @@
36
37 QString sessionId() const;
38 int queryId() const;
39+ bool initialQueryDone() const;
40
41 unity::shell::scopes::ScopeInterface* findTempScope(QString const& id) const;
42
43@@ -222,6 +223,7 @@
44 bool m_hasNavigation;
45 bool m_hasAltNavigation;
46 bool m_favorite;
47+ bool m_initialQueryDone;
48
49 std::unique_ptr<CollectionController> m_searchController;
50 std::unique_ptr<CollectionController> m_activationController;
51
52=== modified file 'src/Unity/scopes.cpp'
53--- src/Unity/scopes.cpp 2014-10-02 15:47:22 +0000
54+++ src/Unity/scopes.cpp 2014-10-15 14:11:46 +0000
55@@ -102,7 +102,6 @@
56 , m_overviewScope(nullptr)
57 , m_listThread(nullptr)
58 , m_loaded(false)
59- , m_queryOnStartup(true)
60 , m_priv(new Priv())
61 {
62 QByteArray noFav = qgetenv("UNITY_SCOPES_NO_FAVORITES");
63@@ -268,6 +267,7 @@
64 for (auto it = scopes.begin(); it != scopes.end(); ++it) {
65 if (!it->second.invisible()) {
66 auto scope = new Scope(this);
67+ connect(scope, SIGNAL(isActiveChanged()), this, SLOT(prepopulateNextScopes()));
68 scope->setScopeData(it->second);
69 m_scopes.append(scope);
70 }
71@@ -300,21 +300,24 @@
72 Q_EMIT metadataRefreshed();
73
74 m_listThread = nullptr;
75-
76- if (m_queryOnStartup)
77- {
78- m_queryOnStartup = false;
79- queryScopesOnStartup();
80- }
81 }
82
83-void Scopes::queryScopesOnStartup()
84+void Scopes::prepopulateNextScopes()
85 {
86- for (auto scope: m_scopes) {
87- if (!scope->isActive()) {
88- scope->setSearchQuery("");
89- // must dispatch search explicitly since setSearchQuery will not do that for inactive scope
90- scope->dispatchSearch();
91+ for (QList<Scope*>::iterator it = m_scopes.begin(); it != m_scopes.end(); it++) {
92+ // query next two scopes following currently active scope
93+ if ((*it)->isActive()) {
94+ ++it;
95+ for (int i = 0; i<2 && it != m_scopes.end(); i++) {
96+ auto scope = *(it++);
97+ if (!scope->initialQueryDone()) {
98+ qDebug() << "Pre-populating scope" << scope->id();
99+ scope->setSearchQuery("");
100+ // must dispatch search explicitly since setSearchQuery will not do that for inactive scope
101+ scope->dispatchSearch();
102+ }
103+ }
104+ break;
105 }
106 }
107 }
108@@ -396,6 +399,7 @@
109 if (it != m_cachedMetadata.end())
110 {
111 auto scope = new Scope(this);
112+ connect(scope, SIGNAL(isActiveChanged()), this, SLOT(prepopulateNextScopes()));
113 scope->setScopeData(*(it.value()));
114 scope->setFavorite(true);
115 beginInsertRows(QModelIndex(), row, row);
116
117=== modified file 'src/Unity/scopes.h'
118--- src/Unity/scopes.h 2014-09-24 14:02:29 +0000
119+++ src/Unity/scopes.h 2014-10-15 14:11:46 +0000
120@@ -81,13 +81,13 @@
121 void discoveryFinished();
122 void refreshFinished();
123 void invalidateScopeResults(QString const&);
124+ void prepopulateNextScopes();
125
126 void initPopulateScopes();
127 void dpkgFinished();
128 void lsbReleaseFinished();
129
130 private:
131- void queryScopesOnStartup();
132 void createUserAgentString();
133
134 static int LIST_DELAY;
135@@ -104,7 +104,6 @@
136 QList<QPair<QString, QString>> m_versions;
137 QString m_userAgent;
138 bool m_loaded;
139- bool m_queryOnStartup;
140
141 LocationService::Ptr m_locationService;
142
143
144=== modified file 'tests/departmentstest.cpp'
145--- tests/departmentstest.cpp 2014-09-30 09:27:29 +0000
146+++ tests/departmentstest.cpp 2014-10-15 14:11:46 +0000
147@@ -114,6 +114,8 @@
148
149 void testRootDepartment()
150 {
151+ performSearch(m_scope, QString(""));
152+
153 QCOMPARE(m_scope->hasNavigation(), true);
154 QCOMPARE(m_scope->hasAltNavigation(), false);
155 QCOMPARE(m_scope->currentNavigationId(), QString(""));
156@@ -147,6 +149,8 @@
157
158 void testChildDepartmentModel()
159 {
160+ performSearch(m_scope, QString(""));
161+
162 QCOMPARE(m_scope->currentNavigationId(), QString(""));
163 QScopedPointer<NavigationInterface> departmentModel(m_scope->getNavigation(QString("toys")));
164 QVERIFY(departmentModel != nullptr);
165@@ -173,6 +177,8 @@
166
167 void testLeafActivationUpdatesModel()
168 {
169+ performSearch(m_scope, QString(""));
170+
171 QCOMPARE(m_scope->currentNavigationId(), QString(""));
172 QSignalSpy spy(m_scope, SIGNAL(searchInProgressChanged()));
173 QScopedPointer<NavigationInterface> navModel(m_scope->getNavigation(QString("books")));
174@@ -223,6 +229,8 @@
175
176 void testIncompleteTreeOnLeaf()
177 {
178+ performSearch(m_scope, QString(""));
179+
180 QScopedPointer<NavigationInterface> navModel;
181 QScopedPointer<NavigationInterface> departmentModel;
182
183
184=== modified file 'tests/resultstest.cpp'
185--- tests/resultstest.cpp 2014-09-10 11:47:34 +0000
186+++ tests/resultstest.cpp 2014-10-15 14:11:46 +0000
187@@ -150,6 +150,8 @@
188
189 void testScopeCommunication()
190 {
191+ performSearch(m_scope, QString(""));
192+
193 // ensure categories have > 0 rows
194 auto categories = m_scope->categories();
195 QVERIFY(categories->rowCount() > 0);
196@@ -231,6 +233,7 @@
197
198 void testTwoSearches()
199 {
200+ performSearch(m_scope, QString(""));
201 // ensure categories have > 0 rows
202 auto categories = m_scope->categories();
203 auto categories_count = categories->rowCount();
204@@ -244,6 +247,8 @@
205
206 void testBasicResultData()
207 {
208+ performSearch(m_scope, QString(""));
209+
210 // get ResultsModel instance
211 auto categories = m_scope->categories();
212 QVERIFY(categories->rowCount() > 0);
213@@ -262,6 +267,8 @@
214
215 void testSessionId()
216 {
217+ performSearch(m_scope, QString(""));
218+
219 std::string lastSessionId;
220
221 QVERIFY(!m_scope->sessionId().isEmpty());
222@@ -568,6 +575,8 @@
223 {
224 QCOMPARE(m_scope->searchInProgress(), false);
225
226+ performSearch(m_scope, QString(""));
227+
228 auto categories = m_scope->categories();
229 QString rawTemplate(R"({"schema-version": 1, "template": {"category-layout": "special"}})");
230 CountObject* countObject = new CountObject(m_scope);

Subscribers

People subscribed via source and target branches

to all changes: