diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-01-12 18:23:28 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-01-25 12:27:08 +0000 |
commit | d8a7da2c00d9b292e56f28cf2df4f191e6edce2c (patch) | |
tree | 8184e332c8836303100e906bfac183c16adaa58a /src/location/maps | |
parent | 3aca8077a21d4219b62a03bdc790a2019eb072cc (diff) |
Introduce QGeoMapObject
QGeoMapObject is a new class of map item, not deriving anymore from
QQuickItem, and designed to be more lightweight, and, most importantly,
to be easily backable by SDK-specific implementations, so to act as
an as thin as possible wrapper around those.
QGeoMapObject is intended to be the base class for this type of items.
This patch provides no mean to dynamically add/remove GeoMapObjects.
The intended way to do it is by using a MapObjectView, coming
initially with the Qt.labs.location extra plugin.
Change-Id: I8d6a45a4a32059c7ec4d904f75352e176bffda1e
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/maps')
-rw-r--r-- | src/location/maps/qgeomap.cpp | 30 | ||||
-rw-r--r-- | src/location/maps/qgeomap_p.h | 6 | ||||
-rw-r--r-- | src/location/maps/qgeomap_p_p.h | 3 |
3 files changed, 39 insertions, 0 deletions
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp index fd03de01..529ebf82 100644 --- a/src/location/maps/qgeomap.cpp +++ b/src/location/maps/qgeomap.cpp @@ -39,6 +39,7 @@ #include "qgeocameracapabilities_p.h" #include "qgeomappingmanagerengine_p.h" #include "qdeclarativegeomapitembase_p.h" +#include "qgeomapobject_p.h" #include <QDebug> QT_BEGIN_NAMESPACE @@ -50,7 +51,10 @@ QGeoMap::QGeoMap(QGeoMapPrivate &dd, QObject *parent) QGeoMap::~QGeoMap() { + Q_D(QGeoMap); clearParameters(); + for (QGeoMapObject *p : d->mapObjects()) + p->setMap(nullptr); // forces replacing pimpls with the default ones. } void QGeoMap::setViewportSize(const QSize& size) @@ -231,6 +235,21 @@ void QGeoMap::clearMapItems() d->m_mapItems.clear(); } +/*! + Fills obj with a backend-specific pimpl. +*/ +bool QGeoMap::createMapObjectImplementation(QGeoMapObject *obj) +{ + Q_D(QGeoMap); + return d->createMapObjectImplementation(obj); +} + +QList<QGeoMapObject *> QGeoMap::mapObjects() const +{ + Q_D(const QGeoMap); + return d->mapObjects(); +} + QString QGeoMap::copyrightsStyleSheet() const { return QStringLiteral("#copyright-root { background: rgba(255, 255, 255, 128) }"); @@ -307,4 +326,15 @@ void QGeoMapPrivate::removeMapItem(QDeclarativeGeoMapItemBase *item) Q_UNUSED(item) } +bool QGeoMapPrivate::createMapObjectImplementation(QGeoMapObject *obj) +{ + Q_UNUSED(obj) + return false; +} + +QList<QGeoMapObject *> QGeoMapPrivate::mapObjects() const +{ + return QList<QGeoMapObject *>(); +} + QT_END_NAMESPACE diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h index 40d520fe..7c7825f2 100644 --- a/src/location/maps/qgeomap_p.h +++ b/src/location/maps/qgeomap_p.h @@ -54,6 +54,7 @@ #include <QtCore/QObject> #include <QtPositioning/private/qdoublevector2d_p.h> #include <QtLocation/private/qgeoprojection_p.h> +#include <QtLocation/qgeoroute.h> QT_BEGIN_NAMESPACE @@ -65,6 +66,7 @@ class QSGNode; class QQuickWindow; class QGeoMapParameter; class QDeclarativeGeoMapItemBase; +class QGeoMapObject; class Q_LOCATION_PRIVATE_EXPORT QGeoMap : public QObject { @@ -122,6 +124,10 @@ public: void removeMapItem(QDeclarativeGeoMapItemBase *item); void clearMapItems(); + bool createMapObjectImplementation(QGeoMapObject *obj); + QList<QGeoMapObject *> mapObjects() const; + + virtual QString copyrightsStyleSheet() const; virtual void setAcceptedGestures(bool pan, bool flick, bool pinch, bool rotate, bool tilt); virtual bool handleEvent(QEvent *event); diff --git a/src/location/maps/qgeomap_p_p.h b/src/location/maps/qgeomap_p_p.h index ef57ceb2..80fc70d2 100644 --- a/src/location/maps/qgeomap_p_p.h +++ b/src/location/maps/qgeomap_p_p.h @@ -89,6 +89,9 @@ protected: virtual void addMapItem(QDeclarativeGeoMapItemBase *item); virtual void removeMapItem(QDeclarativeGeoMapItemBase *item); + virtual bool createMapObjectImplementation(QGeoMapObject *obj); + virtual QList<QGeoMapObject *> mapObjects() const; + 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() |