Merge lp:~mterry/unity8/oobe-revert-geonames into lp:unity8

Proposed by Michał Sawicz
Status: Rejected
Rejected by: Michał Sawicz
Proposed branch: lp:~mterry/unity8/oobe-revert-geonames
Merge into: lp:unity8
Prerequisite: lp:~unity-team/unity8/oobe
Diff against target: 691 lines (+225/-199)
13 files modified
CMakeLists.txt (+0/-1)
debian/control (+1/-1)
plugins/Wizard/CMakeLists.txt (+4/-2)
plugins/Wizard/plugin.cpp (+1/-0)
plugins/Wizard/timezonemodel.cpp (+140/-156)
plugins/Wizard/timezonemodel.h (+55/-22)
qml/Wizard/Pages.qml (+11/-0)
qml/Wizard/Pages/10-welcome.qml (+1/-0)
qml/Wizard/Pages/50-timezone.qml (+3/-13)
qml/Wizard/Pages/passcode-confirm.qml (+2/-1)
qml/Wizard/Pages/passcode-set.qml (+2/-1)
tests/mocks/Wizard/CMakeLists.txt (+4/-2)
tests/mocks/Wizard/mockplugin.cpp (+1/-0)
To merge this branch: bzr merge lp:~mterry/unity8/oobe-revert-geonames
Reviewer Review Type Date Requested Status
Michał Sawicz Disapprove
Unity8 CI Bot continuous-integration Needs Fixing
Lukáš Tinkl (community) Needs Fixing
Review via email: mp+289758@code.launchpad.net

This proposal supersedes a proposal from 2016-03-22.

Commit message

Revert the use of geonames back to libtimezonemap in the wizard until we can fix a bug with it.

Description of the change

Revert the use of geonames back to libtimezonemap. These changes aren't perfect. It's just going back to an earlier version of the code.

To be fixed up later again to geonames once we fix a mystery freeze.

To post a comment you must log in.
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

The changes in qml/Wizard/Pages/passcode-confirm.qml and qml/Wizard/Pages/passcode-set.qml are unrelated and undesired here.

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

FAILED: Continuous integration, rev:2159
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/787/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/437
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial,testname=qmluitests.sh/437
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=autopilot.sh/437
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1031
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1046
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1046
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1044
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1044/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1044
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1044/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1044
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1044/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1044
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1044/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1044
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1044/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1044
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1044/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

No need after all.

review: Disapprove

Unmerged revisions

2159. By Michael Terry

