@@ -60,7 +60,34 @@ IndicatorBase {
60 // Only allow flicking if the content doesn't fit on the page
60 // Only allow flicking if the content doesn't fit on the page
61 interactive: contentHeight > height
61 interactive: contentHeight > height
63+ property int selectedIndex: -1
64+ property bool blockCurrentIndexChange: false
67+ if (count == 0 && selectedIndex != -1) {
71+ // for highlight following
72+ onSelectedIndexChanged: {
63− currentIndex: -1
73+ if (currentIndex != selectedIndex) {
74+ var blocked = blockCurrentIndexChange;
75+ blockCurrentIndexChange = true;
77+ currentIndex = selectedIndex;
79+ blockCurrentIndexChange = blocked;
82+ // for item addition/removal
83+ onCurrentIndexChanged: {
84+ if (!blockCurrentIndexChange) {
85+ if (selectedIndex != -1 && selectedIndex != currentIndex) {
86+ selectedIndex = currentIndex;
64 delegate: Item {
91 delegate: Item {
65 id: menuDelegate
92 id: menuDelegate
@@ -90,9 +117,9 @@ IndicatorBase {
92 if (item.hasOwnProperty("menuSelected")) {
119 if (item.hasOwnProperty("menuSelected")) {
93− item.menuSelected = Qt.binding(function() { return mainMenu.currentIndex == index; });
120+ item.menuSelected = Qt.binding(function() { return mainMenu.selectedIndex == index; });
94− item.selectMenu.connect(function() { mainMenu.currentIndex = index; });
121+ item.selectMenu.connect(function() { mainMenu.selectedIndex = index; });
95− item.deselectMenu.connect(function() { mainMenu.currentIndex = -1; });
122+ item.deselectMenu.connect(function() { mainMenu.selectedIndex = -1; });
97 if (item.hasOwnProperty("menu")) {
124 if (item.hasOwnProperty("menu")) {
98 item.menu = Qt.binding(function() { return model; });
125 item.menu = Qt.binding(function() { return model; });
@@ -149,7 +176,7 @@ IndicatorBase {
150 function reset()
177 function reset()
152− mainMenu.currentIndex = -1;
179+ mainMenu.selectedIndex = -1;
153 mainMenu.positionViewAtBeginning();
180 mainMenu.positionViewAtBeginning();