From 8d8015f8d5912300d8c6a1f8bac298163cb566b1 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 22 Nov 2011 09:28:40 +1000 Subject: [PATCH] Move path with highlightMoveDuration: 0 Task-number: QTBUG-22786 Change-Id: I10043bfa5d8c622fc4e7a25bcb1f96ef43d23890 Reviewed-by: Bea Lam --- src/declarative/items/qquickpathview.cpp | 4 +++- .../qquickpathview/tst_qquickpathview.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/src/declarative/items/qquickpathview.cpp b/src/declarative/items/qquickpathview.cpp index c7eee84..f7e58ea 100644 --- a/src/declarative/items/qquickpathview.cpp +++ b/src/declarative/items/qquickpathview.cpp @@ -1720,7 +1720,9 @@ void QQuickPathViewPrivate::snapToCurrent() const int duration = highlightMoveDuration; - if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2)) { + if (!duration) { + tl.set(moveOffset, targetOffset); + } else if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2)) { qreal distance = modelCount - targetOffset + offset; if (targetOffset > moveOffset) { tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); diff --git a/tests/auto/declarative/qquickpathview/tst_qquickpathview.cpp b/tests/auto/declarative/qquickpathview/tst_qquickpathview.cpp index 5e434b0..8b0ecc2 100644 --- a/tests/auto/declarative/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/declarative/qquickpathview/tst_qquickpathview.cpp @@ -621,6 +621,19 @@ void tst_QQuickPathView::setCurrentIndex() QCOMPARE(pathview->currentItem(), firstItem); QCOMPARE(firstItem->property("onPath"), QVariant(true)); + // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786 + model.moveItem(0, 3); + pathview->setHighlightMoveDuration(0); + pathview->setCurrentIndex(3); + QCOMPARE(pathview->currentIndex(), 3); + firstItem = findItem(pathview, "wrapper", 3); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + model.moveItem(3, 0); + pathview->setCurrentIndex(0); + pathview->setHighlightMoveDuration(300); + // Check the current item is still created when outside the bounds of pathItemCount. pathview->setPathItemCount(2); pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange); -- 1.7.2.5