Merge lp:~nik90/unav/fix-pagestack-navigation into lp:unav

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 30
Proposed branch: lp:~nik90/unav/fix-pagestack-navigation
Merge into: lp:unav
Diff against target: 294 lines (+33/-38)
8 files modified
qml/Coordinate.qml (+2/-2)
qml/FavoritesPage.qml (+7/-5)
qml/Nearby.qml (+6/-3)
qml/PoiListPage.qml (+3/-8)
qml/PoiPage.qml (+1/-9)
qml/RoutePage.qml (+1/-1)
qml/SearchPage.qml (+8/-7)
qml/SharePage.qml (+5/-3)
To merge this branch: bzr merge lp:~nik90/unav/fix-pagestack-navigation
Reviewer Review Type Date Requested Status
costales Approve
Review via email: mp+291032@code.launchpad.net

Commit message

Revamped the pagestack navigation code. pop() and clear() are quite clever at what page they pop.

Description of the change

Improves the pagestack navigation code massively. No more headaches on which page gets pushed from which page and so on. This is how it was meant to be written ;)

To post a comment you must log in.
Revision history for this message
costales (costales) wrote :

Great work :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/Coordinate.qml'
--- qml/Coordinate.qml 2016-04-03 10:34:22 +0000
+++ qml/Coordinate.qml 2016-04-05 19:49:15 +0000
@@ -101,7 +101,7 @@
101 mainPageStack.clickedLng = parseFloat(aux_lng).toFixed(5);101 mainPageStack.clickedLng = parseFloat(aux_lng).toFixed(5);
102 if (mainPageStack.center_onpos === 2)102 if (mainPageStack.center_onpos === 2)
103 mainPageStack.center_onpos = 1;103 mainPageStack.center_onpos = 1;
104 mainPageStack.pop(coordPage);104 mainPageStack.clear();
105 mainPageStack.executeJavaScript(105 mainPageStack.executeJavaScript(
106 "ui.markers_POI_set([{title: '', lat: " + mainPageStack.clickedLat + ", lng: " + mainPageStack.clickedLng + "}]);"106 "ui.markers_POI_set([{title: '', lat: " + mainPageStack.clickedLat + ", lng: " + mainPageStack.clickedLng + "}]);"
107 );107 );
@@ -305,7 +305,7 @@
305 mainPageStack.clickedLng = parseFloat(aux_lng).toFixed(5);305 mainPageStack.clickedLng = parseFloat(aux_lng).toFixed(5);
306 if (mainPageStack.center_onpos === 2)306 if (mainPageStack.center_onpos === 2)
307 mainPageStack.center_onpos = 1;307 mainPageStack.center_onpos = 1;
308 mainPageStack.pop(coordPage);308 mainPageStack.clear();
309 mainPageStack.executeJavaScript(309 mainPageStack.executeJavaScript(
310 "ui.markers_POI_set([{title: '', lat: " + mainPageStack.clickedLat + ", lng: " + mainPageStack.clickedLng + "}]);"310 "ui.markers_POI_set([{title: '', lat: " + mainPageStack.clickedLat + ", lng: " + mainPageStack.clickedLng + "}]);"
311 );311 );
312312
=== modified file 'qml/FavoritesPage.qml'
--- qml/FavoritesPage.qml 2016-04-03 08:11:41 +0000
+++ qml/FavoritesPage.qml 2016-04-05 19:49:15 +0000
@@ -59,14 +59,16 @@
59 visible: header === standardHeader59 visible: header === standardHeader
60 z: 50060 z: 500
61 flickable: favoritesListView61 flickable: favoritesListView
62 // #FIXME: This back button is only here to allow the user to press Escape to go back.
63 // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
64 // at which point this back button can be removed.
62 leadingActionBar.actions: Action {65 leadingActionBar.actions: Action {
63 iconName: "back"66 iconName: "back"
64 text: i18n.tr("Back")67 text: i18n.tr("Back")
65 shortcut: "Escape"68 shortcut: "Escape"
66 enabled: header === standardHeader69 enabled: header === standardHeader
67 onTriggered: {70 onTriggered: {
68 mainPageStack.pop(favoritesPage)71 mainPageStack.pop()
69 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
70 }72 }
71 }73 }
72 trailingActionBar.actions: Action {74 trailingActionBar.actions: Action {
@@ -130,7 +132,7 @@
130 Action {132 Action {
131 iconName: "send"133 iconName: "send"
132 onTriggered: {134 onTriggered: {
133 mainPageStack.pop(favoritesPage);135 mainPageStack.clear();
134 mainPageStack.center_onpos = 2;136 mainPageStack.center_onpos = 2;
135 mainPageStack.routeState = 'yes';137 mainPageStack.routeState = 'yes';
136 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");138 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");
@@ -162,7 +164,7 @@
162 }164 }
163165
164 onClicked: {166 onClicked: {
165 mainPageStack.pop(favoritesPage);167 mainPageStack.clear()
166 if (navApp.settings.saveHistory) {168 if (navApp.settings.saveHistory) {
167 UnavDB.saveTofavHistory(model.name, model.lat, model.lng);169 UnavDB.saveTofavHistory(model.name, model.lat, model.lng);
168 }170 }
@@ -215,7 +217,7 @@
215 }217 }
216 Action {218 Action {
217 text: i18n.tr("Add From Map")219 text: i18n.tr("Add From Map")
218 onTriggered: mainPageStack.pop(favoritesPage);220 onTriggered: mainPageStack.clear()
219 }221 }
220 }222 }
221 }223 }
222224
=== modified file 'qml/Nearby.qml'
--- qml/Nearby.qml 2016-04-01 14:18:40 +0000
+++ qml/Nearby.qml 2016-04-05 19:49:15 +0000
@@ -26,13 +26,15 @@
26 title: i18n.tr("Nearby")26 title: i18n.tr("Nearby")
27 flickable: flickable27 flickable: flickable
28 28
29 // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
30 // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
31 // at which point this back button can be removed.
29 leadingActionBar.actions: Action {32 leadingActionBar.actions: Action {
30 iconName: "back"33 iconName: "back"
31 text: i18n.tr("Back")34 text: i18n.tr("Back")
32 shortcut: "Escape"35 shortcut: "Escape"
33 onTriggered: {36 onTriggered: {
34 mainPageStack.pop(nearbyPage)37 mainPageStack.pop()
35 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
36 }38 }
37 }39 }
38 }40 }
@@ -68,11 +70,12 @@
68 icon.source: model.source70 icon.source: model.source
6971
70 onClicked: {72 onClicked: {
71 mainPageStack.pop(nearbyPage);
72 if (model.mode === "CURRENT") {73 if (model.mode === "CURRENT") {
73 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.currentLat, "lng": mainPageStack.currentLng})74 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.currentLat, "lng": mainPageStack.currentLng})
74 } else if (model.mode === "DESTINATION") {75 } else if (model.mode === "DESTINATION") {
75 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.endLat, "lng": mainPageStack.endLng})76 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.endLat, "lng": mainPageStack.endLng})
77 } else if (model.mode === "MAP") {
78 mainPageStack.clear(); // Show map
76 }79 }
77 }80 }
78 }81 }
7982
=== modified file 'qml/PoiListPage.qml'
--- qml/PoiListPage.qml 2016-04-03 11:11:50 +0000
+++ qml/PoiListPage.qml 2016-04-05 19:49:15 +0000
@@ -44,8 +44,7 @@
44 if (mainPageStack.center_onpos === 2)44 if (mainPageStack.center_onpos === 2)
45 mainPageStack.center_onpos = 1;45 mainPageStack.center_onpos = 1;
46 mainPageStack.executeJavaScript("ui.markers_POI_set(" + JSON.stringify(sortedPoiModel.allPOI()) + ");")46 mainPageStack.executeJavaScript("ui.markers_POI_set(" + JSON.stringify(sortedPoiModel.allPOI()) + ");")
47 mainPageStack.pop(poiListPage.fromPage)47 mainPageStack.clear()
48 mainPageStack.pop(poiListPage)
49 }48 }
50 }49 }
51 }50 }
@@ -259,8 +258,7 @@
259 Action {258 Action {
260 iconName: "send"259 iconName: "send"
261 onTriggered: {260 onTriggered: {
262 mainPageStack.pop(poiListPage.fromPage)261 mainPageStack.clear()
263 mainPageStack.pop(poiListPage)
264 mainPageStack.center_onpos = 2;262 mainPageStack.center_onpos = 2;
265 mainPageStack.routeState = 'yes'263 mainPageStack.routeState = 'yes'
266 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");264 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");
@@ -269,8 +267,6 @@
269 Action {267 Action {
270 iconName: "non-starred"268 iconName: "non-starred"
271 onTriggered: {269 onTriggered: {
272 mainPageStack.pop(poiListPage.fromPage)
273 mainPageStack.pop(poiListPage)
274 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {isAddedFromPopup: true, lat: model.lat, lng: model.lng, favName: model.name})270 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {isAddedFromPopup: true, lat: model.lat, lng: model.lng, favName: model.name})
275 }271 }
276 },272 },
@@ -298,8 +294,7 @@
298 }294 }
299295
300 onClicked: {296 onClicked: {
301 mainPageStack.pop(poiListPage.fromPage)297 mainPageStack.clear()
302 mainPageStack.pop(poiListPage);
303 mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + ", website: \"" + model.website + "\", phone: \"" + model.phone + "\"}]);");298 mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + ", website: \"" + model.website + "\", phone: \"" + model.phone + "\"}]);");
304 }299 }
305300
306301
=== modified file 'qml/PoiPage.qml'
--- qml/PoiPage.qml 2016-03-31 18:20:06 +0000
+++ qml/PoiPage.qml 2016-04-05 19:49:15 +0000
@@ -35,14 +35,6 @@
35 header: standardHeader35 header: standardHeader
36 anchors.fill: parent36 anchors.fill: parent
3737
38 function goBackStandardMode() {
39 mainPageStack.pop(poiPage);
40 if (poiPage.fromPage === "RoutePage.qml")
41 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"));
42 if (poiPage.fromPage === "Nearby.qml")
43 mainPageStack.push(Qt.resolvedUrl("Nearby.qml"));
44 }
45
46 function goBackSearchMode() {38 function goBackSearchMode() {
47 categoryList.forceActiveFocus()39 categoryList.forceActiveFocus()
48 poiPage.header = standardHeader40 poiPage.header = standardHeader
@@ -62,7 +54,7 @@
62 iconName: "back"54 iconName: "back"
63 text: i18n.tr("Back")55 text: i18n.tr("Back")
64 onTriggered: {56 onTriggered: {
65 goBackStandardMode()57 mainPageStack.pop()
66 }58 }
67 }59 }
6860
6961
=== modified file 'qml/RoutePage.qml'
--- qml/RoutePage.qml 2016-04-01 14:18:40 +0000
+++ qml/RoutePage.qml 2016-04-05 19:49:15 +0000
@@ -62,7 +62,6 @@
62 visible: model.visible62 visible: model.visible
6363
64 onClicked: {64 onClicked: {
65 mainPageStack.pop(routePage)
66 if (model.mode === "FAVORITES") {65 if (model.mode === "FAVORITES") {
67 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))66 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))
68 } else if (model.mode === "SEARCH") {67 } else if (model.mode === "SEARCH") {
@@ -76,6 +75,7 @@
76 } else if (model.mode === "CANCEL") {75 } else if (model.mode === "CANCEL") {
77 mainPageStack.routeState = 'no';76 mainPageStack.routeState = 'no';
78 mainPageStack.executeJavaScript("click_cancel_route();")77 mainPageStack.executeJavaScript("click_cancel_route();")
78 mainPageStack.pop()
79 }79 }
80 }80 }
81 }81 }
8282
=== modified file 'qml/SearchPage.qml'
--- qml/SearchPage.qml 2016-03-30 01:01:54 +0000
+++ qml/SearchPage.qml 2016-04-05 19:49:15 +0000
@@ -30,12 +30,14 @@
30 header: PageHeader {30 header: PageHeader {
31 title: i18n.tr("Search")31 title: i18n.tr("Search")
32 flickable: statusLabel.visible ? resultsListView : historyListView32 flickable: statusLabel.visible ? resultsListView : historyListView
33 // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
34 // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
35 // at which point this back button can be removed.
33 leadingActionBar.actions: Action {36 leadingActionBar.actions: Action {
34 iconName: "back"37 iconName: "back"
35 text: i18n.tr("Back")38 text: i18n.tr("Back")
36 onTriggered: {39 onTriggered: {
37 mainPageStack.pop(searchPage)40 mainPageStack.pop()
38 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
39 }41 }
40 }42 }
4143
@@ -261,7 +263,7 @@
261 iconName: "send"263 iconName: "send"
262 visible: model.title !== i18n.tr("Nearby history")264 visible: model.title !== i18n.tr("Nearby history")
263 onTriggered: {265 onTriggered: {
264 mainPageStack.pop(searchPage);266 mainPageStack.clear();
265 mainPageStack.center_onpos = 2;267 mainPageStack.center_onpos = 2;
266 mainPageStack.routeState = 'yes';268 mainPageStack.routeState = 'yes';
267 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");269 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");
@@ -307,7 +309,7 @@
307 geoDistFactor: 5309 geoDistFactor: 5
308 })310 })
309 } else {311 } else {
310 mainPageStack.pop(searchPage);312 mainPageStack.clear();
311 mainPageStack.executeJavaScript("ui.markers_POI_set([{ title: \"" +313 mainPageStack.executeJavaScript("ui.markers_POI_set([{ title: \"" +
312 model.name + "\", lat: " +314 model.name + "\", lat: " +
313 model.lat + ", lng: " +315 model.lat + ", lng: " +
@@ -336,7 +338,7 @@
336 if (navApp.settings.saveHistory) {338 if (navApp.settings.saveHistory) {
337 UnavDB.saveToSearchHistory(model.name, model.lat, model.lng)339 UnavDB.saveToSearchHistory(model.name, model.lat, model.lng)
338 }340 }
339 mainPageStack.pop(searchPage);341 mainPageStack.clear();
340 mainPageStack.center_onpos = 2;342 mainPageStack.center_onpos = 2;
341 mainPageStack.routeState = 'yes'343 mainPageStack.routeState = 'yes'
342 mainPageStack.executeJavaScript("calc2coord(" + model.lat + "," + model.lng + ");")344 mainPageStack.executeJavaScript("calc2coord(" + model.lat + "," + model.lng + ");")
@@ -351,7 +353,6 @@
351 Action {353 Action {
352 iconName: "non-starred"354 iconName: "non-starred"
353 onTriggered: {355 onTriggered: {
354 mainPageStack.pop(searchPage)
355 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {isAddedFromPopup:true, lat: model.lat, lng: model.lng, favName: model.name})356 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {isAddedFromPopup:true, lat: model.lat, lng: model.lng, favName: model.name})
356 }357 }
357 }358 }
@@ -362,7 +363,7 @@
362 if (navApp.settings.saveHistory) {363 if (navApp.settings.saveHistory) {
363 UnavDB.saveToSearchHistory(model.name, model.lat, model.lng);364 UnavDB.saveToSearchHistory(model.name, model.lat, model.lng);
364 }365 }
365 mainPageStack.pop(searchPage);366 mainPageStack.clear();
366 mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + "}]);");367 mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + "}]);");
367 }368 }
368369
369370
=== modified file 'qml/SharePage.qml'
--- qml/SharePage.qml 2016-04-01 14:18:40 +0000
+++ qml/SharePage.qml 2016-04-05 19:49:15 +0000
@@ -27,13 +27,15 @@
27 title: i18n.tr("Share Position")27 title: i18n.tr("Share Position")
28 flickable: flickable28 flickable: flickable
29 29
30 // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
31 // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
32 // at which point this back button can be removed.
30 leadingActionBar.actions: Action {33 leadingActionBar.actions: Action {
31 iconName: "back"34 iconName: "back"
32 text: i18n.tr("Back")35 text: i18n.tr("Back")
33 shortcut: "Escape"36 shortcut: "Escape"
34 onTriggered: {37 onTriggered: {
35 mainPageStack.pop(sharePage)38 mainPageStack.pop()
36 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
37 }39 }
38 }40 }
39 }41 }
@@ -74,7 +76,7 @@
74 } else if (model.model === "DESTINATION") {76 } else if (model.model === "DESTINATION") {
75 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.endLat, "lon": mainPageStack.endLng})77 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.endLat, "lon": mainPageStack.endLng})
76 } else if (model.mode === "MAP") {78 } else if (model.mode === "MAP") {
77 mainPageStack.pop(sharePage); // Show map79 mainPageStack.clear(); // Show map
78 }80 }
79 }81 }
80 }82 }

Subscribers

People subscribed via source and target branches