From 589d39ec6c35edc1ba195474be30dfcf8c31598d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 27 Jun 2012 15:29:54 +1000 Subject: [PATCH] PathView element with 1 item moves in wrong direction when dragged right The shortest direction calculation used integer math to determine which direction to move. For an odd modelCount, the wrong direction could be chosen. For a modelCount of 1 it was particularly obvious. Task-number: QTBUG-21337 Change-Id: I5e75c74153a5b4c62d1536226cd0703dcae04178 Reviewed-by: Andrew den Exter --- src/quick/items/qquickpathview.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index e96e988..33c5b8c 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -1926,7 +1926,7 @@ void QQuickPathViewPrivate::snapToIndex(int index) if (!duration) { tl.set(moveOffset, targetOffset); - } else if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2)) { + } else if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2.0)) { qreal distance = modelCount - targetOffset + offset; if (targetOffset > moveOffset) { tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); @@ -1935,7 +1935,7 @@ void QQuickPathViewPrivate::snapToIndex(int index) } else { tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); } - } else if (moveDirection == Negative || targetOffset - offset <= -modelCount/2) { + } else if (moveDirection == Negative || targetOffset - offset <= -modelCount/2.0) { qreal distance = modelCount - offset + targetOffset; if (targetOffset < moveOffset) { tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance)); -- 1.7.2.5