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
1=== modified file 'qml/Coordinate.qml'
2--- qml/Coordinate.qml 2016-04-03 10:34:22 +0000
3+++ qml/Coordinate.qml 2016-04-05 19:49:15 +0000
4@@ -101,7 +101,7 @@
5 mainPageStack.clickedLng = parseFloat(aux_lng).toFixed(5);
6 if (mainPageStack.center_onpos === 2)
7 mainPageStack.center_onpos = 1;
8- mainPageStack.pop(coordPage);
9+ mainPageStack.clear();
10 mainPageStack.executeJavaScript(
11 "ui.markers_POI_set([{title: '', lat: " + mainPageStack.clickedLat + ", lng: " + mainPageStack.clickedLng + "}]);"
12 );
13@@ -305,7 +305,7 @@
14 mainPageStack.clickedLng = parseFloat(aux_lng).toFixed(5);
15 if (mainPageStack.center_onpos === 2)
16 mainPageStack.center_onpos = 1;
17- mainPageStack.pop(coordPage);
18+ mainPageStack.clear();
19 mainPageStack.executeJavaScript(
20 "ui.markers_POI_set([{title: '', lat: " + mainPageStack.clickedLat + ", lng: " + mainPageStack.clickedLng + "}]);"
21 );
22
23=== modified file 'qml/FavoritesPage.qml'
24--- qml/FavoritesPage.qml 2016-04-03 08:11:41 +0000
25+++ qml/FavoritesPage.qml 2016-04-05 19:49:15 +0000
26@@ -59,14 +59,16 @@
27 visible: header === standardHeader
28 z: 500
29 flickable: favoritesListView
30+ // #FIXME: This back button is only here to allow the user to press Escape 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.
33 leadingActionBar.actions: Action {
34 iconName: "back"
35 text: i18n.tr("Back")
36 shortcut: "Escape"
37 enabled: header === standardHeader
38 onTriggered: {
39- mainPageStack.pop(favoritesPage)
40- mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
41+ mainPageStack.pop()
42 }
43 }
44 trailingActionBar.actions: Action {
45@@ -130,7 +132,7 @@
46 Action {
47 iconName: "send"
48 onTriggered: {
49- mainPageStack.pop(favoritesPage);
50+ mainPageStack.clear();
51 mainPageStack.center_onpos = 2;
52 mainPageStack.routeState = 'yes';
53 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");
54@@ -162,7 +164,7 @@
55 }
56
57 onClicked: {
58- mainPageStack.pop(favoritesPage);
59+ mainPageStack.clear()
60 if (navApp.settings.saveHistory) {
61 UnavDB.saveTofavHistory(model.name, model.lat, model.lng);
62 }
63@@ -215,7 +217,7 @@
64 }
65 Action {
66 text: i18n.tr("Add From Map")
67- onTriggered: mainPageStack.pop(favoritesPage);
68+ onTriggered: mainPageStack.clear()
69 }
70 }
71 }
72
73=== modified file 'qml/Nearby.qml'
74--- qml/Nearby.qml 2016-04-01 14:18:40 +0000
75+++ qml/Nearby.qml 2016-04-05 19:49:15 +0000
76@@ -26,13 +26,15 @@
77 title: i18n.tr("Nearby")
78 flickable: flickable
79
80+ // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
81+ // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
82+ // at which point this back button can be removed.
83 leadingActionBar.actions: Action {
84 iconName: "back"
85 text: i18n.tr("Back")
86 shortcut: "Escape"
87 onTriggered: {
88- mainPageStack.pop(nearbyPage)
89- mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
90+ mainPageStack.pop()
91 }
92 }
93 }
94@@ -68,11 +70,12 @@
95 icon.source: model.source
96
97 onClicked: {
98- mainPageStack.pop(nearbyPage);
99 if (model.mode === "CURRENT") {
100 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.currentLat, "lng": mainPageStack.currentLng})
101 } else if (model.mode === "DESTINATION") {
102 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.endLat, "lng": mainPageStack.endLng})
103+ } else if (model.mode === "MAP") {
104+ mainPageStack.clear(); // Show map
105 }
106 }
107 }
108
109=== modified file 'qml/PoiListPage.qml'
110--- qml/PoiListPage.qml 2016-04-03 11:11:50 +0000
111+++ qml/PoiListPage.qml 2016-04-05 19:49:15 +0000
112@@ -44,8 +44,7 @@
113 if (mainPageStack.center_onpos === 2)
114 mainPageStack.center_onpos = 1;
115 mainPageStack.executeJavaScript("ui.markers_POI_set(" + JSON.stringify(sortedPoiModel.allPOI()) + ");")
116- mainPageStack.pop(poiListPage.fromPage)
117- mainPageStack.pop(poiListPage)
118+ mainPageStack.clear()
119 }
120 }
121 }
122@@ -259,8 +258,7 @@
123 Action {
124 iconName: "send"
125 onTriggered: {
126- mainPageStack.pop(poiListPage.fromPage)
127- mainPageStack.pop(poiListPage)
128+ mainPageStack.clear()
129 mainPageStack.center_onpos = 2;
130 mainPageStack.routeState = 'yes'
131 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");
132@@ -269,8 +267,6 @@
133 Action {
134 iconName: "non-starred"
135 onTriggered: {
136- mainPageStack.pop(poiListPage.fromPage)
137- mainPageStack.pop(poiListPage)
138 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {isAddedFromPopup: true, lat: model.lat, lng: model.lng, favName: model.name})
139 }
140 },
141@@ -298,8 +294,7 @@
142 }
143
144 onClicked: {
145- mainPageStack.pop(poiListPage.fromPage)
146- mainPageStack.pop(poiListPage);
147+ mainPageStack.clear()
148 mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + ", website: \"" + model.website + "\", phone: \"" + model.phone + "\"}]);");
149 }
150
151
152=== modified file 'qml/PoiPage.qml'
153--- qml/PoiPage.qml 2016-03-31 18:20:06 +0000
154+++ qml/PoiPage.qml 2016-04-05 19:49:15 +0000
155@@ -35,14 +35,6 @@
156 header: standardHeader
157 anchors.fill: parent
158
159- function goBackStandardMode() {
160- mainPageStack.pop(poiPage);
161- if (poiPage.fromPage === "RoutePage.qml")
162- mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"));
163- if (poiPage.fromPage === "Nearby.qml")
164- mainPageStack.push(Qt.resolvedUrl("Nearby.qml"));
165- }
166-
167 function goBackSearchMode() {
168 categoryList.forceActiveFocus()
169 poiPage.header = standardHeader
170@@ -62,7 +54,7 @@
171 iconName: "back"
172 text: i18n.tr("Back")
173 onTriggered: {
174- goBackStandardMode()
175+ mainPageStack.pop()
176 }
177 }
178
179
180=== modified file 'qml/RoutePage.qml'
181--- qml/RoutePage.qml 2016-04-01 14:18:40 +0000
182+++ qml/RoutePage.qml 2016-04-05 19:49:15 +0000
183@@ -62,7 +62,6 @@
184 visible: model.visible
185
186 onClicked: {
187- mainPageStack.pop(routePage)
188 if (model.mode === "FAVORITES") {
189 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))
190 } else if (model.mode === "SEARCH") {
191@@ -76,6 +75,7 @@
192 } else if (model.mode === "CANCEL") {
193 mainPageStack.routeState = 'no';
194 mainPageStack.executeJavaScript("click_cancel_route();")
195+ mainPageStack.pop()
196 }
197 }
198 }
199
200=== modified file 'qml/SearchPage.qml'
201--- qml/SearchPage.qml 2016-03-30 01:01:54 +0000
202+++ qml/SearchPage.qml 2016-04-05 19:49:15 +0000
203@@ -30,12 +30,14 @@
204 header: PageHeader {
205 title: i18n.tr("Search")
206 flickable: statusLabel.visible ? resultsListView : historyListView
207+ // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
208+ // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
209+ // at which point this back button can be removed.
210 leadingActionBar.actions: Action {
211 iconName: "back"
212 text: i18n.tr("Back")
213 onTriggered: {
214- mainPageStack.pop(searchPage)
215- mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
216+ mainPageStack.pop()
217 }
218 }
219
220@@ -261,7 +263,7 @@
221 iconName: "send"
222 visible: model.title !== i18n.tr("Nearby history")
223 onTriggered: {
224- mainPageStack.pop(searchPage);
225+ mainPageStack.clear();
226 mainPageStack.center_onpos = 2;
227 mainPageStack.routeState = 'yes';
228 mainPageStack.executeJavaScript("calc2coord("+ model.lat + "," + model.lng + ");");
229@@ -307,7 +309,7 @@
230 geoDistFactor: 5
231 })
232 } else {
233- mainPageStack.pop(searchPage);
234+ mainPageStack.clear();
235 mainPageStack.executeJavaScript("ui.markers_POI_set([{ title: \"" +
236 model.name + "\", lat: " +
237 model.lat + ", lng: " +
238@@ -336,7 +338,7 @@
239 if (navApp.settings.saveHistory) {
240 UnavDB.saveToSearchHistory(model.name, model.lat, model.lng)
241 }
242- mainPageStack.pop(searchPage);
243+ mainPageStack.clear();
244 mainPageStack.center_onpos = 2;
245 mainPageStack.routeState = 'yes'
246 mainPageStack.executeJavaScript("calc2coord(" + model.lat + "," + model.lng + ");")
247@@ -351,7 +353,6 @@
248 Action {
249 iconName: "non-starred"
250 onTriggered: {
251- mainPageStack.pop(searchPage)
252 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"), {isAddedFromPopup:true, lat: model.lat, lng: model.lng, favName: model.name})
253 }
254 }
255@@ -362,7 +363,7 @@
256 if (navApp.settings.saveHistory) {
257 UnavDB.saveToSearchHistory(model.name, model.lat, model.lng);
258 }
259- mainPageStack.pop(searchPage);
260+ mainPageStack.clear();
261 mainPageStack.executeJavaScript("ui.markers_POI_set([{title: \"" + model.name + "\", lat: " + model.lat + ", lng: " + model.lng + "}]);");
262 }
263
264
265=== modified file 'qml/SharePage.qml'
266--- qml/SharePage.qml 2016-04-01 14:18:40 +0000
267+++ qml/SharePage.qml 2016-04-05 19:49:15 +0000
268@@ -27,13 +27,15 @@
269 title: i18n.tr("Share Position")
270 flickable: flickable
271
272+ // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
273+ // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
274+ // at which point this back button can be removed.
275 leadingActionBar.actions: Action {
276 iconName: "back"
277 text: i18n.tr("Back")
278 shortcut: "Escape"
279 onTriggered: {
280- mainPageStack.pop(sharePage)
281- mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
282+ mainPageStack.pop()
283 }
284 }
285 }
286@@ -74,7 +76,7 @@
287 } else if (model.model === "DESTINATION") {
288 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.endLat, "lon": mainPageStack.endLng})
289 } else if (model.mode === "MAP") {
290- mainPageStack.pop(sharePage); // Show map
291+ mainPageStack.clear(); // Show map
292 }
293 }
294 }

Subscribers

People subscribed via source and target branches