diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-09-13 00:54:25 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-09-13 00:54:25 (GMT) |
commit | 90c8a68eef4a87209279f4c528c540efe6525384 (patch) | |
tree | 6d5bc75204a67e2b63519c04df7e945fdf5b4cce /src/declarative | |
parent | b04672e479ae245063e641c77d43e311c0851dc0 (diff) | |
download | Qt-90c8a68eef4a87209279f4c528c540efe6525384.zip Qt-90c8a68eef4a87209279f4c528c540efe6525384.tar.gz Qt-90c8a68eef4a87209279f4c528c540efe6525384.tar.bz2 |
Ensure flickable velocity is updated when view is moved by setCurrentIndex
Task-number: QTBUG-13543
Diffstat (limited to 'src/declarative')
4 files changed, 8 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 062bbfb..c0b664f 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -128,8 +128,8 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate() , flickingHorizontally(false), flickingVertically(false) , hMoved(false), vMoved(false) , movingHorizontally(false), movingVertically(false) - , stealMouse(false), pressed(false) - , interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100) + , stealMouse(false), pressed(false), interactive(true), calcVelocity(false) + , deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100) , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600) , vTime(0), visibleArea(0) , flickableDirection(QDeclarativeFlickable::AutoFlickDirection) @@ -981,7 +981,7 @@ void QDeclarativeFlickable::viewportMoved() qreal prevY = d->lastFlickablePosition.x(); qreal prevX = d->lastFlickablePosition.y(); d->velocityTimeline.clear(); - if (d->pressed) { + if (d->pressed || d->calcVelocity) { int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime); if (elapsed > 0) { qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed; diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index c398faa..2da034c 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -141,6 +141,7 @@ public: bool stealMouse : 1; bool pressed : 1; bool interactive : 1; + bool calcVelocity : 1; QElapsedTimer lastPosTime; QPointF lastPos; QPointF pressPos; diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index a0faf14..6a99733 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -2241,7 +2241,9 @@ void QDeclarativeGridView::trackedPositionChanged() } if (viewPos != pos) { cancelFlick(); + d->calcVelocity = true; d->setPosition(pos); + d->calcVelocity = false; } } } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 177c5b3..ae504aa 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2732,7 +2732,9 @@ void QDeclarativeListView::trackedPositionChanged() } if (viewPos != pos) { cancelFlick(); + d->calcVelocity = true; d->setPosition(pos); + d->calcVelocity = false; } } } |