summaryrefslogtreecommitdiffstats
path: root/src/imports/location/qdeclarativegeomapgesturearea.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-10-22 14:37:37 +0200
committerAlex Blasche <alexander.blasche@digia.com>2013-10-22 14:38:06 +0200
commit71dffcd319c2641e1022bf857f9c72671cb1446a (patch)
tree84a7685d0c174a6c461c06aed60a2961a7d3f8fb /src/imports/location/qdeclarativegeomapgesturearea.cpp
parent2867f1efc989478667ea7ae56ff91cd991d74121 (diff)
parent654b01af941ec620ca8a9b98be8542dda862d4a8 (diff)
Merge branch 'stable' into dev
Conflicts: src/imports/location/qdeclarativegeomap.cpp src/imports/location/qdeclarativegeoroute.cpp src/imports/location/qdeclarativegeoroutemodel.cpp src/imports/location/qdeclarativegeoroutesegment.cpp src/imports/location/qdeclarativepolygonmapitem.cpp src/imports/location/qdeclarativepolylinemapitem.cpp src/imports/positioning/positioning.cpp Change-Id: Ieaa5f567d2144d0267e7eef5bd75bde7e0079fbe
Diffstat (limited to 'src/imports/location/qdeclarativegeomapgesturearea.cpp')
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea.cpp118
1 files changed, 37 insertions, 81 deletions
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp
index f9959e19..9314b42b 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea.cpp
+++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp
@@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype MapPinchEvent
\instantiates QDeclarativeGeoMapPinchEvent
- \inqmlmodule QtLocation 5.0
+ \inqmlmodule QtLocation
\brief MapPinchEvent type provides basic information about pinch event.
@@ -104,13 +104,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty QPoint QtLocation5::MapPinchEvent::center
+ \qmlproperty QPoint QtLocation::MapPinchEvent::center
This read-only property holds the current center point.
*/
/*!
- \qmlproperty real QtLocation5::MapPinchEvent::angle
+ \qmlproperty real QtLocation::MapPinchEvent::angle
This read-only property holds the current angle between the two points in
the range -180 to 180. Positive values for the angles mean counter-clockwise
@@ -119,15 +119,15 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty QPoint QtLocation5::MapPinchEvent::point1
- \qmlproperty QPoint QtLocation5::MapPinchEvent::point2
+ \qmlproperty QPoint QtLocation::MapPinchEvent::point1
+ \qmlproperty QPoint QtLocation::MapPinchEvent::point2
These read-only properties hold the actual touch points generating the pinch.
The points are not in any particular order.
*/
/*!
- \qmlproperty int QtLocation5::MapPinchEvent::pointCount
+ \qmlproperty int QtLocation::MapPinchEvent::pointCount
This read-only property holds the number of points currently touched.
The MapPinch will not react until two touch points have initiated a gesture,
@@ -135,7 +135,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty bool QtLocation5::MapPinchEvent::accepted
+ \qmlproperty bool QtLocation::MapPinchEvent::accepted
Setting this property to false in the \c MapPinch::onPinchStarted handler
will result in no further pinch events being generated, and the gesture
@@ -146,7 +146,7 @@ QT_BEGIN_NAMESPACE
\qmltype MapGestureArea
\instantiates QDeclarativeGeoMapGestureArea
- \inqmlmodule QtLocation 5.0
+ \inqmlmodule QtLocation
\brief The MapGestureArea type provides Map gesture interaction.
@@ -187,7 +187,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty bool QtLocation5::MapGestureArea::enabled
+ \qmlproperty bool QtLocation::MapGestureArea::enabled
This property holds whether the gestures are enabled.
Note: disabling gestures during an active gesture does not have effect on
@@ -196,7 +196,7 @@ QT_BEGIN_NAMESPACE
/*!
- \qmlproperty bool QtLocation5::MapGestureArea::panEnabled
+ \qmlproperty bool QtLocation::MapGestureArea::panEnabled
This property holds whether the pan gestures are enabled.
Note: disabling gestures during an active gesture does not have effect on
@@ -204,7 +204,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty bool QtLocation5::MapGestureArea::pinchEnabled
+ \qmlproperty bool QtLocation::MapGestureArea::pinchEnabled
This property holds whether the pinch gestures are enabled.
Note: disabling gestures during an active gesture does not have effect on
@@ -212,19 +212,19 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty bool QtLocation5::MapGestureArea::isPinchActive
+ \qmlproperty bool QtLocation::MapGestureArea::isPinchActive
This read-only property holds whether any pinch gesture is active.
*/
/*!
- \qmlproperty bool QtLocation5::MapGestureArea::isPanActive
+ \qmlproperty bool QtLocation::MapGestureArea::isPanActive
This read-only property holds whether any pan gesture (panning or flicking) is active.
*/
/*!
- \qmlproperty enumeration QtLocation5::MapGestureArea::activeGestures
+ \qmlproperty enumeration QtLocation::MapGestureArea::activeGestures
This property holds the gestures that will be active. By default
the zoom, pan and flick gestures are enabled.
@@ -246,7 +246,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty real QtLocation5::MapGestureArea::maximumZoomLevelChange
+ \qmlproperty real QtLocation::MapGestureArea::maximumZoomLevelChange
This property holds the maximum zoom level change per pinch, essentially
meant to be used for setting the zoom sensitivity.
@@ -275,7 +275,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::pinchStarted(PinchEvent event)
+ \qmlsignal QtLocation::MapGestureArea::pinchStarted(PinchEvent event)
Raised when a pinch gesture is started.
@@ -283,7 +283,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::pinchUpdated(PinchEvent event)
+ \qmlsignal QtLocation::MapGestureArea::pinchUpdated(PinchEvent event)
Once a pinch has begun this event gets raised as the user moves her fingers
across the map.
@@ -292,7 +292,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::pinchFinished(PinchEvent event)
+ \qmlsignal QtLocation::MapGestureArea::pinchFinished(PinchEvent event)
The end of a pinch gesture is signaled by this event.
@@ -300,7 +300,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::panStarted()
+ \qmlsignal QtLocation::MapGestureArea::panStarted()
This handler is called when the view begins moving due to user
interaction. Typically this means that the user is dragging a finger -
@@ -308,7 +308,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::panFinished()
+ \qmlsignal QtLocation::MapGestureArea::panFinished()
This handler is called when the view stops moving due to user
interaction. If a flick was generated, this handler will
@@ -319,7 +319,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::flickStarted()
+ \qmlsignal QtLocation::MapGestureArea::flickStarted()
This handler is called when the view is flicked. A flick
starts from the point that the mouse or touch is released,
@@ -327,7 +327,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtLocation5::MapGestureArea::flickFinished()
+ \qmlsignal QtLocation::MapGestureArea::flickFinished()
This handler is called when the view stops moving due to a flick.
The order of panFinished() and flickFinished() is not specified.
@@ -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;