Merge lp:~andrewsomething/ubuntu-weather-app/predictive into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Andrew Starr-Bochicchio
Status: Merged
Approved by: Martin Borho
Approved revision: no longer in the source branch.
Merged at revision: 119
Proposed branch: lp:~andrewsomething/ubuntu-weather-app/predictive
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 58 lines (+20/-3)
2 files modified
components/AddLocationSheet.qml (+19/-2)
components/WeatherApi.js (+1/-1)
To merge this branch: bzr merge lp:~andrewsomething/ubuntu-weather-app/predictive
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Martin Borho Approve
Review via email: mp+186407@code.launchpad.net

Commit message

Add predictive search for locations.

Description of the change

Adds predictive search for locations.
- Uses a Timer that triggers a search after a pause so we don't hit the api for each letter typed.
- Add '&type=like' to the API call so we get more results back.

To post a comment you must log in.
Revision history for this message
Martin Borho (martin-borho) wrote :

Very good! Another task done, thanks a lot!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)
119. By Andrew Starr-Bochicchio

Add predictive search for locations. Fixes: https://bugs.launchpad.net/bugs/1218910.

Approved by Ubuntu Phone Apps Jenkins Bot, Martin Borho.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/AddLocationSheet.qml'
2--- components/AddLocationSheet.qml 2013-09-12 15:53:10 +0000
3+++ components/AddLocationSheet.qml 2013-09-18 17:59:34 +0000
4@@ -92,7 +92,6 @@
5 function doSearch() {
6 if(locationString.text !== "") {
7 cityList.visible = true
8- locationString.focus = false
9 citiesModel.clear();
10 searching.running = true;
11 searchWorker.sendMessage({
12@@ -121,7 +120,11 @@
13 height:parent.height
14 placeholderText: i18n.tr("Enter a city name")
15 hasClearButton: true
16- onAccepted: doSearch()
17+ onAccepted: {
18+ doSearch();
19+ search_timer.stop()
20+ locationString.focus = false
21+ }
22 primaryItem: Image {
23 height: parent.height*0.5
24 width: parent.height*0.5
25@@ -129,6 +132,20 @@
26 anchors.verticalCenterOffset: -units.gu(0.2)
27 source: Qt.resolvedUrl("../resources/images/search.svg")
28 }
29+
30+ Timer {
31+ id: search_timer
32+
33+ interval: 1100
34+ repeat: false
35+ onTriggered: {
36+ if (locationString.text != "") {
37+ doSearch();
38+ }
39+ }
40+ }
41+
42+ onTextChanged: search_timer.restart()
43 }
44 ActivityIndicator {
45 id: searching
46
47=== modified file 'components/WeatherApi.js'
48--- components/WeatherApi.js 2013-09-08 19:38:47 +0000
49+++ components/WeatherApi.js 2013-09-18 17:59:34 +0000
50@@ -161,7 +161,7 @@
51 +"&lon="+encodeURIComponent(params.coords.lon)+"&units="+params.units}
52 } else {
53 request = { type: "search",
54- url: _baseUrl+"find?q="+encodeURIComponent(params.name)+"&units="+params.units}
55+ url: _baseUrl+"find?q="+encodeURIComponent(params.name)+"&type=like&units="+params.units}
56 }
57 apiCaller(request, searchResponseHandler, retryHandler);
58 },

Subscribers

People subscribed via source and target branches