diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2019-05-06 14:09:11 +0200 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2019-05-07 11:17:58 +0000 |
commit | 9310d5fb5285ae5eb4b94c01606791319b775b85 (patch) | |
tree | 5f951759082b5eca0781c0cddef812271614da4a /tests | |
parent | 7d001497ddcda501c55aac35b4c7a60980d9c6b5 (diff) |
Container: Keep currentIndex at 0 when removing item 0 if possible
Current behavior is to always decrement the currentIndex when the current item
is removed -- even when the current item is item 0. This means, for example,
that in a TabBar with three tabs and the first tab selected closing the first
tab will leave nothing at all selected.
Change behavior to keep currentIndex at 0 if there are still items left in the
container. Now closing the first tab will leave the next remaining tab selected.
Change-Id: If4e1903366e29fcee8226b776d5b2e03cec189df
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_tabbar.qml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml index 519b1d53..42e767f2 100644 --- a/tests/auto/controls/data/tst_tabbar.qml +++ b/tests/auto/controls/data/tst_tabbar.qml @@ -270,6 +270,29 @@ TestCase { compare(contentChildrenSpy.count, 12) } + function test_removeCurrent() { + var control = createTemporaryObject(tabBar, testCase) + + control.addItem(tabButton.createObject(control, {text: "1"})) + control.addItem(tabButton.createObject(control, {text: "2"})) + control.addItem(tabButton.createObject(control, {text: "3"})) + control.currentIndex = 1 + compare(control.count, 3) + compare(control.currentIndex, 1) + + control.removeItem(1) + compare(control.count, 2) + compare(control.currentIndex, 0) + + control.removeItem(0) + compare(control.count, 1) + compare(control.currentIndex, 0) + + control.removeItem(0) + compare(control.count, 0) + compare(control.currentIndex, -1) + } + Component { id: contentBar TabBar { |