summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2013-03-12 16:04:54 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-19 01:52:28 +0100
commit3a80424aeae19e838be03aa12a5243911ec3f020 (patch)
tree709517b9bf4884474c5742633dc9b2bc1a21d9b7
parentfd528896dbc76832bbcc26beff97d348a365be63 (diff)
Fix jump and property changes on first move when dragging a Flickable.
Fixes a regression whereby on the first mouse move the contentItem was moved the total distance from the touch point to where the drag distance was exceeded. For large drag thresholds this causes a noticeable jump. Task-number: QTBUG-30032 Change-Id: I92c119d27dc2e22203484f9ada5978697d171957 Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp4
3 files changed, 12 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index c0c7b2a0..64ae2094 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -789,9 +789,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
- if (vData.dragStartOffset == 0)
- vData.dragStartOffset = dy;
if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
+ if (!vMoved)
+ vData.dragStartOffset = dy;
qreal newY = dy + vData.pressPos - vData.dragStartOffset;
const qreal minY = vData.dragMinBound;
const qreal maxY = vData.dragMaxBound;
@@ -818,9 +818,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (q->xflick()) {
int dx = int(event->pos().x() - pressPos.x());
- if (hData.dragStartOffset == 0)
- hData.dragStartOffset = dx;
if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
+ if (!hMoved)
+ hData.dragStartOffset = dx;
qreal newX = dx + hData.pressPos - hData.dragStartOffset;
const qreal minX = hData.dragMinBound;
const qreal maxX = hData.dragMaxBound;
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index b0fa7bd6..c8a98d33 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -576,6 +576,9 @@ void tst_qdeclarativeflickable::nestedStopAtBounds()
axis += invert ? threshold : -threshold;
moveEvent.setScenePos(position);
QApplication::sendEvent(view.scene(), &moveEvent);
+ axis += invert ? threshold : -threshold;
+ moveEvent.setScenePos(position);
+ QApplication::sendEvent(view.scene(), &moveEvent);
QVERIFY(outer->contentX() != 50 || outer->contentY() != 50);
QVERIFY((inner->contentX() == 0 || inner->contentX() == 100)
&& (inner->contentY() == 0 || inner->contentY() == 100));
@@ -594,6 +597,9 @@ void tst_qdeclarativeflickable::nestedStopAtBounds()
axis += invert ? -threshold : threshold;
moveEvent.setScenePos(position);
QApplication::sendEvent(view.scene(), &moveEvent);
+ axis += invert ? -threshold : threshold;
+ moveEvent.setScenePos(position);
+ QApplication::sendEvent(view.scene(), &moveEvent);
QVERIFY(outer->contentX() == 50 && outer->contentY() == 50);
QVERIFY((inner->contentX() != 0 && inner->contentX() != 100)
|| (inner->contentY() != 0 && inner->contentY() != 100));
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index 37e64d4d..855ad602 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -597,8 +597,8 @@ void tst_QDeclarativeMouseArea::preventStealing()
QVERIFY(!mouseArea->pressed());
// Flickable content should have moved.
- QCOMPARE(flickable->contentX(), 30.);
- QCOMPARE(flickable->contentY(), 30.);
+ QCOMPARE(flickable->contentX(), 15.);
+ QCOMPARE(flickable->contentY(), 15.);
QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50)));