@@ -32,7 +32,7 @@ Item {
32 // internal
32 // internal
33 readonly property var currentNavigation: scope && scope.hasNavigation ? scope.getNavigation(scope.currentNavigationId) : null
33 readonly property var currentNavigation: scope && scope.hasNavigation ? scope.getNavigation(scope.currentNavigationId) : null
34 // Are we drilling down the tree or up?
34 // Are we drilling down the tree or up?
35− property bool isGoingBack: false
35+ property bool isEnteringChildren: false
37 visible: height != 0
37 visible: height != 0
38 implicitHeight: navigationListView.y + navigationListView.height
38 implicitHeight: navigationListView.y + navigationListView.height
@@ -57,13 +57,17 @@ Item {
57 // parentNavigationId: the parent navigation Id
57 // parentNavigationId: the parent navigation Id
59 delegate: DashNavigationHeader {
59 delegate: DashNavigationHeader {
60− height: units.gu(5)
60+ height: index == 0 && headersModel.count > 1 ? 0 : units.gu(5)
61 width: parent.width
61 width: parent.width
63+ backVisible: index != 0
63 text: headerText
64 text: headerText
64 foregroundColor: d.foregroundColor
65 foregroundColor: d.foregroundColor
66 function pop(popsNeeded) {
67 function pop(popsNeeded) {
70+ isEnteringChildren = false;
67 navigationListView.currentIndex = navigationListView.currentIndex - popsNeeded;
71 navigationListView.currentIndex = navigationListView.currentIndex - popsNeeded;
68 navigationModel.setProperty(navigationListView.currentIndex, "nullifyNavigation", false);
72 navigationModel.setProperty(navigationListView.currentIndex, "nullifyNavigation", false);
69 navigationModel.remove(navigationModel.count - popsNeeded, popsNeeded);
73 navigationModel.remove(navigationModel.count - popsNeeded, popsNeeded);
@@ -76,7 +80,7 @@ Item {
76 onBackClicked: {
80 onBackClicked: {
77 scope.setNavigationState(parentNavigationId);
81 scope.setNavigationState(parentNavigationId);
79− var popsNeeded = headersModel.count - index + 1;
83+ var popsNeeded = headersModel.count - index;
80 pop(popsNeeded);
84 pop(popsNeeded);
@@ -84,7 +88,7 @@ Item {
84 root.leafClicked();
88 root.leafClicked();
85 scope.setNavigationState(navigationId);
89 scope.setNavigationState(navigationId);
87− var popsNeeded = headersModel.count - index;
91+ var popsNeeded = headersModel.count - index - 1;
88 pop(popsNeeded);
92 pop(popsNeeded);
@@ -124,6 +128,7 @@ Item {
124 objectName: "navigation" + index
128 objectName: "navigation" + index
125 visible: height > 0
129 visible: height > 0
126 width: navigationListView.width
130 width: navigationListView.width
131+ itemsIndent: index != 0 ? units.gu(5) : 0
127 scopeStyle: root.scopeStyle
132 scopeStyle: root.scopeStyle
128 foregroundColor: d.foregroundColor
133 foregroundColor: d.foregroundColor
129 property real desiredHeight: {
134 property real desiredHeight: {
@@ -138,61 +143,29 @@ Item {
138 height: desiredHeight
143 height: desiredHeight
139 navigation: (nullifyNavigation || !scope) ? null : scope.getNavigation(navigationId)
144 navigation: (nullifyNavigation || !scope) ? null : scope.getNavigation(navigationId)
140 currentNavigation: root.currentNavigation
145 currentNavigation: root.currentNavigation
141− onEnterNavigation: {
146+ onEnterNavigation: { // var newNavigationId, string newNavigationLabel, bool hasChildren
142 scope.setNavigationState(newNavigationId);
147 scope.setNavigationState(newNavigationId);
143 // We only need to add a new item to the model
148 // We only need to add a new item to the model
144 // if we have children, otherwise just load it
149 // if we have children, otherwise just load it
145 if (hasChildren) {
150 if (hasChildren) {
146− isGoingBack = false;
151+ isEnteringChildren = true;
147 navigationModel.append({"navigationId": newNavigationId, "nullifyNavigation": false});
152 navigationModel.append({"navigationId": newNavigationId, "nullifyNavigation": false});
148− if (navigationModel.count > 2) {
149− headersModel.append({"headerText": navigation.allLabel != "" ? navigation.allLabel : navigation.label,
153+ headersModel.append({"headerText": newNavigationLabel,
150− "navigationId": navigationId,
154+ "navigationId": newNavigationId,
151− "parentNavigationId": navigation.parentNavigationId
155+ "parentNavigationId": navigationId
154 navigationListView.currentIndex++;
157 navigationListView.currentIndex++;
156 root.leafClicked();
159 root.leafClicked();
159− onGoBackToParentClicked: {
160− if (navigationListView.currentIndex == 0) {
161− // This can happen if we jumped to the non root of a deep tree and the user
162− // is now going back, create space in the list for the list to move "left"
163− var aux = navigationListView.highlightMoveDuration;
164− navigationListView.highlightMoveDuration = 0;
165− navigationModel.insert(0, {"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
166− navigationListView.currentIndex = navigationListView.currentIndex + 1;
167− navigationListView.contentX = width * navigationListView.currentIndex;
168− navigationListView.highlightMoveDuration = aux;
171− scope.setNavigationState(navigation.parentNavigationId);
173− navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", false);
174− navigationListView.currentIndex--;
176− if (headersModel.count > 0) {
177− headersModel.remove(headersModel.count - 1);
180− onAllNavigationClicked: {
182− if (root.currentNavigation.parentNavigationId == navigation.navigationId) {
183− // For leaves we have to go to the parent too
184− scope.setNavigationState(root.currentNavigation.parentNavigationId);
188 onContentXChanged: {
163 onContentXChanged: {
189 if (navigationListView.highlightMoveDuration == 0)
164 if (navigationListView.highlightMoveDuration == 0)
192 if (contentX == width * navigationListView.currentIndex) {
167 if (contentX == width * navigationListView.currentIndex) {
193− if (isGoingBack) {
168+ if (isEnteringChildren) {
194− navigationModel.remove(navigationListView.currentIndex + 1);
196 navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", true);
169 navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", true);
@@ -224,6 +197,10 @@ Item {
225 navigationModel.append({"navigationId": currentNavigation.parentNavigationId, "nullifyNavigation": false});
198 navigationModel.append({"navigationId": currentNavigation.parentNavigationId, "nullifyNavigation": false});
200+ headersModel.append({"headerText": currentNavigation.label,
201+ "navigationId": currentNavigation.navigationId,
202+ "parentNavigationId": currentNavigation.parentNavigationId
229 Connections {
206 Connections {