diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-01-19 00:30:19 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-01-30 09:29:09 +0000 |
commit | 0a5dd29d4b02a192ec7e691cf88f623152ce100b (patch) | |
tree | 9d1975b4cf1f61ed3aa56af8d98443632e8c21ba /src/location/maps/qgeomap.cpp | |
parent | 1946896ace3f5fa8b6086fb416ea934fea387f12 (diff) | |
download | qtlocation-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/qgeomap.cpp')
-rw-r--r-- | src/location/maps/qgeomap.cpp | 49 |
1 files changed, 49 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 |