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
=== modified file 'components/AddLocationSheet.qml'
--- components/AddLocationSheet.qml 2013-09-12 15:53:10 +0000
+++ components/AddLocationSheet.qml 2013-09-18 17:59:34 +0000
@@ -92,7 +92,6 @@
92 function doSearch() {92 function doSearch() {
93 if(locationString.text !== "") {93 if(locationString.text !== "") {
94 cityList.visible = true94 cityList.visible = true
95 locationString.focus = false
96 citiesModel.clear();95 citiesModel.clear();
97 searching.running = true;96 searching.running = true;
98 searchWorker.sendMessage({97 searchWorker.sendMessage({
@@ -121,7 +120,11 @@
121 height:parent.height120 height:parent.height
122 placeholderText: i18n.tr("Enter a city name")121 placeholderText: i18n.tr("Enter a city name")
123 hasClearButton: true122 hasClearButton: true
124 onAccepted: doSearch()123 onAccepted: {
124 doSearch();
125 search_timer.stop()
126 locationString.focus = false
127 }
125 primaryItem: Image {128 primaryItem: Image {
126 height: parent.height*0.5129 height: parent.height*0.5
127 width: parent.height*0.5130 width: parent.height*0.5
@@ -129,6 +132,20 @@
129 anchors.verticalCenterOffset: -units.gu(0.2)132 anchors.verticalCenterOffset: -units.gu(0.2)
130 source: Qt.resolvedUrl("../resources/images/search.svg")133 source: Qt.resolvedUrl("../resources/images/search.svg")
131 }134 }
135
136 Timer {
137 id: search_timer
138
139 interval: 1100
140 repeat: false
141 onTriggered: {
142 if (locationString.text != "") {
143 doSearch();
144 }
145 }
146 }
147
148 onTextChanged: search_timer.restart()
132 }149 }
133 ActivityIndicator {150 ActivityIndicator {
134 id: searching151 id: searching
135152
=== modified file 'components/WeatherApi.js'
--- components/WeatherApi.js 2013-09-08 19:38:47 +0000
+++ components/WeatherApi.js 2013-09-18 17:59:34 +0000
@@ -161,7 +161,7 @@
161 +"&lon="+encodeURIComponent(params.coords.lon)+"&units="+params.units}161 +"&lon="+encodeURIComponent(params.coords.lon)+"&units="+params.units}
162 } else {162 } else {
163 request = { type: "search",163 request = { type: "search",
164 url: _baseUrl+"find?q="+encodeURIComponent(params.name)+"&units="+params.units}164 url: _baseUrl+"find?q="+encodeURIComponent(params.name)+"&type=like&units="+params.units}
165 }165 }
166 apiCaller(request, searchResponseHandler, retryHandler);166 apiCaller(request, searchResponseHandler, retryHandler);
167 },167 },

Subscribers

People subscribed via source and target branches