From: Martin Jones Date: Mon, 21 Nov 2011 23:28:40 +0000 (+1000) Subject: Move path with highlightMoveDuration: 0 X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8d8015f8d5912300d8c6a1f8bac298163cb566b1;p=konrad%2Fqtdeclarative.git Move path with highlightMoveDuration: 0 Task-number: QTBUG-22786 Change-Id: I10043bfa5d8c622fc4e7a25bcb1f96ef43d23890 Reviewed-by: Bea Lam --- 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);