Merge lp:~nik90/ubuntu-clock-app/json-search-ui into lp:ubuntu-clock-app
- json-search-ui
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Nekhelesh Ramananthan | ||||||||
Approved revision: | 69 | ||||||||
Merged at revision: | 57 | ||||||||
Proposed branch: | lp:~nik90/ubuntu-clock-app/json-search-ui | ||||||||
Merge into: | lp:ubuntu-clock-app | ||||||||
Prerequisite: | lp:~nik90/ubuntu-clock-app/json-search-backend | ||||||||
Diff against target: |
280 lines (+131/-16) 5 files modified
app/ubuntu-clock-app.qml (+1/-0) app/worldclock/UserWorldCityDelegate.qml (+6/-3) app/worldclock/WorldCityList.qml (+104/-10) backend/modules/Timezone/jsontimezonemodel.cpp (+18/-3) debian/changelog (+2/-0) |
||||||||
To merge this branch: | bzr merge lp:~nik90/ubuntu-clock-app/json-search-ui | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Riccardo Padovani | Approve | ||
Nekhelesh Ramananthan | Needs Fixing | ||
Andrew Hayzen | Pending | ||
Review via email: mp+230339@code.launchpad.net |
Commit message
Adds support for search for world cities online.
Description of the change
Adds support for search for world cities online.
To Test:
1. Swipe down to add a city
2. Search for cities like Springfield, Lyon, etc etc and see if you can choose the correct city from the online search.
3. The online search happens when you see a spinner and "Searching for city string"
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:56
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:57
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:58
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:59
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:60
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:62
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
#unblocked
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:64
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:65
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:66
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zygmunt Krynicki (zyga) wrote : | # |
Look at the C++ comments inline
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:67
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:68
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:69
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
Code looks good, and the app works as expected on rev 197
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
Unapproved changes made after approval.
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Nekhelesh Ramananthan (nik90) wrote : | # |
erm what changes were made after approval? Jenkins you are sometimes dumb :P. Reapproving again :)
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : | # |
Preview Diff
1 | === modified file 'app/ubuntu-clock-app.qml' |
2 | --- app/ubuntu-clock-app.qml 2014-07-27 23:33:23 +0000 |
3 | +++ app/ubuntu-clock-app.qml 2014-08-18 11:41:45 +0000 |
4 | @@ -56,6 +56,7 @@ |
5 | backgroundColor: "#F5F5F5" |
6 | |
7 | useDeprecatedToolbar: false |
8 | + anchorToKeyboard: true |
9 | |
10 | Background {} |
11 | |
12 | |
13 | === modified file 'app/worldclock/UserWorldCityDelegate.qml' |
14 | --- app/worldclock/UserWorldCityDelegate.qml 2014-08-13 05:45:40 +0000 |
15 | +++ app/worldclock/UserWorldCityDelegate.qml 2014-08-18 11:41:45 +0000 |
16 | @@ -46,20 +46,23 @@ |
17 | |
18 | anchors { |
19 | left: parent.left |
20 | + right: localTimeVisual.left |
21 | + rightMargin: units.gu(1) |
22 | verticalCenter: parent.verticalCenter |
23 | } |
24 | |
25 | Label { |
26 | - id: cityNameText |
27 | - fontSize: "medium" |
28 | text: model.city |
29 | + width: parent.width |
30 | + elide: Text.ElideRight |
31 | color: UbuntuColors.midAubergine |
32 | } |
33 | |
34 | Label { |
35 | - id: countryNameText |
36 | text: model.country |
37 | fontSize: "xx-small" |
38 | + width: parent.width |
39 | + elide: Text.ElideRight |
40 | } |
41 | } |
42 | |
43 | |
44 | === modified file 'app/worldclock/WorldCityList.qml' |
45 | --- app/worldclock/WorldCityList.qml 2014-08-11 10:19:26 +0000 |
46 | +++ app/worldclock/WorldCityList.qml 2014-08-18 11:41:45 +0000 |
47 | @@ -35,6 +35,8 @@ |
48 | Page { |
49 | id: worldCityList |
50 | |
51 | + property bool isOnlineMode: false |
52 | + |
53 | title: i18n.tr("Select a city") |
54 | visible: false |
55 | flickable: null |
56 | @@ -65,6 +67,7 @@ |
57 | onTriggered: { |
58 | searchField.text = "" |
59 | worldCityList.state = "default" |
60 | + isOnlineMode = false |
61 | } |
62 | } |
63 | |
64 | @@ -72,6 +75,7 @@ |
65 | id: searchField |
66 | |
67 | inputMethodHints: Qt.ImhNoPredictiveText |
68 | + placeholderText: i18n.tr("Search...") |
69 | |
70 | anchors { |
71 | left: parent ? parent.left : undefined |
72 | @@ -79,9 +83,30 @@ |
73 | rightMargin: units.gu(2) |
74 | } |
75 | |
76 | + Timer { |
77 | + id: search_timer |
78 | + interval: isOnlineMode ? 1 : 500 |
79 | + repeat: false |
80 | + onTriggered: { |
81 | + isOnlineMode = false |
82 | + console.log("Search string: " + searchField.text) |
83 | + |
84 | + if(!isOnlineMode && sortedTimeZoneModel.count === 0) { |
85 | + console.log("Enabling online mode") |
86 | + isOnlineMode = true |
87 | + } |
88 | + |
89 | + if(isOnlineMode) { |
90 | + var url = "http://geoname-lookup.ubuntu.com/?query=" |
91 | + + searchField.text |
92 | + console.log("Online URL: " + url) |
93 | + jsonTimeZoneModel.source = Qt.resolvedUrl(url) |
94 | + } |
95 | + } |
96 | + } |
97 | + |
98 | onTextChanged: { |
99 | - sortedTimeZoneModel.filter.property = "city" |
100 | - sortedTimeZoneModel.filter.pattern = RegExp(searchField.text, "gi") |
101 | + search_timer.restart() |
102 | } |
103 | } |
104 | } |
105 | @@ -95,21 +120,57 @@ |
106 | from suspend instead of waiting for the next minute to update. |
107 | */ |
108 | if(applicationState) |
109 | - timeZoneModel.update() |
110 | + xmlTimeZoneModel.update() |
111 | } |
112 | } |
113 | |
114 | + JsonTimeZoneModel { |
115 | + id: jsonTimeZoneModel |
116 | + updateInterval: 60000 |
117 | + } |
118 | + |
119 | XmlTimeZoneModel { |
120 | - id: timeZoneModel |
121 | + id: xmlTimeZoneModel |
122 | updateInterval: 60000 |
123 | source: Qt.resolvedUrl("world-city-list.xml") |
124 | } |
125 | |
126 | SortFilterModel { |
127 | id: sortedTimeZoneModel |
128 | - model: timeZoneModel |
129 | + model: isOnlineMode ? jsonTimeZoneModel : xmlTimeZoneModel |
130 | sort.property: "city" |
131 | sort.order: Qt.AscendingOrder |
132 | + filter.property: "city" |
133 | + filter.pattern: RegExp(searchField.text, "gi") |
134 | + } |
135 | + |
136 | + Label { |
137 | + id: onlineStateLabel |
138 | + visible: jsonTimeZoneModel.loading || |
139 | + (!jsonTimeZoneModel.loading && sortedTimeZoneModel.count === 0) && |
140 | + isOnlineMode |
141 | + text: { |
142 | + if(jsonTimeZoneModel.loading) |
143 | + return i18n.tr("Searching for a city") |
144 | + else if(!jsonTimeZoneModel.loading && isOnlineMode && sortedTimeZoneModel.count === 0) |
145 | + return i18n.tr("No City Found") |
146 | + else |
147 | + return "" |
148 | + } |
149 | + anchors { |
150 | + horizontalCenter: parent.horizontalCenter |
151 | + top: parent.top |
152 | + topMargin: units.gu(4) |
153 | + } |
154 | + } |
155 | + |
156 | + ActivityIndicator { |
157 | + running: jsonTimeZoneModel.loading && isOnlineMode |
158 | + anchors { |
159 | + top: onlineStateLabel.bottom |
160 | + topMargin: units.gu(3) |
161 | + horizontalCenter: parent.horizontalCenter |
162 | + } |
163 | } |
164 | |
165 | ListView { |
166 | @@ -135,6 +196,10 @@ |
167 | return sortedTimeZoneModel.get(index).city.substring(0,1) |
168 | } |
169 | |
170 | + onFlickStarted: { |
171 | + Qt.inputMethod.hide() |
172 | + } |
173 | + |
174 | anchors.fill: parent |
175 | anchors.rightMargin: fastScroll.showing ? fastScroll.width - units.gu(1) |
176 | : 0 |
177 | @@ -161,15 +226,37 @@ |
178 | } |
179 | } |
180 | |
181 | - delegate: SubtitledListItem { |
182 | - text: city |
183 | - subText: country |
184 | + delegate: ListItem.Base { |
185 | showDivider: false |
186 | |
187 | + Column { |
188 | + id: worldCityDelegateColumn |
189 | + |
190 | + anchors { |
191 | + left: parent.left |
192 | + right: _localTime.left |
193 | + rightMargin: units.gu(1) |
194 | + verticalCenter: parent.verticalCenter |
195 | + } |
196 | + |
197 | + Label { |
198 | + text: city |
199 | + width: parent.width |
200 | + elide: Text.ElideRight |
201 | + color: UbuntuColors.midAubergine |
202 | + } |
203 | + |
204 | + Label { |
205 | + text: country |
206 | + fontSize: "xx-small" |
207 | + width: parent.width |
208 | + elide: Text.ElideRight |
209 | + } |
210 | + } |
211 | + |
212 | Label { |
213 | id: _localTime |
214 | text: localTime |
215 | - fontSize: "medium" |
216 | anchors { |
217 | right: parent.right |
218 | verticalCenter: parent.verticalCenter |
219 | @@ -177,7 +264,14 @@ |
220 | } |
221 | |
222 | onClicked: { |
223 | - cityList.addWorldCity(city, country, timezoneID) |
224 | + var tempCountry = country.split(",") |
225 | + if(tempCountry.length > 2) { |
226 | + cityList.addWorldCity(city, tempCountry[1] + "," |
227 | + + tempCountry[2], timezoneID) |
228 | + } else { |
229 | + cityList.addWorldCity(city, country, timezoneID) |
230 | + } |
231 | + |
232 | mainStack.pop() |
233 | } |
234 | } |
235 | |
236 | === modified file 'backend/modules/Timezone/jsontimezonemodel.cpp' |
237 | --- backend/modules/Timezone/jsontimezonemodel.cpp 2014-08-13 14:38:02 +0000 |
238 | +++ backend/modules/Timezone/jsontimezonemodel.cpp 2014-08-18 11:41:45 +0000 |
239 | @@ -91,9 +91,24 @@ |
240 | foreach (const QVariant &entry, timezoneData.toList()) { |
241 | TimeZone tz; |
242 | |
243 | - tz.cityName = entry.toMap().value("name").toString(); |
244 | - tz.country = entry.toMap().value("country").toString(); |
245 | - tz.timeZone = QTimeZone(entry.toMap().value("timezone").toString().toLatin1()); |
246 | + auto data = entry.toMap(); |
247 | + auto admin1 = data.value("admin1").toString(); |
248 | + auto admin2 = data.value("admin2").toString(); |
249 | + auto country = data.value("country").toString(); |
250 | + |
251 | + tz.cityName = data.value("name").toString(); |
252 | + |
253 | + if (!admin1.isEmpty() && !admin2.isEmpty()) { |
254 | + tz.country = QString("%1, %2, %3").arg(admin2).arg(admin1).arg(country); |
255 | + } else if (!admin1.isEmpty()) { |
256 | + tz.country = QString("%1, %2").arg(admin1).arg(country); |
257 | + } else if (!admin2.isEmpty()) { |
258 | + tz.country = QString("%1, %2").arg(admin2).arg(country); |
259 | + } else { |
260 | + tz.country = country; |
261 | + } |
262 | + |
263 | + tz.timeZone = QTimeZone(data.value("timezone").toString().toLatin1()); |
264 | |
265 | m_timeZones.append(tz); |
266 | } |
267 | |
268 | === modified file 'debian/changelog' |
269 | --- debian/changelog 2014-08-18 11:05:48 +0000 |
270 | +++ debian/changelog 2014-08-18 11:41:45 +0000 |
271 | @@ -5,7 +5,9 @@ |
272 | strings. (LP: #1355414) |
273 | * Synced the fast scroll component with upstream changes |
274 | * Updated inner clock texture as requested by design |
275 | + * Added json backend to search cities online |
276 | * Added support for custom alarm sounds as per the design spec. |
277 | + * Added UI support for searching cities online from geoname-lookup.ubuntu.com |
278 | |
279 | [David Planella] |
280 | * Added internationalization support (LP: #1354522) |
#blocked due to https:/ /launchpad. net/ubuntu- geonames not returning TimeZoneID in the search results.