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
=== modified file 'plugins/time-date/timezonelocationmodel.cpp'
--- plugins/time-date/timezonelocationmodel.cpp 2014-08-28 07:22:28 +0000
+++ plugins/time-date/timezonelocationmodel.cpp 2015-06-09 14:08:49 +0000
@@ -174,9 +174,12 @@
174 list,174 list,
175 [pattern] (const TzLocation& tz) {175 [pattern] (const TzLocation& tz) {
176 QString display("%1, %2");176 QString display("%1, %2");
177 return display.arg(tz.city)177 return g_str_match_string (pattern.toStdString().c_str(),
178 .arg(tz.full_country.isEmpty() ? tz.country : tz.full_country)178 display.arg(tz.city)
179 .contains(pattern, Qt::CaseInsensitive);179 .arg(tz.full_country.isEmpty() ? tz.country
180 : tz.full_country)
181 .toStdString().c_str(),
182 TRUE);
180 }));183 }));
181184
182 Q_EMIT (filterBegin());185 Q_EMIT (filterBegin());
183186
=== modified file 'src/item-model.cpp'
--- src/item-model.cpp 2014-10-28 17:49:47 +0000
+++ src/item-model.cpp 2015-06-09 14:08:49 +0000
@@ -20,6 +20,7 @@
2020
21#include "item-model.h"21#include "item-model.h"
2222
23#include <glib.h>
23#include <libintl.h>24#include <libintl.h>
2425
25#include "debug.h"26#include "debug.h"
@@ -189,17 +190,27 @@
189 int source_row, const QModelIndex &source_parent) const190 int source_row, const QModelIndex &source_parent) const
190{191{
191 QStringList keywords;192 QStringList keywords;
193 gchar * pattern = nullptr;
194 bool ret = false;
192 QModelIndex index = sourceModel()->index(source_row, 0, source_parent);195 QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
193196
194 QVariant data(sourceModel()->data(index, filterRole()));197 QVariant data(sourceModel()->data(index, filterRole()));
198 pattern = g_strdup(filterRegExp().pattern().toStdString().c_str());
195199
196 switch (filterRole()) {200 switch (filterRole()) {
197 case ItemModel::KeywordRole:201 case ItemModel::KeywordRole:
198 keywords = data.value<QStringList>();202 keywords = data.value<QStringList>();
199 return keywords.filter(filterRegExp()).length() > 0;203
204 foreach (const QString& s, keywords)
205 if (g_str_match_string (pattern, s.toStdString().c_str(), TRUE)) {
206 ret = true;
207 goto out;
208 }
200 default:209 default:
201 return false;210 ret = false;
202 }211 }
203212
204 return true;213out:
214 g_free (pattern);
215 return ret;
205}216}
206217
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2014-11-19 18:05:48 +0000
+++ tests/CMakeLists.txt 2015-06-09 14:08:49 +0000
@@ -32,7 +32,7 @@
32)32)
3333
34qt5_use_modules(tst-plugins Core Qml Test)34qt5_use_modules(tst-plugins Core Qml Test)
35target_link_libraries(tst-plugins SystemSettings)35target_link_libraries(tst-plugins SystemSettings ${GLIB_LDFLAGS})
36add_test(tst-plugins tst-plugins)36add_test(tst-plugins tst-plugins)
37set_tests_properties(tst-plugins PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")37set_tests_properties(tst-plugins PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
3838

Subscribers

People subscribed via source and target branches