@@ -54,6 +54,20 @@ Item {
5454 id: headersColumn
5555 anchors.top: parent.top
5656 width: parent.width
57+
58+ function pop(popsNeeded) {
59+ if (popsNeeded == 0)
60+ return;
61+ isEnteringChildren = false;
62+ navigationListView.currentIndex = navigationListView.currentIndex - popsNeeded;
63+ navigationModel.setProperty(navigationListView.currentIndex, "nullifyNavigation", false);
64+ navigationModel.remove(navigationModel.count - popsNeeded, popsNeeded);
65+
66+ popsNeeded = Math.min(headersModel.count, popsNeeded);
67+ // This is effectively deleting ourselves, so needs to be the last thing of the function
68+ headersModel.remove(headersModel.count - popsNeeded, popsNeeded);
69+ }
70+
5771 Repeater {
5872 model: ListModel {
5973 id: headersModel
@@ -71,31 +85,18 @@ Item {
7185 text: headerText
7286 foregroundColor: d.foregroundColor
7387
74− function pop(popsNeeded) {
75− if (popsNeeded == 0)
76− return;
77− isEnteringChildren = false;
78− navigationListView.currentIndex = navigationListView.currentIndex - popsNeeded;
79− navigationModel.setProperty(navigationListView.currentIndex, "nullifyNavigation", false);
80− navigationModel.remove(navigationModel.count - popsNeeded, popsNeeded);
81−
82− popsNeeded = Math.min(headersModel.count, popsNeeded);
83− // This is effectively deleting ourselves, so needs to be the last thing of the function
84− headersModel.remove(headersModel.count - popsNeeded, popsNeeded);
85− }
86−
8788 onBackClicked: {
8889 scope.setNavigationState(parentNavigationId);
8990
9091 var popsNeeded = headersModel.count - index;
91− pop(popsNeeded);
92+ headersColumn.pop(popsNeeded);
9293 }
9394
9495 onTextClicked: {
9596 scope.setNavigationState(navigationId);
9697
9798 var popsNeeded = headersModel.count - index - 1;
98− pop(popsNeeded);
99+ headersColumn.pop(popsNeeded);
99100
100101 root.leafClicked();
101102 }