summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-10-14 14:45:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-14 15:44:44 +0200
commit7f1067c97f55da45ffe3da7ec91ad32a2bcef255 (patch)
tree10b7bf65c36b81107625a12fc521d0fa25b601f6
parent997e06d80c095ac994391bfb5d69c5ec9a52a11f (diff)
Revert "Improve filtering of touch and mouse events."
This reverts commit b34bee26c932b9f7579e99d1dca632cb8c47d85f. Tests with mapviewer example on Linux have shown that the map cannot be dragged anymore. Bisecting the history has revealed b34bee26c to be the culprit. Task-number: QTBUG-34077 Change-Id: If2aa9ebca4d56d03c7f6414d82a1813adb9b7b11 Reviewed-by: Erik Mattsson <erik.mattsson@appello.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp4
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea.cpp74
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea_p.h3
3 files changed, 17 insertions, 64 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 9ce48afe..cd313837 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -874,8 +874,7 @@ void QDeclarativeGeoMap::touchEvent(QTouchEvent *event)
}
QLOC_TRACE0;
event->accept();
- if (!gestureArea_->touchEvent(event))
- event->ignore();
+ gestureArea_->touchEvent(event);
}
/*!
@@ -893,7 +892,6 @@ void QDeclarativeGeoMap::wheelEvent(QWheelEvent *event)
*/
bool QDeclarativeGeoMap::childMouseEventFilter(QQuickItem *item, QEvent *event)
{
- Q_UNUSED(item);
QLOC_TRACE0;
switch (event->type()) {
case QEvent::MouseButtonPress:
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp
index 80b484b7..bb13ce21 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea.cpp
+++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp
@@ -337,7 +337,6 @@ QDeclarativeGeoMapGestureArea::QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap
: QObject(parent),
declarativeMap_(map),
enabled_(true),
- usingTouch_(false),
activeGestures_(ZoomGesture | PanGesture | FlickGesture)
{
map_ = 0;
@@ -348,8 +347,8 @@ QDeclarativeGeoMapGestureArea::QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap
touchPointState_ = touchPoints0;
pinchState_ = pinchInactive;
panState_ = panInactive;
-}
+}
/*!
\internal
*/
@@ -607,51 +606,27 @@ bool QDeclarativeGeoMapGestureArea::mouseReleaseEvent(QMouseEvent *)
/*!
\internal
*/
-bool QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
+void QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
{
- usingTouch_ = true;
-
- if (!(enabled_ && activeGestures_))
- return false;
-
switch (event->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
- foreach (const QTouchEvent::TouchPoint &p, event->touchPoints()) {
- QList<QTouchEvent::TouchPoint>::iterator i;
- for (i = touchPoints_.begin(); i != touchPoints_.end(); ++i) {
- if (i->id() == p.id()) {
- i = touchPoints_.erase(i);
- break;
- }
- }
- switch (p.state()) {
- case Qt::TouchPointPressed:
- case Qt::TouchPointMoved:
- case Qt::TouchPointStationary:
- touchPoints_.insert(i, p);
- break;
- case Qt::TouchPointReleased:
- // already removed
- break;
- default:
- break;
+ touchPoints_.clear();
+ for (int i = 0; i < event->touchPoints().count(); ++i) {
+ if (!(event->touchPoints().at(i).state() & Qt::TouchPointReleased)) {
+ touchPoints_ << event->touchPoints().at(i);
}
}
update();
break;
-
case QEvent::TouchEnd:
touchPoints_.clear();
update();
break;
-
default:
// no-op
break;
}
-
- return true;
}
/*!
@@ -659,31 +634,22 @@ bool QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
*/
bool QDeclarativeGeoMapGestureArea::filterMapChildMouseEvent(QMouseEvent *event)
{
- if (usingTouch_)
- return false;
-
- if (!(enabled_ && activeGestures_))
- return false;
-
- if (isPanActive() || isPinchActive())
- return true;
-
- // Don't filter the event, but use it to see if we should start
- // a gesture.
+ bool used = false;
switch (event->type()) {
case QEvent::MouseButtonPress:
- mousePressEvent(event);
+ used = mousePressEvent(event);
break;
case QEvent::MouseButtonRelease:
- mouseReleaseEvent(event);
+ used = mouseReleaseEvent(event);
break;
case QEvent::MouseMove:
- mouseMoveEvent(event);
+ used = mouseMoveEvent(event);
break;
default:
+ used = false;
break;
}
- return false;
+ return used && (isPanActive() || isPinchActive());
}
/*!
@@ -691,18 +657,8 @@ bool QDeclarativeGeoMapGestureArea::filterMapChildMouseEvent(QMouseEvent *event)
*/
bool QDeclarativeGeoMapGestureArea::filterMapChildTouchEvent(QTouchEvent *event)
{
- usingTouch_ = true;
-
- if (!(enabled_ && activeGestures_))
- return false;
-
- if (event->touchPoints().count() > 1 || isPanActive() || isPinchActive())
- return true;
-
- // Don't filter the event, but use it to see if we should start
- // a gesture.
touchEvent(event);
- return false;
+ return isPanActive() || isPinchActive();
}
/*!
@@ -777,7 +733,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
clearTouchData();
startOneTouchPoint();
touchPointState_ = touchPoints1;
- } else if (touchPoints_.count() >= 2) {
+ } else if (touchPoints_.count() == 2) {
clearTouchData();
startTwoTouchPoints();
touchPointState_ = touchPoints2;
@@ -786,7 +742,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
case touchPoints1:
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
- } else if (touchPoints_.count() >= 2) {
+ } else if (touchPoints_.count() == 2) {
touchCenterCoord_ = map_->screenPositionToCoordinate(sceneCenter_, false);
startTwoTouchPoints();
touchPointState_ = touchPoints2;
diff --git a/src/imports/location/qdeclarativegeomapgesturearea_p.h b/src/imports/location/qdeclarativegeomapgesturearea_p.h
index 955e20c0..0f0dc194 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea_p.h
+++ b/src/imports/location/qdeclarativegeomapgesturearea_p.h
@@ -160,7 +160,7 @@ public:
qreal flickDeceleration() const;
void setFlickDeceleration(qreal deceleration);
- bool touchEvent(QTouchEvent *event);
+ void touchEvent(QTouchEvent *event);
bool mousePressEvent(QMouseEvent *event);
bool mouseMoveEvent(QMouseEvent *event);
@@ -229,7 +229,6 @@ private:
QGeoMap *map_;
QDeclarativeGeoMap *declarativeMap_;
bool enabled_;
- bool usingTouch_;
struct Pinch
{