summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-10-26 19:59:04 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2015-11-23 16:19:52 +0000
commite77b6dc6ea801c720f241342246a57d237850e3f (patch)
tree259f7d9b55503d69006b4211b6fb12d757a1c636
parent7c022af015cbd281521674d20847b619e12e5aaf (diff)
downloadqtlocation-e77b6dc6ea801c720f241342246a57d237850e3f.tar.gz
Fix MapGestureArea API
Qmlfy map gesture area API: * do not use "is" for properties (panActive,pinchActive) * do not use "active" for accepted gestures (acceptedGestures) * do not use "ZoomGestures" (PinchGesture) * make private panEnabled, pinchEnabled * remove pan/pinchEnabled signals * update documentation * fix order of emitting panFinished, flickFinished [ChangeLog][MapGestureArea] Improve QML API including renaming and removal of obsolete elements. Change-Id: I643c923dcd94388475feb402b29ce3df916037a7 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--examples/location/mapviewer/map/MapComponent.qml2
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp2
-rw-r--r--src/imports/location/qquickgeomapgesturearea.cpp184
-rw-r--r--src/imports/location/qquickgeomapgesturearea_p.h64
-rw-r--r--src/location/doc/src/qtlocation-changes.qdoc6
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml105
7 files changed, 212 insertions, 153 deletions
diff --git a/examples/location/mapviewer/map/MapComponent.qml b/examples/location/mapviewer/map/MapComponent.qml
index ece4798b..d2d526d1 100644
--- a/examples/location/mapviewer/map/MapComponent.qml
+++ b/examples/location/mapviewer/map/MapComponent.qml
@@ -269,7 +269,7 @@ Map {
//! [mapnavigation]
// Enable pan, flick, and pinch gestures to zoom in and out
- gesture.activeGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.ZoomGesture
+ gesture.acceptedGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.PinchGesture
gesture.flickDeceleration: 3000
gesture.enabled: true
//! [mapnavigation]
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index c19a4065..dbeb3c5d 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -108,7 +108,7 @@ public:
qmlRegisterType<QDeclarativeGeoRoute >(uri, major, minor, "Route"); // data type
qmlRegisterType<QDeclarativeGeoRouteSegment >(uri, major, minor, "RouteSegment");
qmlRegisterType<QDeclarativeGeoManeuver >(uri, major, minor, "RouteManeuver");
- qmlRegisterUncreatableType<QDeclarativeGeoMapPinchEvent >(uri, major, minor, "MapPinchEvent",
+ qmlRegisterUncreatableType<QGeoMapPinchEvent >(uri, major, minor, "MapPinchEvent",
QStringLiteral("(Map)PinchEvent is not intended instantiable by developer."));
qmlRegisterUncreatableType<QQuickGeoMapGestureArea>(uri, major, minor, "MapGestureArea",
QStringLiteral("(Map)GestureArea is not intended instantiable by developer."));
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index d401fe21..2b76d318 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -976,7 +976,7 @@ void QDeclarativeGeoMap::wheelEvent(QWheelEvent *event)
bool QDeclarativeGeoMap::isInteractive()
{
- return (m_gestureArea->enabled() && m_gestureArea->activeGestures()) || m_gestureArea->isActive();
+ return (m_gestureArea->enabled() && m_gestureArea->acceptedGestures()) || m_gestureArea->isActive();
}
/*!
diff --git a/src/imports/location/qquickgeomapgesturearea.cpp b/src/imports/location/qquickgeomapgesturearea.cpp
index baa9e702..70dffc19 100644
--- a/src/imports/location/qquickgeomapgesturearea.cpp
+++ b/src/imports/location/qquickgeomapgesturearea.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype MapPinchEvent
- \instantiates QDeclarativeGeoMapPinchEvent
+ \instantiates QGeoMapPinchEvent
\inqmlmodule QtLocation
\brief MapPinchEvent type provides basic information about pinch event.
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
without its parent Map.
The two most commonly used properties of the MapGestureArea are the \l enabled
- and \l activeGestures properties. Both of these must be set before a
+ and \l acceptedGestures properties. Both of these must be set before a
MapGestureArea will have any effect upon interaction with the Map.
The \l flickDeceleration property controls how quickly the map pan slows after contact
is released while panning the map.
@@ -172,13 +172,13 @@ QT_BEGIN_NAMESPACE
\section2 Example Usage
- The following example enables the zoom and pan gestures on the map, but not flicking. So the
+ The following example enables the pinch and pan gestures on the map, but not flicking. So the
map scrolling will halt immediately on releasing the mouse button / touch.
\code
Map {
gesture.enabled: true
- gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture
+ gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture
}
\endcode
@@ -190,56 +190,23 @@ QT_BEGIN_NAMESPACE
\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
- the potentially active current gesture.
-*/
-
-
-/*!
- \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
- the potentially active current gesture.
*/
/*!
- \qmlproperty bool QtLocation::MapGestureArea::pinchEnabled
+ \qmlproperty bool QtLocation::MapGestureArea::pinchActive
- This property holds whether the pinch gestures are enabled.
- Note: disabling gestures during an active gesture does not have effect on
- the potentially active current gesture.
+ This read-only property holds whether pinch gesture is active.
*/
/*!
- \qmlproperty bool QtLocation::MapGestureArea::isPinchActive
+ \qmlproperty bool QtLocation::MapGestureArea::panActive
- This read-only property holds whether any pinch gesture is active.
-*/
-
-/*!
- \qmlproperty bool QtLocation::MapGestureArea::isPanActive
-
- This read-only property holds whether any pan gesture (panning or flicking) is active.
+ This read-only property holds whether pan gesture is active.
\note Change notifications for this property were introduced in Qt 5.5.
*/
/*!
- \qmlproperty enumeration QtLocation::MapGestureArea::activeGestures
-
- This property holds the gestures that will be active. By default
- the zoom, pan and flick gestures are enabled.
-
- \list
- \li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000).
- \li MapGestureArea.ZoomGesture - Support the map zoom gesture (value: 0x0001).
- \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0002).
- \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0004).
- \endlist
-*/
-
-/*!
\qmlproperty real QtLocation::MapGestureArea::maximumZoomLevelChange
This property holds the maximum zoom level change per pinch, essentially
@@ -292,7 +259,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::panStarted()
- This signal is emitted when the view begins moving due to user
+ This signal is emitted when the map begins to move due to user
interaction. Typically this means that the user is dragging a finger -
or a mouse with one of more mouse buttons pressed - on the map.
@@ -302,9 +269,9 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::panFinished()
- This signal is emitted when the view stops moving due to user
+ This signal is emitted when the map stops moving due to user
interaction. If a flick was generated, this signal is
- emitted when the flick stops. If a flick was not
+ emitted before flick starts. If a flick was not
generated, this signal is emitted when the
user stops dragging - that is a mouse or touch release.
@@ -315,8 +282,8 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::flickStarted()
- This signal is emitted when the view is flicked. A flick
- starts from the point that the mouse or touch is released,
+ This signal is emitted when the map is flicked. A flick
+ starts from the point where the mouse or touch was released,
while still in motion.
The corresponding handler is \c onFlichStarted.
@@ -325,8 +292,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtLocation::MapGestureArea::flickFinished()
- This signal is emitted when the view stops moving due to a flick.
- The order of panFinished() and flickFinished() is not specified.
+ This signal is emitted when the map stops moving due to a flick.
The corresponding handler is \c onFlickFinished.
*/
@@ -336,8 +302,9 @@ QQuickGeoMapGestureArea::QQuickGeoMapGestureArea(QDeclarativeGeoMap *map)
m_map(0),
m_declarativeMap(map),
m_enabled(true),
- m_activeGestures(ZoomGesture | PanGesture | FlickGesture),
- m_preventStealing(false)
+ m_acceptedGestures(PinchGesture | PanGesture | FlickGesture),
+ m_preventStealing(false),
+ m_panEnabled(true)
{
m_flick.m_enabled = true,
m_flick.m_maxVelocity = QML_MAP_FLICK_DEFAULTMAXVELOCITY;
@@ -401,22 +368,36 @@ QQuickGeoMapGestureArea::~QQuickGeoMapGestureArea()
}
/*!
- \internal
+ \qmlproperty enumeration QtLocation::MapGestureArea::acceptedGestures
+
+ This property holds the gestures that will be active. By default
+ the zoom, pan and flick gestures are enabled.
+
+ \list
+ \li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000).
+ \li MapGestureArea.PinchGesture - Support the map pinch gesture (value: 0x0001).
+ \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0002).
+ \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0004).
+ \endlist
*/
-QQuickGeoMapGestureArea::ActiveGestures QQuickGeoMapGestureArea::activeGestures() const
+
+QQuickGeoMapGestureArea::AcceptedGestures QQuickGeoMapGestureArea::acceptedGestures() const
{
- return m_activeGestures;
+ return m_acceptedGestures;
}
-/*!
- \internal
-*/
-void QQuickGeoMapGestureArea::setActiveGestures(ActiveGestures activeGestures)
+
+void QQuickGeoMapGestureArea::setAcceptedGestures(AcceptedGestures acceptedGestures)
{
- if (activeGestures == m_activeGestures)
+ if (acceptedGestures == m_acceptedGestures)
return;
- m_activeGestures = activeGestures;
- emit activeGesturesChanged();
+ m_acceptedGestures = acceptedGestures;
+
+ setPanEnabled(acceptedGestures & GeoMapGesture::PanGesture);
+ setFlickEnabled(acceptedGestures & GeoMapGesture::FlickGesture);
+ setPinchEnabled(acceptedGestures & GeoMapGesture::PinchGesture);
+
+ emit acceptedGesturesChanged();
}
/*!
@@ -451,6 +432,17 @@ void QQuickGeoMapGestureArea::setEnabled(bool enabled)
if (enabled == m_enabled)
return;
m_enabled = enabled;
+
+ if (enabled) {
+ setPanEnabled(m_acceptedGestures & GeoMapGesture::PanGesture);
+ setFlickEnabled(m_acceptedGestures & GeoMapGesture::FlickGesture);
+ setPinchEnabled(m_acceptedGestures & GeoMapGesture::PinchGesture);
+ } else {
+ setPanEnabled(false);
+ setFlickEnabled(false);
+ setPinchEnabled(false);
+ }
+
emit enabledChanged();
}
@@ -471,7 +463,6 @@ void QQuickGeoMapGestureArea::setPinchEnabled(bool enabled)
if (enabled == m_pinch.m_enabled)
return;
m_pinch.m_enabled = enabled;
- emit pinchEnabledChanged();
}
/*!
@@ -479,7 +470,7 @@ void QQuickGeoMapGestureArea::setPinchEnabled(bool enabled)
*/
bool QQuickGeoMapGestureArea::panEnabled() const
{
- return m_flick.m_enabled;
+ return m_panEnabled;
}
/*!
@@ -489,8 +480,7 @@ void QQuickGeoMapGestureArea::setPanEnabled(bool enabled)
{
if (enabled == m_flick.m_enabled)
return;
- m_flick.m_enabled = enabled;
- emit panEnabledChanged();
+ m_panEnabled = enabled;
// unlike the pinch, the pan existing functionality is to stop immediately
if (!enabled)
@@ -499,6 +489,28 @@ void QQuickGeoMapGestureArea::setPanEnabled(bool enabled)
/*!
\internal
+*/
+bool QQuickGeoMapGestureArea::flickEnabled() const
+{
+ return m_flick.m_enabled;
+}
+
+/*!
+ \internal
+*/
+void QQuickGeoMapGestureArea::setFlickEnabled(bool enabled)
+{
+ if (enabled == m_flick.m_enabled)
+ return;
+ m_flick.m_enabled = enabled;
+ // unlike the pinch, the flick existing functionality is to stop immediately
+ if (!enabled) {
+ stopFlick();
+ }
+}
+
+/*!
+ \internal
Used internally to set the minimum zoom level of the gesture area.
The caller is responsible to only send values that are valid
for the map plugin. Negative values are ignored.
@@ -761,14 +773,14 @@ void QQuickGeoMapGestureArea::update()
touchPointStateMachine();
// Parallel state machine for pinch
- if (isPinchActive() || (m_enabled && m_pinch.m_enabled && (m_activeGestures & (ZoomGesture))))
+ if (isPinchActive() || (m_enabled && m_pinch.m_enabled && (m_acceptedGestures & (PinchGesture))))
pinchStateMachine();
// Parallel state machine for pan (since you can pan at the same time as pinching)
// The stopPan function ensures that pan stops immediately when disabled,
// but the line below allows pan continue its current gesture if you disable
// the whole gesture (enabled_ flag), this keeps the enabled_ consistent with the pinch
- if (isPanActive() || (m_enabled && m_flick.m_enabled && (m_activeGestures & (PanGesture | FlickGesture))))
+ if (isPanActive() || (m_enabled && m_flick.m_enabled && (m_acceptedGestures & (PanGesture | FlickGesture))))
panStateMachine();
}
@@ -1019,7 +1031,7 @@ void QQuickGeoMapGestureArea::updatePinch()
m_pinch.m_lastAngle = m_twoTouchAngle;
emit pinchUpdated(&m_pinch.m_event);
- if (m_activeGestures & ZoomGesture) {
+ if (m_acceptedGestures & PinchGesture) {
// Take maximum and minimumzoomlevel into account
qreal perPinchMinimumZoomLevel = qMax(m_pinch.m_zoom.m_start - m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_minimum);
qreal perPinchMaximumZoomLevel = qMin(m_pinch.m_zoom.m_start + m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_maximum);
@@ -1067,22 +1079,25 @@ void QQuickGeoMapGestureArea::panStateMachine()
break;
case panActive:
if (m_allPoints.count() == 0) {
- m_flickState = flickActive;
if (!tryStartFlick())
{
m_flickState = flickInactive;
// mark as inactive for use by camera
if (m_pinchState == pinchInactive) {
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
- emit panFinished();
m_map->prefetchData();
}
+ emit panFinished();
+ } else {
+ m_flickState = flickActive;
+ emit panFinished();
+ emit flickStarted();
}
}
break;
case flickActive:
if (m_allPoints.count() > 0) { // re touched before movement ended
- endFlick();
+ stopFlick();
m_declarativeMap->setKeepMouseGrab(true);
m_flickState = panActive;
}
@@ -1111,7 +1126,7 @@ void QQuickGeoMapGestureArea::panStateMachine()
*/
bool QQuickGeoMapGestureArea::canStartPan()
{
- if (m_allPoints.count() == 0 || (m_activeGestures & PanGesture) == 0)
+ if (m_allPoints.count() == 0 || (m_acceptedGestures & PanGesture) == 0)
return false;
// Check if thresholds for normal panning are met.
@@ -1145,7 +1160,7 @@ void QQuickGeoMapGestureArea::updatePan()
*/
bool QQuickGeoMapGestureArea::tryStartFlick()
{
- if ((m_activeGestures & FlickGesture) == 0)
+ if ((m_acceptedGestures & FlickGesture) == 0)
return false;
// if we drag then pause before release we should not cause a flick.
qreal velocityX = 0.0;
@@ -1218,16 +1233,15 @@ void QQuickGeoMapGestureArea::startFlick(int dx, int dy, int timeMs)
m_flick.m_animation->setFrom(animationStartCoordinate);
m_flick.m_animation->setTo(animationEndCoordinate);
m_flick.m_animation->start();
- emit flickStarted();
}
void QQuickGeoMapGestureArea::stopPan()
{
- m_velocityX = 0;
- m_velocityY = 0;
if (m_flickState == flickActive) {
- endFlick();
+ stopFlick();
} else if (m_flickState == panActive) {
+ m_velocityX = 0;
+ m_velocityY = 0;
m_flickState = flickInactive;
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
emit panFinished();
@@ -1239,8 +1253,10 @@ void QQuickGeoMapGestureArea::stopPan()
/*!
\internal
*/
-void QQuickGeoMapGestureArea::endFlick()
+void QQuickGeoMapGestureArea::stopFlick()
{
+ m_velocityX = 0;
+ m_velocityY = 0;
if (m_flick.m_animation->isRunning())
m_flick.m_animation->stop();
else
@@ -1250,17 +1266,13 @@ void QQuickGeoMapGestureArea::endFlick()
void QQuickGeoMapGestureArea::handleFlickAnimationStopped()
{
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
- emit panFinished();
- emit flickFinished();
- m_flickState = flickInactive;
- emit panActiveChanged();
- m_map->prefetchData();
+ if (m_flickState == flickActive) {
+ m_flickState = flickInactive;
+ emit flickFinished();
+ m_map->prefetchData();
+ }
}
-
-
-
-
#include "moc_qquickgeomapgesturearea_p.cpp"
QT_END_NAMESPACE
diff --git a/src/imports/location/qquickgeomapgesturearea_p.h b/src/imports/location/qquickgeomapgesturearea_p.h
index 43bb2ce5..cfd8738e 100644
--- a/src/imports/location/qquickgeomapgesturearea_p.h
+++ b/src/imports/location/qquickgeomapgesturearea_p.h
@@ -64,7 +64,7 @@ class QTouchEvent;
class QWheelEvent;
class QGeoMap;
-class QDeclarativeGeoMapPinchEvent : public QObject
+class QGeoMapPinchEvent : public QObject
{
Q_OBJECT
@@ -76,13 +76,13 @@ class QDeclarativeGeoMapPinchEvent : public QObject
Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
public:
- QDeclarativeGeoMapPinchEvent(const QPointF &center, qreal angle,
+ QGeoMapPinchEvent(const QPointF &center, qreal angle,
const QPointF &point1, const QPointF &point2,
int pointCount = 0, bool accepted = true)
: QObject(), m_center(center), m_angle(angle),
m_point1(point1), m_point2(point2),
m_pointCount(pointCount), m_accepted(accepted) {}
- QDeclarativeGeoMapPinchEvent()
+ QGeoMapPinchEvent()
: QObject(),
m_angle(0.0),
m_pointCount(0),
@@ -113,32 +113,32 @@ private:
class QQuickGeoMapGestureArea: public QQuickItem
{
Q_OBJECT
- Q_ENUMS(ActiveGesture)
- Q_FLAGS(ActiveGestures)
+ Q_ENUMS(GeoMapGesture)
+ Q_FLAGS(AcceptedGestures)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(bool pinchEnabled READ pinchEnabled WRITE setPinchEnabled NOTIFY pinchEnabledChanged)
- Q_PROPERTY(bool panEnabled READ panEnabled WRITE setPanEnabled NOTIFY panEnabledChanged)
- Q_PROPERTY(bool isPinchActive READ isPinchActive NOTIFY pinchActiveChanged)
- Q_PROPERTY(bool isPanActive READ isPanActive NOTIFY panActiveChanged)
- Q_PROPERTY(ActiveGestures activeGestures READ activeGestures WRITE setActiveGestures NOTIFY activeGesturesChanged)
+ Q_PROPERTY(bool pinchActive READ isPinchActive NOTIFY pinchActiveChanged)
+ Q_PROPERTY(bool panActive READ isPanActive NOTIFY panActiveChanged)
+ Q_PROPERTY(AcceptedGestures acceptedGestures READ acceptedGestures WRITE setAcceptedGestures NOTIFY acceptedGesturesChanged)
Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1)
+
public:
QQuickGeoMapGestureArea(QDeclarativeGeoMap *map);
~QQuickGeoMapGestureArea();
- enum ActiveGesture {
+ enum GeoMapGesture {
NoGesture = 0x0000,
- ZoomGesture = 0x0001,
+ PinchGesture = 0x0001,
PanGesture = 0x0002,
FlickGesture = 0x004
};
- Q_DECLARE_FLAGS(ActiveGestures, ActiveGesture)
- ActiveGestures activeGestures() const;
- void setActiveGestures(ActiveGestures activeGestures);
+ Q_DECLARE_FLAGS(AcceptedGestures, GeoMapGesture)
+
+ AcceptedGestures acceptedGestures() const;
+ void setAcceptedGestures(AcceptedGestures acceptedGestures);
bool isPinchActive() const;
bool isPanActive() const;
@@ -147,12 +147,6 @@ public:
bool enabled() const;
void setEnabled(bool enabled);
- // backwards compatibility
- bool pinchEnabled() const;
- void setPinchEnabled(bool enabled);
- bool panEnabled() const;
- void setPanEnabled(bool enabled);
-
qreal maximumZoomLevelChange() const;
void setMaximumZoomLevelChange(qreal maxChange);
@@ -183,16 +177,11 @@ Q_SIGNALS:
void pinchActiveChanged();
void enabledChanged();
void maximumZoomLevelChangeChanged();
- void activeGesturesChanged();
+ void acceptedGesturesChanged();
void flickDecelerationChanged();
-
- // backwards compatibility
- void pinchEnabledChanged();
- void panEnabledChanged();
-
- void pinchStarted(QDeclarativeGeoMapPinchEvent *pinch);
- void pinchUpdated(QDeclarativeGeoMapPinchEvent *pinch);
- void pinchFinished(QDeclarativeGeoMapPinchEvent *pinch);
+ void pinchStarted(QGeoMapPinchEvent *pinch);
+ void pinchUpdated(QGeoMapPinchEvent *pinch);
+ void pinchFinished(QGeoMapPinchEvent *pinch);
void panStarted();
void panFinished();
void flickStarted();
@@ -222,7 +211,15 @@ private:
void updatePan();
bool tryStartFlick();
void startFlick(int dx, int dy, int timeMs = 0);
- void endFlick();
+ void stopFlick();
+
+ bool pinchEnabled() const;
+ void setPinchEnabled(bool enabled);
+ bool panEnabled() const;
+ void setPanEnabled(bool enabled);
+ bool flickEnabled() const;
+ void setFlickEnabled(bool enabled);
+
private Q_SLOTS:
void handleFlickAnimationStopped();
@@ -241,7 +238,7 @@ private:
{
Pinch() : m_enabled(true), m_startDist(0), m_lastAngle(0.0) {}
- QDeclarativeGeoMapPinchEvent m_event;
+ QGeoMapPinchEvent m_event;
bool m_enabled;
struct Zoom
{
@@ -260,7 +257,7 @@ private:
qreal m_lastAngle;
} m_pinch;
- ActiveGestures m_activeGestures;
+ AcceptedGestures m_acceptedGestures;
struct Pan
{
@@ -289,6 +286,7 @@ private:
qreal m_distanceBetweenTouchPoints;
QPointF m_sceneCenter;
bool m_preventStealing;
+ bool m_panEnabled;
// prototype state machine...
enum TouchPointState
diff --git a/src/location/doc/src/qtlocation-changes.qdoc b/src/location/doc/src/qtlocation-changes.qdoc
index a901751b..1c79c582 100644
--- a/src/location/doc/src/qtlocation-changes.qdoc
+++ b/src/location/doc/src/qtlocation-changes.qdoc
@@ -45,8 +45,12 @@
\b{\l{QtLocation::MapGestureArea}{MapGestureArea} Component}
\list
- \li added missing panActiveChanged() signal to \l[QML]{QtLocation::MapGestureArea::}{isPanActive} property
+ \li added missing panActiveChanged() signal to \l[QML]{QtLocation::MapGestureArea::}{panActive} property
\li removed movementStopped() signal
+ \li replaced isPanActive, isPinchActive with panActive, pinchActive
+ \li replaced activeGestures with acceptedGestures
+ \li replaced ZoomGesture with PinchGesture
+ \li removed properties panEnabled pinchEnable, please use acceptedGestures instead
\endlist
\b Geoservice's plugin parameters
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index 526cbb6f..4094a7c7 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -61,17 +61,24 @@ Item {
property real flickStartedLatitude
property real flickStartedLongitude
- property bool disableFlickOnStarted: false
- property bool disableFlickOnMovementStarted: false
+ property bool disableOnPanStartedWithNoGesture: false
+ property bool disableOnFlickStartedWithNoGesture: false
+ property bool disableOnPanStartedWithDisabled: false
+ property bool disableOnFlickStartedWithDisabled: false
+
gesture.onPanStarted: {
- if (disableFlickOnMovementStarted)
- map.gesture.panEnabled = false
+ if (disableOnPanStartedWithNoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ if (disableOnPanStartedWithDisabled)
+ map.gesture.enabled = false
}
gesture.onFlickStarted: {
flickStartedLatitude = map.center.latitude
flickStartedLatitude = map.center.longitude
- if (disableFlickOnStarted)
- map.gesture.panEnabled = false
+ if (disableOnFlickStartedWithNoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ if (disableOnFlickStartedWithDisabled)
+ map.gesture.enabled = false
}
MouseArea {
id: mouseAreaTop
@@ -81,6 +88,7 @@ Item {
}
SignalSpy {id: centerSpy; target: map; signalName: 'centerChanged'}
+ SignalSpy {id: panStartedSpy; target: map.gesture; signalName: 'panStarted'}
SignalSpy {id: panFinishedSpy; target: map.gesture; signalName: 'panFinished'}
SignalSpy {id: gestureEnabledSpy; target: map.gesture; signalName: 'enabledChanged'}
SignalSpy {id: flickDecelerationSpy; target: map.gesture; signalName: 'flickDecelerationChanged'}
@@ -95,16 +103,19 @@ Item {
function init()
{
- map.gesture.activeGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
+ map.gesture.acceptedGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
map.gesture.enabled = true
map.gesture.panEnabled = true
map.gesture.flickDeceleration = 500
map.zoomLevel = 0
- map.disableFlickOnStarted = false
- map.disableFlickOnMovementStarted = false
+ map.disableOnPanStartedWithNoGesture = false
+ map.disableOnFlickStartedWithNoGesture = false
+ map.disableOnPanStartedWithDisabled = false
+ map.disableOnFlickStartedWithDisabled = false
centerSpy.clear()
gestureEnabledSpy.clear()
flickDecelerationSpy.clear()
+ panStartedSpy.clear()
panFinishedSpy.clear()
flickStartedSpy.clear()
flickFinishedSpy.clear()
@@ -112,6 +123,8 @@ Item {
mouseAreaBottomSpy.clear()
mouseAreaBottom.visible = false
mouseAreaTop.visible = false
+ compare(map.gesture.pinchActive, false)
+ compare(map.gesture.panActive, false)
}
function initTestCase()
@@ -127,16 +140,17 @@ Item {
map.gesture.enabled = true
compare(gestureEnabledSpy.count, 2)
compare(map.gesture.enabled, true)
- compare(map.gesture.isPinchActive, false)
- verify(map.gesture.activeGestures & MapGestureArea.ZoomGesture)
- map.gesture.activeGestures = MapGestureArea.NoGesture
- compare(map.gesture.activeGestures, MapGestureArea.NoGesture)
- map.gesture.activeGestures = MapGestureArea.NoGesture
- compare(map.gesture.activeGestures, MapGestureArea.NoGesture)
- map.gesture.activeGestures = MapGestureArea.ZoomGesture | MapGestureArea.PanGesture
- compare(map.gesture.activeGestures, MapGestureArea.ZoomGesture | MapGestureArea.PanGesture)
- map.gesture.activeGestures = MapGestureArea.PanGesture
- compare(map.gesture.activeGestures, MapGestureArea.PanGesture)
+ compare(map.gesture.pinchActive, false)
+ compare(map.gesture.panActive, false)
+ verify(map.gesture.acceptedGestures & MapGestureArea.PinchGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.NoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.NoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.PinchGesture | MapGestureArea.PanGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.PinchGesture | MapGestureArea.PanGesture)
+ map.gesture.acceptedGestures = MapGestureArea.PanGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.PanGesture)
compare(map.gesture.flickDeceleration, 2500)
map.gesture.flickDeceleration = 2600
compare(flickDecelerationSpy.count, 1)
@@ -222,7 +236,6 @@ Item {
tryCompare(mouseAreaBottomSpy, "count",0)
}
-
function test_flick_diagonal()
{
map.center.latitude = 50
@@ -244,9 +257,8 @@ Item {
verify(map.center.longitude < moveLongitude)
}
- function test_flicking_while_disabled()
+ function disabled_flicking()
{
- map.gesture.panEnabled = false
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -255,14 +267,25 @@ Item {
mouseMove(page, i, i, 0, Qt.LeftButton);
}
mouseRelease(page, 50, 50)
+ compare(panStartedSpy.count, 0)
+ compare(panFinishedSpy.count, 0)
compare(flickStartedSpy.count, 0)
compare(flickFinishedSpy.count, 0)
- compare(panFinishedSpy.count, 0)
}
- function test_disable_onFlickStarted()
+ function test_disabled_flicking_with_nogesture()
+ {
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ }
+
+ function test_disabled_flicking_with_disabled()
+ {
+ map.gesture.enabled = false
+ disabled_flicking()
+ }
+
+ function disable_onFlickStarted()
{
- map.disableFlickOnStarted = true
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -273,21 +296,30 @@ Item {
mouseRelease(page, 50, 50)
var latitude = map.center.latitude;
var longitude = map.center.longitude
+ tryCompare(panStartedSpy, "count", 1)
tryCompare(flickStartedSpy, "count", 1)
verify(map.center.latitude > 50)
- tryCompare(flickStartedSpy, "count", 1)
tryCompare(panFinishedSpy, "count", 1)
tryCompare(flickFinishedSpy, "count", 1)
// compare that flick was interrupted (less movement than without interrupting)
compare(latitude, map.center.latitude)
compare(longitude, map.center.longitude)
- map.disableFlickOnStarted = false
- map.gesture.panEnabled = true
}
- function test_disable_onMovementStarted()
+ function test_disable_onFlickStarted_with_disabled()
+ {
+ map.disableOnFlickStartedWithDisabled = true
+ disable_onFlickStarted()
+ }
+
+ function test_disable_onFlickStarted_with_nogesture()
+ {
+ map.disableOnFlickStartedWithNoGesture = true
+ disable_onFlickStarted()
+ }
+
+ function disable_onPanStarted()
{
- map.disableFlickOnMovementStarted = true
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -302,6 +334,19 @@ Item {
// compare that flick was interrupted (less movement than without interrupting)
compare(map.center.latitude,50)
compare(map.center.longitude,50)
+ compare(map.gesture.panActive, false)
+ }
+
+ function test_disable_onPanStarted_with_disabled()
+ {
+ map.disableOnPanStartedWithDisabled = true
+ disable_onPanStarted()
+ }
+
+ function test_disable_onPanStarted_with_nogesture()
+ {
+ map.disableOnPanStartedWithNoGesture = true
+ disable_onPanStarted()
}
}
}