summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-01-19 00:30:19 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-30 09:29:09 +0000
commit0a5dd29d4b02a192ec7e691cf88f623152ce100b (patch)
tree9d1975b4cf1f61ed3aa56af8d98443632e8c21ba
parent1946896ace3f5fa8b6086fb416ea934fea387f12 (diff)
downloadqtlocation-0a5dd29d4b02a192ec7e691cf88f623152ce100b.tar.gz
Allow QGeoMap to render map items
Currently QtLocation Map items are always rendered by QtLocation, on top of what QGeoMap generates. This patch introduces a new private api call to QGeoMap, supportedMapItemTypes(), that is used to inform QtLocation to not render map items of those types, but rather pass them over to the QGeoMap, which will take care of the rendering. In this way, more advanced renderers can properly render map items, for example below labels or 3D buildings. Change-Id: I1c82d4f11d4dd44c3011926512520d62e26295d4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem.cpp12
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp24
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitembase.cpp29
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitembase_p.h23
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem.cpp11
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp14
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp17
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativerectanglemapitem.cpp15
-rw-r--r--src/location/declarativemaps/qdeclarativerectanglemapitem_p.h1
-rw-r--r--src/location/maps/qgeomap.cpp49
-rw-r--r--src/location/maps/qgeomap_p.h21
-rw-r--r--src/location/maps/qgeomap_p_p.h7
17 files changed, 214 insertions, 14 deletions
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
index 39581dce..f5127c5e 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
@@ -375,6 +375,10 @@ QDeclarativeCircleMapItem::QDeclarativeCircleMapItem(QQuickItem *parent)
this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
this, SLOT(markSourceDirtyAndUpdate()));
+ QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
+ this, SLOT(markGeoMaterialDirty()));
+ QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
+ this, SLOT(markGeoMaterialDirty()));
// assume that circles are not self-intersecting
// to speed up processing
@@ -432,6 +436,7 @@ void QDeclarativeCircleMapItem::setCenter(const QGeoCoordinate &center)
return;
circle_.setCenter(center);
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit centerChanged(center);
}
@@ -453,6 +458,7 @@ void QDeclarativeCircleMapItem::setColor(const QColor &color)
return;
color_ = color;
dirtyMaterial_ = true;
+ geoMaterialDirty_ = true;
update();
emit colorChanged(color_);
}
@@ -475,6 +481,7 @@ void QDeclarativeCircleMapItem::setRadius(qreal radius)
return;
circle_.setRadius(radius);
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit radiusChanged(radius);
}
@@ -616,6 +623,11 @@ const QGeoShape &QDeclarativeCircleMapItem::geoShape() const
return circle_;
}
+QGeoMap::ItemType QDeclarativeCircleMapItem::itemType() const
+{
+ return QGeoMap::MapCircle;
+}
+
/*!
\internal
*/
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
index 62bef6d3..bcbd67d8 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
@@ -94,6 +94,7 @@ public:
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
const QGeoShape &geoShape() const Q_DECL_OVERRIDE;
+ QGeoMap::ItemType itemType() const Q_DECL_OVERRIDE;
Q_SIGNALS:
void centerChanged(const QGeoCoordinate &center);
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 15d802e6..456291a7 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -192,6 +192,12 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
QDeclarativeGeoMap::~QDeclarativeGeoMap()
{
+ // Removing map parameters and map items from m_map
+ if (m_map) {
+ m_map->clearParameters();
+ m_map->clearMapItems();
+ }
+
if (!m_mapViews.isEmpty())
qDeleteAll(m_mapViews);
// remove any map items associations
@@ -660,8 +666,10 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
// Any map items that were added before the plugin was ready
// need to have setMap called again
foreach (const QPointer<QDeclarativeGeoMapItemBase> &item, m_mapItems) {
- if (item)
- item.data()->setMap(this, m_map);
+ if (item) {
+ item->setMap(this, m_map);
+ m_map->addMapItem(item.data()); // m_map filters out what is not supported.
+ }
}
// All map parameters that were added before the plugin was ready
@@ -1383,9 +1391,11 @@ void QDeclarativeGeoMap::addMapItem(QDeclarativeGeoMapItemBase *item)
if (!item || item->quickMap())
return;
item->setParentItem(this);
- if (m_map)
- item->setMap(this, m_map);
m_mapItems.append(item);
+ if (m_map) {
+ item->setMap(this, m_map);
+ m_map->addMapItem(item);
+ }
emit mapItemsChanged();
}
@@ -1512,6 +1522,7 @@ void QDeclarativeGeoMap::removeMapItem(QDeclarativeGeoMapItemBase *ptr)
{
if (!ptr || !m_map)
return;
+ m_map->removeMapItem(ptr);
QPointer<QDeclarativeGeoMapItemBase> item(ptr);
if (!m_mapItems.contains(item))
return;
@@ -1531,6 +1542,7 @@ void QDeclarativeGeoMap::removeMapItem(QDeclarativeGeoMapItemBase *ptr)
*/
void QDeclarativeGeoMap::clearMapItems()
{
+ m_map->clearMapItems();
if (m_mapItems.isEmpty())
return;
for (int i = 0; i < m_mapItems.count(); ++i) {
@@ -1670,6 +1682,10 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
}
// Force map items to update immediately. Needed to ensure correct item size and positions
// when recursively calling this function.
+ // TODO: See if we really need updatePolish on delegated items, in particular
+ // in relation to
+ // a) fitViewportToMapItems
+ // b) presence of MouseArea
if (item->isPolishScheduled())
item->updatePolish();
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index ca2ec0a9..efaf3817 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -59,6 +59,7 @@
#include <QtCore/QSet>
#include <QtGui/QColor>
#include <QtPositioning/qgeoshape.h>
+#include <QtLocation/private/qgeomap_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
index 93d07386..d3a527cc 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
@@ -77,7 +77,7 @@ QGeoMapViewportChangeEvent &QGeoMapViewportChangeEvent::operator=(const QGeoMapV
}
QDeclarativeGeoMapItemBase::QDeclarativeGeoMapItemBase(QQuickItem *parent)
-: QQuickItem(parent), map_(0), quickMap_(0)
+: QQuickItem(parent), map_(0), quickMap_(0), geoGeometryDirty_(true), geoMaterialDirty_(true)
{
setFiltersChildMouseEvents(true);
connect(this, SIGNAL(childrenChanged()),
@@ -221,8 +221,10 @@ bool QDeclarativeGeoMapItemBase::childMouseEventFilter(QQuickItem *item, QEvent
*/
QSGNode *QDeclarativeGeoMapItemBase::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *pd)
{
- if (!map_ || !quickMap_) {
- delete oldNode;
+ if (!map_ || !quickMap_ || map_->supportedMapItemTypes() & itemType()) {
+ if (oldNode)
+ delete oldNode;
+ oldNode = 0;
return 0;
}
@@ -254,6 +256,26 @@ QSGNode *QDeclarativeGeoMapItemBase::updateMapItemPaintNode(QSGNode *oldNode, Up
return 0;
}
+bool QDeclarativeGeoMapItemBase::isDirty() const
+{
+ return geoGeometryDirty_ || geoMaterialDirty_;
+}
+
+bool QDeclarativeGeoMapItemBase::isGeoMaterialDirty() const
+{
+ return geoMaterialDirty_;
+}
+
+bool QDeclarativeGeoMapItemBase::isGeoGeometryDirty() const
+{
+ return geoGeometryDirty_;
+}
+
+void QDeclarativeGeoMapItemBase::markClean()
+{
+ geoGeometryDirty_ = geoMaterialDirty_ = false;
+}
+
bool QDeclarativeGeoMapItemBase::isPolishScheduled() const
{
return QQuickItemPrivate::get(this)->polishScheduled;
@@ -265,7 +287,6 @@ void QDeclarativeGeoMapItemBase::polishAndUpdate()
update();
}
-
#include "moc_qdeclarativegeomapitembase_p.cpp"
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h
index 82a24233..ff887676 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h
@@ -55,6 +55,7 @@
#include <QtLocation/private/qdeclarativegeomap_p.h>
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeomap_p.h>
QT_BEGIN_NAMESPACE
@@ -95,10 +96,27 @@ public:
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
+ virtual QGeoMap::ItemType itemType() const = 0;
+
+ // Data-related bool. Used by QGeoMaps that render the item directly.
+ bool isDirty() const;
+ bool isGeoMaterialDirty() const;
+ bool isGeoGeometryDirty() const;
+ void markClean();
+
protected Q_SLOTS:
virtual void afterChildrenChanged();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
void polishAndUpdate();
+ inline void markGeoMaterialDirty()
+ {
+ geoMaterialDirty_ = true;
+ }
+
+ inline void markGeoGeometryDirty()
+ {
+ geoGeometryDirty_ = true;
+ }
protected:
float zoomLevelOpacity() const;
@@ -108,6 +126,11 @@ protected:
private Q_SLOTS:
void baseCameraDataChanged(const QGeoCameraData &camera);
+protected:
+ // For consumption by QGeoMaps that are capable of drawing items
+ bool geoGeometryDirty_;
+ bool geoMaterialDirty_;
+
private:
QGeoMap *map_;
QDeclarativeGeoMap *quickMap_;
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
index b3b8aa8a..c5c336b5 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
@@ -149,7 +149,7 @@ void QDeclarativeGeoMapQuickItem::setCoordinate(const QGeoCoordinate &coordinate
geoshape_.setTopLeft(coordinate_);
geoshape_.setBottomRight(coordinate_);
// TODO: Handle zoomLevel != 0.0
-
+ markGeoGeometryDirty();
polishAndUpdate();
emit coordinateChanged();
}
@@ -204,7 +204,7 @@ void QDeclarativeGeoMapQuickItem::setSourceItem(QQuickItem *sourceItem)
if (sourceItem_.data() == sourceItem)
return;
sourceItem_ = sourceItem;
-
+ markGeoGeometryDirty(); // This is equivalent to geometry
polishAndUpdate();
emit sourceItemChanged();
}
@@ -250,6 +250,7 @@ void QDeclarativeGeoMapQuickItem::setAnchorPoint(const QPointF &anchorPoint)
if (anchorPoint == anchorPoint_)
return;
anchorPoint_ = anchorPoint;
+ markGeoGeometryDirty(); // This is equivalent to geometry
polishAndUpdate();
emit anchorPointChanged();
}
@@ -282,6 +283,7 @@ void QDeclarativeGeoMapQuickItem::setZoomLevel(qreal zoomLevel)
if (zoomLevel == zoomLevel_)
return;
zoomLevel_ = zoomLevel;
+ markGeoGeometryDirty(); // This is equivalent to geometry
// TODO: update geoshape_!
polishAndUpdate();
emit zoomLevelChanged();
@@ -299,6 +301,11 @@ const QGeoShape &QDeclarativeGeoMapQuickItem::geoShape() const
return geoshape_;
}
+QGeoMap::ItemType QDeclarativeGeoMapQuickItem::itemType() const
+{
+ return QGeoMap::MapQuickItem;
+}
+
/*!
\internal
*/
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
index 2d910167..23de8861 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
@@ -86,6 +86,7 @@ public:
qreal zoomLevel() const;
const QGeoShape &geoShape() const Q_DECL_OVERRIDE;
+ QGeoMap::ItemType itemType() const Q_DECL_OVERRIDE;
Q_SIGNALS:
void coordinateChanged();
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index 3f05957a..b9632636 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -373,6 +373,10 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent)
this, SLOT(handleBorderUpdated()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
this, SLOT(handleBorderUpdated()));
+ QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
+ this, SLOT(markGeoMaterialDirty()));
+ QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
+ this, SLOT(markGeoMaterialDirty()));
}
/*!
@@ -473,6 +477,7 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value)
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -491,6 +496,7 @@ void QDeclarativePolygonMapItem::addCoordinate(const QGeoCoordinate &coordinate)
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -514,6 +520,7 @@ void QDeclarativePolygonMapItem::removeCoordinate(const QGeoCoordinate &coordina
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -538,6 +545,7 @@ void QDeclarativePolygonMapItem::setColor(const QColor &color)
color_ = color;
dirtyMaterial_ = true;
+ geoMaterialDirty_ = true;
update();
emit colorChanged(color_);
}
@@ -649,6 +657,11 @@ const QGeoShape &QDeclarativePolygonMapItem::geoShape() const
return geopath_;
}
+QGeoMap::ItemType QDeclarativePolygonMapItem::itemType() const
+{
+ return QGeoMap::MapPolygon;
+}
+
/*!
\internal
*/
@@ -671,6 +684,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
geopath_.translate(offsetLati, offsetLongi);
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
index cb4de6b9..9a46bb2c 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
@@ -106,6 +106,7 @@ public:
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
const QGeoShape &geoShape() const Q_DECL_OVERRIDE;
+ QGeoMap::ItemType itemType() const Q_DECL_OVERRIDE;
Q_SIGNALS:
void pathChanged();
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index 601af6ee..712ff2d7 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -534,6 +534,10 @@ QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent)
this, SLOT(updateAfterLinePropertiesChanged()));
QObject::connect(&line_, SIGNAL(widthChanged(qreal)),
this, SLOT(updateAfterLinePropertiesChanged()));
+ QObject::connect(&line_, SIGNAL(colorChanged(QColor)),
+ this, SLOT(markGeoMaterialDirty()));
+ QObject::connect(&line_, SIGNAL(widthChanged(qreal)),
+ this, SLOT(markGeoMaterialDirty()));
}
QDeclarativePolylineMapItem::~QDeclarativePolylineMapItem()
@@ -650,6 +654,7 @@ void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate
geopath_.addCoordinate(coordinate);
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -693,6 +698,7 @@ void QDeclarativePolylineMapItem::replaceCoordinate(int index, const QGeoCoordin
geopath_.replaceCoordinate(index, coordinate);
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -742,8 +748,8 @@ void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordin
geopath_.removeCoordinate(coordinate);
if (geopath_.path().length() == length)
return;
- geometry_.markSourceDirty();
- polishAndUpdate();
+ markGeoGeometryDirty();
+ markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -766,6 +772,7 @@ void QDeclarativePolylineMapItem::removeCoordinate(int index)
geopath_.removeCoordinate(index);
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -810,6 +817,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
geopath_.translate(offsetLati, offsetLongi);
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -899,6 +907,11 @@ const QGeoShape &QDeclarativePolylineMapItem::geoShape() const
return geopath_;
}
+QGeoMap::ItemType QDeclarativePolylineMapItem::itemType() const
+{
+ return QGeoMap::MapPolyline;
+}
+
//////////////////////////////////////////////////////////////////////
/*!
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
index abc1df2f..55703258 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
@@ -144,6 +144,7 @@ public:
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
const QGeoShape &geoShape() const Q_DECL_OVERRIDE;
+ QGeoMap::ItemType itemType() const Q_DECL_OVERRIDE;
QDeclarativeMapLineProperties *line();
diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
index 8abd58dd..fbd2c79b 100644
--- a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
@@ -123,6 +123,10 @@ QDeclarativeRectangleMapItem::QDeclarativeRectangleMapItem(QQuickItem *parent)
this, SLOT(markSourceDirtyAndUpdate()));
QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
this, SLOT(markSourceDirtyAndUpdate()));
+ QObject::connect(&border_, SIGNAL(colorChanged(QColor)),
+ this, SLOT(markGeoMaterialDirty()));
+ QObject::connect(&border_, SIGNAL(widthChanged(qreal)),
+ this, SLOT(markGeoMaterialDirty()));
}
QDeclarativeRectangleMapItem::~QDeclarativeRectangleMapItem()
@@ -168,7 +172,7 @@ void QDeclarativeRectangleMapItem::setTopLeft(const QGeoCoordinate &topLeft)
return;
rectangle_.setTopLeft(topLeft);
-
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft);
}
@@ -200,7 +204,7 @@ void QDeclarativeRectangleMapItem::setBottomRight(const QGeoCoordinate &bottomRi
return;
rectangle_.setBottomRight(bottomRight);
-
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit bottomRightChanged(bottomRight);
}
@@ -227,6 +231,7 @@ void QDeclarativeRectangleMapItem::setColor(const QColor &color)
return;
color_ = color;
dirtyMaterial_ = true;
+ geoMaterialDirty_ = true;
polishAndUpdate();
emit colorChanged(color_);
}
@@ -347,6 +352,11 @@ const QGeoShape &QDeclarativeRectangleMapItem::geoShape() const
return rectangle_;
}
+QGeoMap::ItemType QDeclarativeRectangleMapItem::itemType() const
+{
+ return QGeoMap::MapRectangle;
+}
+
/*!
\internal
*/
@@ -369,6 +379,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
rectangle_.translate(offsetLati, offsetLongi);
geometry_.setPreserveGeometry(true, rectangle_.topLeft());
borderGeometry_.setPreserveGeometry(true, rectangle_.topLeft());
+ markGeoGeometryDirty();
markSourceDirtyAndUpdate();
emit topLeftChanged(rectangle_.topLeft());
emit bottomRightChanged(rectangle_.bottomRight());
diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h b/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h
index 6e6ea5b1..b65db813 100644
--- a/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h
@@ -89,6 +89,7 @@ public:
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
const QGeoShape &geoShape() const Q_DECL_OVERRIDE;
+ QGeoMap::ItemType itemType() const Q_DECL_OVERRIDE;
Q_SIGNALS:
void topLeftChanged(const QGeoCoordinate &topLeft);
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 6c9c2b7f..4529cc0a 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -38,6 +38,7 @@
#include "qgeomap_p_p.h"
#include "qgeocameracapabilities_p.h"
#include "qgeomappingmanagerengine_p.h"
+#include "qdeclarativegeomapitembase_p.h"
#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -49,6 +50,7 @@ QGeoMap::QGeoMap(QGeoMapPrivate &dd, QObject *parent)
QGeoMap::~QGeoMap()
{
+ clearParameters();
}
void QGeoMap::setViewportSize(const QSize& size)
@@ -187,6 +189,38 @@ void QGeoMap::clearParameters()
d->m_mapParameters.clear();
}
+QGeoMap::ItemTypes QGeoMap::supportedMapItemTypes() const
+{
+ Q_D(const QGeoMap);
+ return d->supportedMapItemTypes();
+}
+
+void QGeoMap::addMapItem(QDeclarativeGeoMapItemBase *item)
+{
+ Q_D(QGeoMap);
+ if (item && !d->m_mapItems.contains(item) && d->supportedMapItemTypes() & item->itemType()) {
+ d->m_mapItems.insert(item);
+ d->addMapItem(item);
+ }
+}
+
+void QGeoMap::removeMapItem(QDeclarativeGeoMapItemBase *item)
+{
+ Q_D(QGeoMap);
+ if (item && d->m_mapItems.contains(item)) {
+ d->removeMapItem(item);
+ d->m_mapItems.remove(item);
+ }
+}
+
+void QGeoMap::clearMapItems()
+{
+ Q_D(QGeoMap);
+ for (QDeclarativeGeoMapItemBase *p : d->m_mapItems)
+ d->removeMapItem(p);
+ d->m_mapItems.clear();
+}
+
QGeoMapPrivate::QGeoMapPrivate(QGeoMappingManagerEngine *engine, QGeoProjection *geoProjection)
: QObjectPrivate(),
m_geoProjection(geoProjection),
@@ -211,4 +245,19 @@ void QGeoMapPrivate::removeParameter(QGeoMapParameter *param)
Q_UNUSED(param)
}
+QGeoMap::ItemTypes QGeoMapPrivate::supportedMapItemTypes() const
+{
+ return QGeoMap::NoItem;
+}
+
+void QGeoMapPrivate::addMapItem(QDeclarativeGeoMapItemBase *item)
+{
+ Q_UNUSED(item)
+}
+
+void QGeoMapPrivate::removeMapItem(QDeclarativeGeoMapItemBase *item)
+{
+ Q_UNUSED(item)
+}
+
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index 7f9fca8c..4838cb4e 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -63,6 +63,7 @@ class QGeoCoordinate;
class QSGNode;
class QQuickWindow;
class QGeoMapParameter;
+class QDeclarativeGeoMapItemBase;
class Q_LOCATION_EXPORT QGeoMap : public QObject
{
@@ -70,6 +71,18 @@ class Q_LOCATION_EXPORT QGeoMap : public QObject
Q_DECLARE_PRIVATE(QGeoMap)
public:
+ enum ItemType {
+ NoItem = 0x0000,
+ MapRectangle = 0x0001,
+ MapCircle = 0x0002,
+ MapPolyline = 0x0004,
+ MapPolygon = 0x0008,
+ MapQuickItem = 0x0010,
+ CustomMapItem = 0x8000
+ };
+
+ Q_DECLARE_FLAGS(ItemTypes, ItemType)
+
virtual ~QGeoMap();
// Sets the display size
@@ -102,6 +115,12 @@ public:
void removeParameter(QGeoMapParameter *param);
void clearParameters();
+ ItemTypes supportedMapItemTypes() const;
+
+ void addMapItem(QDeclarativeGeoMapItemBase *item);
+ void removeMapItem(QDeclarativeGeoMapItemBase *item);
+ void clearMapItems();
+
protected:
QGeoMap(QGeoMapPrivate &dd, QObject *parent = 0);
void setCameraData(const QGeoCameraData &cameraData);
@@ -119,6 +138,8 @@ private:
friend class QDeclarativeGeoMap; //updateSceneGraph
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoMap::ItemTypes)
+
QT_END_NAMESPACE
#endif // QGEOMAP_P_H
diff --git a/src/location/maps/qgeomap_p_p.h b/src/location/maps/qgeomap_p_p.h
index 625cd676..ab603be7 100644
--- a/src/location/maps/qgeomap_p_p.h
+++ b/src/location/maps/qgeomap_p_p.h
@@ -54,6 +54,7 @@
#include <QtCore/private/qobject_p.h>
#include <QtCore/QSize>
#include <QtCore/QSet>
+#include "qgeomap_p.h"
QT_BEGIN_NAMESPACE
@@ -62,6 +63,7 @@ class QGeoMappingManagerEngine;
class QGeoMap;
class QGeoMapController;
class QGeoMapParameter;
+class QDeclarativeGeoMapItemBase;
class Q_LOCATION_PRIVATE_EXPORT QGeoMapPrivate : public QObjectPrivate
{
@@ -76,6 +78,10 @@ protected:
virtual void addParameter(QGeoMapParameter *param);
virtual void removeParameter(QGeoMapParameter *param);
+ virtual QGeoMap::ItemTypes supportedMapItemTypes() const;
+ virtual void addMapItem(QDeclarativeGeoMapItemBase *item);
+ virtual void removeMapItem(QDeclarativeGeoMapItemBase *item);
+
virtual void changeViewportSize(const QSize &size) = 0; // called by QGeoMap::setSize()
virtual void changeCameraData(const QGeoCameraData &oldCameraData) = 0; // called by QGeoMap::setCameraData()
virtual void changeActiveMapType(const QGeoMapType mapType) = 0; // called by QGeoMap::setActiveMapType()
@@ -87,6 +93,7 @@ protected:
QGeoCameraData m_cameraData;
QGeoMapType m_activeMapType;
QSet<QGeoMapParameter *> m_mapParameters;
+ QSet<QDeclarativeGeoMapItemBase *> m_mapItems;
};
QT_END_NAMESPACE