Merge lp:~nik90/unav/fix-unav-list-items into lp:~costales/unav/trunk
- fix-unav-list-items
- Merge into trunk
Status: | Merged |
---|---|
Merge reported by: | costales |
Merged at revision: | not available |
Proposed branch: | lp:~nik90/unav/fix-unav-list-items |
Merge into: | lp:~costales/unav/trunk |
Diff against target: |
1479 lines (+615/-766) 5 files modified
qml/AboutPage.qml (+144/-254) qml/FavoritesPage.qml (+11/-28) qml/HeaderListItem.qml (+30/-0) qml/SearchPage.qml (+356/-418) qml/SettingsPage.qml (+74/-66) |
To merge this branch: | bzr merge lp:~nik90/unav/fix-unav-list-items |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
costales | Pending | ||
Review via email: mp+288997@code.launchpad.net |
Commit message
- Converts listitems to using ListItemLayouts
- Replace UbuntuListView with just ListView
- Added custom header listitem which uses the new ListItem instead of the deprecated ListItem.Header.
- Massive simplication of the about page code
Description of the change
This MP basically revamps all the list items shown in uNav to follow the system design. It also converts them to the new ListItemLayouts which is more performant, consistent design etc.
Also replaces UbuntuListView with ListView since we are not using any of the features offered by UbuntuListView thereby wasting memory use.
Simplified massively the about page code by using just one listmodel and one listview.
Added custom header listitem which uses the new ListItem instead of the deprecated ListItem.Header.
Note: It seems like a huge code diff in SearchPage.qml, but turns out I just aligned the code accidentally by pressing Ctrl+A and then Ctrl+I. Rest assured it just aligns the code correctly.
- 7. By Nekhelesh Ramananthan
-
Massive simplication of the about page (code wise)
costales (costales) wrote : | # |
Preview Diff
1 | === modified file 'qml/AboutPage.qml' | |||
2 | --- qml/AboutPage.qml 2016-03-14 18:40:54 +0000 | |||
3 | +++ qml/AboutPage.qml 2016-03-15 01:14:51 +0000 | |||
4 | @@ -16,261 +16,151 @@ | |||
5 | 16 | 16 | ||
6 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
7 | 18 | import Ubuntu.Components 1.3 | 18 | import Ubuntu.Components 1.3 |
8 | 19 | import Ubuntu.Components.ListItems 1.3 as ListItem | ||
9 | 20 | import "js/utils.js" as QmlJs | 19 | import "js/utils.js" as QmlJs |
10 | 21 | 20 | ||
11 | 22 | Page { | 21 | Page { |
265 | 23 | id: aboutPage | 22 | id: aboutPage |
266 | 24 | title: i18n.tr("About") | 23 | |
267 | 25 | 24 | header: PageHeader { | |
268 | 26 | Flickable { | 25 | title: i18n.tr("About") |
269 | 27 | id: flickable | 26 | flickable: creditsListView |
270 | 28 | anchors.fill: parent | 27 | } |
271 | 29 | contentHeight: appColumn.height + donateColumn.height + launchpadColumn.height + devColumn.height + voicesColumn.height + i18nColumn.height + poweredByColumn.height + units.gu(16) | 28 | |
272 | 30 | 29 | ListModel { | |
273 | 31 | Column { | 30 | id: creditsModel |
274 | 32 | id: appColumn | 31 | |
275 | 33 | spacing: units.gu(1) | 32 | Component.onCompleted: initialize() |
276 | 34 | anchors { | 33 | |
277 | 35 | top: parent.top; left: parent.left; right: parent.right; topMargin: units.gu(5) | 34 | function initialize() { |
278 | 36 | } | 35 | // Resources |
279 | 37 | Image { | 36 | creditsModel.append({ category: i18n.tr("Resources"), name: i18n.tr("Bugs"), link: "https://bugs.launchpad.net/unav" }) |
280 | 38 | id: appImage | 37 | creditsModel.append({ category: i18n.tr("Resources"), name: i18n.tr("Translations"), link: "https://translations.launchpad.net/unav" }) |
281 | 39 | source: "../nav/img/about/logo.png" | 38 | creditsModel.append({ category: i18n.tr("Resources"), name: i18n.tr("Answers"), link: "https://answers.launchpad.net/unav" }) |
282 | 40 | anchors.horizontalCenter: parent.horizontalCenter | 39 | creditsModel.append({ category: i18n.tr("Resources"), name: i18n.tr("Contact"), link: "mailto:costales.marcos@gmail.com" }) |
283 | 41 | } | 40 | |
284 | 42 | Label { | 41 | // Developers |
285 | 43 | width: parent.width | 42 | creditsModel.append({ category: i18n.tr("Developers"), name: "JkB", link: "https://launchpad.net/~joergberroth" }) |
286 | 44 | wrapMode: Text.WordWrap | 43 | creditsModel.append({ category: i18n.tr("Developers"), name: "Marcos Costales (" + i18n.tr("Founder") + ")", link: "https://wiki.ubuntu.com/costales" }) |
287 | 45 | horizontalAlignment: Text.AlignHCenter | 44 | |
288 | 46 | //TRANSLATORS: %1 and %2 are links that do not have to be translated: Year + Project + License | 45 | // Voices |
289 | 47 | text: "© uNav 2015-" + new Date().getFullYear() | 46 | switch (Qt.locale().name.substring(0,2).toLowerCase()) { |
290 | 48 | } | 47 | case 'de': |
291 | 49 | Label { | 48 | creditsModel.append({ category: i18n.tr("Voice"), name: "Ilonka Oettershagen", link: "https://plus.google.com/107664665064221547104" }); |
292 | 50 | width: parent.width | 49 | break; |
293 | 51 | wrapMode: Text.WordWrap | 50 | case 'es': |
294 | 52 | horizontalAlignment: Text.AlignHCenter | 51 | creditsModel.append({ category: i18n.tr("Voice"), name: "Fernando Lanero", link: "https://twitter.com/ferlanero" }) |
295 | 53 | //TRANSLATORS: %1 and %2 are links that do not have to be translated: Year + Project + License | 52 | break; |
296 | 54 | text: i18n.tr("Version %1. Under License %2").arg(navApp.applicationVersion).arg("<a href=\"http://www.gnu.org/licenses/gpl-3.0.en.html\">GPL3</a>") | 53 | case 'it': |
297 | 55 | onLinkActivated: Qt.openUrlExternally(link) | 54 | creditsModel.append({ category: i18n.tr("Voice"), name: "Silvia Bindelli", link: "https://twitter.com/SilviaBindelli" }) |
298 | 56 | } | 55 | break; |
299 | 57 | } | 56 | case 'nl': |
300 | 58 | 57 | creditsModel.append({ category: i18n.tr("Voice"), name: "Mark van den Driesche", link: "http://google.com/+Markcortbass" }) | |
301 | 59 | Column { | 58 | break; |
302 | 60 | id: donateColumn | 59 | case 'sl': |
303 | 61 | anchors.top: appColumn.bottom | 60 | creditsModel.append({ category: i18n.tr("Voice"), name: "Bernard Banko", link: "https://launchpad.net/~beernarrd" }) |
304 | 62 | anchors.topMargin: units.gu(3) | 61 | break; |
305 | 63 | width: parent.width | 62 | default: |
306 | 64 | spacing: units.gu(1) | 63 | creditsModel.append({ category: i18n.tr("Voice"), name: "Nathan Haines", link: "http://www.nhaines.com" }) |
307 | 65 | Label { | 64 | } |
308 | 66 | id: donateLabel | 65 | |
309 | 67 | text: i18n.tr("Support its future development") | 66 | // Translators |
310 | 68 | anchors.horizontalCenter: parent.horizontalCenter | 67 | var translators = QmlJs.getTranslators( i18n.tr("translator-credits") ) |
311 | 69 | wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere | 68 | translators.forEach(function(translator) { |
312 | 70 | horizontalAlignment: Text.AlignHCenter | 69 | creditsModel.append({ category: i18n.tr("Translators"), name: translator['name'], link: translator['link'] }); |
313 | 71 | width: parent.width - units.gu(12) | 70 | }); |
314 | 72 | } | 71 | |
315 | 73 | Button { | 72 | // Powered By |
316 | 74 | anchors.horizontalCenter: parent.horizontalCenter | 73 | creditsModel.append({ category: i18n.tr("Powered by"), name: "OpenStreetMap & Contributors", link: "http://www.openstreetmap.org" }) |
317 | 75 | color: UbuntuColors.green | 74 | creditsModel.append({ category: i18n.tr("Powered by"), name: "Mapzen", link: "https://mapzen.com/projects/valhalla" }) |
318 | 76 | text: i18n.tr("Buy Donate Version") | 75 | creditsModel.append({ category: i18n.tr("Powered by"), name: "MapQuest", link: "http://open.mapquest.com/" }) |
319 | 77 | onClicked: Qt.openUrlExternally("scope://com.canonical.scopes.clickstore?q=unavdonateversion") | 76 | creditsModel.append({ category: i18n.tr("Powered by"), name: "OpenStreetMap Nominatin", link: "http://open.mapquestapi.com/nominatim" }) |
320 | 78 | } | 77 | creditsModel.append({ category: i18n.tr("Powered by"), name: "Overpass API", link: "http://wiki.openstreetmap.org/wiki/Overpass_API/XAPI_Compatibility_Layer" }) |
321 | 79 | } | 78 | creditsModel.append({ category: i18n.tr("Powered by"), name: "OpenLayers", link: "http://openlayers.org" }) |
322 | 80 | 79 | creditsModel.append({ category: i18n.tr("Powered by"), name: "Turf.js", link: "http://turfjs.org" }) | |
323 | 81 | Column { | 80 | creditsModel.append({ category: i18n.tr("Powered by"), name: "JQuery", link: "https://jquery.com" }) |
324 | 82 | id: launchpadColumn | 81 | creditsModel.append({ category: i18n.tr("Powered by"), name: "jquery.localize.js", link: "https://github.com/coderifous/jquery-localize" }) |
325 | 83 | anchors.top: donateColumn.bottom | 82 | creditsModel.append({ category: i18n.tr("Powered by"), name: "The Noun Project", link: "https://thenounproject.com" }) |
326 | 84 | width: parent.width | 83 | creditsModel.append({ category: i18n.tr("Powered by"), name: "Wikimedia", link: "https://commons.wikimedia.org/wiki/Category:Multi-touch_gestures" }) |
327 | 85 | ListItem.Header { | 84 | creditsModel.append({ category: i18n.tr("Powered by"), name: "IconFinder", link: "https://www.iconfinder.com/icons/172062/navigation_icon" }) |
328 | 86 | id: lpHeader | 85 | creditsModel.append({ category: i18n.tr("Powered by"), name: "Leaflet Marker", link: "https://github.com/Leaflet/Leaflet" }) |
329 | 87 | text: i18n.tr("Resources") | 86 | } |
330 | 88 | } | 87 | } |
331 | 89 | 88 | ||
332 | 90 | Repeater { | 89 | ListView { |
333 | 91 | id: lpListView | 90 | id: creditsListView |
334 | 92 | 91 | ||
335 | 93 | model: lpModel | 92 | model: creditsModel |
336 | 94 | delegate: ListItem.Standard { | 93 | anchors.fill: parent |
337 | 95 | progression: true | 94 | section.property: "category" |
338 | 96 | showDivider: false | 95 | section.criteria: ViewSection.FullString |
339 | 97 | text: model.name | 96 | section.delegate: HeaderListItem { |
340 | 98 | onClicked: Qt.openUrlExternally(model.link) | 97 | title: section |
341 | 99 | } | 98 | } |
342 | 100 | } | 99 | |
343 | 101 | 100 | header: Item { | |
344 | 102 | ListModel { | 101 | width: parent.width |
345 | 103 | id: lpModel | 102 | height: appColumn.height + donateColumn.height + units.gu(10) |
346 | 104 | Component.onCompleted: initialize() | 103 | Column { |
347 | 105 | function initialize() { | 104 | id: appColumn |
348 | 106 | lpModel.append({ name: i18n.tr("Bugs"), link: "https://bugs.launchpad.net/unav" }) | 105 | spacing: units.gu(1) |
349 | 107 | lpModel.append({ name: i18n.tr("Translations"), link: "https://translations.launchpad.net/unav" }) | 106 | anchors { |
350 | 108 | lpModel.append({ name: i18n.tr("Answers"), link: "https://answers.launchpad.net/unav" }) | 107 | top: parent.top; left: parent.left; right: parent.right; topMargin: units.gu(5) |
351 | 109 | lpModel.append({ name: i18n.tr("Contact"), link: "mailto:costales.marcos@gmail.com" }) | 108 | } |
352 | 110 | } | 109 | Image { |
353 | 111 | } | 110 | id: appImage |
354 | 112 | } | 111 | source: "../nav/img/about/logo.png" |
355 | 113 | 112 | anchors.horizontalCenter: parent.horizontalCenter | |
356 | 114 | Column { | 113 | } |
357 | 115 | id: devColumn | 114 | Label { |
358 | 116 | anchors.top: launchpadColumn.bottom | 115 | width: parent.width |
359 | 117 | anchors.topMargin: units.gu(2) | 116 | wrapMode: Text.WordWrap |
360 | 118 | width: parent.width | 117 | horizontalAlignment: Text.AlignHCenter |
361 | 119 | ListItem.Header { | 118 | //TRANSLATORS: %1 and %2 are links that do not have to be translated: Year + Project + License |
362 | 120 | id: devHeader | 119 | text: "© uNav 2015-" + new Date().getFullYear() |
363 | 121 | text: i18n.tr("Developers") | 120 | } |
364 | 122 | } | 121 | Label { |
365 | 123 | 122 | width: parent.width | |
366 | 124 | Repeater { | 123 | wrapMode: Text.WordWrap |
367 | 125 | id: devListView | 124 | horizontalAlignment: Text.AlignHCenter |
368 | 126 | 125 | //TRANSLATORS: %1 and %2 are links that do not have to be translated: Year + Project + License | |
369 | 127 | model: devModel | 126 | text: i18n.tr("Version %1. Under License %2").arg(navApp.applicationVersion).arg("<a href=\"http://www.gnu.org/licenses/gpl-3.0.en.html\">GPL3</a>") |
370 | 128 | delegate: ListItem.Standard { | 127 | onLinkActivated: Qt.openUrlExternally(link) |
371 | 129 | progression: true | 128 | } |
372 | 130 | showDivider: false | 129 | } |
373 | 131 | text: model.name | 130 | |
374 | 132 | onClicked: Qt.openUrlExternally(model.link) | 131 | Column { |
375 | 133 | } | 132 | id: donateColumn |
376 | 134 | } | 133 | anchors.top: appColumn.bottom |
377 | 135 | 134 | anchors.topMargin: units.gu(3) | |
378 | 136 | ListModel { | 135 | width: parent.width |
379 | 137 | id: devModel | 136 | spacing: units.gu(1) |
380 | 138 | Component.onCompleted: initialize() | 137 | Label { |
381 | 139 | function initialize() { | 138 | id: donateLabel |
382 | 140 | devModel.append({ name: "JkB", link: "https://launchpad.net/~joergberroth" }) | 139 | text: i18n.tr("Support its future development") |
383 | 141 | devModel.append({ name: "Marcos Costales (" + i18n.tr("Founder") + ")", link: "https://wiki.ubuntu.com/costales" }) | 140 | anchors.horizontalCenter: parent.horizontalCenter |
384 | 142 | } | 141 | wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere |
385 | 143 | } | 142 | horizontalAlignment: Text.AlignHCenter |
386 | 144 | } | 143 | width: parent.width - units.gu(12) |
387 | 145 | 144 | } | |
388 | 146 | Column { | 145 | Button { |
389 | 147 | id: voicesColumn | 146 | anchors.horizontalCenter: parent.horizontalCenter |
390 | 148 | anchors.top: devColumn.bottom | 147 | color: UbuntuColors.green |
391 | 149 | anchors.topMargin: units.gu(2) | 148 | text: i18n.tr("Buy Donate Version") |
392 | 150 | width: parent.width | 149 | onClicked: Qt.openUrlExternally("scope://com.canonical.scopes.clickstore?q=unavdonateversion") |
393 | 151 | 150 | } | |
394 | 152 | ListItem.Header { | 151 | } |
395 | 153 | id: voicesHeader | 152 | } |
396 | 154 | text: i18n.tr("Voice") | 153 | |
397 | 155 | } | 154 | delegate: ListItem { |
398 | 156 | 155 | height: creditsDelegateLayout.height | |
399 | 157 | Repeater { | 156 | divider.visible: false |
400 | 158 | id: voicesListView | 157 | ListItemLayout { |
401 | 159 | anchors.top: voicesColumn.bottom | 158 | id: creditsDelegateLayout |
402 | 160 | 159 | title.text: model.name | |
403 | 161 | model: voicesModel | 160 | ProgressionSlot {} |
404 | 162 | delegate: ListItem.Standard { | 161 | } |
405 | 163 | progression: true | 162 | onClicked: Qt.openUrlExternally(model.link) |
406 | 164 | showDivider: false | 163 | } |
407 | 165 | text: model.name | 164 | } |
155 | 166 | onClicked: Qt.openUrlExternally(model.link) | ||
156 | 167 | } | ||
157 | 168 | } | ||
158 | 169 | |||
159 | 170 | ListModel { | ||
160 | 171 | id: voicesModel | ||
161 | 172 | Component.onCompleted: initialize() | ||
162 | 173 | function initialize() { | ||
163 | 174 | switch (Qt.locale().name.substring(0,2).toLowerCase()) { | ||
164 | 175 | case 'de': | ||
165 | 176 | voicesModel.append({name: "Ilonka Oettershagen", link: "https://plus.google.com/107664665064221547104"}); | ||
166 | 177 | break; | ||
167 | 178 | case 'es': | ||
168 | 179 | voicesModel.append({name: "Fernando Lanero", link: "https://twitter.com/ferlanero"}) | ||
169 | 180 | break; | ||
170 | 181 | case 'it': | ||
171 | 182 | voicesModel.append({name: "Silvia Bindelli", link: "https://twitter.com/SilviaBindelli"}) | ||
172 | 183 | break; | ||
173 | 184 | case 'nl': | ||
174 | 185 | voicesModel.append({name: "Mark van den Driesche", link: "http://google.com/+Markcortbass"}) | ||
175 | 186 | break; | ||
176 | 187 | case 'sl': | ||
177 | 188 | voicesModel.append({name: "Bernard Banko", link: "https://launchpad.net/~beernarrd"}) | ||
178 | 189 | break; | ||
179 | 190 | default: | ||
180 | 191 | voicesModel.append({name: "Nathan Haines", link: "http://www.nhaines.com"}) | ||
181 | 192 | } | ||
182 | 193 | } | ||
183 | 194 | } | ||
184 | 195 | } | ||
185 | 196 | |||
186 | 197 | Column { | ||
187 | 198 | id: i18nColumn | ||
188 | 199 | anchors.top: voicesColumn.bottom | ||
189 | 200 | anchors.topMargin: units.gu(2) | ||
190 | 201 | width: parent.width | ||
191 | 202 | |||
192 | 203 | ListItem.Header { | ||
193 | 204 | id: i18nHeader | ||
194 | 205 | text: i18n.tr("Translators") | ||
195 | 206 | } | ||
196 | 207 | |||
197 | 208 | Repeater { | ||
198 | 209 | id: i18nListView | ||
199 | 210 | |||
200 | 211 | model: i18nModel | ||
201 | 212 | delegate: ListItem.Standard { | ||
202 | 213 | progression: true | ||
203 | 214 | showDivider: false | ||
204 | 215 | text: model.name | ||
205 | 216 | onClicked: Qt.openUrlExternally(model.link) | ||
206 | 217 | } | ||
207 | 218 | } | ||
208 | 219 | |||
209 | 220 | ListModel { | ||
210 | 221 | id: i18nModel | ||
211 | 222 | Component.onCompleted: initialize() | ||
212 | 223 | function initialize() { | ||
213 | 224 | var translators = QmlJs.getTranslators( i18n.tr("translator-credits") ) | ||
214 | 225 | translators.forEach(function(translator) { | ||
215 | 226 | i18nModel.append({ name: translator['name'], link: translator['link'] }); | ||
216 | 227 | }); | ||
217 | 228 | } | ||
218 | 229 | } | ||
219 | 230 | } | ||
220 | 231 | |||
221 | 232 | Column { | ||
222 | 233 | id: poweredByColumn | ||
223 | 234 | anchors.top: i18nColumn.bottom | ||
224 | 235 | anchors.topMargin: units.gu(2) | ||
225 | 236 | width: parent.width | ||
226 | 237 | |||
227 | 238 | ListItem.Header { | ||
228 | 239 | id: poweredbyHeader | ||
229 | 240 | text: i18n.tr("Powered by") | ||
230 | 241 | } | ||
231 | 242 | |||
232 | 243 | Repeater { | ||
233 | 244 | id: poweredbyListView | ||
234 | 245 | |||
235 | 246 | model: poweredbyModel | ||
236 | 247 | delegate: ListItem.Standard { | ||
237 | 248 | progression: true | ||
238 | 249 | showDivider: false | ||
239 | 250 | text: model.name | ||
240 | 251 | onClicked: Qt.openUrlExternally(model.link) | ||
241 | 252 | } | ||
242 | 253 | } | ||
243 | 254 | |||
244 | 255 | ListModel { | ||
245 | 256 | id: poweredbyModel | ||
246 | 257 | Component.onCompleted: initialize() | ||
247 | 258 | function initialize() { | ||
248 | 259 | poweredbyModel.append({ name: "OpenStreetMap & Contributors", link: "http://www.openstreetmap.org" }) | ||
249 | 260 | poweredbyModel.append({ name: "Mapzen", link: "https://mapzen.com/projects/valhalla" }) | ||
250 | 261 | poweredbyModel.append({ name: "MapQuest", link: "http://open.mapquest.com/" }) | ||
251 | 262 | poweredbyModel.append({ name: "OpenStreetMap Nominatin", link: "http://open.mapquestapi.com/nominatim" }) | ||
252 | 263 | poweredbyModel.append({ name: "Overpass API", link: "http://wiki.openstreetmap.org/wiki/Overpass_API/XAPI_Compatibility_Layer" }) | ||
253 | 264 | poweredbyModel.append({ name: "OpenLayers", link: "http://openlayers.org" }) | ||
254 | 265 | poweredbyModel.append({ name: "Turf.js", link: "http://turfjs.org" }) | ||
255 | 266 | poweredbyModel.append({ name: "JQuery", link: "https://jquery.com" }) | ||
256 | 267 | poweredbyModel.append({ name: "jquery.localize.js", link: "https://github.com/coderifous/jquery-localize" }) | ||
257 | 268 | poweredbyModel.append({ name: "The Noun Project", link: "https://thenounproject.com" }) | ||
258 | 269 | poweredbyModel.append({ name: "Wikimedia", link: "https://commons.wikimedia.org/wiki/Category:Multi-touch_gestures" }) | ||
259 | 270 | poweredbyModel.append({ name: "IconFinder", link: "https://www.iconfinder.com/icons/172062/navigation_icon" }) | ||
260 | 271 | poweredbyModel.append({ name: "Leaflet Marker", link: "https://github.com/Leaflet/Leaflet" }) | ||
261 | 272 | } | ||
262 | 273 | } | ||
263 | 274 | } | ||
264 | 275 | } | ||
408 | 276 | } | 165 | } |
409 | 166 | |||
410 | 277 | 167 | ||
411 | === modified file 'qml/FavoritesPage.qml' | |||
412 | --- qml/FavoritesPage.qml 2016-03-14 18:40:54 +0000 | |||
413 | +++ qml/FavoritesPage.qml 2016-03-15 01:14:51 +0000 | |||
414 | @@ -200,12 +200,16 @@ | |||
415 | 200 | } | 200 | } |
416 | 201 | } | 201 | } |
417 | 202 | 202 | ||
419 | 203 | UbuntuListView { | 203 | ListView { |
420 | 204 | id: favoritesListView | 204 | id: favoritesListView |
421 | 205 | |||
422 | 205 | model: favoritesModel | 206 | model: favoritesModel |
423 | 206 | anchors.fill: parent | 207 | anchors.fill: parent |
424 | 207 | 208 | ||
425 | 208 | delegate: ListItem { | 209 | delegate: ListItem { |
426 | 210 | id: delegate | ||
427 | 211 | |||
428 | 212 | height: favouriteDelegateLayout.height + divider.height | ||
429 | 209 | leadingActions: ListItemActions { | 213 | leadingActions: ListItemActions { |
430 | 210 | actions: [ | 214 | actions: [ |
431 | 211 | Action { | 215 | Action { |
432 | @@ -237,33 +241,12 @@ | |||
433 | 237 | ] | 241 | ] |
434 | 238 | } | 242 | } |
435 | 239 | 243 | ||
463 | 240 | contentItem.anchors { | 244 | ListItemLayout { |
464 | 241 | leftMargin: units.gu(1) | 245 | id: favouriteDelegateLayout |
465 | 242 | rightMargin: units.gu(1) | 246 | title.text: model.name |
466 | 243 | topMargin: units.gu(0.5) | 247 | subtitle.visible: mainPageStack.center_onpos !== 0 |
467 | 244 | bottomMargin: units.gu(0.5) | 248 | subtitle.text: QmlJs.formatDistance(QmlJs.calcPoiDistance(mainPageStack.currentLat, mainPageStack.currentLng, model.lat, model.lng, 10), navApp.settings.unit) |
468 | 245 | } | 249 | } |
442 | 246 | |||
443 | 247 | Label { | ||
444 | 248 | height: parent.height | ||
445 | 249 | width: parent.width *4/5 | ||
446 | 250 | text: model.name | ||
447 | 251 | elide: Text.ElideRight | ||
448 | 252 | wrapMode: Text.WordWrap | ||
449 | 253 | } | ||
450 | 254 | |||
451 | 255 | Label { | ||
452 | 256 | anchors.bottom: parent.bottom | ||
453 | 257 | width: parent.width /5 | ||
454 | 258 | anchors.right: parent.right | ||
455 | 259 | horizontalAlignment: Text.AlignRight | ||
456 | 260 | visible: (mainPageStack.center_onpos !== 0) | ||
457 | 261 | text: QmlJs.formatDistance( | ||
458 | 262 | QmlJs.calcPoiDistance(mainPageStack.currentLat, mainPageStack.currentLng, model.lat, model.lng, 10), | ||
459 | 263 | navApp.settings.unit | ||
460 | 264 | ) | ||
461 | 265 | fontSize: "small" | ||
462 | 266 | } | ||
469 | 267 | 250 | ||
470 | 268 | onClicked: { | 251 | onClicked: { |
471 | 269 | mainPageStack.pop(favoritesPage) | 252 | mainPageStack.pop(favoritesPage) |
472 | 270 | 253 | ||
473 | === added file 'qml/HeaderListItem.qml' | |||
474 | --- qml/HeaderListItem.qml 1970-01-01 00:00:00 +0000 | |||
475 | +++ qml/HeaderListItem.qml 2016-03-15 01:14:51 +0000 | |||
476 | @@ -0,0 +1,30 @@ | |||
477 | 1 | /* | ||
478 | 2 | * uNav http://launchpad.net/unav | ||
479 | 3 | * Copyright (C) 2016 Nekhelesh Ramananthan https://launchpad.net/~nik90 | ||
480 | 4 | * | ||
481 | 5 | * uNav is free software; you can redistribute it and/or modify | ||
482 | 6 | * it under the terms of the GNU General Public License as published by | ||
483 | 7 | * the Free Software Foundation; either version 3 of the License, or | ||
484 | 8 | * (at your option) any later version. | ||
485 | 9 | * | ||
486 | 10 | * uNav is distributed in the hope that it will be useful, | ||
487 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
488 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
489 | 13 | * GNU General Public License for more details. | ||
490 | 14 | */ | ||
491 | 15 | |||
492 | 16 | import QtQuick 2.4 | ||
493 | 17 | import Ubuntu.Components 1.3 | ||
494 | 18 | |||
495 | 19 | ListItem { | ||
496 | 20 | id: headerListItem | ||
497 | 21 | |||
498 | 22 | property string title | ||
499 | 23 | |||
500 | 24 | height: units.gu(4) | ||
501 | 25 | Label { | ||
502 | 26 | anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(2) } | ||
503 | 27 | text: title | ||
504 | 28 | font.bold: true | ||
505 | 29 | } | ||
506 | 30 | } | ||
507 | 0 | 31 | ||
508 | === modified file 'qml/SearchPage.qml' | |||
509 | --- qml/SearchPage.qml 2016-03-14 18:40:54 +0000 | |||
510 | +++ qml/SearchPage.qml 2016-03-15 01:14:51 +0000 | |||
511 | @@ -18,428 +18,366 @@ | |||
512 | 18 | import QtQuick.Layouts 1.1 | 18 | import QtQuick.Layouts 1.1 |
513 | 19 | import Ubuntu.Components 1.3 | 19 | import Ubuntu.Components 1.3 |
514 | 20 | import Ubuntu.Components.Popups 1.3 | 20 | import Ubuntu.Components.Popups 1.3 |
515 | 21 | import Ubuntu.Components.ListItems 1.3 as ListItems | ||
516 | 22 | import QtQuick.LocalStorage 2.0 | 21 | import QtQuick.LocalStorage 2.0 |
517 | 23 | import QtQuick.XmlListModel 2.0 | 22 | import QtQuick.XmlListModel 2.0 |
518 | 24 | import "js/utils.js" as QmlJs | 23 | import "js/utils.js" as QmlJs |
519 | 25 | import "js/db.js" as UnavDB | 24 | import "js/db.js" as UnavDB |
520 | 26 | 25 | ||
521 | 27 | Page { | 26 | Page { |
939 | 28 | id: searchPage | 27 | id: searchPage |
940 | 29 | 28 | ||
941 | 30 | title: i18n.tr("Search") | 29 | title: i18n.tr("Search") |
942 | 31 | anchors.fill: parent | 30 | |
943 | 32 | 31 | state: "search" | |
944 | 33 | state: "search" | 32 | states: [ |
945 | 34 | states: [ | 33 | PageHeadState { |
946 | 35 | PageHeadState { | 34 | name: "search" |
947 | 36 | name: "search" | 35 | head: searchPage.head |
948 | 37 | head: searchPage.head | 36 | |
949 | 38 | 37 | backAction: Action { | |
950 | 39 | backAction: Action { | 38 | iconName: "back" |
951 | 40 | iconName: "back" | 39 | text: i18n.tr("Back") |
952 | 41 | text: i18n.tr("Back") | 40 | onTriggered: { |
953 | 42 | onTriggered: { | 41 | mainPageStack.pop(searchPage) |
954 | 43 | mainPageStack.pop(searchPage) | 42 | } |
955 | 44 | } | 43 | } |
956 | 45 | } | 44 | |
957 | 46 | 45 | contents: TextField { | |
958 | 47 | contents: TextField { | 46 | id: searchField |
959 | 48 | id: searchField | 47 | width: parent ? parent.width - units.gu(2) : undefined |
960 | 49 | width: parent ? parent.width - units.gu(2) : undefined | 48 | inputMethodHints: Qt.ImhNoPredictiveText |
961 | 50 | inputMethodHints: Qt.ImhNoPredictiveText | 49 | hasClearButton: true |
962 | 51 | hasClearButton: true | 50 | placeholderText: i18n.tr("Where do we go?") |
963 | 52 | placeholderText: i18n.tr("Where do we go?") | 51 | onTriggered: { |
964 | 53 | onTriggered: { | 52 | if (text.length > 2) { |
965 | 54 | if (text.length > 2) { | 53 | statusLabel.visible = true |
966 | 55 | statusLabel.visible = true | 54 | statusLabel.text = i18n.tr("Searching…"); |
967 | 56 | statusLabel.text = i18n.tr("Searching…"); | 55 | resultsListView.visible = false |
968 | 57 | resultsListView.visible = false | 56 | xmlSearchModel.searchString = text; |
969 | 58 | xmlSearchModel.searchString = text; | 57 | xmlSearchModel.search(); |
970 | 59 | xmlSearchModel.search(); | 58 | } else { |
971 | 60 | } else { | 59 | searchField.text = ""; |
972 | 61 | searchField.text = ""; | 60 | } |
973 | 62 | } | 61 | } |
974 | 63 | } | 62 | } |
975 | 64 | } | 63 | } |
976 | 65 | } | 64 | ] |
977 | 66 | ] | 65 | |
978 | 67 | 66 | Label { | |
979 | 68 | Label { | 67 | id: statusLabel |
980 | 69 | id: statusLabel | 68 | width: parent.width - units.gu(4) |
981 | 70 | width: parent.width - units.gu(4) | 69 | anchors.centerIn: parent |
982 | 71 | anchors.horizontalCenter: parent.horizontalCenter | 70 | visible: historyModel.count === 0 |
983 | 72 | anchors.verticalCenter: parent.verticalCenter | 71 | horizontalAlignment: Text.AlignHCenter |
984 | 73 | visible: historyModel.count === 0 | 72 | wrapMode: Text.WordWrap |
985 | 74 | horizontalAlignment: Text.AlignHCenter | 73 | text: navApp.settings.saveHistory ? i18n.tr("No history yet…") |
986 | 75 | wrapMode: Text.WordWrap | 74 | : i18n.tr("History is disabled") |
987 | 76 | text: navApp.settings.saveHistory ? i18n.tr("No history yet…") : i18n.tr("History is disabled") | 75 | } |
988 | 77 | } | 76 | |
989 | 78 | 77 | Icon { | |
990 | 79 | Icon { | 78 | id: historyIcon |
991 | 80 | id: historyIcon | 79 | width: units.gu(6) |
992 | 81 | width: units.gu(6) | 80 | anchors { horizontalCenter: parent.horizontalCenter; bottom: statusLabel.top; bottomMargin: units.gu(2) } |
993 | 82 | anchors.horizontalCenter: parent.horizontalCenter | 81 | visible: historyModel.count === 0 && xmlSearchModel.status !== XmlListModel.Loading |
994 | 83 | anchors.bottom: statusLabel.top | 82 | name: "history" |
995 | 84 | anchors.bottomMargin: units.gu(2) | 83 | } |
996 | 85 | visible: historyModel.count === 0 && xmlSearchModel.status !== XmlListModel.Loading | 84 | |
997 | 86 | name: "history" | 85 | // Indicator to show search activity |
998 | 87 | } | 86 | ActivityIndicator { |
999 | 88 | 87 | id: searchActivity | |
1000 | 89 | // Indicator to show search activity | 88 | anchors { |
1001 | 90 | ActivityIndicator { | 89 | bottom: statusLabel.top |
1002 | 91 | id: searchActivity | 90 | bottomMargin: units.gu (1) |
1003 | 92 | anchors { | 91 | horizontalCenter: parent.horizontalCenter |
1004 | 93 | bottom: statusLabel.top | 92 | } |
1005 | 94 | bottomMargin: units.gu (1) | 93 | running: xmlSearchModel.status === XmlListModel.Loading |
1006 | 95 | horizontalCenter: parent.horizontalCenter | 94 | } |
1007 | 96 | } | 95 | |
1008 | 97 | running: xmlSearchModel.status === XmlListModel.Loading | 96 | ListModel { |
1009 | 98 | } | 97 | id: historyModel |
1010 | 99 | 98 | function initialize() { | |
1011 | 100 | ListModel { | 99 | historyModel.clear(); |
1012 | 101 | id: historyModel | 100 | var res = UnavDB.getSearchHistory(); |
1013 | 102 | function initialize() { | 101 | var len = res.rows.length; |
1014 | 103 | historyModel.clear(); | 102 | for (var i = 0; i < len; ++i) { |
1015 | 104 | var res = UnavDB.getSearchHistory(); | 103 | historyModel.append({ |
1016 | 105 | var len = res.rows.length; | 104 | title: i18n.tr("Search history"), |
1017 | 106 | for (var i = 0; i < len; ++i) { | 105 | name: res.rows.item(i).key, |
1018 | 107 | historyModel.append({ | 106 | lat: res.rows.item(i).lat, |
1019 | 108 | title: i18n.tr("Search history"), | 107 | lng: res.rows.item(i).lng |
1020 | 109 | name: res.rows.item(i).key, | 108 | }); |
1021 | 110 | lat: res.rows.item(i).lat, | 109 | } |
1022 | 111 | lng: res.rows.item(i).lng | 110 | res = UnavDB.getfavHistory(); |
1023 | 112 | }); | 111 | len = res.rows.length; |
1024 | 113 | } | 112 | for (i = 0; i < len; ++i) { |
1025 | 114 | res = UnavDB.getfavHistory(); | 113 | historyModel.append({ |
1026 | 115 | len = res.rows.length; | 114 | title: i18n.tr("Favorite history"), |
1027 | 116 | for (i = 0; i < len; ++i) { | 115 | name: res.rows.item(i).key, |
1028 | 117 | historyModel.append({ | 116 | lat: res.rows.item(i).lat, |
1029 | 118 | title: i18n.tr("Favorite history"), | 117 | lng: res.rows.item(i).lng |
1030 | 119 | name: res.rows.item(i).key, | 118 | }); |
1031 | 120 | lat: res.rows.item(i).lat, | 119 | } |
1032 | 121 | lng: res.rows.item(i).lng | 120 | res = UnavDB.getNearByHistory(); |
1033 | 122 | }); | 121 | len = res.rows.length; |
1034 | 123 | } | 122 | for (i = 0; i < len; ++i) { |
1035 | 124 | res = UnavDB.getNearByHistory(); | 123 | historyModel.append({ |
1036 | 125 | len = res.rows.length; | 124 | title: i18n.tr("Nearby history"), |
1037 | 126 | for (i = 0; i < len; ++i) { | 125 | name: i18n.tr(res.rows.item(i).type), |
1038 | 127 | historyModel.append({ | 126 | en_name: res.rows.item(i).type, |
1039 | 128 | title: i18n.tr("Nearby history"), | 127 | clause: res.rows.item(i).clause |
1040 | 129 | name: i18n.tr(res.rows.item(i).type), | 128 | }); |
1041 | 130 | en_name: res.rows.item(i).type, | 129 | } |
1042 | 131 | clause: res.rows.item(i).clause | 130 | } |
1043 | 132 | }); | 131 | Component.onCompleted: initialize() |
1044 | 133 | } | 132 | } |
1045 | 134 | } | 133 | |
1046 | 135 | Component.onCompleted: initialize() | 134 | //OSMTouch Model: |
1047 | 136 | } | 135 | XmlListModel { |
1048 | 137 | 136 | id: xmlSearchModel | |
1049 | 138 | //OSMTouch Model: | 137 | |
1050 | 139 | XmlListModel { | 138 | onStatusChanged: { |
1051 | 140 | id: xmlSearchModel | 139 | if (status === XmlListModel.Error) { |
1052 | 141 | 140 | statusLabel.text = i18n.tr("Time out! Please try again"); | |
1053 | 142 | onStatusChanged: { | 141 | statusLabel.visible = true; |
1054 | 143 | if (status === XmlListModel.Error) { | 142 | historyIcon.visible = false; |
1055 | 144 | statusLabel.text = i18n.tr("Time out! Please try again"); | 143 | resultsListView.visible = false; |
1056 | 145 | statusLabel.visible = true; | 144 | } if (status === XmlListModel.Ready && count === 0) { |
1057 | 146 | historyIcon.visible = false; | 145 | //TRANSLATORS: The Argument is the search input. E.G. a Town, Address.... |
1058 | 147 | resultsListView.visible = false; | 146 | statusLabel.text = i18n.tr("Sorry, no result for %1").arg(searchField.text); |
1059 | 148 | } if (status === XmlListModel.Ready && count === 0) { | 147 | statusLabel.visible = true; |
1060 | 149 | //TRANSLATORS: The Argument is the search input. E.G. a Town, Address.... | 148 | historyIcon.visible = false; |
1061 | 150 | statusLabel.text = i18n.tr("Sorry, no result for %1").arg(searchField.text); | 149 | resultsListView.visible = false; |
1062 | 151 | statusLabel.visible = true; | 150 | } if (status === XmlListModel.Ready && count >> 0) { |
1063 | 152 | historyIcon.visible = false; | 151 | statusLabel.visible = false; |
1064 | 153 | resultsListView.visible = false; | 152 | historyIcon.visible = false; |
1065 | 154 | } if (status === XmlListModel.Ready && count >> 0) { | 153 | sortedSearchModel.sortXmlList(); |
1066 | 155 | statusLabel.visible = false; | 154 | } |
1067 | 156 | historyIcon.visible = false; | 155 | } |
1068 | 157 | sortedSearchModel.sortXmlList(); | 156 | |
1069 | 158 | } | 157 | readonly property string searchUrl: "https://nominatim.openstreetmap.org/search?format=xml&email=marcos.costales@gmail.com&limit=50&q=" |
1070 | 159 | } | 158 | property string searchString |
1071 | 160 | 159 | ||
1072 | 161 | readonly property string searchUrl: "https://nominatim.openstreetmap.org/search?format=xml&email=marcos.costales@gmail.com&limit=50&q=" | 160 | function search() { |
1073 | 162 | property string searchString | 161 | xmlSearchModel.clear() |
1074 | 163 | 162 | sortedSearchModel.clear() | |
1075 | 164 | function search() { | 163 | source = (searchUrl + searchString); |
1076 | 165 | xmlSearchModel.clear() | 164 | } |
1077 | 166 | sortedSearchModel.clear() | 165 | |
1078 | 167 | source = (searchUrl + searchString); | 166 | function clear() { |
1079 | 168 | } | 167 | source: ""; |
1080 | 169 | 168 | } | |
1081 | 170 | function clear() { | 169 | |
1082 | 171 | source: ""; | 170 | source: "" |
1083 | 172 | } | 171 | query: "/searchresults/place" |
1084 | 173 | 172 | ||
1085 | 174 | source: "" | 173 | XmlRole { name: "name"; query: "@display_name/string()"; isKey: true } |
1086 | 175 | query: "/searchresults/place" | 174 | XmlRole { name: "lat"; query: "@lat/string()"; isKey: true } |
1087 | 176 | 175 | XmlRole { name: "lng"; query: "@lon/string()"; isKey: true } | |
1088 | 177 | XmlRole { name: "name"; query: "@display_name/string()"; isKey: true } | 176 | XmlRole { name: "icon"; query: "@icon/string()"; isKey: true } |
1089 | 178 | XmlRole { name: "lat"; query: "@lat/string()"; isKey: true } | 177 | } |
1090 | 179 | XmlRole { name: "lng"; query: "@lon/string()"; isKey: true } | 178 | |
1091 | 180 | XmlRole { name: "icon"; query: "@icon/string()"; isKey: true } | 179 | ListModel { |
1092 | 181 | } | 180 | id: sortedSearchModel |
1093 | 182 | 181 | ||
1094 | 183 | ListModel { | 182 | function sortXmlList (){ |
1095 | 184 | id: sortedSearchModel | 183 | sortedSearchModel.clear() |
1096 | 185 | 184 | var item | |
1097 | 186 | function sortXmlList (){ | 185 | for (var i = 0; i < xmlSearchModel.count; i++) { |
1098 | 187 | sortedSearchModel.clear() | 186 | item = { |
1099 | 188 | var item | 187 | "name": xmlSearchModel.get(i).name, |
1100 | 189 | for (var i = 0; i < xmlSearchModel.count; i++) { | 188 | "lat": xmlSearchModel.get(i).lat, |
1101 | 190 | item = { | 189 | "lng": xmlSearchModel.get(i).lng, |
1102 | 191 | "name": xmlSearchModel.get(i).name, | 190 | "icon": (xmlSearchModel.get(i).icon).replace('.p.20.png', '.p.32.png'), |
1103 | 192 | "lat": xmlSearchModel.get(i).lat, | 191 | "distance": QmlJs.calcPoiDistance( |
1104 | 193 | "lng": xmlSearchModel.get(i).lng, | 192 | mainPageStack.currentLat, |
1105 | 194 | "icon": (xmlSearchModel.get(i).icon).replace('.p.20.png', '.p.32.png'), | 193 | mainPageStack.currentLng, |
1106 | 195 | "distance": QmlJs.calcPoiDistance( | 194 | xmlSearchModel.get(i).lat, |
1107 | 196 | mainPageStack.currentLat, | 195 | xmlSearchModel.get(i).lng, |
1108 | 197 | mainPageStack.currentLng, | 196 | 10 |
1109 | 198 | xmlSearchModel.get(i).lat, | 197 | ) |
1110 | 199 | xmlSearchModel.get(i).lng, | 198 | } |
1111 | 200 | 10 | 199 | if (i === 0) { |
1112 | 201 | ) | 200 | sortedSearchModel.append(item) |
1113 | 202 | } | 201 | } else { // sort model by distance |
1114 | 203 | if (i === 0) { | 202 | var j = 0; |
1115 | 204 | sortedSearchModel.append(item) | 203 | while (j <= sortedSearchModel.count) { |
1116 | 205 | } else { // sort model by distance | 204 | if (j === sortedSearchModel.count) { |
1117 | 206 | var j = 0; | 205 | sortedSearchModel.append(item) |
1118 | 207 | while (j <= sortedSearchModel.count) { | 206 | break; |
1119 | 208 | if (j === sortedSearchModel.count) { | 207 | } else if (item.distance < sortedSearchModel.get(j).distance){ |
1120 | 209 | sortedSearchModel.append(item) | 208 | sortedSearchModel.insert(j,item) |
1121 | 210 | break; | 209 | break; |
1122 | 211 | } else if (item.distance < sortedSearchModel.get(j).distance){ | 210 | } else { |
1123 | 212 | sortedSearchModel.insert(j,item) | 211 | j++; |
1124 | 213 | break; | 212 | } |
1125 | 214 | } else { | 213 | } |
1126 | 215 | j++; | 214 | } |
1127 | 216 | } | 215 | xmlSearchModel.clear(); |
1128 | 217 | } | 216 | historyListView.visible = false; |
1129 | 218 | } | 217 | resultsListView.visible = true; |
1130 | 219 | xmlSearchModel.clear(); | 218 | } |
1131 | 220 | historyListView.visible = false; | 219 | } |
1132 | 221 | resultsListView.visible = true; | 220 | } |
1133 | 222 | } | 221 | |
1134 | 223 | } | 222 | ListView { |
1135 | 224 | } | 223 | id: historyListView |
1136 | 225 | 224 | ||
1137 | 226 | Component { | 225 | model: historyModel |
1138 | 227 | id: sectionHeading | 226 | visible: !statusLabel.visible |
1139 | 228 | 227 | anchors.fill: parent | |
1140 | 229 | Rectangle { | 228 | |
1141 | 230 | width: parent.width | 229 | section.property: "title" |
1142 | 231 | height: childrenRect.height | 230 | section.criteria: ViewSection.FullString |
1143 | 232 | 231 | section.delegate: HeaderListItem { | |
1144 | 233 | ListItems.Header { | 232 | title: section |
1145 | 234 | id: listHeader | 233 | } |
1146 | 235 | text: section | 234 | |
1147 | 236 | } | 235 | delegate: ListItem { |
1148 | 237 | } | 236 | height: historyDelegateLayout.height + divider.height |
1149 | 238 | } | 237 | leadingActions: ListItemActions { |
1150 | 239 | 238 | actions: [ | |
1151 | 240 | UbuntuListView { | 239 | Action { |
1152 | 241 | id: historyListView | 240 | iconName: "delete" |
1153 | 242 | model: historyModel | 241 | onTriggered: { |
1154 | 243 | visible: !statusLabel.visible | 242 | switch (model.title) { |
1155 | 244 | anchors.fill: parent | 243 | case i18n.tr("Search history"): |
1156 | 245 | 244 | UnavDB.removeHistorySearch(model.name); | |
1157 | 246 | section.property: "title" | 245 | break; |
1158 | 247 | section.criteria: ViewSection.FullString | 246 | case i18n.tr("Nearby history"): |
1159 | 248 | //section.labelPositioning: ViewSection.CurrentLabelAtStart + ViewSection.InlineLabels | 247 | UnavDB.removeHistoryNearby(model.en_name); |
1160 | 249 | section.delegate: sectionHeading | 248 | break; |
1161 | 250 | 249 | case i18n.tr("Favorite history"): | |
1162 | 251 | delegate: ListItem { | 250 | UnavDB.removeHistoryFavorite(model.name); |
1163 | 252 | leadingActions: ListItemActions { | 251 | } |
1164 | 253 | actions: [ | 252 | historyModel.initialize() |
1165 | 254 | Action { | 253 | } |
1166 | 255 | iconName: "delete" | 254 | } |
1167 | 256 | onTriggered: { | 255 | ] |
1168 | 257 | switch (model.title) { | 256 | } |
1169 | 258 | case i18n.tr("Search history"): | 257 | |
1170 | 259 | UnavDB.removeHistorySearch(model.name); | 258 | trailingActions: ListItemActions { |
1171 | 260 | break; | 259 | actions: [ |
1172 | 261 | case i18n.tr("Nearby history"): | 260 | Action { |
1173 | 262 | UnavDB.removeHistoryNearby(model.en_name); | 261 | iconName: "send" |
1174 | 263 | break; | 262 | onTriggered: { |
1175 | 264 | case i18n.tr("Favorite history"): | 263 | mainPageStack.pop(searchPage); |
1176 | 265 | UnavDB.removeHistoryFavorite(model.name); | 264 | mainPageStack.routeState = 'yes'; |
1177 | 266 | } | 265 | mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");"); |
1178 | 267 | historyModel.initialize() | 266 | } |
1179 | 268 | } | 267 | }, |
1180 | 269 | } | 268 | Action { |
1181 | 270 | ] | 269 | iconName: "share" |
1182 | 271 | } | 270 | onTriggered: { |
1183 | 272 | 271 | PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": model.lat, "lon": model.lng}) | |
1184 | 273 | trailingActions: ListItemActions { | 272 | } |
1185 | 274 | actions: [ | 273 | } |
1186 | 275 | Action { | 274 | ] |
1187 | 276 | iconName: "send" | 275 | } |
1188 | 277 | onTriggered: { | 276 | |
1189 | 278 | mainPageStack.pop(searchPage); | 277 | ListItemLayout { |
1190 | 279 | mainPageStack.routeState = 'yes'; | 278 | id: historyDelegateLayout |
1191 | 280 | mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");"); | 279 | |
1192 | 281 | } | 280 | title.text: model.name |
1193 | 282 | }, | 281 | title.maximumLineCount: 2 |
1194 | 283 | Action { | 282 | subtitle.text: QmlJs.formatDistance(QmlJs.calcPoiDistance(mainPageStack.currentLat, mainPageStack.currentLng, model.lat, model.lng, 10), navApp.settings.unit) |
1195 | 284 | iconName: "share" | 283 | subtitle.visible: model.title !== i18n.tr("Nearby history") && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null" |
1196 | 285 | onTriggered: { | 284 | |
1197 | 286 | PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": model.lat, "lon": model.lng}) | 285 | Icon { |
1198 | 287 | } | 286 | id: progressionIcon |
1199 | 288 | } | 287 | height: units.gu(2.5) |
1200 | 289 | ] | 288 | name: "next" |
1201 | 290 | } | 289 | visible: model.title === i18n.tr("Nearby history") |
1202 | 291 | 290 | SlotsLayout.position: SlotsLayout.Last | |
1203 | 292 | contentItem.anchors { | 291 | } |
1204 | 293 | leftMargin: units.gu(2) | 292 | |
1205 | 294 | rightMargin: units.gu(1) | 293 | } |
1206 | 295 | topMargin: units.gu(0.5) | 294 | |
1207 | 296 | bottomMargin: units.gu(0.5) | 295 | onClicked: { |
1208 | 297 | } | 296 | mainPageStack.pop(searchPage) |
1209 | 298 | 297 | if (model.title === i18n.tr("Nearby history")) { | |
1210 | 299 | Label { | 298 | mainPageStack.push(Qt.resolvedUrl("PoiListPage.qml"), |
1211 | 300 | height: parent.height | 299 | { |
1212 | 301 | width: parent.width *4/5 | 300 | lat: mainPageStack.currentLat, |
1213 | 302 | text: model.name | 301 | lng: mainPageStack.currentLng, |
1214 | 303 | elide: Text.ElideRight | 302 | poiType: model.name, |
1215 | 304 | wrapMode: Text.WordWrap | 303 | clause: model.clause, |
1216 | 305 | } | 304 | geoDistFactor: 5 |
1217 | 306 | 305 | }) | |
1218 | 307 | Icon { | 306 | } else { |
1219 | 308 | id: progressionIcon | 307 | mainPageStack.executeJavaScript("ui.markers_POI_set([{ title: \"" + |
1220 | 309 | anchors { | 308 | model.name + "\", lat: " + |
1221 | 310 | right: parent.right | 309 | model.lat + ", lng: " + |
1222 | 311 | verticalCenter: parent.verticalCenter | 310 | model.lng + "}]);"); |
1223 | 312 | } | 311 | } |
1224 | 313 | height: units.gu(2.5) | 312 | } |
1225 | 314 | name: "next" | 313 | } |
1226 | 315 | visible: model.title === i18n.tr("Nearby history") | 314 | } |
1227 | 316 | } | 315 | |
1228 | 317 | 316 | ListView { | |
1229 | 318 | Label { | 317 | id: resultsListView |
1230 | 319 | anchors.bottom: parent.bottom | 318 | |
1231 | 320 | width: parent.width /5 | 319 | anchors.fill: parent |
1232 | 321 | anchors.right: parent.right | 320 | anchors.topMargin: units.gu(6) |
1233 | 322 | horizontalAlignment: Text.AlignRight | 321 | visible: false |
1234 | 323 | visible: model.title !== i18n.tr("Nearby history") && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null" | 322 | |
1235 | 324 | text: QmlJs.formatDistance( | 323 | model: sortedSearchModel |
1236 | 325 | QmlJs.calcPoiDistance( | 324 | |
1237 | 326 | mainPageStack.currentLat, | 325 | delegate: ListItem { |
1238 | 327 | mainPageStack.currentLng, | 326 | height: resultsDelegateLayout.height + divider.height |
1239 | 328 | model.lat, model.lng, | 327 | trailingActions: ListItemActions { |
1240 | 329 | 10 | 328 | actions: [ |
1241 | 330 | ), | 329 | Action { |
1242 | 331 | navApp.settings.unit | 330 | iconName: "send" |
1243 | 332 | ) | 331 | onTriggered: { |
1244 | 333 | fontSize: "small" | 332 | if (navApp.settings.saveHistory) { |
1245 | 334 | } | 333 | UnavDB.saveToSearchHistory(model.name, model.lat, model.lng) |
1246 | 335 | 334 | } | |
1247 | 336 | onClicked: { | 335 | mainPageStack.pop(searchPage); |
1248 | 337 | mainPageStack.pop(searchPage) | 336 | mainPageStack.routeState = 'yes' |
1249 | 338 | if (model.title === i18n.tr("Nearby history")) { | 337 | mainPageStack.executeJavaScript("calc2coord(" + model.lat + "," + model.lng + ");") |
1250 | 339 | mainPageStack.push(Qt.resolvedUrl("PoiListPage.qml"), | 338 | } |
1251 | 340 | { | 339 | }, |
1252 | 341 | lat: mainPageStack.currentLat, | 340 | Action { |
1253 | 342 | lng: mainPageStack.currentLng, | 341 | iconName: "share" |
1254 | 343 | poiType: model.name, | 342 | onTriggered: { |
1255 | 344 | clause: model.clause, | 343 | PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": model.lat, "lon": model.lng}) |
1256 | 345 | geoDistFactor: 5 | 344 | } |
1257 | 346 | }) | 345 | }, |
1258 | 347 | } else { | 346 | Action { |
1259 | 348 | mainPageStack.executeJavaScript("ui.markers_POI_set([{ title: \"" + | 347 | iconName: "non-starred" |
1260 | 349 | model.name + "\", lat: " + | 348 | onTriggered: { |
1261 | 350 | model.lat + ", lng: " + | 349 | mainPageStack.pop(searchPage) |
1262 | 351 | model.lng + "}]);"); | 350 | mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {state:"adding", lat: model.lat, lng: model.lng, favName: model.name}) |
1263 | 352 | } | 351 | } |
1264 | 353 | } | 352 | } |
1265 | 354 | } | 353 | ] |
1266 | 355 | } | 354 | } |
1267 | 356 | 355 | ||
1268 | 357 | UbuntuListView { | 356 | onClicked: { |
1269 | 358 | id: resultsListView | 357 | if (navApp.settings.saveHistory) { |
1270 | 359 | model: sortedSearchModel | 358 | UnavDB.saveToSearchHistory(model.name, model.lat, model.lng) |
1271 | 360 | 359 | } | |
1272 | 361 | width: parent.width | 360 | mainPageStack.pop(searchPage) |
1273 | 362 | height: parent.height - units.gu(6) | 361 | mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + "}]);"); |
1274 | 363 | anchors.top: parent.top | 362 | } |
1275 | 364 | anchors.topMargin: units.gu(6) | 363 | |
1276 | 365 | visible: false | 364 | ListItemLayout { |
1277 | 366 | 365 | id: resultsDelegateLayout | |
1278 | 367 | delegate: ListItem { | 366 | |
1279 | 368 | trailingActions: ListItemActions { | 367 | title.text: model.name |
1280 | 369 | actions: [ | 368 | title.maximumLineCount: 2 |
1281 | 370 | Action { | 369 | subtitle.text: QmlJs.formatDistance(model.distance, navApp.settings.unit) |
1282 | 371 | iconName: "send" | 370 | subtitle.visible: mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null" |
1283 | 372 | onTriggered: { | 371 | |
1284 | 373 | if (navApp.settings.saveHistory) { | 372 | Icon { |
1285 | 374 | UnavDB.saveToSearchHistory(model.name, model.lat, model.lng) | 373 | id: resIcon |
1286 | 375 | } | 374 | height: units.gu(2.5) |
1287 | 376 | mainPageStack.pop(searchPage); | 375 | width: height |
1288 | 377 | mainPageStack.routeState = 'yes' | 376 | visible: model.icon !== "" |
1289 | 378 | mainPageStack.executeJavaScript("calc2coord(" + model.lat + "," + model.lng + ");") | 377 | source: model.icon |
1290 | 379 | } | 378 | SlotsLayout.position: SlotsLayout.Last |
1291 | 380 | }, | 379 | } |
1292 | 381 | Action { | 380 | } |
1293 | 382 | iconName: "share" | 381 | } |
1294 | 383 | onTriggered: { | 382 | } |
878 | 384 | PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": model.lat, "lon": model.lng}) | ||
879 | 385 | } | ||
880 | 386 | }, | ||
881 | 387 | Action { | ||
882 | 388 | iconName: "non-starred" | ||
883 | 389 | onTriggered: { | ||
884 | 390 | mainPageStack.pop(searchPage) | ||
885 | 391 | mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {state:"adding", lat: model.lat, lng: model.lng, favName: model.name}) | ||
886 | 392 | } | ||
887 | 393 | } | ||
888 | 394 | ] | ||
889 | 395 | } | ||
890 | 396 | |||
891 | 397 | onClicked: { | ||
892 | 398 | if (navApp.settings.saveHistory) { | ||
893 | 399 | UnavDB.saveToSearchHistory(model.name, model.lat, model.lng) | ||
894 | 400 | } | ||
895 | 401 | mainPageStack.pop(searchPage) | ||
896 | 402 | mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + "}]);"); | ||
897 | 403 | } | ||
898 | 404 | |||
899 | 405 | contentItem.anchors { | ||
900 | 406 | leftMargin: units.gu(1) | ||
901 | 407 | rightMargin: units.gu(1) | ||
902 | 408 | topMargin: units.gu(0.5) | ||
903 | 409 | bottomMargin: units.gu(0.5) | ||
904 | 410 | } | ||
905 | 411 | |||
906 | 412 | Label { | ||
907 | 413 | anchors.left: parent.left | ||
908 | 414 | height: parent.height | ||
909 | 415 | width: parent.width *4/5 | ||
910 | 416 | text: model.name | ||
911 | 417 | elide: Text.ElideRight | ||
912 | 418 | wrapMode: Text.WordWrap | ||
913 | 419 | |||
914 | 420 | } | ||
915 | 421 | |||
916 | 422 | Icon { | ||
917 | 423 | id: resIcon | ||
918 | 424 | height: 32 | ||
919 | 425 | width: height | ||
920 | 426 | visible: model.icon !== "" | ||
921 | 427 | anchors { | ||
922 | 428 | top: parent.top | ||
923 | 429 | right: parent.right | ||
924 | 430 | } | ||
925 | 431 | source: model.icon | ||
926 | 432 | } | ||
927 | 433 | |||
928 | 434 | Label { | ||
929 | 435 | anchors.bottom: parent.bottom | ||
930 | 436 | width: parent.width /5 | ||
931 | 437 | anchors.right: parent.right | ||
932 | 438 | horizontalAlignment: Text.AlignRight | ||
933 | 439 | visible: mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null" | ||
934 | 440 | text: QmlJs.formatDistance(model.distance, navApp.settings.unit) | ||
935 | 441 | fontSize: "small" | ||
936 | 442 | } | ||
937 | 443 | } | ||
938 | 444 | } | ||
1295 | 445 | } | 383 | } |
1296 | 446 | 384 | ||
1297 | === modified file 'qml/SettingsPage.qml' | |||
1298 | --- qml/SettingsPage.qml 2016-03-14 18:40:54 +0000 | |||
1299 | +++ qml/SettingsPage.qml 2016-03-15 01:14:51 +0000 | |||
1300 | @@ -17,7 +17,7 @@ | |||
1301 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1302 | 18 | import Ubuntu.Components 1.3 | 18 | import Ubuntu.Components 1.3 |
1303 | 19 | import Ubuntu.Components.Popups 1.3 | 19 | import Ubuntu.Components.Popups 1.3 |
1305 | 20 | import Ubuntu.Components.ListItems 1.3 as ListItem | 20 | import Ubuntu.Components.ListItems 1.3 as ListItems |
1306 | 21 | import QtQuick.LocalStorage 2.0 | 21 | import QtQuick.LocalStorage 2.0 |
1307 | 22 | import "js/db.js" as UnavDB | 22 | import "js/db.js" as UnavDB |
1308 | 23 | 23 | ||
1309 | @@ -41,12 +41,12 @@ | |||
1310 | 41 | right: parent.right | 41 | right: parent.right |
1311 | 42 | } | 42 | } |
1312 | 43 | 43 | ||
1317 | 44 | ListItem.Header { | 44 | HeaderListItem { |
1318 | 45 | id: mapModeHeader | 45 | id: mapModeHeader |
1319 | 46 | text: i18n.tr("Navigation") | 46 | title: i18n.tr("Navigation") |
1320 | 47 | } | 47 | } |
1321 | 48 | 48 | ||
1323 | 49 | ListItem.ItemSelector { | 49 | ListItems.ItemSelector { |
1324 | 50 | id: modeList | 50 | id: modeList |
1325 | 51 | text: i18n.tr("Mode:") | 51 | text: i18n.tr("Mode:") |
1326 | 52 | width: parent.width | 52 | width: parent.width |
1327 | @@ -63,40 +63,46 @@ | |||
1328 | 63 | mainPageStack.executeJavaScript("if (nav.get_route_status() != 'no'){nav.set_route_status('waiting4signal')}; settings.set_routing_mode(" + selectedIndex +");") | 63 | mainPageStack.executeJavaScript("if (nav.get_route_status() != 'no'){nav.set_route_status('waiting4signal')}; settings.set_routing_mode(" + selectedIndex +");") |
1329 | 64 | } | 64 | } |
1330 | 65 | } | 65 | } |
1365 | 66 | 66 | ||
1366 | 67 | ListItem.Standard { | 67 | ListItem { |
1367 | 68 | visible: navApp.settings.routingMode === 0 ? true : false | 68 | height: tollsLayout.height + divider.height |
1368 | 69 | showDivider: true | 69 | ListItemLayout { |
1369 | 70 | text: i18n.tr("Avoid Tolls") | 70 | id: tollsLayout |
1370 | 71 | control: Switch { | 71 | title.text: i18n.tr("Avoid Tolls") |
1371 | 72 | id: tollsSwitch | 72 | Switch { |
1372 | 73 | checked: navApp.settings.avoidTolls | 73 | id: tollsSwitch |
1373 | 74 | onClicked: { | 74 | checked: navApp.settings.avoidTolls |
1374 | 75 | navApp.settings.avoidTolls = checked; | 75 | onClicked: { |
1375 | 76 | mainPageStack.executeJavaScript("if (nav.get_route_status() != 'no'){nav.set_route_status('waiting4signal')}; settings.set_avoid_tolls(" + checked.toString() + ");") | 76 | navApp.settings.avoidTolls = checked; |
1376 | 77 | } | 77 | mainPageStack.executeJavaScript("if (nav.get_route_status() != 'no'){nav.set_route_status('waiting4signal')}; settings.set_avoid_tolls(" + checked.toString() + ");") |
1377 | 78 | } | 78 | } |
1378 | 79 | } | 79 | SlotsLayout.position: SlotsLayout.Last |
1379 | 80 | 80 | } | |
1380 | 81 | ListItem.Standard { | 81 | } |
1381 | 82 | visible: navApp.settings.routingMode === 0 ? true : false | 82 | } |
1382 | 83 | showDivider: true | 83 | |
1383 | 84 | text: i18n.tr("Speed Camera Alerts") | 84 | ListItem { |
1384 | 85 | control: Switch { | 85 | height: speedCameraLayout.height + divider.height |
1385 | 86 | id: radarsSwitch | 86 | ListItemLayout { |
1386 | 87 | checked: navApp.settings.alertRadars | 87 | id: speedCameraLayout |
1387 | 88 | onClicked: { | 88 | title.text: i18n.tr("Speed Camera Alerts") |
1388 | 89 | navApp.settings.alertRadars = checked; | 89 | Switch { |
1389 | 90 | mainPageStack.executeJavaScript("if (nav.get_route_status() != 'no'){nav.set_route_status('waiting4signal')}; settings.set_alert_radars(" + checked.toString() + ");"); | 90 | id: radarsSwitch |
1390 | 91 | if (navApp.settings.legalRadarShow) { | 91 | checked: navApp.settings.alertRadars |
1391 | 92 | navApp.settings.legalRadarShow = false; | 92 | onClicked: { |
1392 | 93 | PopupUtils.open(confirmEnableRadar); | 93 | navApp.settings.alertRadars = checked; |
1393 | 94 | } | 94 | mainPageStack.executeJavaScript("if (nav.get_route_status() != 'no'){nav.set_route_status('waiting4signal')}; settings.set_alert_radars(" + checked.toString() + ");"); |
1394 | 95 | } | 95 | if (navApp.settings.legalRadarShow) { |
1395 | 96 | } | 96 | navApp.settings.legalRadarShow = false; |
1396 | 97 | } | 97 | PopupUtils.open(confirmEnableRadar); |
1397 | 98 | 98 | } | |
1398 | 99 | ListItem.ItemSelector { | 99 | } |
1399 | 100 | SlotsLayout.position: SlotsLayout.Last | ||
1400 | 101 | } | ||
1401 | 102 | } | ||
1402 | 103 | } | ||
1403 | 104 | |||
1404 | 105 | ListItems.ItemSelector { | ||
1405 | 100 | id: soundsList | 106 | id: soundsList |
1406 | 101 | text: i18n.tr("Indications:") | 107 | text: i18n.tr("Indications:") |
1407 | 102 | width: parent.width | 108 | width: parent.width |
1408 | @@ -114,12 +120,12 @@ | |||
1409 | 114 | } | 120 | } |
1410 | 115 | } | 121 | } |
1411 | 116 | 122 | ||
1413 | 117 | ListItem.Header { | 123 | HeaderListItem { |
1414 | 118 | id: mapListHeader | 124 | id: mapListHeader |
1416 | 119 | text: i18n.tr("Map") | 125 | title: i18n.tr("Map") |
1417 | 120 | } | 126 | } |
1418 | 121 | 127 | ||
1420 | 122 | ListItem.ItemSelector { | 128 | ListItems.ItemSelector { |
1421 | 123 | id: unitsList | 129 | id: unitsList |
1422 | 124 | text: i18n.tr("Units:") | 130 | text: i18n.tr("Units:") |
1423 | 125 | width: parent.width | 131 | width: parent.width |
1424 | @@ -137,30 +143,32 @@ | |||
1425 | 137 | } | 143 | } |
1426 | 138 | } | 144 | } |
1427 | 139 | 145 | ||
1429 | 140 | ListItem.Header { | 146 | HeaderListItem { |
1430 | 141 | id: privacyListHeader | 147 | id: privacyListHeader |
1453 | 142 | text: i18n.tr("History") | 148 | title: i18n.tr("History") |
1454 | 143 | } | 149 | } |
1455 | 144 | 150 | ||
1456 | 145 | ListItem.Standard { | 151 | ListItem { |
1457 | 146 | showDivider: false | 152 | height: storeSearchLayout.height + divider.height |
1458 | 147 | text: i18n.tr("Store new searches") | 153 | ListItemLayout { |
1459 | 148 | 154 | id: storeSearchLayout | |
1460 | 149 | control: Switch { | 155 | title.text: i18n.tr("Store new searches") |
1461 | 150 | id: saveHistorySwitch | 156 | Switch { |
1462 | 151 | checked: navApp.settings.saveHistory | 157 | id: saveHistorySwitch |
1463 | 152 | onClicked: { | 158 | checked: navApp.settings.saveHistory |
1464 | 153 | navApp.settings.saveHistory = checked; | 159 | onClicked: navApp.settings.saveHistory = checked |
1465 | 154 | } | 160 | SlotsLayout.position: SlotsLayout.Last |
1466 | 155 | } | 161 | } |
1467 | 156 | } | 162 | } |
1468 | 157 | 163 | } | |
1469 | 158 | ListItem.Standard { | 164 | |
1470 | 159 | showDivider: true | 165 | ListItem { |
1471 | 160 | text: i18n.tr("Clear History") | 166 | Label { |
1472 | 161 | onClicked: PopupUtils.open(confirmEraseHistory) | 167 | anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(2) } |
1473 | 162 | } | 168 | text: i18n.tr("Clear History") |
1474 | 163 | 169 | } | |
1475 | 170 | onClicked: PopupUtils.open(confirmEraseHistory) | ||
1476 | 171 | } | ||
1477 | 164 | } | 172 | } |
1478 | 165 | 173 | ||
1479 | 166 | Component { | 174 | Component { |
Thanks a lot Nekhelesh!! Great contribution!!
I added you to the credits with your name and your LP url, if you prefer another, tell me :)
A hug!