From 9575a325c2abce55c7fb2c33c916252790f00352 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 14 May 2012 12:49:52 +1000 Subject: PathView was moving view too soon on drag In order to allow gesture grabbing to work correctly, the view shouldn't react to a drag until the event after the one that triggered it. Change-Id: I3b84e501aa0f82da821498fa26abe8bbf66a6252 Reviewed-by: Bea Lam --- src/quick/items/qquickpathview.cpp | 6 ++---- tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 5f912f98f4..1bc3a3a9ab 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -1345,6 +1345,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event) if (!interactive || !timer.isValid() || !model || !modelCount) return; + qint64 currentTimestamp = computeCurrentTime(event); qreal newPc; QPointF pathPoint = pointNear(event->localPos(), &newPc); if (!stealMouse) { @@ -1352,10 +1353,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event) if (qAbs(delta.x()) > qApp->styleHints()->startDragDistance() || qAbs(delta.y()) > qApp->styleHints()->startDragDistance()) { stealMouse = true; } - } - - qint64 currentTimestamp = computeCurrentTime(event); - if (stealMouse) { + } else { moveReason = QQuickPathViewPrivate::Mouse; qreal diff = (newPc - startPc)*modelCount*mappedRange; if (diff) { diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index fbe96bf672..057eb2cb64 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1231,10 +1231,15 @@ void tst_QQuickPathView::mouseDrag() QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); QGuiApplication::sendEvent(canvas, &mv); } + // first move beyond threshold does not trigger drag + QVERIFY(!pathview->isMoving()); + { QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); QGuiApplication::sendEvent(canvas, &mv); } + // next move beyond threshold does trigger drag + QVERIFY(pathview->isMoving()); QVERIFY(pathview->currentIndex() != current); -- cgit v1.2.3