, offset(0.0), offsetAdj(0.0), mappedRange(1.0)
, stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
, autoHighlight(true), highlightUp(false), layoutScheduled(false)
- , moving(false), flicking(false), requestedOnPath(false), inRequest(false)
+ , moving(false), flicking(false), dragging(false), requestedOnPath(false), inRequest(false)
, dragMargin(0), deceleration(100), maximumFlickVelocity(QML_FLICK_DEFAULTMAXVELOCITY)
, moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset), flickDuration(0)
, firstIndex(-1), pathItems(-1), requestedIndex(-1), requestedZ(0)
q->refill();
}
+void QQuickPathViewPrivate::setDragging(bool d)
+{
+ Q_Q(QQuickPathView);
+ if (dragging == d)
+ return;
+
+ dragging = d;
+ if (dragging)
+ emit q->dragStarted();
+ else
+ emit q->dragEnded();
+
+ emit q->draggingChanged();
+}
+
/*!
\qmlclass PathView QQuickPathView
\inqmlmodule QtQuick 2
}
/*!
+ \qmlproperty bool QtQuick2::PathView::dragging
+
+ This property holds whether the view is currently moving
+ due to the user dragging the view.
+*/
+bool QQuickPathView::isDragging() const
+{
+ Q_D(const QQuickPathView);
+ return d->dragging;
+}
+
+/*!
\qmlsignal QtQuick2::PathView::onMovementStarted()
This handler is called when the view begins moving due to user
*/
/*!
+ \qmlsignal QtQuick2::PathView::onDragStarted()
+
+ This handler is called when the view starts to be dragged due to user
+ interaction.
+*/
+
+/*!
+ \qmlsignal QtQuick2::PathView::onDragEnded()
+
+ This handler is called when the user stops dragging the view.
+
+ If the velocity of the drag is suffient at the time the
+ touch/mouse button is released then a flick will start.
+*/
+
+/*!
\qmlproperty Component QtQuick2::PathView::delegate
The delegate provides a template defining each item instantiated by the view.
emit q->movingChanged();
emit q->movementStarted();
}
+ setDragging(true);
}
startPc = newPc;
lastPosTime = currentTimestamp;
Q_Q(QQuickPathView);
stealMouse = false;
q->setKeepMouseGrab(false);
+ setDragging(false);
if (!interactive || !timer.isValid() || !model || !modelCount) {
timer.invalidate();
if (!tl.isActive())
setKeepMouseGrab(false);
d->timer.invalidate();
d->fixOffset();
+ d->setDragging(false);
if (!d->tl.isActive())
movementEnding();
}
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
QVERIFY(pathview != 0);
+ QSignalSpy movingSpy(pathview, SIGNAL(movingChanged()));
+ QSignalSpy moveStartedSpy(pathview, SIGNAL(movementStarted()));
+ QSignalSpy moveEndedSpy(pathview, SIGNAL(movementEnded()));
+ QSignalSpy draggingSpy(pathview, SIGNAL(draggingChanged()));
+ QSignalSpy dragStartedSpy(pathview, SIGNAL(dragStarted()));
+ QSignalSpy dragEndedSpy(pathview, SIGNAL(dragEnded()));
+
int current = pathview->currentIndex();
QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
}
// first move beyond threshold does not trigger drag
QVERIFY(!pathview->isMoving());
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(movingSpy.count(), 0);
+ QCOMPARE(moveStartedSpy.count(), 0);
+ QCOMPARE(moveEndedSpy.count(), 0);
+ QCOMPARE(draggingSpy.count(), 0);
+ QCOMPARE(dragStartedSpy.count(), 0);
+ QCOMPARE(dragEndedSpy.count(), 0);
{
QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
}
// next move beyond threshold does trigger drag
QVERIFY(pathview->isMoving());
+ QVERIFY(pathview->isDragging());
+ QCOMPARE(movingSpy.count(), 1);
+ QCOMPARE(moveStartedSpy.count(), 1);
+ QCOMPARE(moveEndedSpy.count(), 0);
+ QCOMPARE(draggingSpy.count(), 1);
+ QCOMPARE(dragStartedSpy.count(), 1);
+ QCOMPARE(dragEndedSpy.count(), 0);
QVERIFY(pathview->currentIndex() != current);
QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(draggingSpy.count(), 2);
+ QCOMPARE(dragStartedSpy.count(), 1);
+ QCOMPARE(dragEndedSpy.count(), 1);
+ QTRY_COMPARE(movingSpy.count(), 2);
+ QTRY_COMPARE(moveEndedSpy.count(), 1);
+ QCOMPARE(moveStartedSpy.count(), 1);
delete canvas;
}
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
QVERIFY(pathview != 0);
+ QSignalSpy draggingSpy(pathview, SIGNAL(draggingChanged()));
+ QSignalSpy dragStartedSpy(pathview, SIGNAL(dragStarted()));
+ QSignalSpy dragEndedSpy(pathview, SIGNAL(dragEnded()));
+
// drag between snap points
QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
QTest::qWait(100);
QTRY_VERIFY(pathview->offset() != qFloor(pathview->offset()));
QTRY_VERIFY(pathview->isMoving());
+ QVERIFY(pathview->isDragging());
+ QCOMPARE(draggingSpy.count(), 1);
+ QCOMPARE(dragStartedSpy.count(), 1);
+ QCOMPARE(dragEndedSpy.count(), 0);
// steal mouse grab - cancels PathView dragging
QQuickItem *item = canvas->rootObject()->findChild<QQuickItem*>("text");
// returns to a snap point.
QTRY_VERIFY(pathview->offset() == qFloor(pathview->offset()));
QTRY_VERIFY(!pathview->isMoving());
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(draggingSpy.count(), 2);
+ QCOMPARE(dragStartedSpy.count(), 1);
+ QCOMPARE(dragEndedSpy.count(), 1);
QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));