Revert use of geonames

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-03-22 09:09:22 +0000
3+++ CMakeLists.txt 2016-03-03 18:41:20 +0000
4@@ -58,7 +58,6 @@
5 find_package(Qt5Sql 5.4 REQUIRED)
6
7 pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=13)
8-pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
9 pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
10 pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
11 pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
12
13=== modified file 'debian/control'
14--- debian/control 2016-03-22 09:09:22 +0000
15+++ debian/control 2016-03-22 09:09:23 +0000
16@@ -15,7 +15,6 @@
17 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
18 libconnectivity-qt1-dev (>= 0.7.1),
19 libevdev-dev,
20- libgeonames-dev (>= 0.2),
21 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
22 libgl1-mesa-dri,
23 libgles2-mesa-dev[armhf],
24@@ -29,6 +28,7 @@
25 libqt5svg5-dev,
26 libqt5xmlpatterns5-dev,
27 libsystemsettings-dev,
28+ libtimezonemap1-dev,
29 libudev-dev,
30 libunity-api-dev (>= 7.107),
31 libusermetricsoutput1-dev,
32
33=== modified file 'plugins/Wizard/CMakeLists.txt'
34--- plugins/Wizard/CMakeLists.txt 2016-03-22 09:09:22 +0000
35+++ plugins/Wizard/CMakeLists.txt 2016-03-22 09:09:23 +0000
36@@ -1,4 +1,6 @@
37-include_directories(${GLIB_INCLUDE_DIRS} ${GEONAMES_INCLUDE_DIRS})
38+pkg_search_module(TIMEZONEMAP REQUIRED timezonemap)
39+
40+include_directories(${GLIB_INCLUDE_DIRS} ${TIMEZONEMAP_INCLUDE_DIRS})
41
42 add_library(Wizard-qml MODULE
43 plugin.cpp
44@@ -10,7 +12,7 @@
45 )
46
47 qt5_use_modules(Wizard-qml DBus Qml Concurrent)
48-target_link_libraries(Wizard-qml ${GLIB_LDFLAGS} ${GEONAMES_LDFLAGS})
49+target_link_libraries(Wizard-qml ${GLIB_LDFLAGS} ${TIMEZONEMAP_LDFLAGS})
50 add_unity8_plugin(Wizard 0.1 Wizard TARGETS Wizard-qml)
51
52 set(POLKIT_LIB_DIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/polkit-1")
53
54=== modified file 'plugins/Wizard/plugin.cpp'
55--- plugins/Wizard/plugin.cpp 2016-03-22 09:09:22 +0000
56+++ plugins/Wizard/plugin.cpp 2016-03-22 09:09:23 +0000
57@@ -30,5 +30,6 @@
58 qmlRegisterSingletonType<System>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new System; });
59 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
60 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
61+ qmlRegisterType<TimeZoneFilterModel>(uri, 0, 1, "TimeZoneFilterModel");
62 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
63 }
64
65=== modified file 'plugins/Wizard/timezonemodel.cpp'
66--- plugins/Wizard/timezonemodel.cpp 2016-03-22 09:09:22 +0000
67+++ plugins/Wizard/timezonemodel.cpp 2016-03-22 09:09:23 +0000
68@@ -18,15 +18,17 @@
69
70 #include <glib.h>
71 #include <glib-object.h>
72+#include <timezonemap/tz.h>
73
74 #include "LocalePlugin.h"
75 #include "timezonemodel.h"
76
77 TimeZoneLocationModel::TimeZoneLocationModel(QObject *parent):
78 QAbstractListModel(parent),
79- m_listUpdating(false),
80- m_cancellable(nullptr)
81+ m_workerThread(new TimeZonePopulateWorker())
82 {
83+ qRegisterMetaType<TzLocationWizard>();
84+
85 m_roleNames[Qt::DisplayRole] = "displayName";
86 m_roleNames[TimeZoneRole] = "timeZone";
87 m_roleNames[CityRole] = "city";
88@@ -34,52 +36,78 @@
89 m_roleNames[OffsetRole] = "offset";
90 m_roleNames[LatitudeRole] = "latitude";
91 m_roleNames[LongitudeRole] = "longitude";
92+
93+ QObject::connect(m_workerThread,
94+ &TimeZonePopulateWorker::resultReady,
95+ this,
96+ &TimeZoneLocationModel::processModelResult);
97+ QObject::connect(m_workerThread,
98+ &TimeZonePopulateWorker::finished,
99+ this,
100+ &TimeZoneLocationModel::store);
101+ QObject::connect(m_workerThread,
102+ &TimeZonePopulateWorker::finished,
103+ m_workerThread,
104+ &QObject::deleteLater);
105+
106+ init();
107+}
108+
109+void TimeZoneLocationModel::init()
110+{
111+ beginResetModel();
112+ m_workerThread->start();
113+}
114+
115+void TimeZoneLocationModel::store()
116+{
117+ m_workerThread = nullptr;
118+ endResetModel();
119+}
120+
121+void TimeZoneLocationModel::processModelResult(const TzLocationWizard &location)
122+{
123+ m_locations.append(location);
124 }
125
126 int TimeZoneLocationModel::rowCount(const QModelIndex &parent) const
127 {
128- if (parent.isValid()) {
129+ if (parent.isValid())
130 return 0;
131- } else if (m_filter.isEmpty()) {
132- return m_countryLocations.count();
133- } else {
134- return m_locations.count();
135- }
136+ return m_locations.count();
137 }
138
139 QVariant TimeZoneLocationModel::data(const QModelIndex &index, int role) const
140 {
141- GeonamesCity *city;
142- if (m_filter.isEmpty()) {
143- city = m_countryLocations.value(index.row());
144- } else {
145- city = m_locations.value(index.row());
146- }
147- if (!city)
148+ if (index.row() >= m_locations.count() || index.row() < 0)
149 return QVariant();
150
151+ const TzLocationWizard tz = m_locations.at(index.row());
152+
153+ const QString country(tz.full_country.isEmpty() ? tz.country : tz.full_country);
154+
155 switch (role) {
156 case Qt::DisplayRole:
157- return QStringLiteral("%1, %2, %3").arg(geonames_city_get_name(city))
158- .arg(geonames_city_get_state(city))
159- .arg(geonames_city_get_country(city));
160+ if (!tz.state.isEmpty())
161+ return QStringLiteral("%1, %2, %3").arg(tz.city).arg(tz.state).arg(country);
162+ else
163+ return QStringLiteral("%1, %2").arg(tz.city).arg(country);
164 case SimpleRole:
165- return QStringLiteral("%1, %2").arg(geonames_city_get_name(city))
166- .arg(geonames_city_get_country(city));
167+ return QStringLiteral("%1, %2").arg(tz.city).arg(country);
168 case TimeZoneRole:
169- return geonames_city_get_timezone(city);
170+ return tz.timezone;
171 case CountryRole:
172- return geonames_city_get_country(city);
173+ return tz.country;
174 case CityRole:
175- return geonames_city_get_name(city);
176+ return tz.city;
177 case OffsetRole: {
178- QTimeZone tmp(geonames_city_get_timezone(city));
179+ QTimeZone tmp(tz.timezone.toLatin1());
180 return static_cast<double>(tmp.standardTimeOffset(QDateTime::currentDateTime())) / 3600;
181 }
182 case LatitudeRole:
183- return geonames_city_get_latitude(city);
184+ return tz.latitude;
185 case LongitudeRole:
186- return geonames_city_get_longitude(city);
187+ return tz.longitude;
188 default:
189 qWarning() << Q_FUNC_INFO << "Unknown role";
190 return QVariant();
191@@ -91,154 +119,110 @@
192 return m_roleNames;
193 }
194
195-void TimeZoneLocationModel::setModel(const QList<GeonamesCity *> &locations)
196-{
197- beginResetModel();
198-
199- Q_FOREACH(GeonamesCity *city, m_locations) {
200- geonames_city_free(city);
201- }
202-
203- m_locations = locations;
204- endResetModel();
205-}
206-
207-void TimeZoneLocationModel::filterFinished(GObject *source_object,
208- GAsyncResult *res,
209- gpointer user_data)
210-{
211- Q_UNUSED(source_object);
212-
213- g_autofree gint *cities = nullptr;
214- guint cities_len = 0;
215- g_autoptr(GError) error = nullptr;
216-
217- cities = geonames_query_cities_finish(res, &cities_len, &error);
218- if (error) {
219- if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
220- TimeZoneLocationModel *model = static_cast<TimeZoneLocationModel *>(user_data);
221- g_clear_object(&model->m_cancellable);
222- model->setListUpdating(false);
223- qWarning() << "Could not filter timezones:" << error->message;
224- }
225- return;
226- }
227-
228- QList<GeonamesCity *> locations;
229-
230- for (guint i = 0; i < cities_len; ++i) {
231- GeonamesCity *city = geonames_get_city(cities[i]);
232- if (city) {
233- locations.append(city);
234- }
235- }
236-
237- TimeZoneLocationModel *model = static_cast<TimeZoneLocationModel *>(user_data);
238-
239- g_clear_object(&model->m_cancellable);
240-
241- model->setModel(locations);
242- model->setListUpdating(false);
243-}
244-
245-bool TimeZoneLocationModel::listUpdating() const
246-{
247- return m_listUpdating;
248-}
249-
250-void TimeZoneLocationModel::setListUpdating(bool listUpdating)
251-{
252- if (m_listUpdating != listUpdating) {
253- m_listUpdating = listUpdating;
254- Q_EMIT listUpdatingChanged();
255- }
256-}
257-
258-QString TimeZoneLocationModel::filter() const
259+void TimeZonePopulateWorker::run()
260+{
261+ buildCityMap();
262+}
263+
264+void TimeZonePopulateWorker::buildCityMap()
265+{
266+ TzDB *tzdb = tz_load_db();
267+ GPtrArray *tz_locations = tz_get_locations(tzdb);
268+
269+ TimeZoneLocationModel::TzLocationWizard tmpTz;
270+
271+ for (guint i = 0; i < tz_locations->len; ++i) {
272+ auto tmp = static_cast<CcTimezoneLocation *>(g_ptr_array_index(tz_locations, i));
273+ gchar *en_name, *country, *zone, *state, *full_country;
274+ gdouble latitude;
275+ gdouble longitude;
276+ g_object_get (tmp, "en_name", &en_name,
277+ "country", &country,
278+ "zone", &zone,
279+ "state", &state,
280+ "full_country", &full_country,
281+ "latitude", &latitude,
282+ "longitude", &longitude,
283+ nullptr);
284+ // There are empty entries in the DB
285+ if (g_strcmp0(en_name, "") != 0) {
286+ tmpTz.city = en_name;
287+ tmpTz.country = country;
288+ tmpTz.timezone = zone;
289+ tmpTz.state = state;
290+ tmpTz.full_country = full_country;
291+ tmpTz.latitude = latitude;
292+ tmpTz.longitude = longitude;
293+
294+ Q_EMIT (resultReady(tmpTz));
295+ }
296+ g_free (en_name);
297+ g_free (country);
298+ g_free (zone);
299+ g_free (state);
300+ g_free (full_country);
301+ }
302+
303+ g_ptr_array_free (tz_locations, TRUE);
304+ tz_db_free(tzdb);
305+}
306+
307+
308+TimeZoneFilterModel::TimeZoneFilterModel(QObject *parent)
309+ : QSortFilterProxyModel(parent)
310+{
311+ setDynamicSortFilter(false);
312+ setSortLocaleAware(true);
313+ setSortRole(TimeZoneLocationModel::CityRole);
314+ m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive);
315+ sort(0);
316+}
317+
318+bool TimeZoneFilterModel::filterAcceptsRow(int row, const QModelIndex &parentIndex) const
319+{
320+ if (!sourceModel()) {
321+ return true;
322+ }
323+
324+ if (!m_filter.isEmpty()) { // filtering by freeform text input, cf setFilter(QString)
325+ const QString city = sourceModel()->index(row, 0, parentIndex).data(TimeZoneLocationModel::CityRole).toString();
326+
327+ if (m_stringMatcher.indexIn(city) == 0) { // match at the beginning of the city name
328+ return true;
329+ }
330+ } else if (!m_country.isEmpty()) { // filter by country code
331+ const QString countryCode = sourceModel()->index(row, 0, parentIndex).data(TimeZoneLocationModel::CountryRole).toString();
332+ return m_country.compare(countryCode, Qt::CaseInsensitive) == 0;
333+ }
334+
335+ return false;
336+}
337+
338+QString TimeZoneFilterModel::filter() const
339 {
340 return m_filter;
341 }
342
343-void TimeZoneLocationModel::setFilter(const QString &filter)
344+void TimeZoneFilterModel::setFilter(const QString &filter)
345 {
346 if (filter != m_filter) {
347 m_filter = filter;
348+ m_stringMatcher.setPattern(m_filter);
349 Q_EMIT filterChanged();
350- }
351-
352- setListUpdating(true);
353-
354- if (m_cancellable) {
355- g_cancellable_cancel(m_cancellable);
356- g_clear_object(&m_cancellable);
357- }
358-
359- setModel(QList<GeonamesCity *>());
360-
361- if (filter.isEmpty()) {
362- setListUpdating(false);
363- return;
364- }
365-
366- m_cancellable = g_cancellable_new();
367- geonames_query_cities(filter.toUtf8().data(),
368- GEONAMES_QUERY_DEFAULT,
369- m_cancellable,
370- filterFinished,
371- this);
372+ invalidate();
373+ }
374 }
375
376-QString TimeZoneLocationModel::country() const
377+QString TimeZoneFilterModel::country() const
378 {
379 return m_country;
380 }
381
382-static bool citycmp(GeonamesCity *a, GeonamesCity *b)
383-{
384- return geonames_city_get_population(b) < geonames_city_get_population(a);
385-}
386-
387-void TimeZoneLocationModel::setCountry(const QString &country)
388+void TimeZoneFilterModel::setCountry(const QString &country)
389 {
390 if (m_country == country)
391 return;
392
393- beginResetModel();
394-
395 m_country = country;
396-
397- Q_FOREACH(GeonamesCity *city, m_countryLocations) {
398- geonames_city_free(city);
399- }
400- m_countryLocations.clear();
401-
402- gint num_cities = geonames_get_n_cities();
403- for (gint i = 0; i < num_cities; i++) {
404- GeonamesCity *city = geonames_get_city(i);
405- if (city && m_country == geonames_city_get_country_code(city)) {
406- m_countryLocations.append(city);
407- }
408- }
409-
410- std::sort(m_countryLocations.begin(), m_countryLocations.end(), citycmp);
411-
412- endResetModel();
413-
414 Q_EMIT countryChanged(country);
415 }
416-
417-TimeZoneLocationModel::~TimeZoneLocationModel()
418-{
419- if (m_cancellable) {
420- g_cancellable_cancel(m_cancellable);
421- g_clear_object(&m_cancellable);
422- }
423-
424- Q_FOREACH(GeonamesCity *city, m_countryLocations) {
425- geonames_city_free(city);
426- }
427-
428- Q_FOREACH(GeonamesCity *city, m_locations) {
429- geonames_city_free(city);
430- }
431-}
432
433=== modified file 'plugins/Wizard/timezonemodel.h'
434--- plugins/Wizard/timezonemodel.h 2016-03-22 09:09:22 +0000
435+++ plugins/Wizard/timezonemodel.h 2016-03-22 09:09:23 +0000
436@@ -1,5 +1,5 @@
437 /*
438- * Copyright (C) 2016 Canonical Ltd.
439+ * Copyright (C) 2015 Canonical Ltd.
440 *
441 * This program is free software: you can redistribute it and/or modify it
442 * under the terms of the GNU General Public License version 3, as published
443@@ -17,21 +17,21 @@
444 #ifndef TIMEZONEMODEL_H
445 #define TIMEZONEMODEL_H
446
447-#include <geonames.h>
448-#include <glib.h>
449 #include <QAbstractListModel>
450+#include <QSortFilterProxyModel>
451+#include <QThread>
452+#include <QtConcurrent>
453+#include <QtGui/QImage>
454+
455+class TimeZonePopulateWorker;
456
457 class TimeZoneLocationModel: public QAbstractListModel
458 {
459 Q_OBJECT
460- Q_PROPERTY(bool listUpdating READ listUpdating NOTIFY listUpdatingChanged)
461- Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
462- Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
463 Q_ENUMS(Roles)
464-
465 public:
466 explicit TimeZoneLocationModel(QObject *parent = nullptr);
467- ~TimeZoneLocationModel();
468+ ~TimeZoneLocationModel() = default;
469
470 enum Roles {
471 TimeZoneRole = Qt::UserRole + 1,
472@@ -43,11 +43,56 @@
473 LongitudeRole
474 };
475
476+ struct TzLocationWizard {
477+ QString city;
478+ QString country;
479+ QString timezone;
480+ QString state;
481+ QString full_country;
482+ double latitude;
483+ double longitude;
484+ };
485+
486 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
487 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
488 QHash<int, QByteArray> roleNames() const override;
489
490- bool listUpdating() const;
491+private Q_SLOTS:
492+ void processModelResult(const TzLocationWizard &location);
493+ void store();
494+
495+private:
496+ void init();
497+ QHash<int, QByteArray> m_roleNames;
498+ QList<TzLocationWizard> m_locations;
499+ TimeZonePopulateWorker *m_workerThread;
500+};
501+
502+Q_DECLARE_METATYPE (TimeZoneLocationModel::TzLocationWizard)
503+
504+class TimeZonePopulateWorker: public QThread
505+{
506+ Q_OBJECT
507+public:
508+ void run() override;
509+
510+Q_SIGNALS:
511+ void resultReady(const TimeZoneLocationModel::TzLocationWizard &tz);
512+
513+private:
514+ void buildCityMap();
515+};
516+
517+class TimeZoneFilterModel: public QSortFilterProxyModel
518+{
519+ Q_OBJECT
520+ Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
521+ Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
522+
523+public:
524+ explicit TimeZoneFilterModel(QObject *parent = nullptr);
525+ ~TimeZoneFilterModel() = default;
526+ bool filterAcceptsRow(int row, const QModelIndex &parentIndex) const override;
527
528 QString filter() const;
529 void setFilter(const QString &filter);
530@@ -56,25 +101,13 @@
531 void setCountry(const QString &country);
532
533 Q_SIGNALS:
534- void listUpdatingChanged();
535 void filterChanged();
536 void countryChanged(const QString &country);
537
538 private:
539- void setModel(const QList<GeonamesCity *> &locations);
540- void setListUpdating(bool listUpdating);
541- static void filterFinished(GObject *source_object,
542- GAsyncResult *res,
543- gpointer user_data);
544-
545-
546- bool m_listUpdating;
547 QString m_filter;
548+ QStringMatcher m_stringMatcher;
549 QString m_country;
550- GCancellable *m_cancellable;
551- QHash<int, QByteArray> m_roleNames;
552- QList<GeonamesCity *> m_locations;
553- QList<GeonamesCity *> m_countryLocations;
554 };
555
556 #endif
557
558=== modified file 'qml/Wizard/Pages.qml'
559--- qml/Wizard/Pages.qml 2016-03-22 09:09:22 +0000
560+++ qml/Wizard/Pages.qml 2016-03-22 09:09:23 +0000
561@@ -34,12 +34,23 @@
562 property int passwordMethod: UbuntuSecurityPrivacyPanel.Passphrase
563 property string password: ""
564
565+ property string countryCode: "US" // default country (for the timezone page)
566 property bool seenSIMPage: false // we want to see the SIM page at most once
567
568 property alias modemManager: modemManager
569 property alias simManager0: simManager0
570 property alias simManager1: simManager1
571
572+ TimeZoneModel { // preload the heavy models
573+ id: tzModel
574+ }
575+
576+ TimeZoneFilterModel {
577+ id: tzFilterModel
578+ sourceModel: tzModel
579+ country: countryCode
580+ }
581+
582 theme: ThemeSettings {
583 name: "Ubuntu.Components.Themes.Ambiance"
584 }
585
586=== modified file 'qml/Wizard/Pages/10-welcome.qml'
587--- qml/Wizard/Pages/10-welcome.qml 2016-03-22 09:09:22 +0000
588+++ qml/Wizard/Pages/10-welcome.qml 2016-03-22 09:09:23 +0000
589@@ -157,6 +157,7 @@
590 System.updateSessionLocale(plugin.languageCodes[plugin.currentLanguage]);
591 }
592 i18n.language = plugin.languageCodes[plugin.currentLanguage]; // re-notify of change after above call (for qlocale change)
593+ root.countryCode = plugin.languageCodes[plugin.currentLanguage].split('_')[1].split('.')[0]; // extract the country code, save it for the timezone page
594
595 if (!root.modemManager.available || !root.modemManager.ready || root.modemManager.modems.length === 0 ||
596 (root.simManager0.present && root.simManager0.ready) || (root.simManager1.present && root.simManager1.ready) ||
597
598=== modified file 'qml/Wizard/Pages/50-timezone.qml'
599--- qml/Wizard/Pages/50-timezone.qml 2016-03-22 09:09:22 +0000
600+++ qml/Wizard/Pages/50-timezone.qml 2016-03-22 09:09:23 +0000
601@@ -87,6 +87,8 @@
602 }
603
604 resetViews();
605+ tzFilterModel.filter = Qt.binding(function() { return searchField.text; });
606+ tzFilterModel.invalidate();
607 searchField.forceActiveFocus();
608 }
609 }
610@@ -188,21 +190,9 @@
611 anchors.left: parent.left
612 anchors.right: parent.right
613 currentIndex: -1
614- model: TimeZoneModel {
615- id: timeZoneModel
616- filter: searchField.text
617- country: i18n.language.split('_')[1].split('.')[0]
618- }
619+ model: tzFilterModel
620 delegate: tzComponent
621 }
622-
623- ActivityIndicator {
624- anchors.centerIn: tzList
625- running: tzList.count == 0 &&
626- searchField.length > 0 &&
627- timeZoneModel.listUpdating
628- visible: running
629- }
630 }
631
632 Item {
633
634=== modified file 'qml/Wizard/Pages/passcode-confirm.qml'
635--- qml/Wizard/Pages/passcode-confirm.qml 2016-03-22 09:09:22 +0000
636+++ qml/Wizard/Pages/passcode-confirm.qml 2016-03-22 09:09:23 +0000
637@@ -37,7 +37,8 @@
638 UnityComponents.Lockscreen {
639 id: lockscreen
640 anchors {
641- fill: content
642+ fill: parent
643+ topMargin: customMargin
644 }
645
646 infoText: i18n.tr("Confirm passcode")
647
648=== modified file 'qml/Wizard/Pages/passcode-set.qml'
649--- qml/Wizard/Pages/passcode-set.qml 2016-03-22 09:09:22 +0000
650+++ qml/Wizard/Pages/passcode-set.qml 2016-03-22 09:09:23 +0000
651@@ -48,7 +48,8 @@
652 UnityComponents.Lockscreen {
653 id: lockscreen
654 anchors {
655- fill: content
656+ fill: parent
657+ topMargin: customMargin
658 }
659
660 infoText: i18n.tr("Choose passcode")
661
662=== modified file 'tests/mocks/Wizard/CMakeLists.txt'
663--- tests/mocks/Wizard/CMakeLists.txt 2016-03-22 09:09:22 +0000
664+++ tests/mocks/Wizard/CMakeLists.txt 2016-03-22 09:09:23 +0000
665@@ -1,5 +1,7 @@
666+pkg_search_module(TIMEZONEMAP REQUIRED timezonemap)
667+
668 include_directories(
669- ${GLIB_INCLUDE_DIRS} ${GEONAMES_INCLUDE_DIRS}
670+ ${GLIB_INCLUDE_DIRS} ${TIMEZONEMAP_INCLUDE_DIRS}
671 ${CMAKE_SOURCE_DIR}/plugins/Wizard
672 )
673
674@@ -13,5 +15,5 @@
675 )
676
677 qt5_use_modules(MockWizard-qml DBus Qml Concurrent)
678-target_link_libraries(MockWizard-qml ${GLIB_LDFLAGS} ${GEONAMES_LDFLAGS})
679+target_link_libraries(MockWizard-qml ${GLIB_LDFLAGS} ${TIMEZONEMAP_LDFLAGS})
680 add_unity8_mock(Wizard 0.1 Wizard TARGETS MockWizard-qml)
681
682=== modified file 'tests/mocks/Wizard/mockplugin.cpp'
683--- tests/mocks/Wizard/mockplugin.cpp 2016-03-22 09:09:22 +0000
684+++ tests/mocks/Wizard/mockplugin.cpp 2016-03-22 09:09:23 +0000
685@@ -30,5 +30,6 @@
686 qmlRegisterSingletonType<MockSystem>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new MockSystem; });
687 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
688 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
689+ qmlRegisterType<TimeZoneFilterModel>(uri, 0, 1, "TimeZoneFilterModel");
690 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
691 }

Subscribers

People subscribed via source and target branches