@@ -60,7 +60,34 @@ IndicatorBase {
6060 // Only allow flicking if the content doesn't fit on the page
6161 interactive: contentHeight > height
6262
63− currentIndex: -1
63+ property int selectedIndex: -1
64+ property bool blockCurrentIndexChange: false
65+ // for count = 0
66+ onCountChanged: {
67+ if (count == 0 && selectedIndex != -1) {
68+ selectedIndex = -1;
69+ }
70+ }
71+ // for highlight following
72+ onSelectedIndexChanged: {
73+ if (currentIndex != selectedIndex) {
74+ var blocked = blockCurrentIndexChange;
75+ blockCurrentIndexChange = true;
76+
77+ currentIndex = selectedIndex;
78+
79+ blockCurrentIndexChange = blocked;
80+ }
81+ }
82+ // for item addition/removal
83+ onCurrentIndexChanged: {
84+ if (!blockCurrentIndexChange) {
85+ if (selectedIndex != -1 && selectedIndex != currentIndex) {
86+ selectedIndex = currentIndex;
87+ }
88+ }
89+ }
90+
6491 delegate: Item {
6592 id: menuDelegate
6693
@@ -90,9 +117,9 @@ IndicatorBase {
90117 }
91118
92119 if (item.hasOwnProperty("menuSelected")) {
93− item.menuSelected = Qt.binding(function() { return mainMenu.currentIndex == index; });
94− item.selectMenu.connect(function() { mainMenu.currentIndex = index; });
95− item.deselectMenu.connect(function() { mainMenu.currentIndex = -1; });
120+ item.menuSelected = Qt.binding(function() { return mainMenu.selectedIndex == index; });
121+ item.selectMenu.connect(function() { mainMenu.selectedIndex = index; });
122+ item.deselectMenu.connect(function() { mainMenu.selectedIndex = -1; });
96123 }
97124 if (item.hasOwnProperty("menu")) {
98125 item.menu = Qt.binding(function() { return model; });
@@ -149,7 +176,7 @@ IndicatorBase {
149176
150177 function reset()
151178 {
152− mainMenu.currentIndex = -1;
179+ mainMenu.selectedIndex = -1;
153180 mainMenu.positionViewAtBeginning();
154181 }
155182}