summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-01-12 18:23:28 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-01-25 12:27:08 +0000
commitd8a7da2c00d9b292e56f28cf2df4f191e6edce2c (patch)
tree8184e332c8836303100e906bfac183c16adaa58a
parent3aca8077a21d4219b62a03bdc790a2019eb072cc (diff)
downloadqtlocation-d8a7da2c00d9b292e56f28cf2df4f191e6edce2c.tar.gz
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>
-rw-r--r--src/location/declarativemaps/declarativemaps.pri5
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp96
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h9
-rw-r--r--src/location/declarativemaps/qgeomapobject.cpp262
-rw-r--r--src/location/declarativemaps/qgeomapobject_p.h131
-rw-r--r--src/location/declarativemaps/qgeomapobject_p_p.h92
-rw-r--r--src/location/maps/qgeomap.cpp30
-rw-r--r--src/location/maps/qgeomap_p.h6
-rw-r--r--src/location/maps/qgeomap_p_p.h3
9 files changed, 626 insertions, 8 deletions
diff --git a/src/location/declarativemaps/declarativemaps.pri b/src/location/declarativemaps/declarativemaps.pri
index e607ea2b..335dc55a 100644
--- a/src/location/declarativemaps/declarativemaps.pri
+++ b/src/location/declarativemaps/declarativemaps.pri
@@ -29,6 +29,8 @@ PRIVATE_HEADERS += \
declarativemaps/qdeclarativegeomapitemgroup_p.h \
declarativemaps/qparameterizableobject_p.h \
declarativemaps/mapitemviewdelegateincubator_p.h \
+ declarativemaps/qgeomapobject_p.h \
+ declarativemaps/qgeomapobject_p_p.h \
../imports/positioning/qquickgeocoordinateanimation_p.h
SOURCES += \
@@ -57,9 +59,8 @@ SOURCES += \
declarativemaps/qparameterizableobject.cpp \
declarativemaps/qdeclarativegeomapitemgroup.cpp \
declarativemaps/mapitemviewdelegateincubator.cpp \
+ declarativemaps/qgeomapobject.cpp \
../imports/positioning/qquickgeocoordinateanimation.cpp
load(qt_build_paths)
LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lpoly2tri$$qtPlatformTargetSuffix() -lclip2tri$$qtPlatformTargetSuffix()
-
-
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 34885f54..42ed633d 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -43,6 +43,7 @@
#include "qgeocameracapabilities_p.h"
#include "qgeomap_p.h"
#include "qdeclarativegeomapparameter_p.h"
+#include "qgeomapobject_p.h"
#include <QtPositioning/QGeoCircle>
#include <QtPositioning/QGeoRectangle>
#include <QtPositioning/QGeoPath>
@@ -102,15 +103,17 @@ QT_BEGIN_NAMESPACE
\section2 Map Objects
Map related objects can be declared within the body of a Map object in Qt Quick and will
- automatically appear on the Map. To add objects programmatically, first be
- sure they are created with the Map as their parent (for example in an argument to
- Component::createObject), and then call the \l addMapItem method on the Map.
+ automatically appear on the Map. To add an object programmatically, first be
+ sure it is created with the Map as its parent (for example in an argument to
+ Component::createObject).
+ Then call the \l addMapItem method on the Map, if the type of this object is one of
+ \l MapCircle, \l MapRectangle, \l MapPolyline, \l MapPolygon, \l MapRoute or \l MapQuickItem.
A corresponding \l removeMapItem method also exists to do the opposite and
- remove an object from the Map.
+ remove any of the above types of map objects from the Map.
Moving Map objects around, resizing them or changing their shape normally
does not involve any special interaction with Map itself -- changing these
- details about a map object will automatically update the display.
+ properties in a map object will automatically update the display.
\section2 Interaction
@@ -257,7 +260,7 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap()
delete m_copyrights.data();
m_copyrights.clear();
- delete m_map;
+ delete m_map; // map objects get reset here
}
/*!
@@ -422,6 +425,9 @@ void QDeclarativeGeoMap::initialize()
m_map->setCameraData(m_cameraData);
+ for (auto obj : qAsConst(m_pendingMapObjects))
+ obj->setMap(m_map);
+
m_initialized = true;
if (centerHasChanged)
@@ -578,6 +584,10 @@ void QDeclarativeGeoMap::populateMap()
addMapItemGroup(itemGroup);
continue;
}
+
+ QGeoMapObject *mapObject = qobject_cast<QGeoMapObject *>(k);
+ if (mapObject)
+ addMapObject(mapObject);
}
}
@@ -1647,6 +1657,11 @@ QGeoServiceProvider::Error QDeclarativeGeoMap::error() const
return m_error;
}
+QGeoMap *QDeclarativeGeoMap::map() const
+{
+ return m_map;
+}
+
/*!
\internal
*/
@@ -1845,6 +1860,75 @@ QList<QObject *> QDeclarativeGeoMap::mapParameters()
return ret;
}
+/*
+ \internal
+*/
+void QDeclarativeGeoMap::addMapObject(QGeoMapObject *object)
+{
+ if (!object || object->map())
+ return;
+
+ if (!m_initialized) {
+ m_pendingMapObjects.append(object);
+ return;
+ }
+
+ int curObjects = m_map->mapObjects().size();
+ // object adds itself to the map
+ object->setMap(m_map);
+
+ if (curObjects != m_map->mapObjects().size())
+ emit mapObjectsChanged();
+}
+
+/*
+ \internal
+*/
+void QDeclarativeGeoMap::removeMapObject(QGeoMapObject *object)
+{
+ if (!object || object->map() != m_map) // if !initialized this is fine, since both object and m_map are supposed to be NULL
+ return;
+
+ if (!m_initialized) {
+ m_pendingMapObjects.removeOne(object);
+ return;
+ }
+
+ int curObjects = m_map->mapObjects().size();
+ // object adds itself to the map
+ object->setMap(nullptr);
+
+ if (curObjects != m_map->mapObjects().size())
+ emit mapObjectsChanged();
+}
+
+/*
+ \internal
+*/
+void QDeclarativeGeoMap::clearMapObjects()
+{
+ if (!m_initialized) {
+ m_pendingMapObjects.clear();
+ } else {
+ const QList<QGeoMapObject *> objs = m_map->mapObjects();
+ for (QGeoMapObject *o: objs)
+ o->setMap(nullptr);
+ if (objs.size())
+ emit mapObjectsChanged();
+ }
+}
+
+/*
+ \internal
+*/
+QList<QGeoMapObject *> QDeclarativeGeoMap::mapObjects()
+{
+ if (!m_initialized)
+ return m_pendingMapObjects;
+ else
+ return m_map->mapObjects();
+}
+
/*!
\qmlproperty list<MapItem> QtLocation::Map::mapItems
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index 5c568d8f..27ee9822 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -175,6 +175,12 @@ public:
Q_INVOKABLE void clearMapParameters();
QList<QObject *> mapParameters();
+ void addMapObject(QGeoMapObject *object);
+ void removeMapObject(QGeoMapObject *object);
+ void clearMapObjects();
+ QList<QGeoMapObject *> mapObjects();
+
+
Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &position, bool clipToViewPort = true) const;
Q_INVOKABLE QPointF fromCoordinate(const QGeoCoordinate &coordinate, bool clipToViewPort = true) const;
@@ -188,6 +194,7 @@ public:
QString errorString() const;
QGeoServiceProvider::Error error() const;
+ QGeoMap* map() const;
Q_SIGNALS:
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
@@ -212,6 +219,7 @@ Q_SIGNALS:
void copyrightsChanged(const QImage &copyrightsImage);
void copyrightsChanged(const QString &copyrightsHtml);
void mapReadyChanged(bool ready);
+ void mapObjectsChanged();
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE ;
@@ -273,6 +281,7 @@ private:
double m_maximumViewportLatitude;
bool m_initialized;
QList<QDeclarativeGeoMapParameter *> m_mapParameters;
+ QList<QGeoMapObject*> m_pendingMapObjects; // Used only in the initialization phase
QGeoCameraCapabilities m_cameraCapabilities;
qreal m_userMinimumZoomLevel;
qreal m_userMaximumZoomLevel;
diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp
new file mode 100644
index 00000000..7ccbbf16
--- /dev/null
+++ b/src/location/declarativemaps/qgeomapobject.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativegeomap_p.h"
+#include "qgeomapobject_p.h"
+#include "qgeomapobject_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+
+ \qmltype GeoMapObject
+ \instantiates QGeoMapObject
+ \inqmlmodule Qt.labs.location
+ \ingroup qml-QtLocation5-maps
+
+ \brief The GeoObject type is a base class for geographical objects that can be added to a map.
+
+ The difference between a GeoMapObject and a MapItem is twofold. First, GeoMapObject are always backed
+ by a plugin-specific implementation and do not come with a default implementation. If a plugin does
+ not support a specific GeoMapObject type, adding such a GeoMapObject will have no effect.
+ Second, GeoMapObject are not QQuickItems, thus being a much more lightweight way to add content to
+ a map.
+
+ GeoMapObject support is plugin-dependent, and is documented per plugin.
+*/
+
+template<>
+QGeoMapObjectPrivate *QExplicitlySharedDataPointer<QGeoMapObjectPrivate>::clone()
+{
+ return d->clone();
+}
+
+QGeoMapObject::~QGeoMapObject()
+{
+
+}
+
+/*!
+ Returns whether this geographical object and \a other are equal.
+*/
+bool QGeoMapObject::operator ==(const QGeoMapObject &other) const
+{
+ return ( (d_ptr.constData() == other.d_ptr.constData())
+ || (*d_ptr) == (*other.d_ptr));
+}
+
+/*!
+ Returns whether this geographical object and \a other are not equal.
+*/
+bool QGeoMapObject::operator !=(const QGeoMapObject &other) const
+{
+ return !(operator==(other));
+}
+
+/*!
+ \internal
+ Returns which features are supported by the geographical object
+*/
+QGeoMapObject::Features QGeoMapObject::features() const
+{
+ return d_ptr->features();
+}
+
+QGeoMapObjectPrivate *QGeoMapObject::implementation() const
+{
+ return d_ptr.data();
+}
+
+bool QGeoMapObject::setImplementation(QGeoMapObjectPrivate *pimpl)
+{
+ if (d_ptr->type() != pimpl->type())
+ return false;
+ d_ptr = QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(pimpl);
+ return true;
+}
+
+bool QGeoMapObject::implemented() const
+{
+ return !d_ptr->engineName().isEmpty();
+}
+
+bool QGeoMapObject::visible() const
+{
+ return d_ptr->visible();
+}
+
+void QGeoMapObject::setVisible(bool visible)
+{
+ if (visible == d_ptr->visible())
+ return;
+
+ d_ptr->setVisible(visible);
+
+ if (d_ptr->m_componentCompleted)
+ setChildrenVisibility();
+ emit visibleChanged();
+}
+
+QGeoMapObject::Type QGeoMapObject::type() const
+{
+ return d_ptr->type();
+}
+
+QList<QGeoMapObject *> QGeoMapObject::geoMapObjectChildren() const
+{
+ return quickChildren<QGeoMapObject>();
+}
+
+QGeoMapObject::QGeoMapObject(const QExplicitlySharedDataPointer<QGeoMapObjectPrivate> &dd, QObject *parent)
+ : QParameterizableObject(parent), d_ptr(dd)
+{
+}
+
+void QGeoMapObject::setChildrenVisibility()
+{
+ const bool v = visible();
+ const QList<QGeoMapObject *> kids = geoMapObjectChildren();
+ for (auto kid : qAsConst(kids))
+ kid->setVisible(v);
+}
+
+void QGeoMapObject::classBegin()
+{
+
+}
+
+void QGeoMapObject::completeComponent()
+{
+ d_ptr->m_componentCompleted = true;
+ setChildrenVisibility();
+}
+
+void QGeoMapObject::componentComplete()
+{
+ completeComponent();
+ emit completed();
+}
+
+void QGeoMapObject::setMap(QGeoMap *map)
+{
+ if (d_ptr->m_map == map)
+ return;
+
+ d_ptr->m_map = map;
+ if (map) {
+ QGeoMapObjectPrivate *pimpl = d_ptr.data();
+ if (!map->createMapObjectImplementation(this))
+ qWarning() << "Unsupported type " << type();
+ else
+ delete pimpl; // delete old implementation
+ }
+
+ const QList<QGeoMapObject *> kids = geoMapObjectChildren();
+ for (auto kid : kids)
+ kid->setMap(map);
+}
+
+QGeoMap *QGeoMapObject::map() const
+{
+ return d_ptr->m_map;
+}
+
+
+//
+// QGeoMapObjectPrivate
+//
+
+QGeoMapObjectPrivate::QGeoMapObjectPrivate()
+{
+}
+
+QGeoMapObjectPrivate::QGeoMapObjectPrivate(QGeoMapObject *q) : q(q)
+{
+}
+
+QGeoMapObjectPrivate::QGeoMapObjectPrivate(const QGeoMapObjectPrivate &other)
+ :QSharedData(other)
+ ,q(other.q)
+ ,m_componentCompleted(other.m_componentCompleted)
+ ,m_visible(other.m_visible)
+{
+
+}
+
+QGeoMapObjectPrivate::~QGeoMapObjectPrivate()
+{
+}
+
+bool QGeoMapObjectPrivate::operator ==(const QGeoMapObjectPrivate &other) const
+{
+ return (type() == other.type() && engineName() == other.engineName()
+ && equals(other));
+}
+
+QByteArray QGeoMapObjectPrivate::engineName() const
+{
+ return QByteArray();
+}
+
+QGeoMapObject::Type QGeoMapObjectPrivate::type() const
+{
+ return QGeoMapObject::InvalidType;
+}
+
+QGeoMapObject::Features QGeoMapObjectPrivate::features() const
+{
+ return QGeoMapObject::NoFeature;
+}
+
+bool QGeoMapObjectPrivate::equals(const QGeoMapObjectPrivate &other) const
+{
+ return (visible() == other.visible() && type() == other.type()
+ && engineName() == other.engineName() && features() == other.features()
+ && m_map == other.m_map);
+}
+
+bool QGeoMapObjectPrivate::visible() const
+{
+ return m_visible;
+}
+
+void QGeoMapObjectPrivate::setVisible(bool visible)
+{
+ m_visible = visible;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qgeomapobject_p.h b/src/location/declarativemaps/qgeomapobject_p.h
new file mode 100644
index 00000000..9f479dd7
--- /dev/null
+++ b/src/location/declarativemaps/qgeomapobject_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECTBASE_H
+#define QGEOMAPOBJECTBASE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocation/private/qparameterizableobject_p.h>
+#include <QExplicitlySharedDataPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QGeoMapObjectPrivate;
+class QGeoMap;
+
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapObject : public QParameterizableObject, public QQmlParserStatus
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(Type type READ type CONSTANT)
+
+public:
+ enum Feature {
+ NoFeature = 0x0,
+ Clickable = 0x01,
+ Draggable = 0x02,
+ AllFeatures = 0xFFFFFFFF
+ };
+
+ enum Type {
+ InvalidType = 0,
+ LayerType = 1,
+ RouteType = 2,
+ RectangleType = 3,
+ CircleType = 4,
+ PolylineType = 5,
+ PolygonType = 6,
+ IconType = 7,
+ UserType = 0x0100
+ };
+
+ Q_ENUM(Type)
+ Q_DECLARE_FLAGS(Features, Feature)
+
+ virtual ~QGeoMapObject();
+
+ bool operator == (const QGeoMapObject &other) const;
+ bool operator != (const QGeoMapObject &other) const;
+
+ Features features() const;
+ QGeoMapObjectPrivate *implementation() const;
+ bool setImplementation(QGeoMapObjectPrivate *pimpl);
+ bool implemented() const;
+
+ bool visible() const;
+ void setVisible(bool visible);
+
+ Type type() const;
+
+ virtual QList<QGeoMapObject*> geoMapObjectChildren() const;
+ virtual void setMap(QGeoMap *map);
+ QGeoMap *map() const;
+
+Q_SIGNALS:
+ void visibleChanged();
+ void selected();
+ void completed();
+
+protected:
+ QGeoMapObject(const QExplicitlySharedDataPointer<QGeoMapObjectPrivate> &dd, QObject *parent = nullptr);
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate> d_ptr;
+
+ void setChildrenVisibility();
+
+ // QQmlParserStatus interface
+ void classBegin() override;
+ void componentComplete() override;
+ void completeComponent();
+
+ friend class QGeoMap;
+ friend class QDeclarativeGeoMap;
+ friend class QGeoMapLayer;
+ friend class QDeclarativeNavigator;
+};
+QT_END_NAMESPACE
+
+#endif // QGEOMAPOBJECTBASE_H
diff --git a/src/location/declarativemaps/qgeomapobject_p_p.h b/src/location/declarativemaps/qgeomapobject_p_p.h
new file mode 100644
index 00000000..365298b3
--- /dev/null
+++ b/src/location/declarativemaps/qgeomapobject_p_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECTBASE_P_H
+#define QGEOMAPOBJECTBASE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeomap_p.h>
+#include <QSharedData>
+#include <QPointer>
+
+#include <QUrl>
+#include "qgeomapobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QGeoMapObject;
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapObjectPrivate : public QSharedData
+{
+public:
+ virtual ~QGeoMapObjectPrivate();
+
+ bool operator == (const QGeoMapObjectPrivate &other) const;
+
+ virtual QByteArray engineName() const;
+ virtual QGeoMapObject::Features features() const;
+ virtual bool equals(const QGeoMapObjectPrivate &other) const;
+ virtual QGeoMapObject::Type type() const;
+ virtual bool visible() const;
+ virtual void setVisible(bool visible);
+ virtual QGeoMapObjectPrivate *clone() = 0; // to allow proper detaching
+
+ QGeoMapObject *q = nullptr;
+ QPointer<QGeoMap> m_map;
+ bool m_componentCompleted = false;
+ bool m_visible = false;
+
+protected:
+ QGeoMapObjectPrivate(QGeoMapObject *q);
+ QGeoMapObjectPrivate(const QGeoMapObjectPrivate &other);
+
+private:
+ QGeoMapObjectPrivate();
+};
+
+QT_END_NAMESPACE
+
+#endif // QGEOMAPOBJECTBASE_P_H
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()