Merge lp:~laney/ubuntu-system-settings/time-date-delay-search into lp:ubuntu-system-settings

Proposed by Iain Lane
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 731
Merged at revision: 732
Proposed branch: lp:~laney/ubuntu-system-settings/time-date-delay-search
Merge into: lp:ubuntu-system-settings
Diff against target: 211 lines (+54/-15)
5 files modified
plugins/time-date/ChooseTimeZone.qml (+14/-4)
plugins/time-date/timedate.cpp (+6/-1)
plugins/time-date/timedate.h (+6/-1)
plugins/time-date/timezonelocationmodel.cpp (+20/-8)
plugins/time-date/timezonelocationmodel.h (+8/-1)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/time-date-delay-search
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+222796@code.launchpad.net

Commit message

time-date: Don't try to search while the model is building. Display an ActivityIndicator when searching while constructing the model to avoid confusing message.

Description of the change

time-date: Don't try to search while the model is building

When the model is constructed, execute any pending searches.

If you've entered a search before the model is constructed you'll see "No
matching place" until the model comes back. This is confusing, so add an
activity indicator while the construction is taking place.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:731
http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/870/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/796
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/736
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-amd64-ci/62
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/62
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/62/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-i386-ci/62
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/1217
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1478
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1478/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/8311
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/656
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/875
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/875/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/870/rebuild

