PathView was moving view too soon on drag
authorMartin Jones <martin.jones@nokia.com>
Mon, 14 May 2012 02:49:52 +0000 (12:49 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 14 May 2012 03:37:29 +0000 (05:37 +0200)
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 <bea.lam@nokia.com>
src/quick/items/qquickpathview.cpp
tests/auto/quick/qquickpathview/tst_qquickpathview.cpp

index 5f912f9..1bc3a3a 100644 (file)
@@ -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) {
index fbe96bf..057eb2c 100644 (file)
@@ -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);