diff options
author | Martin Jones <[email protected]> | 2012-07-03 13:57:54 +1000 |
---|---|---|
committer | Qt by Nokia <[email protected]> | 2012-07-04 10:12:10 +0200 |
commit | 6a013bf73b27f112bc7cff04225b92d893804b29 (patch) | |
tree | a9f9264c6470731398a27fef83e6c924f80809f0 /src/quick/items/qquickpathview.cpp | |
parent | b9c039b3ac76d20ffe2d05259d5406b7c1bac25d (diff) |
PathView needs drag events similar to Flickable
Added dragging property and dragStarted() and dragEnded() signals.
Task-number: QTBUG-21740
Change-Id: I718835ff7e46af615951ec5f248eba41bac31071
Reviewed-by: Andrew den Exter <[email protected]>
Diffstat (limited to 'src/quick/items/qquickpathview.cpp')
-rw-r--r-- | src/quick/items/qquickpathview.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 33c5b8c9ed..afa988a9b7 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -118,7 +118,7 @@ QQuickPathViewPrivate::QQuickPathViewPrivate() , 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) @@ -435,6 +435,21 @@ void QQuickPathViewPrivate::regenerate() 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 @@ -1078,6 +1093,18 @@ bool QQuickPathView::isFlicking() const } /*! + \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 @@ -1109,6 +1136,22 @@ bool QQuickPathView::isFlicking() const */ /*! + \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. @@ -1377,6 +1420,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event) emit q->movingChanged(); emit q->movementStarted(); } + setDragging(true); } startPc = newPc; lastPosTime = currentTimestamp; @@ -1399,6 +1443,7 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *) Q_Q(QQuickPathView); stealMouse = false; q->setKeepMouseGrab(false); + setDragging(false); if (!interactive || !timer.isValid() || !model || !modelCount) { timer.invalidate(); if (!tl.isActive()) @@ -1535,6 +1580,7 @@ void QQuickPathView::mouseUngrabEvent() setKeepMouseGrab(false); d->timer.invalidate(); d->fixOffset(); + d->setDragging(false); if (!d->tl.isActive()) movementEnding(); } |