review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks fine and work without issue, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/time-date/ChooseTimeZone.qml'
2--- plugins/time-date/ChooseTimeZone.qml 2014-01-30 11:02:27 +0000
3+++ plugins/time-date/ChooseTimeZone.qml 2014-06-11 13:10:25 +0000
4@@ -1,7 +1,7 @@
5 /*
6 * This file is part of system-settings
7 *
8- * Copyright (C) 2013 Canonical Ltd.
9+ * Copyright (C) 2013-2014 Canonical Ltd.
10 *
11 * Contact: Iain Lane <iain.lane@canonical.com>
12 *
13@@ -109,11 +109,21 @@
14 }
15 }
16
17+ ActivityIndicator {
18+ anchors.centerIn: parent
19+ running: setTimeZoneSelector.selectedIndex == 1 &&
20+ locationsListView.count == 0 &&
21+ filterCities.length > 0 &&
22+ timeDatePanel.listUpdating
23+ }
24+
25 Label {
26 objectName: "nothingLabel"
27 anchors.centerIn: parent
28- visible: setTimeZoneSelector.selectedIndex ==1 &&
29- locationsListView.count == 0
30- text: (filterCities.length == 0) ? i18n.tr("Enter your current location.") : i18n.tr("No matching place")
31+ visible: setTimeZoneSelector.selectedIndex == 1 &&
32+ locationsListView.count == 0 &&
33+ (filterCities.length == 0 || !timeDatePanel.listUpdating)
34+ text: (filterCities.length == 0) ? i18n.tr("Enter your current location.")
35+ : i18n.tr("No matching place")
36 }
37 }
38
39=== modified file 'plugins/time-date/timedate.cpp'
40--- plugins/time-date/timedate.cpp 2014-04-22 15:20:59 +0000
41+++ plugins/time-date/timedate.cpp 2014-06-11 13:10:25 +0000
42@@ -1,5 +1,5 @@
43 /*
44- * Copyright (C) 2013 Canonical Ltd
45+ * Copyright (C) 2013-2014 Canonical Ltd
46 *
47 * This program is free software: you can redistribute it and/or modify
48 * it under the terms of the GNU General Public License version 3 as
49@@ -158,5 +158,10 @@
50 m_timeDateInterface.call("SetTime", new_time, false, false);
51 }
52
53+bool TimeDate::getListUpdating()
54+{
55+ return m_timeZoneModel.modelUpdating;
56+}
57+
58 TimeDate::~TimeDate() {
59 }
60
61=== modified file 'plugins/time-date/timedate.h'
62--- plugins/time-date/timedate.h 2014-04-22 15:20:59 +0000
63+++ plugins/time-date/timedate.h 2014-06-11 13:10:25 +0000
64@@ -1,5 +1,5 @@
65 /*
66- * Copyright (C) 2013 Canonical Ltd
67+ * Copyright (C) 2013-2014 Canonical Ltd
68 *
69 * This program is free software: you can redistribute it and/or modify
70 * it under the terms of the GNU General Public License version 3 as
71@@ -46,6 +46,9 @@
72 READ getUseNTP
73 WRITE setUseNTP
74 NOTIFY useNTPChanged)
75+ Q_PROPERTY (bool listUpdating
76+ READ getListUpdating
77+ NOTIFY listUpdatingChanged)
78
79 public:
80 explicit TimeDate(QObject *parent = 0);
81@@ -58,6 +61,7 @@
82 bool getUseNTP();
83 void setUseNTP(bool enabled);
84 Q_INVOKABLE void setTime (qlonglong new_time);
85+ bool getListUpdating();
86
87 public Q_SLOTS:
88 void slotChanged(QString, QVariantMap, QStringList);
89@@ -67,6 +71,7 @@
90 void timeZoneChanged();
91 void timeZoneModelChanged();
92 void useNTPChanged();
93+ void listUpdatingChanged();
94
95 private:
96 QString m_currentTimeZone;
97
98=== modified file 'plugins/time-date/timezonelocationmodel.cpp'
99--- plugins/time-date/timezonelocationmodel.cpp 2014-04-23 08:38:03 +0000
100+++ plugins/time-date/timezonelocationmodel.cpp 2014-06-11 13:10:25 +0000
101@@ -1,5 +1,5 @@
102 /*
103- * Copyright (C) 2013 Canonical Ltd
104+ * Copyright (C) 2013-2014 Canonical Ltd
105 *
106 * This program is free software: you can redistribute it and/or modify
107 * it under the terms of the GNU General Public License version 3 as
108@@ -27,34 +27,45 @@
109
110 TimeZoneLocationModel::TimeZoneLocationModel(QObject *parent):
111 QAbstractTableModel(parent),
112+ modelUpdating(true),
113 m_pattern(),
114+ m_workerThread(new TimeZonePopulateWorker()),
115 m_watcher()
116 {
117 qRegisterMetaType<TzLocation>();
118
119- TimeZonePopulateWorker *workerThread = new TimeZonePopulateWorker();
120- QObject::connect(workerThread,
121+ QObject::connect(m_workerThread,
122 &TimeZonePopulateWorker::resultReady,
123 this,
124 &TimeZoneLocationModel::processModelResult);
125- QObject::connect(workerThread,
126+ QObject::connect(m_workerThread,
127 &TimeZonePopulateWorker::finished,
128 this,
129 &TimeZoneLocationModel::store);
130- QObject::connect(workerThread,
131+ QObject::connect(m_workerThread,
132 &TimeZonePopulateWorker::finished,
133- workerThread,
134+ m_workerThread,
135 &QObject::deleteLater);
136- workerThread->start();
137+ QObject::connect(m_workerThread,
138+ &TimeZonePopulateWorker::finished,
139+ this,
140+ &TimeZoneLocationModel::modelUpdated);
141+
142+ m_workerThread->start();
143 }
144
145 void TimeZoneLocationModel::store()
146 {
147+ m_workerThread = nullptr;
148+ modelUpdating = false;
149 qSort(m_originalLocations.begin(), m_originalLocations.end());
150 QObject::connect(&m_watcher,
151 &QFutureWatcher<TzLocation>::finished,
152 this,
153 &TimeZoneLocationModel::filterFinished);
154+
155+ if (!m_pattern.isEmpty())
156+ filter(m_pattern);
157 }
158
159 void TimeZoneLocationModel::processModelResult(TzLocation location)
160@@ -143,7 +154,8 @@
161 if (m_watcher.isRunning())
162 m_watcher.cancel();
163
164- if (pattern.isEmpty() || pattern.isNull()) {
165+ if (pattern.isEmpty() || pattern.isNull() ||
166+ (m_workerThread && m_workerThread->isRunning())) {
167 setModel(QList<TzLocation>());
168 m_pattern = pattern;
169 return;
170
171=== modified file 'plugins/time-date/timezonelocationmodel.h'
172--- plugins/time-date/timezonelocationmodel.h 2014-04-22 13:40:24 +0000
173+++ plugins/time-date/timezonelocationmodel.h 2014-06-11 13:10:25 +0000
174@@ -1,5 +1,5 @@
175 /*
176- * Copyright (C) 2013 Canonical Ltd
177+ * Copyright (C) 2013-2014 Canonical Ltd
178 *
179 * This program is free software: you can redistribute it and/or modify
180 * it under the terms of the GNU General Public License version 3 as
181@@ -27,6 +27,8 @@
182
183 #include <QtConcurrent>
184
185+class TimeZonePopulateWorker;
186+
187 class TimeZoneLocationModel : public QAbstractTableModel
188 {
189 Q_OBJECT
190@@ -66,9 +68,12 @@
191 QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
192 QHash<int, QByteArray> roleNames() const;
193
194+ bool modelUpdating;
195+
196 Q_SIGNALS:
197 void filterBegin();
198 void filterComplete();
199+ void modelUpdated();
200
201 public Q_SLOTS:
202 void processModelResult(TzLocation);
203@@ -80,6 +85,8 @@
204 QList<TzLocation> m_originalLocations;
205 QString m_pattern;
206
207+ TimeZonePopulateWorker *m_workerThread;
208+
209 bool substringFilter(const QString& input);
210 QFutureWatcher<TzLocation> m_watcher;
211 void setModel(QList<TzLocation> locations);

Subscribers

People subscribed via source and target branches