Merge lp:~lukas-kde/unity8/appdrawer-search-more into lp:unity8

Proposed by Lukáš Tinkl
Status: Needs review
Proposed branch: lp:~lukas-kde/unity8/appdrawer-search-more
Merge into: lp:unity8
Prerequisite: lp:~mzanetti/unity8/appdrawer-recent-apps
Diff against target: 384 lines (+91/-25)
14 files modified
plugins/Greeter/Unity/Launcher/launcheritem.cpp (+13/-0)
plugins/Greeter/Unity/Launcher/launcheritem.h (+3/-0)
plugins/Unity/Launcher/appdrawermodel.cpp (+3/-0)
plugins/Unity/Launcher/launcheritem.cpp (+13/-0)
plugins/Unity/Launcher/launcheritem.h (+3/-0)
plugins/Unity/Launcher/ualwrapper.cpp (+6/-4)
plugins/Unity/Launcher/ualwrapper.h (+1/-0)
plugins/Utils/appdrawerproxymodel.cpp (+24/-19)
qml/Launcher/Drawer.qml (+1/-0)
tests/mocks/Unity/Launcher/MockLauncherItem.cpp (+13/-0)
tests/mocks/Unity/Launcher/MockLauncherItem.h (+3/-0)
tests/plugins/Unity/Launcher/appdrawermodeltest.cpp (+6/-2)
tests/plugins/Unity/Launcher/ualwrapper.cpp (+1/-0)
tests/plugins/Unity/Launcher/ualwrapper.h (+1/-0)
To merge this branch: bzr merge lp:~lukas-kde/unity8/appdrawer-search-more
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Albert Astals Cid (community) Approve
Review via email: mp+321998@code.launchpad.net

This proposal supersedes a proposal from 2017-04-04.

Commit message

Appdrawer: search in more fields (appid and description), optimize and massively speed up

Description of the change

Prereq-archive: ppa:ci-train-ppa-service/2701

Appdrawer: search in more fields (appid and description), optimize and massively speed up

As I added more field to search in, it slowed down a bit. So I optimized the tiny bits throughout the AppDrawerProxyModel but the biggest bottleneck turned out to be the toplevel dynamicSortFilter in Drawer.qml

* Are there any related MPs required for this MP to build/function as expected? Please list.

Yes, https://code.launchpad.net/~lukas-kde/unity-api/launcheritem-description/+merge/321924 and https://code.launchpad.net/~mzanetti/unity8/appdrawer-recent-apps/+merge/319697

 * Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

 * If you changed the UI, has there been a design review?

N/A

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

I guess the startsWith -> contains change is the most "controversial" change here.

Maybe contains should be only for description? What do others think?

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
2919. By Lukáš Tinkl

restore sortRole

Revision history for this message
Albert Astals Cid (aacid) wrote :

> I guess the startsWith -> contains change is the most "controversial" change here.
>
> Maybe contains should be only for description? What do others think?

Given yesterday's news i guess it doesn't make sense to nitpick much over this.

Revision history for this message
Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass? If not, please explain why.
Waiting

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
2920. By Lukáš Tinkl

merge parent

2921. By Lukáš Tinkl

fix segfaulting test (add the missing description field)

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
2922. By Lukáš Tinkl

don't crash

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2922
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3702/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3702/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

^^ now it fails to build on zesty because of ual not being up to date (wrt xenial)

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2922
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3704/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/4922/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4950
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4758
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4758/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4758
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4758/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4758/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4758
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4758/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4758
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4758/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4758
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4758/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3704/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

2922. By Lukáš Tinkl

don't crash

2921. By Lukáš Tinkl

fix segfaulting test (add the missing description field)

2920. By Lukáš Tinkl

merge parent

2919. By Lukáš Tinkl

restore sortRole

2918. By Lukáš Tinkl

merge lp:~mzanetti/unity8/appdrawer-recent-apps

2917. By Lukáš Tinkl

invalidate and sort only after the source model had been set

2916. By Lukáš Tinkl

massive speedup by not using dynamicFilter \o/

2915. By Lukáš Tinkl

optimize the filterString search

2914. By Lukáš Tinkl

