summaryrefslogtreecommitdiff
path: root/src/imports/location
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-12-01 23:00:31 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-12-01 23:00:31 +0100
commit99a1ba7c488939f606628593e7d21e42aa583502 (patch)
tree4ed34a0bc7500a9a429d8009f4777fb7250ab65f /src/imports/location
parentf87ba0409856a678e8a940b70f7452c3a1b730c3 (diff)
parenteea315187d1add70aaf69745c031b8d6342b2303 (diff)
downloadqtlocation-99a1ba7c488939f606628593e7d21e42aa583502.tar.gz
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/imports/location/qdeclarativegeomap.cpp src/imports/location/qdeclarativegeomap_p.h Change-Id: Iaf232acbe9098eb1b57f571638dd37f75b2ff345
Diffstat (limited to 'src/imports/location')
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/imports/location/qdeclarativecirclemapitem.cpp32
-rw-r--r--src/imports/location/qdeclarativecirclemapitem_p.h6
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp130
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h14
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp12
-rw-r--r--src/imports/location/qdeclarativegeomapitembase_p.h5
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem.cpp30
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem_p.h2
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp19
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem_p.h2
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem.cpp17
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem_p.h2
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp34
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem_p.h4
-rw-r--r--src/imports/location/qdeclarativeroutemapitem.cpp7
-rw-r--r--src/imports/location/qdeclarativeroutemapitem_p.h3
-rw-r--r--src/imports/location/qquickgeomapgesturearea.cpp184
-rw-r--r--src/imports/location/qquickgeomapgesturearea_p.h64
19 files changed, 257 insertions, 312 deletions
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/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp
index 92977179..eb3de7a2 100644
--- a/src/imports/location/qdeclarativecirclemapitem.cpp
+++ b/src/imports/location/qdeclarativecirclemapitem.cpp
@@ -35,7 +35,6 @@
****************************************************************************/
#include "qdeclarativecirclemapitem_p.h"
-#include "qdeclarativegeomapquickitem_p.h"
#include "qdeclarativepolygonmapitem_p.h"
#include "qgeocameracapabilities_p.h"
#include "qgeoprojection_p.h"
@@ -302,9 +301,9 @@ QDeclarativeCircleMapItem::QDeclarativeCircleMapItem(QQuickItem *parent)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
// assume that circles are not self-intersecting
// to speed up processing
@@ -335,21 +334,18 @@ QDeclarativeMapLineProperties *QDeclarativeCircleMapItem::border()
return &border_;
}
-void QDeclarativeCircleMapItem::updateMapItemAssumeDirty()
+void QDeclarativeCircleMapItem::markSourceDirtyAndUpdate()
{
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
void QDeclarativeCircleMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
- if (map) {
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
- }
+ if (map)
+ markSourceDirtyAndUpdate();
}
/*!
@@ -365,10 +361,7 @@ void QDeclarativeCircleMapItem::setCenter(const QGeoCoordinate &center)
return;
center_ = center;
-
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit centerChanged(center_);
}
@@ -389,7 +382,7 @@ void QDeclarativeCircleMapItem::setColor(const QColor &color)
return;
color_ = color;
dirtyMaterial_ = true;
- updateMapItem();
+ update();
emit colorChanged(color_);
}
@@ -411,9 +404,7 @@ void QDeclarativeCircleMapItem::setRadius(qreal radius)
return;
radius_ = radius;
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit radiusChanged(radius);
}
@@ -459,7 +450,7 @@ QSGNode *QDeclarativeCircleMapItem::updateMapItemPaintNode(QSGNode *oldNode, Upd
/*!
\internal
*/
-void QDeclarativeCircleMapItem::updateMapItem()
+void QDeclarativeCircleMapItem::updatePolish()
{
if (!map() || !center().isValid())
return;
@@ -501,7 +492,6 @@ void QDeclarativeCircleMapItem::updateMapItem()
}
setPositionOnMap(circlePath_.at(0), geometry_.firstPointOffset());
- update();
}
/*!
@@ -541,7 +531,7 @@ void QDeclarativeCircleMapItem::afterViewportChanged(const QGeoMapViewportChange
geometry_.markScreenDirty();
borderGeometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
diff --git a/src/imports/location/qdeclarativecirclemapitem_p.h b/src/imports/location/qdeclarativecirclemapitem_p.h
index fb786e08..9b142309 100644
--- a/src/imports/location/qdeclarativecirclemapitem_p.h
+++ b/src/imports/location/qdeclarativecirclemapitem_p.h
@@ -56,8 +56,6 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeGeoMapQuickItem;
-
class QGeoMapCircleGeometry : public QGeoMapPolygonGeometry
{
public:
@@ -101,10 +99,10 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
- void updateMapItemAssumeDirty();
+ void markSourceDirtyAndUpdate();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 026a515a..67f723b9 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -179,6 +179,7 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
m_map(0),
m_error(QGeoServiceProvider::NoError),
m_zoomLevel(8.0),
+ m_color(QColor::fromRgbF(0.9, 0.9, 0.9)),
m_componentCompleted(false),
m_mappingManagerInitialized(false),
m_pendingFitViewport(false),
@@ -422,9 +423,11 @@ QSGNode *QDeclarativeGeoMap::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
QSGSimpleRectNode *root = static_cast<QSGSimpleRectNode *>(oldNode);
if (!root)
- root = new QSGSimpleRectNode(boundingRect(), QColor::fromRgbF(0.9, 0.9, 0.9));
- else
+ root = new QSGSimpleRectNode(boundingRect(), m_color);
+ else {
root->setRect(boundingRect());
+ root->setColor(m_color);
+ }
QSGNode *content = root->childCount() ? root->firstChild() : 0;
content = m_map->updateSceneGraph(content, window());
@@ -773,6 +776,28 @@ bool QDeclarativeGeoMap::copyrightsVisible() const
}
+
+/*!
+ \qmlproperty color QtLocation::Map::color
+
+ This property holds the background color of the map element.
+
+ \since 5.6
+*/
+void QDeclarativeGeoMap::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update();
+ emit colorChanged(m_color);
+ }
+}
+
+QColor QDeclarativeGeoMap::color() const
+{
+ return m_color;
+}
+
void QDeclarativeGeoMap::fitViewportToGeoShape()
{
if (!m_map) return;
@@ -888,18 +913,6 @@ QPointF QDeclarativeGeoMap::fromCoordinate(const QGeoCoordinate &coordinate, boo
}
/*!
- \qmlmethod QtLocation::Map::toScreenPosition(coordinate coordinate)
- \obsolete
-
- This function is missed named and is equilavent to \l {fromCoordinate}, which should be used
- instead.
-*/
-QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
-{
- return fromCoordinate(coordinate);
-}
-
-/*!
\qmlmethod void QtLocation::Map::pan(int dx, int dy)
Starts panning the map by \a dx pixels along the x-axis and
@@ -999,7 +1012,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();
}
/*!
@@ -1199,89 +1212,6 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF
}
-// TODO Remove this function -> BC break
-/*!
- \qmlmethod void QtLocation::Map::fitViewportToGeoShape(QGeoShape shape)
-
- \internal
-
- Fits the current viewport to the boundary of the shape. The camera is positioned
- in the center of the shape, and at the largest integral zoom level possible which
- allows the whole shape to be visible on screen
-
-*/
-void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
-{
- if (!m_map || !m_mappingManagerInitialized)
- return;
-
- QGeoShape shape;
-
- if (variantShape.userType() == qMetaTypeId<QGeoRectangle>())
- shape = variantShape.value<QGeoRectangle>();
- else if (variantShape.userType() == qMetaTypeId<QGeoCircle>())
- shape = variantShape.value<QGeoCircle>();
- else if (variantShape.userType() == qMetaTypeId<QGeoShape>())
- shape = variantShape.value<QGeoShape>();
-
- if (!shape.isValid())
- return;
-
- double bboxWidth;
- double bboxHeight;
- QGeoCoordinate centerCoordinate;
-
- switch (shape.type()) {
- case QGeoShape::RectangleType:
- {
- QGeoRectangle rect = shape;
- QDoubleVector2D topLeftPoint = m_map->coordinateToItemPosition(rect.topLeft(), false);
- QDoubleVector2D botRightPoint = m_map->coordinateToItemPosition(rect.bottomRight(), false);
- bboxWidth = qAbs(topLeftPoint.x() - botRightPoint.x());
- bboxHeight = qAbs(topLeftPoint.y() - botRightPoint.y());
- centerCoordinate = rect.center();
- break;
- }
- case QGeoShape::CircleType:
- {
- QGeoCircle circle = shape;
- centerCoordinate = circle.center();
- QGeoCoordinate edge = centerCoordinate.atDistanceAndAzimuth(circle.radius(), 90);
- QDoubleVector2D centerPoint = m_map->coordinateToItemPosition(centerCoordinate, false);
- QDoubleVector2D edgePoint = m_map->coordinateToItemPosition(edge, false);
- bboxWidth = qAbs(centerPoint.x() - edgePoint.x()) * 2;
- bboxHeight = bboxWidth;
- break;
- }
- case QGeoShape::UnknownType:
- //Fallthrough to default
- default:
- return;
- }
-
- // position camera to the center of bounding box
- setProperty("center", QVariant::fromValue(centerCoordinate));
-
- //If the shape is empty we just change centerposition, not zoom
- if (bboxHeight == 0 && bboxWidth == 0)
- return;
-
- // adjust zoom
- double bboxWidthRatio = bboxWidth / (bboxWidth + bboxHeight);
- double mapWidthRatio = width() / (width() + height());
- double zoomRatio;
-
- if (bboxWidthRatio > mapWidthRatio)
- zoomRatio = bboxWidth / width();
- else
- zoomRatio = bboxHeight / height();
-
- qreal newZoom = std::log10(zoomRatio) / std::log10(0.5);
-
- newZoom = std::floor(qMax(minimumZoomLevel(), (m_map->mapController()->zoom() + newZoom)));
- setProperty("zoomLevel", QVariant::fromValue(newZoom));
-}
-
/*!
\qmlmethod void QtLocation::Map::fitViewportToMapItems()
@@ -1333,6 +1263,10 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
continue;
}
}
+ // Force map items to update immediately. Needed to ensure correct item size and positions
+ // when recursively calling this function.
+ if (item->isPolishScheduled())
+ item->updatePolish();
topLeftX = item->position().x();
topLeftY = item->position().y();
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index 9db3b199..69d4687d 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -55,6 +55,7 @@
#include <QtQuick/QQuickItem>
#include <QtCore/QPointer>
#include <QtCore/QMutex>
+#include <QtGui/QColor>
#include <QtPositioning/qgeoshape.h>
QT_BEGIN_NAMESPACE
@@ -80,6 +81,7 @@ class QDeclarativeGeoMap : public QQuickItem
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
Q_PROPERTY(QGeoShape visibleRegion READ visibleRegion WRITE setVisibleRegion)
Q_PROPERTY(bool copyrightsVisible READ copyrightsVisible WRITE setCopyrightsVisible NOTIFY copyrightsVisibleChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -111,6 +113,9 @@ public:
void setCopyrightsVisible(bool visible);
bool copyrightsVisible() const;
+ void setColor(const QColor &color);
+ QColor color() const;
+
QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes();
Q_INVOKABLE void removeMapItem(QDeclarativeGeoMapItemBase *item);
@@ -121,13 +126,8 @@ public:
Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &position, bool clipToViewPort = true) const;
Q_INVOKABLE QPointF fromCoordinate(const QGeoCoordinate &coordinate, bool clipToViewPort = true) const;
-#if QT_DEPRECATED_SINCE(5,5)
- QT_DEPRECATED Q_INVOKABLE QPointF toScreenPosition(const QGeoCoordinate &coordinate) const;
-#endif
-
QQuickGeoMapGestureArea *gesture();
- Q_INVOKABLE void fitViewportToGeoShape(const QVariant &shape);
Q_INVOKABLE void fitViewportToMapItems();
Q_INVOKABLE void pan(int dx, int dy);
Q_INVOKABLE void prefetchData(); // optional hint for prefetch
@@ -147,6 +147,7 @@ Q_SIGNALS:
void errorChanged();
void copyrightLinkActivated(const QString &link);
void copyrightsVisibleChanged(bool visible);
+ void colorChanged(const QColor &color);
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE ;
@@ -196,9 +197,10 @@ private:
QString m_errorString;
QGeoServiceProvider::Error m_error;
qreal m_zoomLevel;
+ QGeoShape m_region;
+ QColor m_color;
bool m_componentCompleted;
bool m_mappingManagerInitialized;
- QGeoShape m_region;
bool m_pendingFitViewport;
bool m_copyrightsVisible;
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index e76c11b0..cde00abf 100644
--- a/src/imports/location/qdeclarativegeomapitembase.cpp
+++ b/src/imports/location/qdeclarativegeomapitembase.cpp
@@ -39,6 +39,7 @@
#include <QtQml/QQmlInfo>
#include <QtQuick/QSGOpacityNode>
#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuick/private/qquickitem_p.h>
QT_BEGIN_NAMESPACE
@@ -248,6 +249,17 @@ QSGNode *QDeclarativeGeoMapItemBase::updateMapItemPaintNode(QSGNode *oldNode, Up
return 0;
}
+bool QDeclarativeGeoMapItemBase::isPolishScheduled() const
+{
+ return QQuickItemPrivate::get(this)->polishScheduled;
+}
+
+void QDeclarativeGeoMapItemBase::polishAndUpdate()
+{
+ polish();
+ update();
+}
+
#include "moc_qdeclarativegeomapitembase_p.cpp"
diff --git a/src/imports/location/qdeclarativegeomapitembase_p.h b/src/imports/location/qdeclarativegeomapitembase_p.h
index d4ad34c5..c7793fbd 100644
--- a/src/imports/location/qdeclarativegeomapitembase_p.h
+++ b/src/imports/location/qdeclarativegeomapitembase_p.h
@@ -89,13 +89,14 @@ public:
virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
protected Q_SLOTS:
- virtual void updateMapItem() = 0;
virtual void afterChildrenChanged();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
+ void polishAndUpdate();
protected:
float zoomLevelOpacity() const;
bool childMouseEventFilter(QQuickItem *item, QEvent *event);
+ bool isPolishScheduled() const;
private Q_SLOTS:
void baseCameraDataChanged(const QGeoCameraData &camera);
@@ -106,6 +107,8 @@ private:
QSizeF lastSize_;
QGeoCameraData lastCameraData_;
+
+ friend class QDeclarativeGeoMap;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp
index 81f88dac..ca67b183 100644
--- a/src/imports/location/qdeclarativegeomapquickitem.cpp
+++ b/src/imports/location/qdeclarativegeomapquickitem.cpp
@@ -146,8 +146,7 @@ void QDeclarativeGeoMapQuickItem::setCoordinate(const QGeoCoordinate &coordinate
coordinate_ = coordinate;
- updateMapItem();
-
+ polishAndUpdate();
emit coordinateChanged();
}
@@ -158,10 +157,11 @@ void QDeclarativeGeoMapQuickItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
if (map && quickMap) {
- QObject::connect(quickMap, SIGNAL(heightChanged()), this, SLOT(updateMapItem()));
- QObject::connect(quickMap, SIGNAL(widthChanged()), this, SLOT(updateMapItem()));
- QObject::connect(map, SIGNAL(cameraDataChanged(QGeoCameraData)), this, SLOT(updateMapItem()));
- updateMapItem();
+ connect(quickMap, SIGNAL(heightChanged()), this, SLOT(polishAndUpdate()));
+ connect(quickMap, SIGNAL(widthChanged()), this, SLOT(polishAndUpdate()));
+ connect(map, SIGNAL(cameraDataChanged(QGeoCameraData)),
+ this, SLOT(polishAndUpdate()));
+ polishAndUpdate();
}
}
@@ -203,8 +203,7 @@ void QDeclarativeGeoMapQuickItem::setSourceItem(QQuickItem *sourceItem)
return;
sourceItem_ = sourceItem;
- updateMapItem();
-
+ polishAndUpdate();
emit sourceItemChanged();
}
@@ -249,7 +248,7 @@ void QDeclarativeGeoMapQuickItem::setAnchorPoint(const QPointF &anchorPoint)
if (anchorPoint == anchorPoint_)
return;
anchorPoint_ = anchorPoint;
- updateMapItem();
+ polishAndUpdate();
emit anchorPointChanged();
}
@@ -281,7 +280,7 @@ void QDeclarativeGeoMapQuickItem::setZoomLevel(qreal zoomLevel)
if (zoomLevel == zoomLevel_)
return;
zoomLevel_ = zoomLevel;
- updateMapItem();
+ polishAndUpdate();
emit zoomLevelChanged();
}
@@ -293,7 +292,7 @@ qreal QDeclarativeGeoMapQuickItem::zoomLevel() const
/*!
\internal
*/
-void QDeclarativeGeoMapQuickItem::updateMapItem()
+void QDeclarativeGeoMapQuickItem::updatePolish()
{
if (!quickMap() && sourceItem_) {
mapAndSourceItemSet_ = false;
@@ -311,13 +310,13 @@ void QDeclarativeGeoMapQuickItem::updateMapItem()
sourceItem_.data()->setParentItem(opacityContainer_);
sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft);
connect(sourceItem_.data(), SIGNAL(xChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
connect(sourceItem_.data(), SIGNAL(yChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
connect(sourceItem_.data(), SIGNAL(widthChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
connect(sourceItem_.data(), SIGNAL(heightChanged()),
- this, SLOT(updateMapItem()));
+ this, SLOT(polishAndUpdate()));
}
QScopedValueRollback<bool> rollback(updatingGeometry_);
@@ -330,7 +329,6 @@ void QDeclarativeGeoMapQuickItem::updateMapItem()
setWidth(sourceItem_.data()->width());
setHeight(sourceItem_.data()->height());
setPositionOnMap(coordinate(), scaleFactor() * anchorPoint_);
- update();
}
/*!
diff --git a/src/imports/location/qdeclarativegeomapquickitem_p.h b/src/imports/location/qdeclarativegeomapquickitem_p.h
index af9f6ec6..0410f060 100644
--- a/src/imports/location/qdeclarativegeomapquickitem_p.h
+++ b/src/imports/location/qdeclarativegeomapquickitem_p.h
@@ -90,9 +90,9 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
virtual void afterChildrenChanged() Q_DECL_OVERRIDE;
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index 9a71614f..6fdef816 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -332,7 +332,7 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent)
void QDeclarativePolygonMapItem::handleBorderUpdated()
{
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem()
@@ -367,7 +367,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m
if (map) {
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
}
@@ -423,7 +423,7 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value)
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -441,7 +441,7 @@ void QDeclarativePolygonMapItem::addCoordinate(const QGeoCoordinate &coordinate)
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -465,7 +465,7 @@ void QDeclarativePolygonMapItem::removeCoordinate(const QGeoCoordinate &coordina
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -489,7 +489,7 @@ void QDeclarativePolygonMapItem::setColor(const QColor &color)
color_ = color;
dirtyMaterial_ = true;
- updateMapItem();
+ update();
emit colorChanged(color_);
}
@@ -519,7 +519,7 @@ QSGNode *QDeclarativePolygonMapItem::updateMapItemPaintNode(QSGNode *oldNode, Up
/*!
\internal
*/
-void QDeclarativePolygonMapItem::updateMapItem()
+void QDeclarativePolygonMapItem::updatePolish()
{
if (!map() || path_.count() == 0)
return;
@@ -546,7 +546,6 @@ void QDeclarativePolygonMapItem::updateMapItem()
setHeight(combined.height());
setPositionOnMap(path_.at(0), -1 * geometry_.sourceBoundingBox().topLeft());
- update();
}
/*!
@@ -582,7 +581,7 @@ void QDeclarativePolygonMapItem::afterViewportChanged(const QGeoMapViewportChang
borderGeometry_.setPreserveGeometry(true, borderGeometry_.geoLeftBound());
geometry_.markScreenDirty();
borderGeometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -639,7 +638,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
borderGeometry_.setPreserveGeometry(true, leftBoundCoord);
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
diff --git a/src/imports/location/qdeclarativepolygonmapitem_p.h b/src/imports/location/qdeclarativepolygonmapitem_p.h
index 86a9ec4c..8b803b1d 100644
--- a/src/imports/location/qdeclarativepolygonmapitem_p.h
+++ b/src/imports/location/qdeclarativepolygonmapitem_p.h
@@ -111,9 +111,9 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
void handleBorderUpdated();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp
index 9201701c..71a205d3 100644
--- a/src/imports/location/qdeclarativepolylinemapitem.cpp
+++ b/src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -472,7 +472,7 @@ void QDeclarativePolylineMapItem::updateAfterLinePropertiesChanged()
{
// mark dirty just in case we're a width change
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -483,7 +483,7 @@ void QDeclarativePolylineMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
if (map) {
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
}
@@ -546,7 +546,7 @@ void QDeclarativePolylineMapItem::setPathFromGeoList(const QList<QGeoCoordinate>
path_ = path;
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -563,7 +563,7 @@ void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate
path_.append(coordinate);
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -586,7 +586,7 @@ void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordin
path_.removeAt(index);
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -652,7 +652,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
+ newCoordinate.longitude() - firstLongitude));
geometry_.setPreserveGeometry(true, leftBoundCoord);
geometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
emit pathChanged();
}
@@ -688,13 +688,13 @@ void QDeclarativePolylineMapItem::afterViewportChanged(const QGeoMapViewportChan
}
geometry_.setPreserveGeometry(true, geometry_.geoLeftBound());
geometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
\internal
*/
-void QDeclarativePolylineMapItem::updateMapItem()
+void QDeclarativePolylineMapItem::updatePolish()
{
if (!map() || path_.count() == 0)
return;
@@ -709,7 +709,6 @@ void QDeclarativePolylineMapItem::updateMapItem()
setHeight(geometry_.sourceBoundingBox().height());
setPositionOnMap(path_.at(0), -1 * geometry_.sourceBoundingBox().topLeft());
- update();
}
/*!
diff --git a/src/imports/location/qdeclarativepolylinemapitem_p.h b/src/imports/location/qdeclarativepolylinemapitem_p.h
index 6eeeb11f..a7b7f167 100644
--- a/src/imports/location/qdeclarativepolylinemapitem_p.h
+++ b/src/imports/location/qdeclarativepolylinemapitem_p.h
@@ -132,9 +132,9 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void setPathFromGeoList(const QList<QGeoCoordinate> &path);
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
void updateAfterLinePropertiesChanged();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index 2dbb630b..c28bcf3e 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -177,9 +177,9 @@ QDeclarativeRectangleMapItem::QDeclarativeRectangleMapItem(QQuickItem *parent)
{
setFlag(ItemHasContents, true);
QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
- this, SLOT(updateMapItemAssumeDirty()));
+ this, SLOT(markSourceDirtyAndUpdate()));
}
QDeclarativeRectangleMapItem::~QDeclarativeRectangleMapItem()
@@ -192,11 +192,8 @@ QDeclarativeRectangleMapItem::~QDeclarativeRectangleMapItem()
void QDeclarativeRectangleMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
- if (map) {
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
- }
+ if (map)
+ markSourceDirtyAndUpdate();
}
/*!
@@ -229,9 +226,7 @@ void QDeclarativeRectangleMapItem::setTopLeft(const QGeoCoordinate &topLeft)
topLeft_ = topLeft;
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft_);
}
@@ -243,11 +238,11 @@ QGeoCoordinate QDeclarativeRectangleMapItem::topLeft()
/*!
\internal
*/
-void QDeclarativeRectangleMapItem::updateMapItemAssumeDirty()
+void QDeclarativeRectangleMapItem::markSourceDirtyAndUpdate()
{
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -263,9 +258,7 @@ void QDeclarativeRectangleMapItem::setBottomRight(const QGeoCoordinate &bottomRi
bottomRight_ = bottomRight;
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit bottomRightChanged(bottomRight_);
}
@@ -291,7 +284,7 @@ void QDeclarativeRectangleMapItem::setColor(const QColor &color)
return;
color_ = color;
dirtyMaterial_ = true;
- updateMapItem();
+ polishAndUpdate();
emit colorChanged(color_);
}
@@ -333,7 +326,7 @@ QSGNode *QDeclarativeRectangleMapItem::updateMapItemPaintNode(QSGNode *oldNode,
/*!
\internal
*/
-void QDeclarativeRectangleMapItem::updateMapItem()
+void QDeclarativeRectangleMapItem::updatePolish()
{
if (!map() || !topLeft().isValid() || !bottomRight().isValid())
return;
@@ -368,7 +361,6 @@ void QDeclarativeRectangleMapItem::updateMapItem()
}
setPositionOnMap(pathClosed.at(0), geometry_.firstPointOffset());
- update();
}
/*!
@@ -404,7 +396,7 @@ void QDeclarativeRectangleMapItem::afterViewportChanged(const QGeoMapViewportCha
borderGeometry_.setPreserveGeometry(true, borderGeometry_.geoLeftBound());
geometry_.markScreenDirty();
borderGeometry_.markScreenDirty();
- updateMapItem();
+ polishAndUpdate();
}
/*!
@@ -448,9 +440,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
bottomRight_ = newBottomRight;
geometry_.setPreserveGeometry(true, newTopLeft);
borderGeometry_.setPreserveGeometry(true, newTopLeft);
- geometry_.markSourceDirty();
- borderGeometry_.markSourceDirty();
- updateMapItem();
+ markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft_);
emit bottomRightChanged(bottomRight_);
}
diff --git a/src/imports/location/qdeclarativerectanglemapitem_p.h b/src/imports/location/qdeclarativerectanglemapitem_p.h
index d4c319ab..fb9936b0 100644
--- a/src/imports/location/qdeclarativerectanglemapitem_p.h
+++ b/src/imports/location/qdeclarativerectanglemapitem_p.h
@@ -105,10 +105,10 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void updatePolish() Q_DECL_OVERRIDE;
protected Q_SLOTS:
- virtual void updateMapItem() Q_DECL_OVERRIDE;
- void updateMapItemAssumeDirty();
+ void markSourceDirtyAndUpdate();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
diff --git a/src/imports/location/qdeclarativeroutemapitem.cpp b/src/imports/location/qdeclarativeroutemapitem.cpp
index 78485cc0..19930cc3 100644
--- a/src/imports/location/qdeclarativeroutemapitem.cpp
+++ b/src/imports/location/qdeclarativeroutemapitem.cpp
@@ -119,12 +119,19 @@ void QDeclarativeRouteMapItem::setRoute(QDeclarativeGeoRoute *route)
route_ = route;
+ connect(route_, SIGNAL(pathChanged()), this, SLOT(updateRoutePath()));
+
if (route_)
setPathFromGeoList(route_->routePath());
emit routeChanged(route_);
}
+void QDeclarativeRouteMapItem::updateRoutePath()
+{
+ setPathFromGeoList(route_->routePath());
+}
+
/*!
\internal void QDeclarativeRouteMapItem::setPath(const QJSValue &value)
diff --git a/src/imports/location/qdeclarativeroutemapitem_p.h b/src/imports/location/qdeclarativeroutemapitem_p.h
index 9bb3a443..3acac3cc 100644
--- a/src/imports/location/qdeclarativeroutemapitem_p.h
+++ b/src/imports/location/qdeclarativeroutemapitem_p.h
@@ -74,6 +74,9 @@ public:
Q_SIGNALS:
void routeChanged(const QDeclarativeGeoRoute *route);
+private slots:
+ void updateRoutePath();
+
protected:
void setPath(const QJSValue &value) Q_DECL_OVERRIDE;
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