aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-12-30 13:45:40 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-30 07:28:39 +0100
commit017a82c6702768aed68c34f319fa14da591f3df2 (patch)
tree8d3fe0e90ae40cf236769e25a440148c67225865
parentae739f001626de8f1f04f3f325488978870b0369 (diff)
touchUpdated should be called for release and cancel.
touchUpdated should be emitted whenever the touch is updated, even if the update means there are no longer any valid touch points. Change-Id: Iceac5a65094784928108acc764bbc1d5c2b9a08a Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp5
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml6
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml7
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp5
4 files changed, 20 insertions, 3 deletions
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index 461c237657..8f27f04273 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -281,7 +281,7 @@ void QQuickTouchPoint::setSceneY(qreal sceneY)
\qmlsignal QtQuick2::MultiPointTouchArea::touchUpdated(list<TouchPoint> touchPoints)
This handler is called when the touch points handled by the MultiPointTouchArea change. This includes adding new touch points,
- removing previous touch points, as well as updating current touch point data. \a touchPoints is the list of all current touch
+ removing or canceling previous touch points, as well as updating current touch point data. \a touchPoints is the list of all current touch
points.
*/
@@ -480,7 +480,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
if (ended) emit touchPointsReleased(_releasedTouchPoints);
if (moved) emit touchPointsUpdated(_movedTouchPoints);
if (started) emit touchPointsPressed(_pressedTouchPoints);
- if (!_touchPoints.isEmpty()) emit touchUpdated(_touchPoints.values());
+ if (ended || moved || started) emit touchUpdated(_touchPoints.values());
}
}
@@ -597,6 +597,7 @@ void QQuickMultiPointTouchArea::ungrab()
dtp->setInUse(false);
}
_touchPoints.clear();
+ emit touchUpdated(QList<QObject*>());
}
}
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml
index 53a2bf87f9..5db377011c 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml
+++ b/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml
@@ -7,6 +7,9 @@ Flickable {
contentWidth: width
contentHeight: height * 2
+ property int cancelCount: 0
+ property int touchCount: 0
+
MultiPointTouchArea {
anchors.fill: parent
minimumTouchPoints: 2
@@ -20,6 +23,9 @@ Flickable {
TouchPoint { id: point1; objectName: "point1" },
TouchPoint { id: point2; objectName: "point2" }
]
+
+ onTouchPointsCanceled: cancelCount = touchPoints.length
+ onTouchUpdated: touchCount = touchPoints.length
}
}
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml
index 3a6aa86a1c..85f8cd6f39 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml
+++ b/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml
@@ -9,17 +9,22 @@ MultiPointTouchArea {
touchPointUpdateCount = 0;
touchPointReleaseCount = 0;
touchCount = 0;
+ touchUpdatedHandled = false;
}
property int touchPointPressCount: 0
property int touchPointUpdateCount: 0
property int touchPointReleaseCount: 0
property int touchCount: 0
+ property bool touchUpdatedHandled: false
maximumTouchPoints: 5
onTouchPointsPressed: { touchPointPressCount = touchPoints.length }
onTouchPointsUpdated: { touchPointUpdateCount = touchPoints.length }
onTouchPointsReleased: { touchPointReleaseCount = touchPoints.length }
- onTouchUpdated: { touchCount = touchPoints.length }
+ onTouchUpdated: {
+ touchCount = touchPoints.length
+ touchUpdatedHandled = true
+ }
}
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index 230825011a..837c31f073 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -149,6 +149,7 @@ void tst_QQuickMultiPointTouchArea::signalTest()
QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3);
QCOMPARE(area->property("touchCount").toInt(), 0);
+ QCOMPARE(area->property("touchUpdatedHandled").toBool(), true);
QMetaObject::invokeMethod(area, "clearCounts");
delete canvas;
@@ -600,6 +601,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QCOMPARE(point11->pressed(), true);
QCOMPARE(point12->pressed(), true);
+ QCOMPARE(flickable->property("cancelCount").toInt(), 0);
+ QCOMPARE(flickable->property("touchCount").toInt(), 2);
p1 += QPoint(0,15); p2 += QPoint(0,15);
QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
@@ -620,6 +623,8 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
QVERIFY(flickable->contentY() < 0);
QCOMPARE(point11->pressed(), false);
QCOMPARE(point12->pressed(), false);
+ QCOMPARE(flickable->property("cancelCount").toInt(), 2);
+ QCOMPARE(flickable->property("touchCount").toInt(), 0);
QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);