From 8454a21b837ccf3968f6dbc56ed4f06d60d63c8f Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 23 Jul 2014 15:40:42 +0200 Subject: Flickable: Cancel interaction on interactive changes Otherwise if you have a listview with a flickable inside with a mouseare inside the pressed is never set to false if you make the interactive property of the outer list depend on the moving of the inner flickable. This makes that when later you change currentIndex of the list and you have StrictlyEnforceRange set, the list won't move because it still thinks it is pressed Change-Id: I2c2021f486fc0a31840c3f2199bc7cb76dc01e3e Reviewed-by: Martin Jones --- tests/auto/qmltest/listview/tst_listview.qml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests') diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml index 03be57909f..069b62a726 100644 --- a/tests/auto/qmltest/listview/tst_listview.qml +++ b/tests/auto/qmltest/listview/tst_listview.qml @@ -108,6 +108,33 @@ Item { property int createdDelegates: 0 } + ListView + { + id: listInteractiveCurrentIndexEnforce + width: 600 + height: 600 + + snapMode: ListView.SnapOneItem + orientation: ListView.Horizontal + interactive: !currentItem.moving + highlightRangeMode: ListView.StrictlyEnforceRange + + model: 4 + + focus: true + Keys.onPressed: if (event.key == Qt.Key_K) currentIndex = currentIndex + 1; + + delegate: Flickable { + width: 600 + height: 600 + contentWidth: 600 + contentHeight: 1200 + + MouseArea { anchors.fill: parent } + Rectangle { anchors.fill: parent; color: index == 0 ? "red" : index == 1 ? "green" : index == 2 ? "blue" : "white" } + } + } + Component { id: delegateModelAfterCreateComponent Rectangle { @@ -272,5 +299,19 @@ Item { listViewDelegateModelAfterCreate.model = 40; verify(listViewDelegateModelAfterCreate.createdDelegates > 0); } + + function test_listInteractiveCurrentIndexEnforce() { + mousePress(listInteractiveCurrentIndexEnforce, 10, 50); + mouseMove(listInteractiveCurrentIndexEnforce, 10, 40); + mouseMove(listInteractiveCurrentIndexEnforce, 10, 30); + mouseMove(listInteractiveCurrentIndexEnforce, 10, 20); + mouseMove(listInteractiveCurrentIndexEnforce, 10, 10); + compare(listInteractiveCurrentIndexEnforce.interactive, false); + mouseRelease(listInteractiveCurrentIndexEnforce, 10, 10); + tryCompare(listInteractiveCurrentIndexEnforce, "interactive", true); + keyClick("k"); + compare(listInteractiveCurrentIndexEnforce.currentIndex, 1); + tryCompare(listInteractiveCurrentIndexEnforce, "contentX", listInteractiveCurrentIndexEnforce.width); + } } } -- cgit v1.2.3