summaryrefslogtreecommitdiff
path: root/src/location/maps
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 /src/location/maps
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>
Diffstat (limited to 'src/location/maps')
-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
3 files changed, 77 insertions, 0 deletions
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