Merge lp:~seb128/ubuntu-system-settings/str-match-vivid into lp:ubuntu-system-settings/15.04

Proposed by Sebastien Bacher
Status: Merged
Approved by: Ken VanDine
Approved revision: 1418
Merged at revision: 1419
Proposed branch: lp:~seb128/ubuntu-system-settings/str-match-vivid
Merge into: lp:ubuntu-system-settings/15.04
Diff against target: 74 lines (+21/-7)
3 files modified
plugins/time-date/timezonelocationmodel.cpp (+6/-3)
src/item-model.cpp (+14/-3)
tests/CMakeLists.txt (+1/-1)
To merge this branch: bzr merge lp:~seb128/ubuntu-system-settings/str-match-vivid
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Jonas G. Drange (community) Approve
Review via email: mp+261510@code.launchpad.net

Commit message

Improve filtering in main page and timezone filters.

Description of the change

Improve filtering in main page and timezone filters.

To post a comment you must log in.
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Looking forward to this!

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 'plugins/time-date/timezonelocationmodel.cpp'
2--- plugins/time-date/timezonelocationmodel.cpp 2014-08-28 07:22:28 +0000
3+++ plugins/time-date/timezonelocationmodel.cpp 2015-06-09 14:08:49 +0000
4@@ -174,9 +174,12 @@
5 list,
6 [pattern] (const TzLocation& tz) {
7 QString display("%1, %2");
8- return display.arg(tz.city)
9- .arg(tz.full_country.isEmpty() ? tz.country : tz.full_country)
10- .contains(pattern, Qt::CaseInsensitive);
11+ return g_str_match_string (pattern.toStdString().c_str(),
12+ display.arg(tz.city)
13+ .arg(tz.full_country.isEmpty() ? tz.country
14+ : tz.full_country)
15+ .toStdString().c_str(),
16+ TRUE);
17 }));
18
19 Q_EMIT (filterBegin());
20
21=== modified file 'src/item-model.cpp'
22--- src/item-model.cpp 2014-10-28 17:49:47 +0000
23+++ src/item-model.cpp 2015-06-09 14:08:49 +0000
24@@ -20,6 +20,7 @@
25
26 #include "item-model.h"
27
28+#include <glib.h>
29 #include <libintl.h>
30
31 #include "debug.h"
32@@ -189,17 +190,27 @@
33 int source_row, const QModelIndex &source_parent) const
34 {
35 QStringList keywords;
36+ gchar * pattern = nullptr;
37+ bool ret = false;
38 QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
39
40 QVariant data(sourceModel()->data(index, filterRole()));
41+ pattern = g_strdup(filterRegExp().pattern().toStdString().c_str());
42
43 switch (filterRole()) {
44 case ItemModel::KeywordRole:
45 keywords = data.value<QStringList>();
46- return keywords.filter(filterRegExp()).length() > 0;
47+
48+ foreach (const QString& s, keywords)
49+ if (g_str_match_string (pattern, s.toStdString().c_str(), TRUE)) {
50+ ret = true;
51+ goto out;
52+ }
53 default:
54- return false;
55+ ret = false;
56 }
57
58- return true;
59+out:
60+ g_free (pattern);
61+ return ret;
62 }
63
64=== modified file 'tests/CMakeLists.txt'
65--- tests/CMakeLists.txt 2014-11-19 18:05:48 +0000
66+++ tests/CMakeLists.txt 2015-06-09 14:08:49 +0000
67@@ -32,7 +32,7 @@
68 )
69
70 qt5_use_modules(tst-plugins Core Qml Test)
71-target_link_libraries(tst-plugins SystemSettings)
72+target_link_libraries(tst-plugins SystemSettings ${GLIB_LDFLAGS})
73 add_test(tst-plugins tst-plugins)
74 set_tests_properties(tst-plugins PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
75

Subscribers

People subscribed via source and target branches