perform the search in appName and Description too

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Greeter/Unity/Launcher/launcheritem.cpp'
2--- plugins/Greeter/Unity/Launcher/launcheritem.cpp 2017-04-06 13:50:59 +0000
3+++ plugins/Greeter/Unity/Launcher/launcheritem.cpp 2017-04-06 13:50:59 +0000
4@@ -89,6 +89,19 @@
5 }
6 }
7
8+QString LauncherItem::description() const
9+{
10+ return m_description;
11+}
12+
13+void LauncherItem::setDescription(const QString &description)
14+{
15+ if (m_description != description) {
16+ m_description = description;
17+ Q_EMIT descriptionChanged(m_description);
18+ }
19+}
20+
21 uint LauncherItem::popularity() const
22 {
23 // Not exposing usage order in greeter session at this point.
24
25=== modified file 'plugins/Greeter/Unity/Launcher/launcheritem.h'
26--- plugins/Greeter/Unity/Launcher/launcheritem.h 2017-04-06 13:50:59 +0000
27+++ plugins/Greeter/Unity/Launcher/launcheritem.h 2017-04-06 13:50:59 +0000
28@@ -35,6 +35,7 @@
29 QString name() const override;
30 QString icon() const override;
31 QStringList keywords() const override;
32+ QString description() const override;
33 uint popularity() const override;
34 bool pinned() const override;
35 bool running() const override;
36@@ -52,6 +53,7 @@
37 void setName(const QString &name);
38 void setIcon(const QString &icon);
39 void setKeywords(const QStringList &keywords);
40+ void setDescription(const QString &description);
41 void setPinned(bool pinned);
42 void setRunning(bool running);
43 void setRecent(bool recent);
44@@ -67,6 +69,7 @@
45 QString m_name;
46 QString m_icon;
47 QStringList m_keywords;
48+ QString m_description;
49 bool m_pinned;
50 bool m_running;
51 bool m_recent;
52
53=== modified file 'plugins/Unity/Launcher/appdrawermodel.cpp'
54--- plugins/Unity/Launcher/appdrawermodel.cpp 2017-04-06 13:50:59 +0000
55+++ plugins/Unity/Launcher/appdrawermodel.cpp 2017-04-06 13:50:59 +0000
56@@ -32,6 +32,7 @@
57 }
58 LauncherItem* item = new LauncherItem(appId, info.name, info.icon, this);
59 item->setKeywords(info.keywords);
60+ item->setDescription(info.description);
61 item->setPopularity(info.popularity);
62 m_list.append(item);
63 }
64@@ -59,6 +60,8 @@
65 return m_list.at(index.row())->icon();
66 case RoleKeywords:
67 return m_list.at(index.row())->keywords();
68+ case RoleDescription:
69+ return m_list.at(index.row())->description();
70 case RoleUsage:
71 return m_list.at(index.row())->popularity();
72 }
73
74=== modified file 'plugins/Unity/Launcher/launcheritem.cpp'
75--- plugins/Unity/Launcher/launcheritem.cpp 2017-04-06 13:50:59 +0000
76+++ plugins/Unity/Launcher/launcheritem.cpp 2017-04-06 13:50:59 +0000
77@@ -104,6 +104,19 @@
78 }
79 }
80
81+QString LauncherItem::description() const
82+{
83+ return m_description;
84+}
85+
86+void LauncherItem::setDescription(const QString &description)
87+{
88+ if (m_description != description) {
89+ m_description = description;
90+ Q_EMIT descriptionChanged(m_description);
91+ }
92+}
93+
94 bool LauncherItem::pinned() const
95 {
96 return m_pinned;
97
98=== modified file 'plugins/Unity/Launcher/launcheritem.h'
99--- plugins/Unity/Launcher/launcheritem.h 2017-04-06 13:50:59 +0000
100+++ plugins/Unity/Launcher/launcheritem.h 2017-04-06 13:50:59 +0000
101@@ -39,6 +39,7 @@
102 QString name() const override;
103 QString icon() const override;
104 QStringList keywords() const override;
105+ QString description() const override;
106 uint popularity() const override;
107 bool pinned() const override;
108 bool running() const override;
109@@ -56,6 +57,7 @@
110 void setName(const QString &name);
111 void setIcon(const QString &icon);
112 void setKeywords(const QStringList &keywords);
113+ void setDescription(const QString &description);
114 void setPopularity(uint popularity);
115 void setPinned(bool pinned);
116 void setRunning(bool running);
117@@ -72,6 +74,7 @@
118 QString m_name;
119 QString m_icon;
120 QStringList m_keywords;
121+ QString m_description;
122 uint m_popularity;
123 bool m_pinned;
124 bool m_running;
125
126=== modified file 'plugins/Unity/Launcher/ualwrapper.cpp'
127--- plugins/Unity/Launcher/ualwrapper.cpp 2017-04-06 13:50:59 +0000
128+++ plugins/Unity/Launcher/ualwrapper.cpp 2017-04-06 13:50:59 +0000
129@@ -66,14 +66,16 @@
130
131 std::shared_ptr<Application> ualApp;
132 ualApp = Application::create(ualAppId, Registry::getDefault());
133+ auto appInfo = ualApp->info();
134
135 info.appId = appId;
136- info.name = QString::fromStdString(ualApp->info()->name());
137- info.icon = QString::fromStdString(ualApp->info()->iconPath());
138- for (const std::string &keyword : ualApp->info()->keywords().value()) {
139+ info.name = QString::fromStdString(appInfo->name());
140+ info.icon = QString::fromStdString(appInfo->iconPath());
141+ info.description = QString::fromStdString(appInfo->description());
142+ for (const std::string &keyword : appInfo->keywords().value()) {
143 info.keywords << QString::fromStdString(keyword);
144 }
145- info.popularity = ualApp->info()->popularity();
146+ info.popularity = appInfo->popularity();
147 info.valid = true;
148 } catch (const std::runtime_error &e) {
149 qWarning() << "ubuntu-app-launch threw an exception getting app info for appId:" << appId << ":" << e.what();
150
151=== modified file 'plugins/Unity/Launcher/ualwrapper.h'
152--- plugins/Unity/Launcher/ualwrapper.h 2017-04-06 13:50:59 +0000
153+++ plugins/Unity/Launcher/ualwrapper.h 2017-04-06 13:50:59 +0000
154@@ -25,6 +25,7 @@
155 bool valid = false;
156 QString name;
157 QString icon;
158+ QString description;
159 QStringList keywords;
160 uint popularity = 0;
161 };
162
163=== modified file 'plugins/Utils/appdrawerproxymodel.cpp'
164--- plugins/Utils/appdrawerproxymodel.cpp 2017-01-25 17:44:54 +0000
165+++ plugins/Utils/appdrawerproxymodel.cpp 2017-04-06 13:50:59 +0000
166@@ -25,7 +25,6 @@
167 {
168 setSortRole(AppDrawerModelInterface::RoleName);
169 setSortLocaleAware(true);
170- sort(0);
171
172 connect(this, &QAbstractListModel::rowsInserted, this, &AppDrawerProxyModel::countChanged);
173 connect(this, &QAbstractListModel::rowsRemoved, this, &AppDrawerProxyModel::countChanged);
174@@ -45,6 +44,8 @@
175 setSortRole(m_sortBy == SortByAToZ ? AppDrawerModelInterface::RoleName : AppDrawerModelInterface::RoleUsage);
176 connect(m_source, &QAbstractItemModel::rowsRemoved, this, &AppDrawerProxyModel::invalidate);
177 connect(m_source, &QAbstractItemModel::rowsInserted, this, &AppDrawerProxyModel::invalidate);
178+ connect(m_source, &QAbstractItemModel::modelReset, this, &AppDrawerProxyModel::invalidate);
179+ sort(0);
180 Q_EMIT sourceChanged();
181 }
182 }
183@@ -59,7 +60,7 @@
184 if (m_group != group) {
185 m_group = group;
186 Q_EMIT groupChanged();
187- invalidateFilter();
188+ invalidate();
189 }
190 }
191
192@@ -73,7 +74,7 @@
193 if (m_filterLetter != filterLetter) {
194 m_filterLetter = filterLetter;
195 Q_EMIT filterLetterChanged();
196- invalidateFilter();
197+ invalidate();
198 }
199 }
200
201@@ -87,7 +88,7 @@
202 if (m_filterString != filterString) {
203 m_filterString = filterString;
204 Q_EMIT filterStringChanged();
205- invalidateFilter();
206+ invalidate();
207 }
208 }
209
210@@ -113,10 +114,10 @@
211
212 QVariant AppDrawerProxyModel::data(const QModelIndex &index, int role) const
213 {
214- QModelIndex idx = mapToSource(index);
215+ const QModelIndex idx = mapToSource(index);
216 if (role == Qt::UserRole) {
217- QString name = m_source->data(idx, AppDrawerModelInterface::RoleName).toString();
218- return name.length() > 0 ? QString(name.at(0)).toUpper() : QChar();
219+ const QString name = m_source->data(idx, AppDrawerModelInterface::RoleName).toString();
220+ return !name.isEmpty() ? name.at(0).toUpper() : QChar();
221 }
222 return m_source->data(idx, role);
223 }
224@@ -135,30 +136,34 @@
225 {
226 Q_UNUSED(source_parent)
227
228+ const QModelIndex idx{m_source->index(source_row, 0)};
229+
230 if (m_group == GroupByAToZ && source_row > 0) {
231- QString currentName = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString();
232- QChar currentLetter = currentName.length() > 0 ? currentName.at(0) : QChar();
233- QString previousName = m_source->data(m_source->index(source_row - 1,0 ), AppDrawerModelInterface::RoleName).toString();
234- QChar previousLetter = previousName.length() > 0 ? previousName.at(0) : QChar();
235- if (currentLetter.toLower() == previousLetter.toLower()) {
236+ const QString currentName = m_source->data(idx, AppDrawerModelInterface::RoleName).toString();
237+ const QChar currentLetter = !currentName.isEmpty() ? currentName.at(0).toLower() : QChar();
238+ const QString previousName = m_source->data(m_source->index(source_row - 1, 0), AppDrawerModelInterface::RoleName).toString();
239+ const QChar previousLetter = !previousName.isEmpty() ? previousName.at(0).toLower() : QChar();
240+ if (currentLetter == previousLetter) {
241 return false;
242 }
243- } else if(m_group == GroupByAll && source_row > 0) {
244+ } else if (m_group == GroupByAll && source_row > 0) {
245 return false;
246 }
247+
248 if (!m_filterLetter.isEmpty()) {
249- QString currentName = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString();
250- QString currentLetter = currentName.length() > 0 ? QString(currentName.at(0)) : QString();
251+ const QString currentName = m_source->data(idx, AppDrawerModelInterface::RoleName).toString();
252+ const QString currentLetter = !currentName.isEmpty() ? QString(currentName.at(0)) : QString();
253 if (currentLetter.toLower() != m_filterLetter.toLower()) {
254 return false;
255 }
256 }
257 if (!m_filterString.isEmpty()) {
258- QStringList allWords = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleKeywords).toStringList();
259- allWords.prepend(m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString());
260+ const auto roles = {AppDrawerModelInterface::RoleAppId, AppDrawerModelInterface::RoleName,
261+ AppDrawerModelInterface::RoleDescription, AppDrawerModelInterface::RoleKeywords};
262 bool found = false;
263- Q_FOREACH (const QString &currentWord, allWords) {
264- if (currentWord.startsWith(m_filterString, Qt::CaseInsensitive)) {
265+ Q_FOREACH (const auto &role, roles) {
266+ const QString data = m_source->data(idx, role).toString();
267+ if (data.contains(m_filterString, Qt::CaseInsensitive)) {
268 found = true;
269 break;
270 }
271
272=== modified file 'qml/Launcher/Drawer.qml'
273--- qml/Launcher/Drawer.qml 2017-03-24 11:51:31 +0000
274+++ qml/Launcher/Drawer.qml 2017-04-06 13:50:59 +0000
275@@ -79,6 +79,7 @@
276 source: appDrawerModel
277 filterString: searchField.displayText
278 sortBy: AppDrawerProxyModel.SortByAToZ
279+ dynamicSortFilter: false
280 }
281
282 Item {
283
284=== modified file 'tests/mocks/Unity/Launcher/MockLauncherItem.cpp'
285--- tests/mocks/Unity/Launcher/MockLauncherItem.cpp 2017-04-06 13:50:59 +0000
286+++ tests/mocks/Unity/Launcher/MockLauncherItem.cpp 2017-04-06 13:50:59 +0000
287@@ -72,6 +72,19 @@
288 return m_keywords;
289 }
290
291+QString MockLauncherItem::description() const
292+{
293+ return m_description;
294+}
295+
296+void MockLauncherItem::setDescription(const QString &description)
297+{
298+ if (m_description != description) {
299+ m_description = description;
300+ Q_EMIT descriptionChanged(m_description);
301+ }
302+}
303+
304 uint MockLauncherItem::popularity() const
305 {
306 return m_popularity;
307
308=== modified file 'tests/mocks/Unity/Launcher/MockLauncherItem.h'
309--- tests/mocks/Unity/Launcher/MockLauncherItem.h 2017-04-06 13:50:59 +0000
310+++ tests/mocks/Unity/Launcher/MockLauncherItem.h 2017-04-06 13:50:59 +0000
311@@ -40,6 +40,7 @@
312 QString name() const override;
313 QString icon() const override;
314 QStringList keywords() const override;
315+ QString description() const override;
316 uint popularity() const override;
317
318 bool pinned() const override;
319@@ -56,6 +57,7 @@
320
321 private:
322 void setKeywords(const QStringList &keywords);
323+ void setDescription(const QString &description);
324 void setPopularity(uint popularity);
325 void setPinned(bool pinned);
326 void setRunning(bool running);
327@@ -72,6 +74,7 @@
328 QString m_name;
329 QString m_icon;
330 QStringList m_keywords;
331+ QString m_description;
332 uint m_popularity;
333 bool m_pinned;
334 bool m_running;
335
336=== modified file 'tests/plugins/Unity/Launcher/appdrawermodeltest.cpp'
337--- tests/plugins/Unity/Launcher/appdrawermodeltest.cpp 2017-04-06 13:50:59 +0000
338+++ tests/plugins/Unity/Launcher/appdrawermodeltest.cpp 2017-04-06 13:50:59 +0000
339@@ -24,16 +24,20 @@
340 Q_OBJECT
341
342 private:
343- AppDrawerModel *appDrawerModel;
344+ AppDrawerModel *appDrawerModel{nullptr};
345
346 private Q_SLOTS:
347
348 void initTestCase() {
349 UalWrapper::s_list << QStringLiteral("app1") << QStringLiteral("app2");
350- appDrawerModel = new AppDrawerModel(this);
351+ appDrawerModel = new AppDrawerModel();
352 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 2);
353 }
354
355+ void cleanupTestCase() {
356+ appDrawerModel->deleteLater();
357+ }
358+
359 void testUalAppAddedRemoved() {
360 QCOMPARE(appDrawerModel->rowCount(QModelIndex()), 2);
361
362
363=== modified file 'tests/plugins/Unity/Launcher/ualwrapper.cpp'
364--- tests/plugins/Unity/Launcher/ualwrapper.cpp 2017-04-06 13:50:59 +0000
365+++ tests/plugins/Unity/Launcher/ualwrapper.cpp 2017-04-06 13:50:59 +0000
366@@ -42,6 +42,7 @@
367 info.name = "App_" + appId;
368 info.icon = "/dummy/icon/path/" + appId + ".png";
369 info.keywords << QStringLiteral("keyword1") << QStringLiteral("keyword2");
370+ info.description = "Dummy description";
371 info.popularity = 1;
372 info.valid = true;
373 return info;
374
375=== modified file 'tests/plugins/Unity/Launcher/ualwrapper.h'
376--- tests/plugins/Unity/Launcher/ualwrapper.h 2017-04-06 13:50:59 +0000
377+++ tests/plugins/Unity/Launcher/ualwrapper.h 2017-04-06 13:50:59 +0000
378@@ -28,6 +28,7 @@
379 QString name;
380 QString icon;
381 QStringList keywords;
382+ QString description;
383 uint popularity = 0;
384 };
385

Subscribers

People subscribed via source and target branches