diff options
60 files changed, 8 insertions, 6746 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index 3dcc9427..4028678f 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -56,7 +56,6 @@ #include <QtLocation/private/qdeclarativegeomapparameter_p.h> #include <QtLocation/private/qdeclarativegeomapcopyrightsnotice_p.h> #include <QtLocation/private/qdeclarativegeomapitemgroup_p.h> -#include <QtLocation/private/qgeomapobject_p.h> //Place includes #include <QtLocation/private/qdeclarativecategory_p.h> @@ -172,7 +171,6 @@ public: // Register the 5.11 types minor = 11; - qmlRegisterAnonymousType<QGeoMapObject>(uri, major); qmlRegisterType<QDeclarativeGeoMap, 11>(uri, major, minor, "Map"); qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 11>(uri, major, minor, "GeoMapItemBase", QStringLiteral("GeoMapItemBase is not intended instantiable by developer.")); diff --git a/src/imports/locationlabs/CMakeLists.txt b/src/imports/locationlabs/CMakeLists.txt index 68aa13bb..ba85ec28 100644 --- a/src/imports/locationlabs/CMakeLists.txt +++ b/src/imports/locationlabs/CMakeLists.txt @@ -7,7 +7,6 @@ qt_internal_add_qml_module(locationlabsplugin CLASS_NAME QtLocationLabsDeclarativeModule SOURCES locationlabs.cpp - locationlabssingleton_p.h locationlabssingleton.cpp LIBRARIES Qt::LocationPrivate ) diff --git a/src/imports/locationlabs/locationlabs.cpp b/src/imports/locationlabs/locationlabs.cpp index 92c7ce25..78d8d1b0 100644 --- a/src/imports/locationlabs/locationlabs.cpp +++ b/src/imports/locationlabs/locationlabs.cpp @@ -37,30 +37,15 @@ ** ****************************************************************************/ -#include <QtLocation/private/qmapiconobject_p.h> -#include <QtLocation/private/qmapobjectview_p.h> -#include <QtLocation/private/qmaprouteobject_p.h> -#include <QtLocation/private/qmapcircleobject_p.h> -#include <QtLocation/private/qmappolygonobject_p.h> -#include <QtLocation/private/qmappolylineobject_p.h> #include <QtLocation/private/qdeclarativenavigator_p.h> #include <QtLocation/private/qdeclarativenavigator_p_p.h> #include <QtLocation/private/qnavigationmanagerengine_p.h> #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> #include <QtCore/QDebug> -#include "locationlabssingleton_p.h" QT_BEGIN_NAMESPACE -static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine) -{ - Q_UNUSED(engine); - Q_UNUSED(jsEngine); - - return new LocationLabsSingleton; -} - class QtLocationLabsDeclarativeModule: public QQmlExtensionPlugin { Q_OBJECT @@ -78,16 +63,9 @@ public: int minor = 0; // Register the 1.0 labs types - qmlRegisterType<QMapIconObject>(uri, major, minor, "MapIconObject"); - qmlRegisterType<QMapObjectView>(uri, major, minor, "MapObjectView"); - qmlRegisterType<QMapRouteObject>(uri, major, minor, "MapRouteObject"); - qmlRegisterType<QMapCircleObject>(uri, major, minor, "MapCircleObject"); - qmlRegisterType<QMapPolygonObject>(uri, major, minor, "MapPolygonObject"); - qmlRegisterType<QMapPolylineObject>(uri, major, minor, "MapPolylineObject"); qmlRegisterAnonymousType<QDeclarativeNavigationBasicDirections>(uri, major); qmlRegisterType<QDeclarativeNavigator>(uri, major, minor, "Navigator"); qmlRegisterAnonymousType<QAbstractNavigator>(uri, major); - qmlRegisterSingletonType<LocationLabsSingleton>(uri, major, minor, "QtLocationLabs", singleton_type_factory); } else { qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri); } diff --git a/src/imports/locationlabs/locationlabssingleton.cpp b/src/imports/locationlabs/locationlabssingleton.cpp deleted file mode 100644 index c053da9e..00000000 --- a/src/imports/locationlabs/locationlabssingleton.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "locationlabssingleton_p.h" - -/*! - \qmltype QtLocationLabs - \instantiates LocationLabsSingleton - \inqmlmodule Qt.labs.location - \since 5.13 - - \brief The QtLocationLabs global object provides experimental, tech-preview functions for working with - location-based types in QML. - - \qml - import Qt.labs.location 1.0 - - Map { - id: map - MouseArea { - anchors.fill: parent - onClicked: { - var mapObjects = QtLocationLabs.mapObjectsAt(map.toCoordinate(Qt.point(mouseX,mouseY)), map) - } - } - } - \endqml -*/ - -LocationLabsSingleton::LocationLabsSingleton(QObject *parent) -: QObject(parent) -{ -} - -/*! - \qmlmethod coordinate ::QtLocationLabs::mapObjectsAt(coordinate, map) - - Returns the map objects in \a map covering \a coordinate. -*/ -QList<QObject *> LocationLabsSingleton::mapObjectsAt(const QGeoCoordinate &coordinate, QDeclarativeGeoMap *map) const -{ - if (!map) - return QList<QObject *>(); - return map->map()->mapObjectsAt(coordinate); -} diff --git a/src/imports/locationlabs/locationlabssingleton_p.h b/src/imports/locationlabs/locationlabssingleton_p.h deleted file mode 100644 index 2d5accab..00000000 --- a/src/imports/locationlabs/locationlabssingleton_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LOCATIONLABSSINGLETON_P_H -#define LOCATIONLABSSINGLETON_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 <QtCore/QObject> -#include <QtPositioning/QGeoCoordinate> -#include <QtLocation/private/qdeclarativegeomap_p.h> - -class LocationLabsSingleton : public QObject -{ - Q_OBJECT - -public: - explicit LocationLabsSingleton(QObject *parent = nullptr); - - Q_INVOKABLE QList<QObject *> mapObjectsAt(const QGeoCoordinate &coordinate, QDeclarativeGeoMap *map) const; -}; - -#endif // LOCATIONLABSSINGLETON_P_H diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt index 20aa1984..b8725b16 100644 --- a/src/location/CMakeLists.txt +++ b/src/location/CMakeLists.txt @@ -79,8 +79,6 @@ qt_internal_add_module(Location declarativemaps/qdeclarativegeomaptype_p.h declarativemaps/qdeclarativegeomaptype.cpp declarativemaps/qdeclarativegeomapparameter_p.h declarativemaps/qdeclarativegeomapparameter.cpp - declarativemaps/qgeomapobject_p.h declarativemaps/qgeomapobject_p_p.h - declarativemaps/qgeomapobject.cpp declarativemaps/qparameterizableobject_p.h declarativemaps/qparameterizableobject.cpp declarativemaps/error_messages.cpp declarativemaps/error_messages_p.h declarativemaps/locationvaluetypehelper.cpp declarativemaps/locationvaluetypehelper_p.h @@ -184,20 +182,6 @@ qt_internal_add_module(Location qt_internal_extend_target(Location CONDITION QT_FEATURE_location_labs_plugin SOURCES labs/qdeclarativenavigator.cpp labs/qdeclarativenavigator_p.h labs/qdeclarativenavigator_p_p.h - labs/qgeotiledmaplabs.cpp labs/qgeotiledmaplabs_p.h - labs/qmapcircleobject.cpp labs/qmapcircleobject_p.h labs/qmapcircleobject_p_p.h - labs/qmapiconobject.cpp labs/qmapiconobject_p.h labs/qmapiconobject_p_p.h - labs/qmapobjectview.cpp labs/qmapobjectview_p.h labs/qmapobjectview_p_p.h - labs/qmappolygonobject.cpp labs/qmappolygonobject_p.h labs/qmappolygonobject_p_p.h - labs/qmappolylineobject.cpp labs/qmappolylineobject_p.h labs/qmappolylineobject_p_p.h - labs/qmaprouteobject.cpp labs/qmaprouteobject_p.h labs/qmaprouteobject_p_p.h - labs/qsg/qgeomapobjectqsgsupport.cpp labs/qsg/qgeomapobjectqsgsupport_p.h - labs/qsg/qmapcircleobjectqsg.cpp labs/qsg/qmapcircleobjectqsg_p_p.h - labs/qsg/qmapiconobjectqsg.cpp labs/qsg/qmapiconobjectqsg_p_p.h - labs/qsg/qmappolygonobjectqsg.cpp labs/qsg/qmappolygonobjectqsg_p_p.h - labs/qsg/qmappolylineobjectqsg.cpp labs/qsg/qmappolylineobjectqsg_p_p.h - labs/qsg/qmaprouteobjectqsg.cpp labs/qsg/qmaprouteobjectqsg_p_p.h - labs/qsg/qqsgmapobject.cpp labs/qsg/qqsgmapobject_p.h INCLUDE_DIRECTORIES labs ) diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp deleted file mode 100644 index c8ee7c98..00000000 --- a/src/location/declarativemaps/qgeomapobject.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.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(const QExplicitlySharedDataPointer<QGeoMapObjectPrivate> &pimpl) -{ - if (d_ptr->type() != pimpl->type()) - return false; - d_ptr = 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->m_visible) - return; - - const bool oldVisible = QGeoMapObject::visible(); - d_ptr->setVisible(visible); - if (d_ptr->m_componentCompleted) - setChildrenVisibility(); - if (QGeoMapObject::visible() != oldVisible) - emit visibleChanged(); -} - -void QGeoMapObject::setParentVisiblity(bool visible) -{ - if (visible == d_ptr->m_parentVisible) - return; - - const bool oldVisible = QGeoMapObject::visible(); - d_ptr->setParentVisibility(visible); - if (d_ptr->m_componentCompleted) - setChildrenVisibility(); - if (QGeoMapObject::visible() != oldVisible) - 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 : kids) - kid->setParentVisiblity(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; - - if (map) { - bool oldVisible = d_ptr->m_visible; - bool oldCmponentCompleted = d_ptr->m_componentCompleted; - if (!map->createMapObjectImplementation(this)) { - if (type() != ViewType) - qWarning() << "Unsupported type " << type(); - } - // old implementation gets destroyed if/when d_ptr gets replaced - d_ptr->m_componentCompleted = oldCmponentCompleted; - d_ptr->setVisible(oldVisible); - d_ptr->setMap(map); - } - - const QList<QGeoMapObject *> kids = geoMapObjectChildren(); - for (auto kid : kids) - kid->setMap(map); - - // Each subclass is in charge to do the equivalent of - // if (!map) { - // // Map was set, now it has ben re-set to NULL, but not inside d_ptr. - // // so m_map inside d_ptr can still be used to remove itself, inside the destructor. - // d_ptr = new QMapCircleObjectPrivateDefault(*d); - // // Old pimpl deleted implicitly by QExplicitlySharedDataPointer - // } - // After this method is called. -} - -QGeoMap *QGeoMapObject::map() const -{ - return d_ptr->m_map; -} - -QGeoShape QGeoMapObject::geoShape() const -{ - return d_ptr->geoShape(); -} - -void QGeoMapObject::setGeoShape(const QGeoShape &shape) -{ - d_ptr->setGeoShape(shape); -} - - -// -// 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 && m_parentVisible; -} - -void QGeoMapObjectPrivate::setVisible(bool visible) -{ - m_visible = visible; -} - -void QGeoMapObjectPrivate::setParentVisibility(bool visible) -{ - m_parentVisible = visible; -} - -void QGeoMapObjectPrivate::setMap(QGeoMap *map) -{ - m_map = map; -} - -QT_END_NAMESPACE diff --git a/src/location/declarativemaps/qgeomapobject_p.h b/src/location/declarativemaps/qgeomapobject_p.h deleted file mode 100644 index bcf12c5f..00000000 --- a/src/location/declarativemaps/qgeomapobject_p.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.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> -#include <QtPositioning/qgeoshape.h> -#include <qqml.h> - -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) - Q_PROPERTY(QGeoShape geoShape READ geoShape WRITE setGeoShape STORED false) // non-NOTIFYable - Q_INTERFACES(QQmlParserStatus) - -public: - enum Feature { - NoFeature = 0x0, - Clickable = 0x01, - Draggable = 0x02, - AllFeatures = 0xFFFFFFFF - }; - - enum Type { - InvalidType = 0, - ViewType = 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(const QExplicitlySharedDataPointer<QGeoMapObjectPrivate> &pimpl); - bool implemented() const; - - bool visible() const; - void setVisible(bool visible); - void setParentVisiblity(bool visible); - - Type type() const; - - virtual QList<QGeoMapObject*> geoMapObjectChildren() const; - virtual void setMap(QGeoMap *map); - QGeoMap *map() const; - - QGeoShape geoShape() const; - void setGeoShape(const QGeoShape &shape); - -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 - -QML_DECLARE_TYPE(QGeoMapObject) - -#endif // QGEOMAPOBJECTBASE_H diff --git a/src/location/declarativemaps/qgeomapobject_p_p.h b/src/location/declarativemaps/qgeomapobject_p_p.h deleted file mode 100644 index 1d17d7fd..00000000 --- a/src/location/declarativemaps/qgeomapobject_p_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.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 void setParentVisibility(bool visible); - virtual void setMap(QGeoMap *map); - virtual QGeoMapObjectPrivate *clone() = 0; // to allow proper detaching - virtual QGeoShape geoShape() const = 0; - virtual void setGeoShape(const QGeoShape &shape) = 0; - - QGeoMapObject *q = nullptr; - QPointer<QGeoMap> m_map; - bool m_componentCompleted = false; - bool m_visible = true; - bool m_parentVisible = true; - -protected: - QGeoMapObjectPrivate(QGeoMapObject *q); - QGeoMapObjectPrivate(const QGeoMapObjectPrivate &other); - -private: - QGeoMapObjectPrivate(); -}; - -QT_END_NAMESPACE - -#endif // QGEOMAPOBJECTBASE_P_H diff --git a/src/location/labs/qgeotiledmaplabs.cpp b/src/location/labs/qgeotiledmaplabs.cpp deleted file mode 100644 index bd6113d3..00000000 --- a/src/location/labs/qgeotiledmaplabs.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgeotiledmaplabs_p.h" -#include <QtLocation/private/qgeotiledmap_p_p.h> -#include <QtLocation/private/qgeomapobject_p.h> -#include <QtLocation/private/qmappolylineobjectqsg_p_p.h> -#include <QtLocation/private/qmappolygonobjectqsg_p_p.h> -#include <QtLocation/private/qmapcircleobjectqsg_p_p.h> -#include <QtLocation/private/qmaprouteobjectqsg_p_p.h> -#include <QtLocation/private/qmapiconobjectqsg_p_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> -#include <QtLocation/private/qgeomapobjectqsgsupport_p.h> -#include <QtPositioning/private/qlocationutils_p.h> -#include <math.h> - -QT_BEGIN_NAMESPACE - -class QGeoTiledMapLabsPrivate : public QGeoTiledMapPrivate -{ - Q_DECLARE_PUBLIC(QGeoTiledMapLabs) -public: - QGeoTiledMapLabsPrivate(QGeoTiledMappingManagerEngine *engine, QGeoTiledMapLabs *map); - virtual ~QGeoTiledMapLabsPrivate(); - - QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj) override; - QList<QGeoMapObject *> mapObjects() const override; - void removeMapObject(QGeoMapObject *obj); - QList<QObject *>mapObjectsAt(const QGeoCoordinate &coordinate) const; - - void updateMapObjects(QSGNode *root, QQuickWindow *window); - void updateObjectsGeometry(); - -protected: - void changeViewportSize(const QSize &size) override; - void changeCameraData(const QGeoCameraData &oldCameraData) override; - void changeActiveMapType(const QGeoMapType &mapType) override; - - QGeoMapObjectQSGSupport m_qsgSupport; -}; - -QGeoTiledMapLabsPrivate::QGeoTiledMapLabsPrivate(QGeoTiledMappingManagerEngine *engine, QGeoTiledMapLabs *map) - : QGeoTiledMapPrivate(engine) -{ - m_qsgSupport.m_map = map; -} - -QGeoTiledMapLabsPrivate::~QGeoTiledMapLabsPrivate() -{ - -} - -QGeoMapObjectPrivate *QGeoTiledMapLabsPrivate::createMapObjectImplementation(QGeoMapObject *obj) -{ - return m_qsgSupport.createMapObjectImplementationPrivate(obj); -} - -QList<QGeoMapObject *> QGeoTiledMapLabsPrivate::mapObjects() const -{ - return m_qsgSupport.mapObjects(); -} - -void QGeoTiledMapLabsPrivate::removeMapObject(QGeoMapObject *obj) -{ - m_qsgSupport.removeMapObject(obj); -} - -QList<QObject *> QGeoTiledMapLabsPrivate::mapObjectsAt(const QGeoCoordinate &coordinate) const -{ - // ToDo: use a space partitioning strategy - QList<QObject *> res; - for (const auto o: mapObjects()) { - // explicitly handle lines - bool contains = false; - if (o->type() == QGeoMapObject::PolylineType ) { - QMapPolylineObject *mpo = static_cast<QMapPolylineObject *>(o); - qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate); - QGeoPath path = o->geoShape(); - path.setWidth(mpp * mpo->border()->width()); - contains = path.contains(coordinate); - } else if (o->type() == QGeoMapObject::RouteType) { - qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate); - QGeoPath path = o->geoShape(); - path.setWidth(mpp * 4); // MapRouteObjectQSG has a hardcoded 4 pixels width; - contains = path.contains(coordinate); - } else { - contains = o->geoShape().contains(coordinate); - } - - if (contains) - res.append(o); - } - return res; -} - -void QGeoTiledMapLabsPrivate::updateMapObjects(QSGNode *root, QQuickWindow *window) -{ - m_qsgSupport.updateMapObjects(root, window); -} - -void QGeoTiledMapLabsPrivate::updateObjectsGeometry() -{ - m_qsgSupport.updateObjectsGeometry(); -} - -void QGeoTiledMapLabsPrivate::changeViewportSize(const QSize &size) -{ - updateObjectsGeometry(); - QGeoTiledMapPrivate::changeViewportSize(size); -} - -void QGeoTiledMapLabsPrivate::changeCameraData(const QGeoCameraData &oldCameraData) -{ - updateObjectsGeometry(); - QGeoTiledMapPrivate::changeCameraData(oldCameraData); -} - -void QGeoTiledMapLabsPrivate::changeActiveMapType(const QGeoMapType &mapType) -{ - updateObjectsGeometry(); - QGeoTiledMapPrivate::changeActiveMapType(mapType); -} - - -/* - QGeoTiledMapLabs -*/ - - - -QGeoTiledMapLabs::QGeoTiledMapLabs(QGeoTiledMappingManagerEngine *engine, QObject *parent) - : QGeoTiledMap(*new QGeoTiledMapLabsPrivate(engine, this), engine, parent) -{ - -} - -QGeoTiledMapLabs::~QGeoTiledMapLabs() -{ - -} - -bool QGeoTiledMapLabs::createMapObjectImplementation(QGeoMapObject *obj) -{ - Q_D(QGeoTiledMapLabs); - return d->m_qsgSupport.createMapObjectImplementation(obj, d); -} - -QSGNode *QGeoTiledMapLabs::updateSceneGraph(QSGNode *node, QQuickWindow *window) -{ - Q_D(QGeoTiledMapLabs); - QSGNode *root = QGeoTiledMap::updateSceneGraph(node, window); - d->updateMapObjects(root, window); - return root; -} - -void QGeoTiledMapLabs::removeMapObject(QGeoMapObject *obj) -{ - Q_D(QGeoTiledMapLabs); - d->removeMapObject(obj); -} - -QList<QObject *> QGeoTiledMapLabs::mapObjectsAt(const QGeoCoordinate &coordinate) const -{ - Q_D(const QGeoTiledMapLabs); - return d->mapObjectsAt(coordinate); -} - -QGeoTiledMapLabs::QGeoTiledMapLabs(QGeoTiledMapLabsPrivate &dd, QGeoTiledMappingManagerEngine *engine, QObject *parent) - : QGeoTiledMap(dd, engine, parent) -{ - -} - -QT_END_NAMESPACE - diff --git a/src/location/labs/qgeotiledmaplabs_p.h b/src/location/labs/qgeotiledmaplabs_p.h deleted file mode 100644 index 5e603d69..00000000 --- a/src/location/labs/qgeotiledmaplabs_p.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGEOTILEDMAPLABS_P_H -#define QGEOTILEDMAPLABS_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 <QtQml/qqml.h> -#include <QPointer> -#include <QtLocation/private/qgeotiledmap_p.h> -#include <QtQuick/qsgsimplerectnode.h> -#include <QtLocation/private/qqsgmapobject_p.h> - -QT_BEGIN_NAMESPACE - -class QDeclarativeGeoServiceProvider; -class QDeclarativeGeoMap; -class QMapRouteObject; -class QNavigationManager; -class QGeoTiledMapLabsPrivate; -class Q_LOCATION_PRIVATE_EXPORT QGeoTiledMapLabs : public QGeoTiledMap -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QGeoTiledMapLabs) -public: - QGeoTiledMapLabs(QGeoTiledMappingManagerEngine *engine, QObject *parent); - virtual ~QGeoTiledMapLabs(); - - bool createMapObjectImplementation(QGeoMapObject *obj) override; - void removeMapObject(QGeoMapObject *obj) override; - QList<QObject *> mapObjectsAt(const QGeoCoordinate &coordinate) const override; - -protected: - QSGNode *updateSceneGraph(QSGNode *node, QQuickWindow *window) override; - - QSGClipNode *m_clip = nullptr; - QSGSimpleRectNode *m_simpleRectNode = nullptr; - - // From QGeoTiledMap - QGeoTiledMapLabs(QGeoTiledMapLabsPrivate &dd, QGeoTiledMappingManagerEngine *engine, QObject *parent); -private: - Q_DISABLE_COPY(QGeoTiledMapLabs) -}; - -QT_END_NAMESPACE - -#endif // QGEOTILEDMAPLABS_P_H diff --git a/src/location/labs/qmapcircleobject.cpp b/src/location/labs/qmapcircleobject.cpp deleted file mode 100644 index ce03370c..00000000 --- a/src/location/labs/qmapcircleobject.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmapcircleobject_p.h" -#include "qmapcircleobject_p_p.h" -#include <QExplicitlySharedDataPointer> -#include <QtPositioning/qgeocircle.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapCircleObject - \instantiates QMapCircleObject - \inqmlmodule Qt.labs.location - \ingroup qml-QtLocation5-maps - \inherits QGeoMapObject - - \brief The MapCircleObject displays a circle on a Map. - - The MapCircleObject displays a circle on a Map. - The MapIconObject type only makes sense when contained in a Map or in a \l MapObjectView. -*/ - -QMapCircleObjectPrivate::QMapCircleObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q) -{ - -} - -QMapCircleObjectPrivate::~QMapCircleObjectPrivate() -{ - -} - -QGeoMapObject::Type QMapCircleObjectPrivate::type() const -{ - return QGeoMapObject::CircleType; -} - -QGeoShape QMapCircleObjectPrivate::geoShape() const -{ - return QGeoCircle(center(), radius()); -} - -void QMapCircleObjectPrivate::setGeoShape(const QGeoShape &shape) -{ - if (shape == geoShape()) - return; - - const QGeoCircle circle(shape); // if shape isn't a circle, circle will be created as a default-constructed circle - const bool centerHasChanged = circle.center() != center(); - const bool radiusHasChanged = circle.radius() != radius(); - - if (centerHasChanged) - setCenter(circle.center()); // to handle overrides - if (radiusHasChanged) - setRadius(circle.radius()); // to handle overrides - - if (centerHasChanged) - emit static_cast<QMapCircleObject *>(q)->centerChanged(); - if (radiusHasChanged) - emit static_cast<QMapCircleObject *>(q)->radiusChanged(); -} - -// -// QMapCircleObjectPrivate default implementation -// - -QMapCircleObjectPrivateDefault::QMapCircleObjectPrivateDefault(QGeoMapObject *q) : QMapCircleObjectPrivate(q) -{ - -} - -QMapCircleObjectPrivateDefault::QMapCircleObjectPrivateDefault(const QMapCircleObjectPrivate &other) : QMapCircleObjectPrivate(other.q) -{ - m_center = other.center(); - m_radius = other.radius(); - m_fillColor = other.color(); - m_borderColor = other.borderColor(); - m_borderWidth = other.borderWidth(); -} - -QMapCircleObjectPrivateDefault::~QMapCircleObjectPrivateDefault() -{ - -} - -QGeoCoordinate QMapCircleObjectPrivateDefault::center() const -{ - return m_center; -} - -void QMapCircleObjectPrivateDefault::setCenter(const QGeoCoordinate ¢er) -{ - m_center = center; -} - -qreal QMapCircleObjectPrivateDefault::radius() const -{ - return m_radius; -} - -void QMapCircleObjectPrivateDefault::setRadius(qreal radius) -{ - m_radius = radius; -} - -QColor QMapCircleObjectPrivateDefault::color() const -{ - return m_fillColor; -} - -void QMapCircleObjectPrivateDefault::setColor(const QColor &color) -{ - m_fillColor = color; -} - -QColor QMapCircleObjectPrivateDefault::borderColor() const -{ - return m_borderColor; -} - -void QMapCircleObjectPrivateDefault::setBorderColor(const QColor &color) -{ - m_borderColor = color; -} - -qreal QMapCircleObjectPrivateDefault::borderWidth() const -{ - return m_borderWidth; -} - -void QMapCircleObjectPrivateDefault::setBorderWidth(qreal width) -{ - m_borderWidth = width; -} - -bool QMapCircleObjectPrivate::equals(const QGeoMapObjectPrivate &other) const -{ - if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used - return false; - - const QMapCircleObjectPrivate &o = static_cast<const QMapCircleObjectPrivate &>(other); - return (QGeoMapObjectPrivate::equals(o) - && center() == o.center() - && radius() == o.radius() - && color() == o.color() - && borderColor() == o.borderColor() - && borderWidth() == o.borderWidth()); -} - -QGeoMapObjectPrivate *QMapCircleObjectPrivateDefault::clone() -{ - return new QMapCircleObjectPrivateDefault(static_cast<QMapCircleObjectPrivate &>(*this)); -} - -QMapCircleObject::QMapCircleObject(QObject *parent) - : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapCircleObjectPrivateDefault(this)), parent) - -{ - QMapCircleObjectPrivate *d = static_cast<QMapCircleObjectPrivate*>(d_ptr.data()); - d->setBorderColor(QColor(Qt::black)); // These are QDeclarativeMapLineProperties defaults - d->setBorderWidth(1.0); -} - -QMapCircleObject::~QMapCircleObject() -{ - -} - -/*! - \qmlproperty coordinate Qt.labs.location::MapCircleObject::center - - This property holds the central point about which the circle is defined. - - \sa radius -*/ -QGeoCoordinate QMapCircleObject::center() const -{ - return static_cast<const QMapCircleObjectPrivate*>(d_ptr.data())->center(); -} - -/*! - \qmlproperty real Qt.labs.location::MapCircleObject::radius - - This property holds the radius of the circle, in meters on the ground. - - \sa center -*/ -qreal QMapCircleObject::radius() const -{ - return static_cast<const QMapCircleObjectPrivate*>(d_ptr.data())->radius(); -} - -/*! - \qmlproperty color Qt.labs.location::MapCircleObject::color - - This property holds the fill color of the circle when drawn. For no fill, - use a transparent color. -*/ -QColor QMapCircleObject::color() const -{ - return static_cast<const QMapCircleObjectPrivate*>(d_ptr.data())->color(); -} - -/*! - \qmlpropertygroup Qt.labs.location::MapCircleObject::border - \qmlproperty int MapCircleObject::border.width - \qmlproperty color MapCircleObject::border.color - - This property is part of the border group property. - The border property holds the width and color used to draw the border of the circle. - The width is in pixels and is independent of the zoom level of the map. - - The default values correspond to a black border with a width of 1 pixel. - For no line, use a width of 0 or a transparent color. -*/ -QDeclarativeMapLineProperties *QMapCircleObject::border() -{ - if (!m_border) { - m_border = new QDeclarativeMapLineProperties(this); - connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){ - static_cast<QMapCircleObjectPrivate*>(d_ptr.data())->setBorderColor(color); - }); - connect(m_border, &QDeclarativeMapLineProperties::widthChanged, this, [this](qreal width){ - static_cast<QMapCircleObjectPrivate*>(d_ptr.data())->setBorderWidth(width); - }); - } - return m_border; -} - -void QMapCircleObject::setCenter(const QGeoCoordinate ¢er) -{ - auto ptr = static_cast<QMapCircleObjectPrivate*>(d_ptr.data()); - if (ptr->center() == center) - return; - - ptr->setCenter(center); - emit centerChanged(); -} - -void QMapCircleObject::setRadius(qreal radius) -{ - auto d = static_cast<QMapCircleObjectPrivate*>(d_ptr.data()); - if (d->radius() == radius) - return; - - d->setRadius(radius); - emit radiusChanged(); -} - -void QMapCircleObject::setColor(const QColor &color) -{ - auto d = static_cast<QMapCircleObjectPrivate*>(d_ptr.data()); - if (d->color() == color) - return; - - d->setColor(color); - emit colorChanged(); -} - -void QMapCircleObject::setMap(QGeoMap *map) -{ - QMapCircleObjectPrivate *d = static_cast<QMapCircleObjectPrivate *>(d_ptr.data()); - if (d->m_map == map) - return; - - QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected - - if (!map) { - // Map was set, now it has ben re-set to NULL, but not inside d_ptr. - // so m_map inside d_ptr can still be used to remove itself, inside the destructor. - d_ptr = new QMapCircleObjectPrivateDefault(*d); - // Old pimpl deleted implicitly by QExplicitlySharedDataPointer - } -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qmapcircleobject_p.h b/src/location/labs/qmapcircleobject_p.h deleted file mode 100644 index 045485e7..00000000 --- a/src/location/labs/qmapcircleobject_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPCIRCLEOBJECT_P_H -#define QMAPCIRCLEOBJECT_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/qgeomapobject_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> -#include <QtCore/QUrl> -#include <QGeoCoordinate> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapCircleObject : public QGeoMapObject -{ - Q_OBJECT - Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged) - Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QDeclarativeMapLineProperties *border READ border CONSTANT) - -public: - QMapCircleObject(QObject *parent = nullptr); - ~QMapCircleObject() override; - - QGeoCoordinate center() const; - qreal radius() const; - QColor color() const; - - void setCenter(const QGeoCoordinate ¢er); - void setRadius(qreal radius); - void setColor(const QColor &color); - - QDeclarativeMapLineProperties * border(); - void setMap(QGeoMap *map) override; - -signals: - void centerChanged(); - void radiusChanged(); - void colorChanged(); - -protected: - QDeclarativeMapLineProperties *m_border = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QMAPCIRCLEOBJECT_P_H diff --git a/src/location/labs/qmapcircleobject_p_p.h b/src/location/labs/qmapcircleobject_p_p.h deleted file mode 100644 index 287b4d3b..00000000 --- a/src/location/labs/qmapcircleobject_p_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPCIRCLEOBJECT_P_P_H -#define QMAPCIRCLEOBJECT_P_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/qgeomapobject_p_p.h> -#include <QGeoCoordinate> -#include <QColor> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapCircleObjectPrivate : public QGeoMapObjectPrivate -{ -public: - QMapCircleObjectPrivate(QGeoMapObject *q); - ~QMapCircleObjectPrivate() override; - - QGeoMapObject::Type type() const override final; - - virtual QGeoCoordinate center() const = 0; - virtual void setCenter(const QGeoCoordinate ¢er) = 0; - virtual qreal radius() const = 0; - virtual void setRadius(qreal radius) = 0; - virtual QColor color() const = 0; - virtual void setColor(const QColor &color) = 0; - virtual QColor borderColor() const = 0; - virtual void setBorderColor(const QColor &color) = 0; - virtual qreal borderWidth() const = 0; - virtual void setBorderWidth(qreal width) = 0; - - // QGeoMapObjectPrivate interface - bool equals(const QGeoMapObjectPrivate &other) const override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; -}; - - -class Q_LOCATION_PRIVATE_EXPORT QMapCircleObjectPrivateDefault : public QMapCircleObjectPrivate -{ -public: - QMapCircleObjectPrivateDefault(QGeoMapObject *q); - QMapCircleObjectPrivateDefault(const QMapCircleObjectPrivate &other); - ~QMapCircleObjectPrivateDefault() override; - - // QMapCircleObjectPrivate interface - QGeoCoordinate center() const override; - void setCenter(const QGeoCoordinate ¢er) override; - qreal radius() const override; - void setRadius(qreal radius) override; - QColor color() const override; - void setColor(const QColor &color) override; - QColor borderColor() const override; - void setBorderColor(const QColor &color) override; - qreal borderWidth() const override; - void setBorderWidth(qreal width) override; - - // QGeoMapObjectPrivate interface - QGeoMapObjectPrivate *clone() override; - -public: - QGeoCoordinate m_center; - qreal m_radius = 0; - QColor m_fillColor = Qt::transparent; - QColor m_borderColor; - qreal m_borderWidth = 1.0; - -private: - QMapCircleObjectPrivateDefault(const QMapCircleObjectPrivateDefault &other) = delete; -}; - -QT_END_NAMESPACE - -#endif // QMAPCIRCLEOBJECT_P_P_H diff --git a/src/location/labs/qmapiconobject.cpp b/src/location/labs/qmapiconobject.cpp deleted file mode 100644 index 00c1dd91..00000000 --- a/src/location/labs/qmapiconobject.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmapiconobject_p.h" -#include "qmapiconobject_p_p.h" -#include <QExplicitlySharedDataPointer> -#include <QtPositioning/QGeoCircle> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapIconObject - \instantiates QMapIconObject - \inqmlmodule Qt.labs.location - \ingroup qml-QtLocation5-maps - \inherits QGeoMapObject - - \brief The MapIconObject displays an icon on a Map. - - The MapIconObject displays an icon on a Map. - The MapIconObject type only makes sense when contained in a Map or in a \l MapObjectView. -*/ - -QMapIconObjectPrivate::~QMapIconObjectPrivate() -{ - -} - -QMapIconObjectPrivate::QMapIconObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q) -{ - -} - -QGeoMapObject::Type QMapIconObjectPrivate::type() const -{ - return QGeoMapObject::IconType; -} - -bool QMapIconObjectPrivate::equals(const QGeoMapObjectPrivate &other) const -{ - if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used - return false; - - const QMapIconObjectPrivate &o = static_cast<const QMapIconObjectPrivate &>(other); - return (QGeoMapObjectPrivate::equals(o) - && content() == o.content() - && coordinate() == o.coordinate()); -} - -// -// QGeoMapIconPrivate default implementation -// - -QMapIconObjectPrivateDefault::QMapIconObjectPrivateDefault(QGeoMapObject *q) : QMapIconObjectPrivate(q) -{ - -} -QMapIconObjectPrivateDefault::QMapIconObjectPrivateDefault(const QMapIconObjectPrivate &other) : QMapIconObjectPrivate(other.q) -{ - m_coordinate = other.coordinate(); - m_content = other.content(); - m_iconSize = other.iconSize(); - qreal radius = QGeoCircle(other.geoShape()).radius(); - m_radius = (qIsFinite(radius)) ? radius : 100.0; -} - -QMapIconObjectPrivateDefault::~QMapIconObjectPrivateDefault() -{ - -} - -QGeoCoordinate QMapIconObjectPrivateDefault::coordinate() const -{ - return m_coordinate; -} - -void QMapIconObjectPrivateDefault::setCoordinate(const QGeoCoordinate &coordinate) -{ - m_coordinate = coordinate; -} - -QVariant QMapIconObjectPrivateDefault::content() const -{ - return m_content; -} - -void QMapIconObjectPrivateDefault::setContent(const QVariant &content) -{ - m_content = content; -} - -QSizeF QMapIconObjectPrivateDefault::iconSize() const -{ - return m_iconSize; -} - -void QMapIconObjectPrivateDefault::setIconSize(const QSizeF &size) -{ - m_iconSize = size; -} - -QGeoMapObjectPrivate *QMapIconObjectPrivateDefault::clone() -{ - return new QMapIconObjectPrivateDefault(static_cast<QMapIconObjectPrivate &>(*this)); -} - -QGeoShape QMapIconObjectPrivateDefault::geoShape() const -{ - return QGeoCircle(coordinate(), m_radius); // fixing the radius to 100 meters, as a meaningful size for - // fitting the viewport to this icon without losing context completely -} - -void QMapIconObjectPrivateDefault::setGeoShape(const QGeoShape &shape) -{ - QGeoCoordinate crd; - const QGeoCircle circle(shape); // if shape isn't a circle, circle will be created as a default-constructed circle - if (circle.isValid()) { - crd = circle.center(); - m_radius = circle.radius(); - } else { - crd = shape.boundingGeoRectangle().center(); - } - - if (crd == coordinate()) - return; - - setCoordinate(crd); - emit static_cast<QMapIconObject *>(q)->coordinateChanged(crd); -} - - -/* - - QGeoMapIconPrivate default implementation - -*/ - - -QMapIconObject::QMapIconObject(QObject *parent) - : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapIconObjectPrivateDefault(this)), parent) -{} - -QMapIconObject::~QMapIconObject() -{ - -} - -/*! - \qmlproperty Variant Qt.labs.location::MapIconObject::content - - This property holds the content to be used for the icon. The actual content of this property is somehow - backend-dependent. The implementation for the raster engine accepts local urls or paths. - Other implementations may accept additional content types. -*/ -QVariant QMapIconObject::content() const -{ - const QMapIconObjectPrivate *d = static_cast<const QMapIconObjectPrivate *>(d_ptr.data()); - return d->content(); -} - -/*! - \qmlproperty Variant Qt.labs.location::MapIconObject::coordinate - - The coordinate where the icon is going to be shown. - What pixel of the icon matches the coordinate is somehow backend-dependent. - For example, due to limitations, some backends might associate the center of the icon with the - coordinate, others one of the corners. - If there is a choice, backend developers should use the center of the icon as the default anchor - point. - - The behavior is also intended to be customizable with a \l DynamicParameter, when - using backends that support anchoring arbitrary points of the icon to the coordinate. - What kind of parameter to use and how to achieve this behavior is intended to be - documented per-backend. -*/ -QGeoCoordinate QMapIconObject::coordinate() const -{ - const QMapIconObjectPrivate *d = static_cast<const QMapIconObjectPrivate *>(d_ptr.data()); - return d->coordinate(); -} - -void QMapIconObject::setContent(QVariant content) -{ - QMapIconObjectPrivate *d = static_cast<QMapIconObjectPrivate *>(d_ptr.data()); - if (d->content() == content) - return; - - d->setContent(content); - emit contentChanged(content); -} - -void QMapIconObject::setCoordinate(const QGeoCoordinate ¢er) -{ - QMapIconObjectPrivate *d = static_cast<QMapIconObjectPrivate*>(d_ptr.data()); - if (d->coordinate() == center) - return; - - d->setCoordinate(center); - emit coordinateChanged(center); -} - -/*! - \qmlproperty Variant Qt.labs.location::MapIconObject::iconSize - - The size of the icon as it will be shown on the map. -*/ -QSizeF QMapIconObject::iconSize() const -{ - const QMapIconObjectPrivate *d = static_cast<const QMapIconObjectPrivate *>(d_ptr.data()); - return d->iconSize(); -} - - -void QMapIconObject::setIconSize(const QSizeF &size) -{ - QMapIconObjectPrivate *d = static_cast<QMapIconObjectPrivate*>(d_ptr.data()); - if (d->iconSize() == size) - return; - - d->setIconSize(size); - emit iconSizeChanged(); -} - -void QMapIconObject::setMap(QGeoMap *map) -{ - QMapIconObjectPrivate *d = static_cast<QMapIconObjectPrivate *>(d_ptr.data()); - if (d->m_map == map) - return; - - QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected - - if (!map) { - // Map was set, now it has ben re-set to NULL, but not inside d_ptr. - // so m_map inside d_ptr can still be used to remove itself, inside the destructor. - d_ptr = new QMapIconObjectPrivateDefault(*d); - // Old pimpl deleted implicitly by QExplicitlySharedDataPointer - } -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qmapiconobject_p.h b/src/location/labs/qmapiconobject_p.h deleted file mode 100644 index f40d5b1b..00000000 --- a/src/location/labs/qmapiconobject_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGEOMAPICON_P_H -#define QGEOMAPICON_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/qgeomapobject_p.h> -#include <QtCore/QUrl> -#include <QGeoCoordinate> -#include <QtCore/qsize.h> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapIconObject : public QGeoMapObject -{ - Q_OBJECT - Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged) - Q_PROPERTY(QVariant content READ content WRITE setContent NOTIFY contentChanged) - Q_PROPERTY(QSizeF iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) - -public: - QMapIconObject(QObject *parent = nullptr); - ~QMapIconObject() override; - - QVariant content() const; - QGeoCoordinate coordinate() const; - QSizeF iconSize() const; - - void setContent(QVariant content); - void setCoordinate(const QGeoCoordinate &coordinate); - void setIconSize(const QSizeF &size); - - void setMap(QGeoMap *map) override; - -signals: - void contentChanged(QVariant content); - void coordinateChanged(QGeoCoordinate coordinate); - void iconSizeChanged(); -}; - -QT_END_NAMESPACE - -#endif // QGEOMAPICON_P_H diff --git a/src/location/labs/qmapiconobject_p_p.h b/src/location/labs/qmapiconobject_p_p.h deleted file mode 100644 index a96a8ab9..00000000 --- a/src/location/labs/qmapiconobject_p_p.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGEOMAPICON_P_P_H -#define QGEOMAPICON_P_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/qgeomapobject_p_p.h> -#include <QGeoCoordinate> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapIconObjectPrivate : public QGeoMapObjectPrivate -{ -public: - QMapIconObjectPrivate(QGeoMapObject *q); - ~QMapIconObjectPrivate() override; - - QGeoMapObject::Type type() const override final; - - virtual QGeoCoordinate coordinate() const = 0; - virtual void setCoordinate(const QGeoCoordinate &coordinate) = 0; - virtual QVariant content() const = 0; - virtual void setContent(const QVariant &content) = 0; - virtual QSizeF iconSize() const = 0; - virtual void setIconSize(const QSizeF &size) = 0; - - // QGeoMapObjectPrivate interface - bool equals(const QGeoMapObjectPrivate &other) const override; -}; - -class Q_LOCATION_PRIVATE_EXPORT QMapIconObjectPrivateDefault : public QMapIconObjectPrivate -{ -public: - QMapIconObjectPrivateDefault(QGeoMapObject *q); - QMapIconObjectPrivateDefault(const QMapIconObjectPrivate &other); - ~QMapIconObjectPrivateDefault() override; - - // QGeoMapIconPrivate interface - QGeoCoordinate coordinate() const override; - void setCoordinate(const QGeoCoordinate &coordinate) override; - QVariant content() const override; - void setContent(const QVariant &content) override; - QSizeF iconSize() const override; - void setIconSize(const QSizeF &size) override; - - // QGeoMapObjectPrivate interface - QGeoMapObjectPrivate *clone() override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; - -public: - QVariant m_content; - QGeoCoordinate m_coordinate; - QSizeF m_iconSize; - qreal m_radius = 100.0; // can be set only via setGeoShape, will be used only by - -private: - QMapIconObjectPrivateDefault(const QMapIconObjectPrivateDefault &other) = delete; -}; - -QT_END_NAMESPACE - -#endif // QGEOMAPICON_P_P_H diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp deleted file mode 100644 index 4756a522..00000000 --- a/src/location/labs/qmapobjectview.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmapobjectview_p.h" -#include "qmapobjectview_p_p.h" -#include <private/qqmldelegatemodel_p.h> -#include <QtLocation/private/qgeomap_p.h> - -#include <QtPositioning/QGeoRectangle> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapObjectView - \instantiates QMapObjectView - \inqmlmodule Qt.labs.location - \ingroup qml-QtLocation5-maps - \inherits QGeoMapObject - - \brief The MapObjectView is used to populate Map with map objects from a model. - - The MapObjectView is used to populate Map with map objects, either from a model or via - \l addMapObject or \l removeMapObject. - - The MapObjectView type only makes sense when contained in a Map, meaning that it will not work when added inside - other QML elements. - This can also be intended as an object layer on top of a Map. -*/ - -/* - - QMapObjectViewPrivate - -*/ - -static const QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::Asynchronous; - -QMapObjectViewPrivate::QMapObjectViewPrivate(QGeoMapObject *q) - : QGeoMapObjectPrivate(q) -{ -} - -QMapObjectViewPrivate::~QMapObjectViewPrivate() -{ - -} - -QGeoMapObject::Type QMapObjectViewPrivate::type() const -{ - return QGeoMapObject::ViewType; -} - - -/* - - QMapObjectViewPrivateDefault - -*/ - - -QMapObjectViewPrivateDefault::QMapObjectViewPrivateDefault(const QMapObjectViewPrivate &other) -: QMapObjectViewPrivate(other.q), m_model(other.model()), m_delegate(other.delegate()) -{ -} - -QMapObjectViewPrivateDefault::~QMapObjectViewPrivateDefault() -{ - -} - -QVariant QMapObjectViewPrivateDefault::model() const -{ - return m_model; -} - -void QMapObjectViewPrivateDefault::setModel(const QVariant &model) -{ - m_model = model; -} - -QQmlComponent *QMapObjectViewPrivateDefault::delegate() const -{ - return m_delegate; -} - -void QMapObjectViewPrivateDefault::setDelegate(QQmlComponent *delegate) -{ - m_delegate = delegate; -} - -QMapObjectViewPrivateDefault::QMapObjectViewPrivateDefault(QGeoMapObject *q) : QMapObjectViewPrivate(q) -{ - -} - -QGeoMapObjectPrivate *QMapObjectViewPrivateDefault::clone() -{ - return new QMapObjectViewPrivateDefault(*this); -} - -bool QMapObjectViewPrivateDefault::equals(const QGeoMapObjectPrivate &other) const -{ - if (other.type() != type()) - return false; - - const QMapObjectViewPrivate &o = static_cast<const QMapObjectViewPrivate &>(other); - return (QGeoMapObjectPrivate::equals(o) - && model() == o.model() - && delegate() == o.delegate()); -} - -QGeoShape QMapObjectViewPrivateDefault::geoShape() const -{ - const QMapObjectView *qq = static_cast<const QMapObjectView *>(q); - QGeoRectangle rect; - const QList<QGeoMapObject *> kids = qq->geoMapObjectChildren(); - for (const auto &kid: kids) { - if (!rect.isValid()) - rect = kid->geoShape().boundingGeoRectangle(); - else - rect = rect.united(kid->geoShape().boundingGeoRectangle()); - } - return rect; -} - -void QMapObjectViewPrivateDefault::setGeoShape(const QGeoShape &/*shape*/) -{ - // MOV doesn't support setting the geoshape. -} - -/* - - QMapObjectView - -*/ - - -QMapObjectView::QMapObjectView(QObject *parent) - : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapObjectViewPrivateDefault(this)), parent) -{ - -} - -QMapObjectView::~QMapObjectView() -{ - flushDelegateModel(); - flushUserAddedMapObjects(); -} - -QList<QGeoMapObject *> QMapObjectView::geoMapObjectChildren() const -{ - auto kids = QGeoMapObject::geoMapObjectChildren(); - for (const auto &object : m_instantiatedMapObjects) { - if (auto *obj = qobject_cast<QGeoMapObject*>(object)) - kids << obj; - } - for (const auto &object : m_userAddedMapObjects) { - if (object) - kids << object; - } - return kids; -} - -void QMapObjectView::classBegin() -{ - QQmlContext *ctx = qmlContext(this); - m_delegateModel = new QQmlDelegateModel(ctx, this); - m_delegateModel->classBegin(); - - QQmlInstanceModel *model = m_delegateModel; - connect(model, &QQmlInstanceModel::modelUpdated, this, &QMapObjectView::modelUpdated); - connect(model, &QQmlInstanceModel::createdItem, this, &QMapObjectView::createdItem); -// connect(model, &QQmlInstanceModel::destroyingItem, this, &QMapObjectView::destroyingItem); -// connect(model, &QQmlInstanceModel::initItem, this, &QMapObjectView::initItem); -} - -void QMapObjectView::componentComplete() -{ - QGeoMapObject::componentComplete(); - QMapObjectViewPrivate *d = static_cast<QMapObjectViewPrivate *>(d_ptr.data()); - if (d->delegate()) - m_delegateModel->setDelegate(d->delegate()); - if (d->model().isValid()) - m_delegateModel->setModel(d->model()); - m_delegateModel->componentComplete(); -} - -/*! - \qmlproperty Variant Qt.labs.location::MapObjectView::model - - This property holds the model that provides data used for creating the map items defined by the - delegate. Only QAbstractItemModel based models are supported. -*/ -QVariant QMapObjectView::model() const -{ - const QMapObjectViewPrivate *d = static_cast<const QMapObjectViewPrivate *>(d_ptr.data()); - return d->model(); -} - -/*! - \qmlproperty Component Qt.labs.location::MapObjectView::delegate - - This property holds the delegate which defines how each item in the - model should be displayed. The Component must contain exactly one - QGeoMapObject -derived object as the root object. -*/ -QQmlComponent *QMapObjectView::delegate() const -{ - const QMapObjectViewPrivate *d = static_cast<const QMapObjectViewPrivate *>(d_ptr.data()); - return d->delegate(); -} - -void QMapObjectView::setModel(QVariant model) -{ - QMapObjectViewPrivate *d = static_cast<QMapObjectViewPrivate *>(d_ptr.data()); - if (d->model() == model) - return; - d->setModel(model); - - if (d_ptr->m_componentCompleted) - m_delegateModel->setModel(model); - - emit modelChanged(model); -} - -void QMapObjectView::setDelegate(QQmlComponent *delegate) -{ - QMapObjectViewPrivate *d = static_cast<QMapObjectViewPrivate *>(d_ptr.data()); - if (d->delegate() == delegate) - return; - d->setDelegate(delegate); - - if (d_ptr->m_componentCompleted) - m_delegateModel->setDelegate(delegate); - - emit delegateChanged(delegate); -} - -/*! - \qmlmethod void Qt.labs.location::MapObjectView::addMapObject(MapObject object) - - Adds the given \a object to the MapObjectView (for example MapIconObject, MapRouteObject), and, - indirectly, to the underlying map. If the object already is on the MapObjectView, it will not be added again. - - \sa removeMapObject -*/ -void QMapObjectView::addMapObject(QGeoMapObject *object) -{ - if (m_userAddedMapObjects.indexOf(object) < 0) - m_userAddedMapObjects.append(object); - if (map() && object->map() != map()) - object->setMap(map()); -} - -/*! - \qmlmethod void Qt.labs.location::MapObjectView::removeMapObject(MapObject object) - - Removes the given \a object from the MapObjectView (for example MapIconObject, MapRouteObject), and, - indirectly, from the underlying map. - - \sa addMapObject -*/ -void QMapObjectView::removeMapObject(QGeoMapObject *object) -{ - int idx = m_userAddedMapObjects.indexOf(object); - if ( idx >= 0) { - object->setMap(nullptr); - m_userAddedMapObjects.remove(idx); - } -} - -void QMapObjectView::destroyingItem(QObject * /*object*/) -{ - -} - -void QMapObjectView::initItem(int /*index*/, QObject * /*object*/) -{ - -} - -void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset) -{ - // move changes are expressed as one remove + one insert, with the same moveId. - // For simplicity, they will be treated as remove + insert. - // Changes will be also ignored, as they represent only data changes, not layout changes - if (reset) { // Assuming this means "remove everything already instantiated" - flushDelegateModel(); - } else { - // Remove map objects from the back to the front to retain the mapping to what is received from the changesets - const QList<QQmlChangeSet::Change> &removes = changeSet.removes(); - std::map<int, int> mapRemoves; - for (int i = 0; i < removes.size(); i++) - mapRemoves.insert(std::pair<int, int>(removes.at(i).start(), i)); - - for (auto rit = mapRemoves.rbegin(); rit != mapRemoves.rend(); ++rit) { - const QQmlChangeSet::Change &c = removes.at(rit->second); - for (int idx = c.end() - 1; idx >= c.start(); --idx) - removeMapObjectFromMap(idx); - } - } - - QBoolBlocker createBlocker(m_creatingObject, true); - for (const QQmlChangeSet::Change &c: changeSet.inserts()) { - for (int idx = c.start(); idx < c.end(); idx++) { - m_instantiatedMapObjects.insert(idx, nullptr); - QGeoMapObject *mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(idx, incubationMode)); - if (mo) {// if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect. - mo->setParentAndNotify(this); - addMapObjectToMap(mo, idx); - } - } - } -} - -void QMapObjectView::addMapObjectToMap(QGeoMapObject *object, int index) -{ - if (!object) - return; - - m_instantiatedMapObjects[index] = object; - if (map()) - object->setMap(map()); - else - m_pendingMapObjects << object; - - // ToDo: - // Figure out the proper way to replace "mo->setVisible(visible());". Options: - // - simply leave it to the user to set up a property binding - // - set up a property binding automatically - // - add a viewVisibility member to QGeoMapObject that gets combined at all times, - // and a connection for it. -} - -void QMapObjectView::removeMapObjectFromMap(int index) -{ - if (index >= 0 && index < m_instantiatedMapObjects.size()) { - QGeoMapObject *mo = m_instantiatedMapObjects.takeAt(index); - if (!mo) - return; - - mo->setMap(nullptr); - QQmlInstanceModel::ReleaseFlags releaseStatus = m_delegateModel->release(mo); -#ifdef QT_DEBUG - if (releaseStatus == QQmlInstanceModel::Referenced) - qWarning() << "object "<<mo<<" still referenced"; -#else - Q_UNUSED(releaseStatus); -#endif - } -} - -// See QObject *QQmlDelegateModel::object(int index, QQmlIncubator::IncubationMode incubationMode) doc -// for explanation on when createdItem is emitted. -void QMapObjectView::createdItem(int index, QObject * /*object*/) -{ - if (m_creatingObject) { - // see QDeclarativeGeoMapItemView::createdItem - return; - } - - // If here, according to the documentation above, object() should be called again for index, - // or else, it will be destroyed exiting this scope - QGeoMapObject *mo = nullptr; - mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode)); - if (mo) { - mo->setParentAndNotify(this); - addMapObjectToMap(mo, index); - } else { - qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object"; - } -} - - -void QMapObjectView::flushDelegateModel() -{ - // Backward as removeItemFromMap modifies m_instantiatedItems - for (int i = m_instantiatedMapObjects.size() -1; i >= 0 ; i--) - removeMapObjectFromMap(i); -} - -void QMapObjectView::flushUserAddedMapObjects() -{ - for (int i = 0; i < m_userAddedMapObjects.size(); ++i) { - auto obj = m_userAddedMapObjects.at(i); - if (obj) - obj->setMap(nullptr); // obj parent might not be this. If so, it would not be destroyed by destroying this view. - } -} - -void QMapObjectView::setMap(QGeoMap *map) -{ - QMapObjectViewPrivate *d = static_cast<QMapObjectViewPrivate *>(d_ptr.data()); - if (d->m_map == map) - return; - - QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected - - for (int i = 0; i < m_userAddedMapObjects.size(); ++i) { - auto obj = m_userAddedMapObjects.at(i); - if (obj && obj->map() != map) - obj->setMap(map); - } - - if (!map) { - // Map was set, now it has ben re-set to NULL - flushDelegateModel(); - flushUserAddedMapObjects(); - bool oldVisible = d_ptr->m_visible; - bool oldCmponentCompleted = d_ptr->m_componentCompleted; - d_ptr = new QMapObjectViewPrivateDefault(*d); - d_ptr->m_componentCompleted = oldCmponentCompleted; - d_ptr->setVisible(oldVisible); - } else if (d->m_componentCompleted) { - // Map was null, now it's set AND delegateModel is already complete. - // some delegates may have been incubated but not added to the map. - for (int i = 0; i < m_pendingMapObjects.size(); ++i) { - auto obj = m_pendingMapObjects.at(i); - if (obj && obj->map() != map) - obj->setMap(map); - } - m_pendingMapObjects.clear(); - } -} - -QT_END_NAMESPACE - diff --git a/src/location/labs/qmapobjectview_p.h b/src/location/labs/qmapobjectview_p.h deleted file mode 100644 index d4af02e3..00000000 --- a/src/location/labs/qmapobjectview_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPOBJECTVIEW_P_H -#define QMAPOBJECTVIEW_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/qgeomapobject_p.h> -#include <QQmlComponent> -#include <QList> - -QT_BEGIN_NAMESPACE - -class QQmlDelegateModel; -class QMapObjectViewPrivate; -class QQmlChangeSet; -class Q_LOCATION_PRIVATE_EXPORT QMapObjectView : public QGeoMapObject -{ - Q_OBJECT - Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) - Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) - Q_INTERFACES(QQmlParserStatus) -public: - QMapObjectView(QObject *parent = nullptr); - ~QMapObjectView() override; - - // QGeoMapObject interface - QList<QGeoMapObject *> geoMapObjectChildren() const override; - void setMap(QGeoMap *map) override; - - // QQmlParserStatus interface - void classBegin() override; - void componentComplete() override; - - QVariant model() const; - void setModel(QVariant model); - - QQmlComponent *delegate() const; - void setDelegate(QQmlComponent * delegate); - -public Q_SLOTS: - // The dynamic API that matches Map.add/remove MapItem - void addMapObject(QGeoMapObject *object); - void removeMapObject(QGeoMapObject *object); - -signals: - void modelChanged(QVariant model); - void delegateChanged(QQmlComponent * delegate); - -protected Q_SLOTS: - void destroyingItem(QObject *object); - void initItem(int index, QObject *object); - void createdItem(int index, QObject *object); - void modelUpdated(const QQmlChangeSet &changeSet, bool reset); - -protected: - void addMapObjectToMap(QGeoMapObject *object, int index); - void removeMapObjectFromMap(int index); - void flushDelegateModel(); - void flushUserAddedMapObjects(); - - QQmlDelegateModel *m_delegateModel = nullptr; - QList<QPointer<QGeoMapObject>> m_instantiatedMapObjects; - QList<QPointer<QGeoMapObject>> - m_pendingMapObjects; // for items instantiated before the map is set - QList<QPointer<QGeoMapObject>> m_userAddedMapObjects; // A third list containing the objects - // dynamically added through addMapObject - bool m_creatingObject = false; -}; - -QT_END_NAMESPACE - -#endif // QMAPOBJECTVIEW_P_H diff --git a/src/location/labs/qmapobjectview_p_p.h b/src/location/labs/qmapobjectview_p_p.h deleted file mode 100644 index d9b054e2..00000000 --- a/src/location/labs/qmapobjectview_p_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPOBJECTVIEW_P_P_H -#define QMAPOBJECTVIEW_P_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/qgeomapobject_p_p.h> -#include <QPointer> -#include <QList> -#include <QQmlComponent> - -QT_BEGIN_NAMESPACE - -class QQmlDelegateModel; -class QGeoMap; -class Q_LOCATION_PRIVATE_EXPORT QMapObjectViewPrivate : public QGeoMapObjectPrivate -{ -public: - QMapObjectViewPrivate(QGeoMapObject *q); - ~QMapObjectViewPrivate() override; - - virtual QVariant model() const = 0; - virtual void setModel(const QVariant &model) = 0; - virtual QQmlComponent *delegate() const = 0; - virtual void setDelegate(QQmlComponent *delegate) = 0; - - QGeoMapObject::Type type() const override final; -}; - -class Q_LOCATION_PRIVATE_EXPORT QMapObjectViewPrivateDefault : public QMapObjectViewPrivate -{ -public: - QMapObjectViewPrivateDefault(QGeoMapObject *q); - QMapObjectViewPrivateDefault(const QMapObjectViewPrivate &other); - ~QMapObjectViewPrivateDefault() override; - - QVariant model() const override; - void setModel(const QVariant &model) override; - QQmlComponent *delegate() const override; - void setDelegate(QQmlComponent *delegate) override; - - // QGeoMapObjectPrivate interface -public: - QGeoMapObjectPrivate *clone() override; - bool equals(const QGeoMapObjectPrivate &other) const override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; - - QVariant m_model; - QQmlComponent *m_delegate = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QMAPOBJECTVIEW_P_P_H diff --git a/src/location/labs/qmappolygonobject.cpp b/src/location/labs/qmappolygonobject.cpp deleted file mode 100644 index 5923e7f3..00000000 --- a/src/location/labs/qmappolygonobject.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmappolygonobject_p.h" -#include "qmappolygonobject_p_p.h" -#include <QtLocation/private/locationvaluetypehelper_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapPolygonObject - \instantiates QMapPolygonObject - \inqmlmodule Qt.labs.location - \ingroup qml-QtLocation5-maps - \inherits QGeoMapObject - - \brief The MapPolygonObject displays a polygon on a Map. - - The MapPolygonObject displays a polygon on a Map. - The MapPolygonObject type only makes sense when contained in a Map or in a \l MapObjectView. -*/ - -QMapPolygonObjectPrivate::QMapPolygonObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q) -{ - -} - -QMapPolygonObjectPrivate::~QMapPolygonObjectPrivate() -{ - -} - -QMapPolygonObjectPrivateDefault::QMapPolygonObjectPrivateDefault(QGeoMapObject *q) : QMapPolygonObjectPrivate(q) -{ - -} - -QMapPolygonObjectPrivateDefault::QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivate &other) : QMapPolygonObjectPrivate(other.q) -{ - m_path.setPerimeter(other.path()); // to stay on the safe side - QGeoPolygon poly(other.geoShape()); // to handle holes - for (int i = 0; i < poly.holesCount(); i++) - m_path.addHole(poly.holePath(i)); - m_borderColor = other.borderColor(); - m_fillColor = other.fillColor(); - m_borderWidth = other.borderWidth(); -} - -QMapPolygonObjectPrivateDefault::~QMapPolygonObjectPrivateDefault() -{ - -} - -QGeoMapObject::Type QMapPolygonObjectPrivate::type() const -{ - return QGeoMapObject::PolygonType; -} - -QList<QGeoCoordinate> QMapPolygonObjectPrivateDefault::path() const -{ - return m_path.perimeter(); -} - -void QMapPolygonObjectPrivateDefault::setPath(const QList<QGeoCoordinate> &path) -{ - m_path.setPerimeter(path); -} - -QColor QMapPolygonObjectPrivateDefault::fillColor() const -{ - return m_fillColor; -} - -void QMapPolygonObjectPrivateDefault::setFillColor(const QColor &color) -{ - m_fillColor = color; -} - -QColor QMapPolygonObjectPrivateDefault::borderColor() const -{ - return m_borderColor; -} - -void QMapPolygonObjectPrivateDefault::setBorderColor(const QColor &color) -{ - m_borderColor = color; -} - -qreal QMapPolygonObjectPrivateDefault::borderWidth() const -{ - return m_borderWidth; -} - -void QMapPolygonObjectPrivateDefault::setBorderWidth(qreal width) -{ - m_borderWidth = width; -} - -QGeoMapObjectPrivate *QMapPolygonObjectPrivateDefault::clone() -{ - return new QMapPolygonObjectPrivateDefault(static_cast<QMapPolygonObjectPrivate &>(*this)); -} - -QGeoShape QMapPolygonObjectPrivateDefault::geoShape() const -{ - return m_path; -} - -void QMapPolygonObjectPrivateDefault::setGeoShape(const QGeoShape &shape) -{ - if (shape == m_path) - return; - - const QGeoPolygon poly(shape); - for (int i = 0; i < poly.holesCount(); i++) - m_path.addHole(poly.holePath(i)); - setPath(poly.perimeter()); // to handle overrides. Last as it normally emits static_cast<QMapPolygonObject *>(q)->pathChanged(); -} - -bool QMapPolygonObjectPrivate::equals(const QGeoMapObjectPrivate &other) const -{ - if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used - return false; - - const QMapPolygonObjectPrivate &o = static_cast<const QMapPolygonObjectPrivate &>(other); - return (QGeoMapObjectPrivate::equals(o) - && geoShape() == o.geoShape() - && borderColor() == o.borderColor() - && fillColor() == o.fillColor() - && borderWidth() == o.borderWidth()); -} - -QGeoShape QMapPolygonObjectPrivate::geoShape() const -{ - return QGeoPolygon(path()); -} - -void QMapPolygonObjectPrivate::setGeoShape(const QGeoShape &shape) -{ - if (shape == geoShape()) - return; - - const QGeoPolygon poly(shape); - setPath(poly.perimeter()); // to handle overrides - emit static_cast<QMapPolygonObject *>(q)->pathChanged(); -} - - - - -QMapPolygonObject::QMapPolygonObject(QObject *parent) - : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapPolygonObjectPrivateDefault(this)), parent) -{ - QMapPolygonObjectPrivate *d = static_cast<QMapPolygonObjectPrivate*>(d_ptr.data()); - d->setBorderColor(QColor(Qt::black)); // These are QDeclarativeMapLineProperties defaults - d->setBorderWidth(1.0); -} - -QMapPolygonObject::~QMapPolygonObject() -{} - -/*! - \qmlproperty VariantList Qt.labs.location::MapPolygonObject::path - - This property holds the ordered list of coordinates which - define the polygon border. -*/ -QVariantList QMapPolygonObject::path() const -{ - QVariantList p; - for (const QGeoCoordinate &c: static_cast<const QMapPolygonObjectPrivate *>(d_ptr.data())->path()) - p << QVariant::fromValue(c); - return p; -} - -void QMapPolygonObject::setPath(const QVariantList &path) -{ - QList<QGeoCoordinate> p; - bool ok = false; - for (const auto &c: path) { - const QGeoCoordinate coord = parseCoordinate(c, &ok); - if (ok) - p << coord; - } - auto pimpl = static_cast<QMapPolygonObjectPrivate *>(d_ptr.data()); - if (p != pimpl->path()) { - pimpl->setPath(p); - emit pathChanged(); - } -} - -/*! - \qmlproperty color Qt.labs.location::MapPolygonObject::color - - This property holds the fill color of the polygon when drawn. For no fill, - use a transparent color. -*/ -QColor QMapPolygonObject::color() const -{ - return static_cast<const QMapPolygonObjectPrivate*>(d_ptr.data())->fillColor(); -} - -/*! - \qmlpropertygroup Qt.labs.location::MapPolygonObject::border - \qmlproperty int MapPolygonObject::border.width - \qmlproperty color MapPolygonObject::border.color - - This property is part of the border property group. The border - property group holds the width and color used to draw the border. - - The width is in pixels and is independent of the zoom level of the map. - The default values correspond to a black border with a width of 1 pixel. - - For no border, use a width of 0 or a transparent color. -*/ -QDeclarativeMapLineProperties *QMapPolygonObject::border() -{ - if (!m_border) { - m_border = new QDeclarativeMapLineProperties(this); - connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){ - static_cast<QMapPolygonObjectPrivate*>(d_ptr.data())->setBorderColor(color); - }); - connect(m_border, &QDeclarativeMapLineProperties::widthChanged, this, [this](qreal width){ - static_cast<QMapPolygonObjectPrivate*>(d_ptr.data())->setBorderWidth(width); - }); - } - return m_border; -} - -void QMapPolygonObject::setColor(const QColor &fillColor) -{ - auto ptr = static_cast<QMapPolygonObjectPrivate*>(d_ptr.data()); - - if (ptr->fillColor() == fillColor) - return; - - ptr->setFillColor(fillColor); - emit colorChanged(); -} - -void QMapPolygonObject::setMap(QGeoMap *map) -{ - QMapPolygonObjectPrivate *d = static_cast<QMapPolygonObjectPrivate *>(d_ptr.data()); - if (d->m_map == map) - return; - - QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected - - if (!map) { - // Map was set, now it has ben re-set to NULL, but not inside d_ptr. - // so m_map inside d_ptr can still be used to remove itself, inside the destructor. - d_ptr = new QMapPolygonObjectPrivateDefault(*d); - // Old pimpl deleted implicitly by QExplicitlySharedDataPointer - } -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qmappolygonobject_p.h b/src/location/labs/qmappolygonobject_p.h deleted file mode 100644 index 5ef4f381..00000000 --- a/src/location/labs/qmappolygonobject_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPPOLYGONOBJECT_P_H -#define QMAPPOLYGONOBJECT_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/qgeomapobject_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapPolygonObject : public QGeoMapObject -{ - Q_OBJECT - - Q_PROPERTY(QVariantList path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QDeclarativeMapLineProperties *border READ border CONSTANT) - -public: - QMapPolygonObject(QObject *parent = nullptr); - ~QMapPolygonObject() override; - - QVariantList path() const; - void setPath(const QVariantList &path); - - QColor color() const; - void setColor(const QColor &color); - - QDeclarativeMapLineProperties *border(); - void setMap(QGeoMap *map) override; - -signals: - void pathChanged(); - void colorChanged(); - -protected: - QDeclarativeMapLineProperties *m_border = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QMAPPOLYGONOBJECT_P_H diff --git a/src/location/labs/qmappolygonobject_p_p.h b/src/location/labs/qmappolygonobject_p_p.h deleted file mode 100644 index 0eb180e1..00000000 --- a/src/location/labs/qmappolygonobject_p_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPPOLYGONOBJECT_P_P_H -#define QMAPPOLYGONOBJECT_P_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/qgeomapobject_p_p.h> -#include <QGeoCoordinate> -#include <QColor> -#include <QGeoPolygon> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapPolygonObjectPrivate : public QGeoMapObjectPrivate -{ -public: - QMapPolygonObjectPrivate(QGeoMapObject *q); - ~QMapPolygonObjectPrivate() override; - - QGeoMapObject::Type type() const override final; - - virtual QList<QGeoCoordinate> path() const = 0; - virtual void setPath(const QList<QGeoCoordinate> &path) = 0; - virtual QColor fillColor() const = 0; - virtual void setFillColor(const QColor &color) = 0; - virtual QColor borderColor() const = 0; - virtual void setBorderColor(const QColor &color) = 0; - virtual qreal borderWidth() const = 0; - virtual void setBorderWidth(qreal width) = 0; - - // QGeoMapObjectPrivate interface - bool equals(const QGeoMapObjectPrivate &other) const override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; -}; - -class Q_LOCATION_PRIVATE_EXPORT QMapPolygonObjectPrivateDefault : public QMapPolygonObjectPrivate -{ -public: - QMapPolygonObjectPrivateDefault(QGeoMapObject *q); - QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivate &other); - ~QMapPolygonObjectPrivateDefault() override; - - // QMapPolygonObjectPrivate interface - QList<QGeoCoordinate> path() const override; - void setPath(const QList<QGeoCoordinate> &path) override; - QColor fillColor() const override; - void setFillColor(const QColor &color) override; - QColor borderColor() const override; - void setBorderColor(const QColor &color) override; - qreal borderWidth() const override; - void setBorderWidth(qreal width) override; - - // QGeoMapObjectPrivate interface - QGeoMapObjectPrivate *clone() override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; - -public: - QGeoPolygon m_path; // small overhead compared to plain QList<QGeoCoordinate> - QColor m_borderColor = Qt::transparent; - QColor m_fillColor = Qt::transparent; - qreal m_borderWidth = 0; - -private: - QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivateDefault &other) = delete; -}; - -QT_END_NAMESPACE - - -#endif // QMAPPOLYGONOBJECT_P_P_H diff --git a/src/location/labs/qmappolylineobject.cpp b/src/location/labs/qmappolylineobject.cpp deleted file mode 100644 index 4170877d..00000000 --- a/src/location/labs/qmappolylineobject.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmappolylineobject_p.h" -#include "qmappolylineobject_p_p.h" -#include <QtLocation/private/locationvaluetypehelper_p.h> -#include <QtPositioning/QGeoPath> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapPolylineObject - \instantiates QMapPolylineObject - \inqmlmodule Qt.labs.location - \ingroup qml-QtLocation5-maps - \inherits QGeoMapObject - - \brief The MapPolylineObject displays a polyline on a Map. - - The MapPolylineObject displays a polyline on a Map. - The MapPolylineObject type only makes sense when contained in a Map or in a \l MapObjectView. -*/ - -QMapPolylineObjectPrivate::QMapPolylineObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q) -{ - -} - -QMapPolylineObjectPrivate::~QMapPolylineObjectPrivate() -{ - -} - -QGeoMapObject::Type QMapPolylineObjectPrivate::type() const -{ - return QGeoMapObject::PolylineType; -} - -QMapPolylineObjectPrivateDefault::QMapPolylineObjectPrivateDefault(QGeoMapObject *q) : QMapPolylineObjectPrivate(q) -{ - -} - -QMapPolylineObjectPrivateDefault::QMapPolylineObjectPrivateDefault(const QMapPolylineObjectPrivate &other) : QMapPolylineObjectPrivate(other.q) -{ - m_path.setPath(other.path()); - m_color = other.color(); - m_width = other.width(); -} - -QMapPolylineObjectPrivateDefault::~QMapPolylineObjectPrivateDefault() -{ - -} - -QList<QGeoCoordinate> QMapPolylineObjectPrivateDefault::path() const -{ - return m_path.path(); -} - -void QMapPolylineObjectPrivateDefault::setPath(const QList<QGeoCoordinate> &path) -{ - m_path.setPath(path); -} - -QColor QMapPolylineObjectPrivateDefault::color() const -{ - return m_color; -} - -void QMapPolylineObjectPrivateDefault::setColor(const QColor &color) -{ - m_color = color; -} - -qreal QMapPolylineObjectPrivateDefault::width() const -{ - return m_width; -} - -void QMapPolylineObjectPrivateDefault::setWidth(qreal width) -{ - m_width = width; -} - -bool QMapPolylineObjectPrivate::equals(const QGeoMapObjectPrivate &other) const -{ - if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used - return false; - - const QMapPolylineObjectPrivate &o = static_cast<const QMapPolylineObjectPrivate &>(other); - return (QGeoMapObjectPrivate::equals(o) - && path() == o.path() - && color() == o.color() - && width() == o.width()); -} - -QGeoShape QMapPolylineObjectPrivate::geoShape() const -{ - return QGeoPath(path()); -} - -void QMapPolylineObjectPrivate::setGeoShape(const QGeoShape &shape) -{ - const QGeoPath p(shape); - if (p.path() == path()) - return; - - setPath(p.path()); // to handle overrides - emit static_cast<QMapPolylineObject *>(q)->pathChanged(); -} - - - -QGeoMapObjectPrivate *QMapPolylineObjectPrivateDefault::clone() -{ - return new QMapPolylineObjectPrivateDefault(static_cast<QMapPolylineObjectPrivate &>(*this)); -} - -QMapPolylineObject::QMapPolylineObject(QObject *parent) - : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapPolylineObjectPrivateDefault(this)), parent) -{ - QMapPolylineObjectPrivate *d = static_cast<QMapPolylineObjectPrivate*>(d_ptr.data()); - d->setColor(QColor(Qt::black)); // These are QDeclarativeMapLineProperties defaults - d->setWidth(1.0); -} - -QMapPolylineObject::~QMapPolylineObject() -{} - -/*! - \qmlproperty VariantList Qt.labs.location::MapPolylineObject::path - - This property holds the ordered list of coordinates which - define the polyline. -*/ -QVariantList QMapPolylineObject::path() const -{ - QVariantList p; - for (const QGeoCoordinate &c: static_cast<const QMapPolylineObjectPrivate*>(d_ptr.data())->path()) - p << QVariant::fromValue(c); - return p; -} - -/*! - \qmlpropertygroup Qt.labs.location::MapPolylineObject::line - \qmlproperty int MapPolylineObject::line.width - \qmlproperty color MapPolylineObject::line.color - - This property is part of the line property group. The line - property group holds the width and color used to draw the line. - - The width is in pixels and is independent of the zoom level of the map. - The default values correspond to a black border with a width of 1 pixel. - - For no line, use a width of 0 or a transparent color. -*/ -QDeclarativeMapLineProperties *QMapPolylineObject::border() -{ - if (!m_border) { - m_border = new QDeclarativeMapLineProperties(this); - connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){ - static_cast<QMapPolylineObjectPrivate*>(d_ptr.data())->setColor(color); - }); - connect(m_border, &QDeclarativeMapLineProperties::widthChanged, this, [this](qreal width){ - static_cast<QMapPolylineObjectPrivate*>(d_ptr.data())->setWidth(width); - }); - } - return m_border; -} - -void QMapPolylineObject::setPath(const QVariantList &path) -{ - QList<QGeoCoordinate> p; - bool ok = false; - for (const auto &c: path) { - const QGeoCoordinate coord = parseCoordinate(c, &ok); - if (ok) - p << coord; - } - auto pimpl = static_cast<QMapPolylineObjectPrivate *>(d_ptr.data()); - if (p != pimpl->path()) { - pimpl->setPath(p); - emit pathChanged(); - } -} - -void QMapPolylineObject::setMap(QGeoMap *map) -{ - QMapPolylineObjectPrivate *d = static_cast<QMapPolylineObjectPrivate *>(d_ptr.data()); - if (d->m_map == map) - return; - - QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected - - if (!map) { - // Map was set, now it has ben re-set to NULL, but not inside d_ptr. - // so m_map inside d_ptr can still be used to remove itself, inside the destructor. - d_ptr = new QMapPolylineObjectPrivateDefault(*d); - // Old pimpl deleted implicitly by QExplicitlySharedDataPointer - } -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qmappolylineobject_p.h b/src/location/labs/qmappolylineobject_p.h deleted file mode 100644 index 26057e90..00000000 --- a/src/location/labs/qmappolylineobject_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPPOLYLINEOBJECT_P_H -#define QMAPPOLYLINEOBJECT_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/qgeomapobject_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapPolylineObject : public QGeoMapObject -{ - Q_OBJECT - - Q_PROPERTY(QVariantList path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(QDeclarativeMapLineProperties *line READ border CONSTANT) - -public: - QMapPolylineObject(QObject *parent = nullptr); - ~QMapPolylineObject() override; - - QVariantList path() const; - void setPath(const QVariantList &path); - - QDeclarativeMapLineProperties *border(); - void setMap(QGeoMap *map) override; - -signals: - void pathChanged(); - -protected: - QDeclarativeMapLineProperties *m_border = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QMAPPOLYLINEOBJECT_P_H diff --git a/src/location/labs/qmappolylineobject_p_p.h b/src/location/labs/qmappolylineobject_p_p.h deleted file mode 100644 index 08edcac8..00000000 --- a/src/location/labs/qmappolylineobject_p_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPPOLYLINEOBJECT_P_P_H -#define QMAPPOLYLINEOBJECT_P_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/qgeomapobject_p_p.h> -#include <QGeoCoordinate> -#include <QGeoPath> -#include <QColor> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapPolylineObjectPrivate : public QGeoMapObjectPrivate -{ -public: - QMapPolylineObjectPrivate(QGeoMapObject *q); - ~QMapPolylineObjectPrivate() override; - - QGeoMapObject::Type type() const override final; - - virtual QList<QGeoCoordinate> path() const = 0; - virtual void setPath(const QList<QGeoCoordinate> &path) = 0; - virtual QColor color() const = 0; - virtual void setColor(const QColor &color) = 0; - virtual qreal width() const = 0; - virtual void setWidth(qreal width) = 0; - - // QGeoMapObjectPrivate interface - bool equals(const QGeoMapObjectPrivate &other) const override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; -}; - -class Q_LOCATION_PRIVATE_EXPORT QMapPolylineObjectPrivateDefault : public QMapPolylineObjectPrivate -{ -public: - QMapPolylineObjectPrivateDefault(QGeoMapObject *q); - QMapPolylineObjectPrivateDefault(const QMapPolylineObjectPrivate &other); - ~QMapPolylineObjectPrivateDefault() override; - - // QGeoMapPolylinePrivate interface - QList<QGeoCoordinate> path() const override; - void setPath(const QList<QGeoCoordinate> &path) override; - QColor color() const override; - void setColor(const QColor &color) override; - qreal width() const override; - void setWidth(qreal width) override; - - // QGeoMapObjectPrivate interface - QGeoMapObjectPrivate *clone() override; - -public: - QGeoPath m_path; // small overhead compared to plain QList<QGeoCoordinate> - QColor m_color; - qreal m_width = 0; - -private: - QMapPolylineObjectPrivateDefault(const QMapPolylineObjectPrivateDefault &other) = delete; -}; - -QT_END_NAMESPACE - - -#endif // QMAPPOLYLINEOBJECT_P_P_H diff --git a/src/location/labs/qmaprouteobject.cpp b/src/location/labs/qmaprouteobject.cpp deleted file mode 100644 index 6e3f9bb5..00000000 --- a/src/location/labs/qmaprouteobject.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtLocation/private/qdeclarativegeoroute_p.h> -#include "qmaprouteobject_p.h" -#include "qmaprouteobject_p_p.h" - -#include <QtPositioning/QGeoRectangle> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype MapRouteObject - \instantiates QMapRouteObject - \inqmlmodule Qt.labs.location - \ingroup qml-QtLocation5-maps - \inherits QGeoMapObject - - \brief The MapRouteObject displays a geographical route on a Map. - - The MapRouteObject type displays a Route obtained through a RouteModel or - other means, on the Map as a Polyline following the path of the Route. -*/ - -/* - - QGeoMapRoutePrivate - -*/ - -QMapRouteObjectPrivate::QMapRouteObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q) -{ - -} - -QMapRouteObjectPrivate::QMapRouteObjectPrivate(const QMapRouteObjectPrivate &other) : QGeoMapObjectPrivate(other) -{ - // QGeoMapRoutePrivate doesn't contain anything because QGeoRoute has already everything necessary. -} - -QMapRouteObjectPrivate::~QMapRouteObjectPrivate() -{ - -} - -QGeoMapObject::Type QMapRouteObjectPrivate::type() const -{ - return QGeoMapObject::RouteType; -} - -QDeclarativeGeoRoute *QMapRouteObjectPrivate::declarativeGeoRoute() const -{ - const QMapRouteObject *r = static_cast<QMapRouteObject *>(q); - return r->m_route; -} - -/*! - \qmlproperty Route Qt.labs.location::MapRouteObject::route - - This property holds the route to be drawn. -*/ -QGeoRoute QMapRouteObjectPrivate::route() const -{ - const QDeclarativeGeoRoute *r = declarativeGeoRoute(); - if (r) - return r->route(); - return {}; -} - -void QMapRouteObjectPrivate::setRoute(const QDeclarativeGeoRoute *route) -{ - Q_UNUSED(route); -} - -bool QMapRouteObjectPrivate::equals(const QGeoMapObjectPrivate &other) const -{ - if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used - return false; - - const QMapRouteObjectPrivate &o = static_cast<const QMapRouteObjectPrivate &>(other); - return (QGeoMapObjectPrivate::equals(o) - && route() == o.route()); // Could also be done shallow, comparing declarativeGeoRoute() -} - -QGeoMapObjectPrivate *QMapRouteObjectPrivate::clone() -{ - return new QMapRouteObjectPrivate(*this); -} - -QGeoShape QMapRouteObjectPrivate::geoShape() const -{ - return route().bounds(); -} - -void QMapRouteObjectPrivate::setGeoShape(const QGeoShape &/*shape*/) -{ - // Not supported for MapRouteObject -} - - -/* - - QGeoMapRoute - -*/ - -QMapRouteObject::QMapRouteObject(QObject *parent) - : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapRouteObjectPrivate(this)), parent) -{ - -} - -QMapRouteObject::~QMapRouteObject() -{ - -} - -QDeclarativeGeoRoute *QMapRouteObject::route() const -{ - return m_route; -} - -QGeoRoute QMapRouteObject::geoRoute() const -{ - if (m_route) - return m_route->route(); - return {}; -} - -void QMapRouteObject::setRoute(QDeclarativeGeoRoute *route) -{ - if (route == m_route) - return; -// if ((!m_route && !route) || (m_route && route && m_route->route() == route->route())) -// return; - - m_route = route; - QMapRouteObjectPrivate *d = static_cast<QMapRouteObjectPrivate *>(d_ptr.data()); - d->setRoute(route); - emit routeChanged(route); -} - -void QMapRouteObject::setMap(QGeoMap *map) -{ - QMapRouteObjectPrivate *d = static_cast<QMapRouteObjectPrivate *>(d_ptr.data()); - if (d->m_map == map) - return; - - QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected - - if (!map) { - // Map was set, now it has ben re-set to NULL, but not inside d_ptr. - // so m_map inside d_ptr can still be used to remove itself, inside the destructor. - d_ptr = new QMapRouteObjectPrivate(*d); // This is not losing data: check MapRouteObjectPrivate::declarativeGeoRoute() - // Old pimpl deleted implicitly by QExplicitlySharedDataPointer - } -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qmaprouteobject_p.h b/src/location/labs/qmaprouteobject_p.h deleted file mode 100644 index ce97f623..00000000 --- a/src/location/labs/qmaprouteobject_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEMAPROUTEDELEGATE_P_H -#define QDECLARATIVEMAPROUTEDELEGATE_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 <QtQml/qqml.h> - -#include <QtLocation/private/qgeomapobject_p.h> -#include <QtLocation/private/qparameterizableobject_p.h> - -Q_MOC_INCLUDE(<QtLocation/private/qdeclarativegeoroute_p.h>) - -QT_BEGIN_NAMESPACE - -class QDeclarativeGeoRoute; -class QGeoRoute; -class QMapRouteObjectPrivate; -class Q_LOCATION_PRIVATE_EXPORT QMapRouteObject : public QGeoMapObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeGeoRoute *route READ route WRITE setRoute NOTIFY routeChanged) - -public: - explicit QMapRouteObject(QObject *parent = nullptr); - ~QMapRouteObject() override; - - QDeclarativeGeoRoute *route() const; - QGeoRoute geoRoute() const; - - void setMap(QGeoMap *map) override; - void setRoute(QDeclarativeGeoRoute * route); - -signals: - void routeChanged(QDeclarativeGeoRoute * route); - -protected: - QDeclarativeGeoRoute *m_route = nullptr; - - friend class QMapRouteObjectPrivate; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QMapRouteObject) - -#endif // QDECLARATIVEMAPROUTEDELEGATE_P_H diff --git a/src/location/labs/qmaprouteobject_p_p.h b/src/location/labs/qmaprouteobject_p_p.h deleted file mode 100644 index e024a0f2..00000000 --- a/src/location/labs/qmaprouteobject_p_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGEOMAPROUTE_P_P_H -#define QGEOMAPROUTE_P_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/qgeomapobject_p_p.h> -#include <QtLocation/private/qdeclarativegeoroute_p.h> -QT_BEGIN_NAMESPACE - -class QGeoRoute; - -class Q_LOCATION_PRIVATE_EXPORT QMapRouteObjectPrivate : public QGeoMapObjectPrivate -{ -public: - QMapRouteObjectPrivate(QGeoMapObject *q); - QMapRouteObjectPrivate(const QMapRouteObjectPrivate &other); - ~QMapRouteObjectPrivate() override; - - QGeoMapObject::Type type() const override final; - - QDeclarativeGeoRoute *declarativeGeoRoute() const; - - virtual QGeoRoute route() const; - virtual void setRoute(const QDeclarativeGeoRoute *route); - - // QGeoMapObjectPrivate interface - bool equals(const QGeoMapObjectPrivate &other) const override; - QGeoMapObjectPrivate *clone() override; - QGeoShape geoShape() const override; - void setGeoShape(const QGeoShape &shape) override; -}; - -QT_END_NAMESPACE - -#endif // QGEOMAPROUTE_P_P_H diff --git a/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp deleted file mode 100644 index 906ef2ea..00000000 --- a/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgeomapobjectqsgsupport_p.h" -#include <QtLocation/private/qgeomap_p_p.h> - -QT_BEGIN_NAMESPACE - -static int findMapObject(QGeoMapObject *o, const QList<MapObject> &list) -{ - for (int i = 0; i < list.size(); ++i) - { - if (list.at(i).object.data() == o) - return i; - } - return -1; -} - -bool QGeoMapObjectQSGSupport::createMapObjectImplementation(QGeoMapObject *obj, QGeoMapPrivate *d) -{ - QExplicitlySharedDataPointer<QGeoMapObjectPrivate> pimpl = - QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(d->createMapObjectImplementation(obj)); - if (pimpl.constData()) { - bool res = obj->setImplementation(pimpl); - if (res) - emit m_map->sgNodeChanged(); - return res; - } - return false; -} - -QGeoMapObjectPrivate *QGeoMapObjectQSGSupport::createMapObjectImplementationPrivate(QGeoMapObject *obj) -{ - QGeoMapObjectPrivate *res = nullptr; - - { - QQSGMapObject *sgo = nullptr; - switch (obj->type()) { - case QGeoMapObject::PolylineType: { - QMapPolylineObjectPrivate &oldImpl = static_cast<QMapPolylineObjectPrivate &>(*obj->implementation()); - QMapPolylineObjectPrivateQSG *pimpl = - new QMapPolylineObjectPrivateQSG(oldImpl); - sgo = pimpl; - res = pimpl; - break; - } - case QGeoMapObject::PolygonType: { - QMapPolygonObjectPrivate &oldImpl = static_cast<QMapPolygonObjectPrivate &>(*obj->implementation()); - QMapPolygonObjectPrivateQSG *pimpl = - new QMapPolygonObjectPrivateQSG(oldImpl); - sgo = pimpl; - res = pimpl; - break; - } - case QGeoMapObject::CircleType: { - QMapCircleObjectPrivate &oldImpl = static_cast<QMapCircleObjectPrivate &>(*obj->implementation()); - QMapCircleObjectPrivateQSG *pimpl = - new QMapCircleObjectPrivateQSG(oldImpl); - sgo = pimpl; - res = pimpl; - break; - } - case QGeoMapObject::RouteType: { - QMapRouteObjectPrivate &oldImpl = static_cast<QMapRouteObjectPrivate &>(*obj->implementation()); - QMapRouteObjectPrivateQSG *pimpl = - new QMapRouteObjectPrivateQSG(oldImpl); - sgo = pimpl; - res = pimpl; - break; - } - case QGeoMapObject::IconType: { - QMapIconObjectPrivate &oldImpl = static_cast<QMapIconObjectPrivate &>(*obj->implementation()); - QMapIconObjectPrivateQSG *pimpl = - new QMapIconObjectPrivateQSG(oldImpl); - sgo = pimpl; - res = pimpl; - break; - } - default: - // Use the following warning only for debugging purposes. - // qWarning() << "QGeoMapObjectQSGSupport::createMapObjectImplementationPrivate: not instantiating pimpl for unsupported object type " << obj->type(); - break; - } - - if (res) { - QPointer<QGeoMapObject> p(obj); - MapObject mo(p, sgo); - m_pendingMapObjects << mo; - } - } - return res; -} - -QList<QGeoMapObject *> QGeoMapObjectQSGSupport::mapObjects() const -{ - QList<QGeoMapObject *> res; - for (int i = 0; i < m_mapObjects.size(); ++i) { - res.append(m_mapObjects.at(i).object.data()); - } - return res; -} - -void QGeoMapObjectQSGSupport::removeMapObject(QGeoMapObject *obj) -{ - int idx = findMapObject(obj, m_mapObjects); - if (idx >= 0) { - const MapObject &mo = m_mapObjects.takeAt(idx); - obj->disconnect(m_map); - m_removedMapObjects << mo; - emit m_map->sgNodeChanged(); - } else { - idx = findMapObject(obj, m_pendingMapObjects); - if (idx >= 0) { - m_pendingMapObjects.removeAt(idx); - obj->disconnect(m_map); - } else { - // obj not here. - } - } -} - -// called in the render thread -void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *window) -{ - if (!root) - return; - - if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent()) - root->appendChildNode(m_mapObjectsRootNode.get()); - - if (!m_mapObjectsRootNode) { - m_mapObjectsRootNode = std::make_unique<QDeclarativePolygonMapItemPrivateOpenGL::RootNode>(); - root->appendChildNode(m_mapObjectsRootNode.get()); - m_mapObjectsRootNode->setFlag(QSGNode::OwnedByParent, false); - } - - m_mapObjectsRootNode->removeAllChildNodes(); - for (int i = 0; i < m_removedMapObjects.size(); ++i) { - MapObject mo = m_removedMapObjects[i]; - if (mo.qsgNode) { - delete mo.qsgNode; - mo.qsgNode = nullptr; - // mo.sgObject is now invalid as it is destroyed right after appending - // mo to m_removedMapObjects - } - } - m_removedMapObjects.clear(); - - for (int i = 0; i < m_mapObjects.size(); ++i) { - // already added as node - if (Q_UNLIKELY(!m_mapObjects.at(i).object)) { - qWarning() << "unexpected NULL pointer in m_mapObjects at "<<i; - continue; - } - - MapObject &mo = m_mapObjects[i]; - QQSGMapObject *sgo = mo.sgObject; - QSGNode *oldNode = mo.qsgNode; - mo.qsgNode = sgo->updateMapObjectNode(oldNode, &mo.visibleNode, m_mapObjectsRootNode.get(), window); - if (Q_UNLIKELY(!mo.qsgNode)) { - qWarning() << "updateMapObjectNode for "<<mo.object->type() << " returned NULL"; - } else if (mo.visibleNode && (mo.visibleNode->visible() != mo.object->visible())) { - mo.visibleNode->setVisible(mo.object->visible()); - mo.qsgNode->markDirty(QSGNode::DirtySubtreeBlocked); - } - } - - QList<int> toRemove; - for (int i = 0; i < m_pendingMapObjects.size(); ++i) { - // already added as node - MapObject &mo = m_pendingMapObjects[i]; - QQSGMapObject *sgo = mo.sgObject; - QSGNode *oldNode = mo.qsgNode; - sgo->updateGeometry(); // or subtree will be blocked - mo.qsgNode = sgo->updateMapObjectNode(oldNode, &mo.visibleNode, m_mapObjectsRootNode.get(), window); - if (mo.qsgNode) { - if (mo.visibleNode && (mo.visibleNode->visible() != mo.object->visible())) { - mo.visibleNode->setVisible(mo.object->visible()); - mo.qsgNode->markDirty(QSGNode::DirtySubtreeBlocked); - } - m_mapObjects << mo; - toRemove.push_front(i); - QObject::connect(mo.object, &QGeoMapObject::visibleChanged, - m_map, &QGeoMap::sgNodeChanged); - } else { - // leave it to be processed, don't spit warnings - } - } - - for (int i: qAsConst(toRemove)) - m_pendingMapObjects.removeAt(i); - m_mapObjectsRootNode->setSubtreeBlocked(false); -} - -// called in GUI thread -void QGeoMapObjectQSGSupport::updateObjectsGeometry() -{ - for (int i = 0; i < m_mapObjects.size(); ++i) { - // already added as node - if (Q_UNLIKELY(!m_mapObjects.at(i).object)) { - qWarning() << "unexpected NULL pointer in m_mapObjects at "<<i; - continue; - } - - QQSGMapObject *sgo = m_mapObjects.at(i).sgObject; - sgo->updateGeometry(); - } - emit m_map->sgNodeChanged(); -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qsg/qgeomapobjectqsgsupport_p.h b/src/location/labs/qsg/qgeomapobjectqsgsupport_p.h deleted file mode 100644 index df42a55c..00000000 --- a/src/location/labs/qsg/qgeomapobjectqsgsupport_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGEOMAPOBJECTQSGSUPPORT_P_H -#define QGEOMAPOBJECTQSGSUPPORT_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/qgeomapobject_p.h> -#include <QtLocation/private/qgeomapobject_p_p.h> -#include <QtLocation/private/qmappolylineobjectqsg_p_p.h> -#include <QtLocation/private/qmappolygonobjectqsg_p_p.h> -#include <QtLocation/private/qmapcircleobjectqsg_p_p.h> -#include <QtLocation/private/qmaprouteobjectqsg_p_p.h> -#include <QtLocation/private/qmapiconobjectqsg_p_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> -#include <QtLocation/private/qdeclarativepolygonmapitem_p_p.h> -#include <QtCore/qpointer.h> -#include <memory> - -QT_BEGIN_NAMESPACE -struct Q_LOCATION_PRIVATE_EXPORT MapObject { - MapObject(QPointer<QGeoMapObject> &o, QQSGMapObject *sgo) - : object(o), sgObject(sgo) {} - - QPointer<QGeoMapObject> object; - QQSGMapObject *sgObject = nullptr; // this is a QMap*ObjectPrivateQSG. it becomes invalid when the pimpl is destroyed - VisibleNode *visibleNode = nullptr; // This is a Map*Node (like a MapPolygonNode) that is a QSGNode. This doesn't disappear by itself - QSGNode *qsgNode = nullptr; -}; - -class Q_LOCATION_PRIVATE_EXPORT QGeoMapObjectQSGSupport -{ -public: - bool createMapObjectImplementation(QGeoMapObject *obj, QGeoMapPrivate *d); - QGeoMapObjectPrivate *createMapObjectImplementationPrivate(QGeoMapObject *obj); - QList<QGeoMapObject *> mapObjects() const; - void removeMapObject(QGeoMapObject *obj); - void updateMapObjects(QSGNode *root, QQuickWindow *window); - void updateObjectsGeometry(); - - QList<MapObject> m_mapObjects; - QList<MapObject> m_pendingMapObjects; - QList<MapObject> m_removedMapObjects; - QGeoMap *m_map = nullptr; - std::unique_ptr<QDeclarativePolygonMapItemPrivateOpenGL::RootNode> m_mapObjectsRootNode; -}; - -QT_END_NAMESPACE - -#endif // QGEOMAPOBJECTQSGSUPPORT_P_H diff --git a/src/location/labs/qsg/qmapcircleobjectqsg.cpp b/src/location/labs/qsg/qmapcircleobjectqsg.cpp deleted file mode 100644 index 3cf98907..00000000 --- a/src/location/labs/qsg/qmapcircleobjectqsg.cpp +++ /dev/null @@ -1,391 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmapcircleobjectqsg_p_p.h" - -QT_BEGIN_NAMESPACE - -static const int CircleSamples = 128; - -QMapCircleObjectPrivateQSG::QMapCircleObjectPrivateQSG(QGeoMapObject *q) - : QMapCircleObjectPrivateDefault(q), m_dataCPU(new CircleDataCPU) -{ - -} - -QMapCircleObjectPrivateQSG::QMapCircleObjectPrivateQSG(const QMapCircleObjectPrivate &other) - : QMapCircleObjectPrivateDefault(other), m_dataCPU(new CircleDataCPU) -{ - // Data already cloned by the *Default copy constructor, but necessary - // update operations triggered only by setters overrides - if (!QDeclarativeCircleMapItemPrivateCPU::crossEarthPole(center(), radius())) - switchToGL(); // this marks source dirty - - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -QMapCircleObjectPrivateQSG::~QMapCircleObjectPrivateQSG() -{ - if (m_map) - m_map->removeMapObject(q); -} - -void QMapCircleObjectPrivateQSG::updateGeometry() -{ - if (m_dataGL) - updateGeometryGL(); - else - updateGeometryCPU(); -} - -void QMapCircleObjectPrivateQSG::CircleDataCPU::updateCirclePath(const QGeoCoordinate ¢er, qreal radius, const QGeoProjectionWebMercator &p) -{ - QList<QGeoCoordinate> path; - QDeclarativeCircleMapItemPrivateCPU::calculatePeripheralPoints(path, center, radius, CircleSamples, m_leftBound); - m_circlePath.clear(); - for (const QGeoCoordinate &c : path) - m_circlePath << p.geoToMapProjection(c); -} - -void QMapCircleObjectPrivateQSG::updateGeometryCPU() -{ - if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator - || !qIsFinite(radius()) || !center().isValid()) - return; - - const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection()); - QScopedValueRollback<bool> rollback(m_dataCPU->m_updatingGeometry); - m_dataCPU->m_updatingGeometry = true; - - m_dataCPU->updateCirclePath(center(), radius(), p); - QList<QDoubleVector2D> circlePath = m_dataCPU->m_circlePath; - - int pathCount = circlePath.size(); - bool preserve = QDeclarativeCircleMapItemPrivateCPU::preserveCircleGeometry(circlePath, center(), radius(), p); - // using leftBound_ instead of the analytically calculated circle_.boundingGeoRectangle().topLeft()); - // to fix QTBUG-62154 - m_dataCPU->m_geometry.markSourceDirty(); - m_dataCPU->m_geometry.setPreserveGeometry(true, m_dataCPU->m_leftBound); // to set the geoLeftBound_ - m_dataCPU->m_geometry.setPreserveGeometry(preserve, m_dataCPU->m_leftBound); - - bool invertedCircle = false; - if (QDeclarativeCircleMapItemPrivateCPU::crossEarthPole(center(), radius()) && circlePath.size() == pathCount) { - m_dataCPU->m_geometry.updateScreenPointsInvert(circlePath, *m_map); // invert fill area for really huge circles - invertedCircle = true; - } else { - m_dataCPU->m_geometry.updateSourcePoints(*m_map, circlePath); - m_dataCPU->m_geometry.updateScreenPoints(*m_map); - } - - m_dataCPU->m_borderGeometry.clear(); - - //if (borderColor() != Qt::transparent && borderWidth() > 0) - { - QList<QDoubleVector2D> closedPath = circlePath; - closedPath << closedPath.first(); - - if (invertedCircle) { - closedPath = m_dataCPU->m_circlePath; - closedPath << closedPath.first(); - std::reverse(closedPath.begin(), closedPath.end()); - } - - m_dataCPU->m_borderGeometry.markSourceDirty(); - m_dataCPU->m_borderGeometry.setPreserveGeometry(true, m_dataCPU->m_leftBound); - m_dataCPU->m_borderGeometry.setPreserveGeometry(preserve, m_dataCPU->m_leftBound); - - // Use srcOrigin_ from fill geometry after clipping to ensure that translateToCommonOrigin won't fail. - const QGeoCoordinate &geometryOrigin = m_dataCPU->m_geometry.origin(); - - m_dataCPU->m_borderGeometry.clearSource(); - - QDoubleVector2D borderLeftBoundWrapped; - QList<QList<QDoubleVector2D > > clippedPaths = - m_dataCPU->m_borderGeometry.clipPath(*m_map, closedPath, borderLeftBoundWrapped); - if (clippedPaths.size()) { - borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin); - m_dataCPU->m_borderGeometry.pathToScreen(*m_map, clippedPaths, borderLeftBoundWrapped); - m_dataCPU->m_borderGeometry.updateScreenPoints(*m_map, borderWidth(), false); - } else { - m_dataCPU->m_borderGeometry.clear(); - } - } - - QPointF origin = m_map->geoProjection().coordinateToItemPosition(m_dataCPU->m_geometry.origin(), false).toPointF(); - m_dataCPU->m_geometry.translate(origin - m_dataCPU->m_geometry.firstPointOffset()); - m_dataCPU->m_borderGeometry.translate(origin - m_dataCPU->m_borderGeometry.firstPointOffset()); -} - -void QMapCircleObjectPrivateQSG::CircleDataGL::updateCirclePath(const QGeoCoordinate ¢er, qreal radius, const QGeoProjectionWebMercator &p) -{ - m_circlePath.clear(); - if (radius < 0.001) // 1mm is small enough, probably already way too small. - return; - QDeclarativeCircleMapItemPrivate::calculatePeripheralPoints(m_circlePath, - center, - radius, - CircleSamples, - m_leftBound); - - m_leftBoundMercator = p.geoToMapProjection(m_leftBound); - m_geometry.setPreserveGeometry(true, m_leftBound); - m_borderGeometry.setPreserveGeometry(true, m_leftBound); -} - -void QMapCircleObjectPrivateQSG::updateGeometryGL() -{ - if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator) - return; - - const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection()); - if (m_dataGL->m_geometry.isSourceDirty() - || m_dataGL->m_borderGeometry.isSourceDirty()) { - m_dataGL->updateCirclePath(center(), radius(), p); - - if (m_dataGL->m_circlePath.length() == 0) { // Possibly cleared - m_dataGL->m_geometry.clear(); - m_dataGL->m_borderGeometry.clear(); - return; - } - m_dataGL->m_geometry.m_dataChanged = m_dataGL->m_borderGeometry.m_dataChanged = true; - m_dataGL->m_geometry.updateSourcePoints(*m_map, m_dataGL->m_circlePath); - m_dataGL->m_borderGeometry.updateSourcePoints(*m_map, QGeoCircle(center(), radius())); - m_dataGL->m_circlePath.clear(); // not needed anymore - } - m_dataGL->m_geometry.markScreenDirty(); // ToDo: this needs refactor. It's useless, remove screenDirty_ altogether. - m_dataGL->m_borderGeometry.markScreenDirty(); - m_dataGL->m_borderGeometry.m_wrapOffset = m_dataGL->m_geometry.m_wrapOffset = p.projectionWrapFactor(m_dataGL->m_leftBoundMercator) + 1; -} - -QGeoMapObjectPrivate *QMapCircleObjectPrivateQSG::clone() -{ - return new QMapCircleObjectPrivateQSG(static_cast<QMapCircleObjectPrivate &>(*this)); -} - -void QMapCircleObjectPrivateQSG::switchToGL() -{ - if (m_dataGL) - return; - std::unique_ptr<CircleDataGL> data(new CircleDataGL); - m_dataGL.swap(data); - m_dataGL->markSourceDirty(); - m_dataCPU.reset(nullptr); -} - -void QMapCircleObjectPrivateQSG::switchToCPU() -{ - if (m_dataCPU) - return; - std::unique_ptr<CircleDataCPU> data(new CircleDataCPU); - m_dataCPU.swap(data); - m_dataGL.reset(nullptr); -} - -QSGNode *QMapCircleObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow * window) -{ - if (m_dataGL) - return updateMapObjectNodeGL(oldNode, visibleNode, root, window); - else - return updateMapObjectNodeCPU(oldNode, visibleNode, root, window); -} - -QSGNode *QMapCircleObjectPrivateQSG::updateMapObjectNodeCPU(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) -{ - Q_UNUSED(window); - if (!m_dataCPU->m_node || !oldNode) { - m_dataCPU->m_node = new MapPolygonNode(); - *visibleNode = static_cast<VisibleNode *>(m_dataCPU->m_node); - if (oldNode) - delete oldNode; - } else { - m_dataCPU->m_node = static_cast<MapPolygonNode *>(oldNode); - } - - if (!m_dataCPU->m_geometry.size() && !m_dataCPU->m_borderGeometry.size()) { - visibleNode = nullptr; - return nullptr; - } - - //TODO: update only material - if (m_dataCPU->m_geometry.isScreenDirty() || m_dataCPU->m_borderGeometry.isScreenDirty() || oldNode != m_dataCPU->m_node) { - //QMapPolygonObject *p = static_cast<QMapPolygonObject *>(q); - m_dataCPU->m_node->update(color(), borderColor(), &m_dataCPU->m_geometry, &m_dataCPU->m_borderGeometry); - m_dataCPU->m_geometry.setPreserveGeometry(false); - m_dataCPU->m_borderGeometry.setPreserveGeometry(false); - m_dataCPU->m_geometry.markClean(); - m_dataCPU->m_borderGeometry.markClean(); - } - - if (m_dataCPU->m_geometry.size() || m_dataCPU->m_borderGeometry.size()) { - root->appendChildNode(m_dataCPU->m_node); - } else { - delete m_dataCPU->m_node; - m_dataCPU->m_node = nullptr; - visibleNode = nullptr; - return nullptr; - } - return m_dataCPU->m_node; -} - -QSGNode *QMapCircleObjectPrivateQSG::updateMapObjectNodeGL(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) -{ - Q_UNUSED(window); - if (!m_dataGL->m_rootNode || !oldNode) { - m_dataGL->m_rootNode = new QDeclarativePolygonMapItemPrivateOpenGL::RootNode(); - m_dataGL->m_node = new MapPolygonNodeGL(); - m_dataGL->m_rootNode->appendChildNode(m_dataGL->m_node); - m_dataGL->m_polylinenode = new MapPolylineNodeOpenGLExtruded(); - m_dataGL->m_rootNode->appendChildNode(m_dataGL->m_polylinenode); - m_dataGL->m_rootNode->markDirty(QSGNode::DirtyNodeAdded); - *visibleNode = static_cast<VisibleNode *>(m_dataGL->m_rootNode); - if (oldNode) - delete oldNode; - } else { - m_dataGL->m_rootNode = static_cast<QDeclarativePolygonMapItemPrivateOpenGL::RootNode *>(oldNode); - } - - const QMatrix4x4 &combinedMatrix = m_map->geoProjection().qsgTransform(); - const QDoubleVector3D &cameraCenter = m_map->geoProjection().centerMercator(); - - if (m_dataGL->m_borderGeometry.isScreenDirty()) { - /* Do the border update first */ - m_dataGL->m_polylinenode->update(borderColor(), - float(borderWidth()), - &m_dataGL->m_borderGeometry, - combinedMatrix, - cameraCenter, - Qt::SquareCap, - true); // No LOD for circles ATM - m_dataGL->m_borderGeometry.setPreserveGeometry(false); - m_dataGL->m_borderGeometry.markClean(); - } - if (m_dataGL->m_geometry.isScreenDirty()) { - m_dataGL->m_node->update(color(), - &m_dataGL->m_geometry, - combinedMatrix, - cameraCenter); - m_dataGL->m_geometry.setPreserveGeometry(false); - m_dataGL->m_geometry.markClean(); - } - - if (!m_dataGL->m_polylinenode->isSubtreeBlocked() || !m_dataGL->m_node->isSubtreeBlocked()) { - m_dataGL->m_rootNode->setSubtreeBlocked(false); - root->appendChildNode(m_dataGL->m_rootNode); - return m_dataGL->m_rootNode; - } else { - delete m_dataGL->m_rootNode; - m_dataGL->m_rootNode = nullptr; - m_dataGL->m_node = nullptr; - m_dataGL->m_polylinenode = nullptr; - *visibleNode = nullptr; - return nullptr; - } -} - -void QMapCircleObjectPrivateQSG::setCenter(const QGeoCoordinate ¢er) -{ - QMapCircleObjectPrivateDefault::setCenter(center); - if (!QDeclarativeCircleMapItemPrivate::crossEarthPole(this->center(), this->radius())) // Switching implementation for circles crossing/not crossing poles - switchToGL(); - else - switchToCPU(); - - if (m_dataGL) - m_dataGL->markSourceDirty(); - - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapCircleObjectPrivateQSG::setRadius(qreal radius) -{ - QMapCircleObjectPrivateDefault::setRadius(radius); - if (!QDeclarativeCircleMapItemPrivate::crossEarthPole(this->center(), this->radius())) // Switching implementation for circles crossing/not crossing poles - switchToGL(); - else - switchToCPU(); - - if (m_dataGL) - m_dataGL->markSourceDirty(); - - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapCircleObjectPrivateQSG::setColor(const QColor &color) -{ - QMapCircleObjectPrivateDefault::setColor(color); - if (m_dataCPU) - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapCircleObjectPrivateQSG::setBorderColor(const QColor &color) -{ - QMapCircleObjectPrivateDefault::setBorderColor(color); - if (m_dataCPU) - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapCircleObjectPrivateQSG::setBorderWidth(qreal width) -{ - QMapCircleObjectPrivateDefault::setBorderWidth(width); - if (m_dataCPU) - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h b/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h deleted file mode 100644 index 5dd375bd..00000000 --- a/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPCIRCLEOBJECTQSG_P_H -#define QMAPCIRCLEOBJECTQSG_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/qgeomapobject_p_p.h> -#include <QtLocation/private/qdeclarativecirclemapitem_p_p.h> -#include <QtLocation/private/qdeclarativepolygonmapitem_p.h> -#include <QtLocation/private/qmapcircleobject_p.h> -#include <QtLocation/private/qmapcircleobject_p_p.h> -#include <QtLocation/private/qqsgmapobject_p.h> -#include <QtCore/qscopedvaluerollback.h> -#include <QGeoCoordinate> -#include <QColor> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapCircleObjectPrivateQSG : public QMapCircleObjectPrivateDefault, public QQSGMapObject -{ -public: - QMapCircleObjectPrivateQSG(QGeoMapObject *q); - QMapCircleObjectPrivateQSG(const QMapCircleObjectPrivate &other); - ~QMapCircleObjectPrivateQSG() override; - - // QQSGMapObject - void updateGeometry() override; - void updateGeometryCPU(); - void updateGeometryGL(); - QSGNode *updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) override; - QSGNode *updateMapObjectNodeCPU(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window); - QSGNode *updateMapObjectNodeGL(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window); - - // QGeoMapCirclePrivate interface - void setCenter(const QGeoCoordinate ¢er) override; - void setRadius(qreal radius) override; - void setColor(const QColor &color) override; - void setBorderColor(const QColor &color) override; - void setBorderWidth(qreal width) override; - - // QGeoMapObjectPrivate - QGeoMapObjectPrivate *clone() override; - - void switchToGL(); - void switchToCPU(); - -public: - // Data Members -struct CircleDataCPU { - MapPolygonNode *m_node = nullptr; - QList<QDoubleVector2D> m_circlePath; - QGeoCoordinate m_leftBound; - QGeoMapCircleGeometry m_geometry; - QGeoMapPolylineGeometry m_borderGeometry; - bool m_updatingGeometry = false; - - void updateCirclePath(const QGeoCoordinate ¢er, qreal radius, const QGeoProjectionWebMercator &p); -}; -struct CircleDataGL { - QList<QGeoCoordinate> m_circlePath; - QGeoCoordinate m_leftBound; - QDoubleVector2D m_leftBoundMercator; - QGeoMapPolygonGeometryOpenGL m_geometry; - QGeoMapPolylineGeometryOpenGL m_borderGeometry; - QDeclarativePolygonMapItemPrivateOpenGL::RootNode *m_rootNode = nullptr; - MapPolygonNodeGL *m_node = nullptr; - MapPolylineNodeOpenGLExtruded *m_polylinenode = nullptr; - - void updateCirclePath(const QGeoCoordinate ¢er, qreal radius, const QGeoProjectionWebMercator &p); - void markSourceDirty() - { - m_geometry.markSourceDirty(); - m_borderGeometry.markSourceDirty(); - } -}; - std::unique_ptr<CircleDataCPU> m_dataCPU; - std::unique_ptr<CircleDataGL> m_dataGL; -}; - -QT_END_NAMESPACE - -#endif // QMAPCIRCLEOBJECT_P_P_H - diff --git a/src/location/labs/qsg/qmapiconobjectqsg.cpp b/src/location/labs/qsg/qmapiconobjectqsg.cpp deleted file mode 100644 index 9996866b..00000000 --- a/src/location/labs/qsg/qmapiconobjectqsg.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmapiconobjectqsg_p_p.h" -#include <QtQuick/qsgimagenode.h> -#include <QtQuick/qsgnode.h> -#include <QtQuick/qquickimageprovider.h> -#include <QtQuick/qquickwindow.h> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqml.h> -#include <QtNetwork/qnetworkaccessmanager.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> - -QT_BEGIN_NAMESPACE - -class RootNode : public QSGTransformNode, public VisibleNode -{ -public: - RootNode() { } - - bool isSubtreeBlocked() const override - { - return subtreeBlocked(); - } -}; - -QMapIconObjectPrivateQSG::QMapIconObjectPrivateQSG(QGeoMapObject *q) - : QMapIconObjectPrivateDefault(q) -{ - -} - -QMapIconObjectPrivateQSG::QMapIconObjectPrivateQSG(const QMapIconObjectPrivate &other) - : QMapIconObjectPrivateDefault(other) -{ - // Data already cloned by the *Default copy constructor, but necessary - // update operations triggered only by setters overrides - setContent(content()); -// setCoordinate(coordinate()); -} - -QMapIconObjectPrivateQSG::~QMapIconObjectPrivateQSG() -{ - if (m_map) - m_map->removeMapObject(q); -} - -void QMapIconObjectPrivateQSG::updateGeometry() -{ - if (!m_map) - return; - - m_geometryDirty = true; - const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection()); - - m_itemPosition = p.coordinateToItemPosition(coordinate()); - if (m_itemPosition.isFinite()) { - m_transformation.setToIdentity(); - m_transformation.translate(QVector3D(m_itemPosition.x(), m_itemPosition.y(), 0)); - } - - // TODO: support and test for zoomLevel -} - -QSGNode *QMapIconObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) -{ - Q_UNUSED(visibleNode); - RootNode *node = static_cast<RootNode *>(oldNode); - if (!node) { - node = new RootNode(); - m_imageNode = window->createImageNode(); - m_imageNode->setOwnsTexture(true); - node->appendChildNode(m_imageNode); - *visibleNode = static_cast<VisibleNode *>(node); - } - - if (m_imageDirty) { - m_imageDirty = false; - m_imageNode->setTexture(window->createTextureFromImage(m_image)); - QRect rect = m_image.rect(); - m_imageNode->setSourceRect(rect); - m_imageNode->setRect(QRectF(QPointF(0,0), iconSize())); - } - - if (m_geometryDirty) { - m_geometryDirty = false; - if (!m_itemPosition.isFinite()) { - node->setSubtreeBlocked(true); - } else { - node->setSubtreeBlocked(false); - node->setMatrix(m_transformation); - } - } - - root->appendChildNode(node); - - return node; -} - -void QMapIconObjectPrivateQSG::setCoordinate(const QGeoCoordinate &coordinate) -{ - QMapIconObjectPrivateDefault::setCoordinate(coordinate); - updateGeometry(); -} - -template<typename T> -static T *getContent(const QVariant &content) -{ - QObject *obj = qvariant_cast<QObject *>(content); - return qobject_cast<T *>(obj); -} - -static inline QString imageId(const QUrl &url) -{ - return url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); -} - -void QMapIconObjectPrivateQSG::clearContent() -{ - m_image = QImage(); -} - -void QMapIconObjectPrivateQSG::setContent(const QVariant &content) -{ - // First reset all local containers - clearContent(); - QQmlEngine *engine = qmlEngine(q); - - // Then pull the new content - QMapIconObjectPrivateDefault::setContent(content); - switch (content.typeId()) { - case QMetaType::User: { - // TODO: Handle QObject subclasses -- first decide which ones - break; - } - case QMetaType::QString: - case QMetaType::QUrl: { - // URL, including image/texture providers - // Supporting only image providers for now - const QUrl url = content.toUrl(); - if (!url.isValid()) { - m_image = QImage(content.toString()); - m_imageDirty = true; - updateGeometry(); - } else if (url.scheme().isEmpty() || url.scheme() == QLatin1String("file")) { - m_image = QImage(url.toString(QUrl::RemoveScheme)); - m_imageDirty = true; - updateGeometry(); - } else if (url.scheme() == QLatin1String("image")) { - QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(url.host())); - QSize outSize; - m_image = provider->requestImage(imageId(url), &outSize, QSize()); - if (outSize.isEmpty()) - break; - m_imageDirty = true; - updateGeometry(); - } else { // ToDo: Use QNAM - - } - - break; - } - case QMetaType::QByteArray: { - // ToDo: Build the image from bytearray - break; - } - default: - qWarning() << "Unsupported parameter type: " << content.typeId(); - break; - } - - if (m_map && m_imageDirty) - emit m_map->sgNodeChanged(); -} - -void QMapIconObjectPrivateQSG::setIconSize(const QSizeF &size) -{ - QMapIconObjectPrivateDefault::setIconSize(size); - updateGeometry(); -} - -QGeoMapObjectPrivate *QMapIconObjectPrivateQSG::clone() -{ - return new QMapIconObjectPrivateQSG(static_cast<QMapIconObjectPrivate &>(*this)); -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qsg/qmapiconobjectqsg_p_p.h b/src/location/labs/qsg/qmapiconobjectqsg_p_p.h deleted file mode 100644 index bcd807d4..00000000 --- a/src/location/labs/qsg/qmapiconobjectqsg_p_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPICONOBJECTQSG_P_P_H -#define QMAPICONOBJECTQSG_P_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/qmapiconobject_p.h> -#include <QtLocation/private/qmapiconobject_p_p.h> -#include <QtLocation/private/qqsgmapobject_p.h> -#include <QtCore/qscopedvaluerollback.h> -#include <QtGui/qimage.h> - -QT_BEGIN_NAMESPACE - -class QSGImageNode; -class Q_LOCATION_PRIVATE_EXPORT QMapIconObjectPrivateQSG : public QMapIconObjectPrivateDefault, public QQSGMapObject -{ -public: - QMapIconObjectPrivateQSG(QGeoMapObject *q); - QMapIconObjectPrivateQSG(const QMapIconObjectPrivate &other); - ~QMapIconObjectPrivateQSG() override; - - void clearContent(); - - // QQSGMapObject - void updateGeometry() override; - QSGNode *updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) override; - - // QGeoMapIconPrivate interface - void setCoordinate(const QGeoCoordinate &coordinate) override; - void setContent(const QVariant &content) override; - void setIconSize(const QSizeF &size) override; - - // QGeoMapObjectPrivate - QGeoMapObjectPrivate *clone() override; - -public: - // Data Members - bool m_imageDirty = false; - bool m_geometryDirty = false; - QImage m_image; - QSGImageNode *m_imageNode = nullptr; - QDoubleVector2D m_itemPosition; - QMatrix4x4 m_transformation; -}; - -QT_END_NAMESPACE - -#endif // QMAPICONOBJECTQSG_P_P_H diff --git a/src/location/labs/qsg/qmappolygonobjectqsg.cpp b/src/location/labs/qsg/qmappolygonobjectqsg.cpp deleted file mode 100644 index ea40658d..00000000 --- a/src/location/labs/qsg/qmappolygonobjectqsg.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmappolygonobjectqsg_p_p.h" -#include <QtQuick/qsgnode.h> -#include <QtQuick/qsgsimplerectnode.h> -#include <QtPositioning/private/qgeopolygon_p.h> - -QT_BEGIN_NAMESPACE - -QMapPolygonObjectPrivateQSG::QMapPolygonObjectPrivateQSG(QGeoMapObject *q) - : QMapPolygonObjectPrivateDefault(q) -{ - -} - -QMapPolygonObjectPrivateQSG::QMapPolygonObjectPrivateQSG(const QMapPolygonObjectPrivate &other) - : QMapPolygonObjectPrivateDefault(other) -{ - // Data already cloned by the *Default copy constructor, but necessary - // update operations triggered only by setters overrides - markSourceDirty(); - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -QMapPolygonObjectPrivateQSG::~QMapPolygonObjectPrivateQSG() -{ - if (m_map) - m_map->removeMapObject(q); -} - -void QMapPolygonObjectPrivateQSG::setPath(const QList<QGeoCoordinate> &p) -{ - if (p == path()) - return; - QMapPolygonObjectPrivateDefault::setPath(p); - markSourceDirty(); - updateGeometry(); - - if (m_map) - emit m_map->sgNodeChanged(); - emit static_cast<QMapPolygonObject *>(q)->pathChanged(); -} - -void QMapPolygonObjectPrivateQSG::setFillColor(const QColor &color) -{ - QMapPolygonObjectPrivateDefault::setFillColor(color); - - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapPolygonObjectPrivateQSG::setBorderColor(const QColor &color) -{ - QMapPolygonObjectPrivateDefault::setBorderColor(color); - - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapPolygonObjectPrivateQSG::setBorderWidth(qreal width) -{ - QMapPolygonObjectPrivateDefault::setBorderWidth(width); - - if (m_map) - emit m_map->sgNodeChanged(); -} - -QGeoMapObjectPrivate *QMapPolygonObjectPrivateQSG::clone() -{ - return new QMapPolygonObjectPrivateQSG(static_cast<QMapPolygonObjectPrivate &>(*this)); -} - -void QMapPolygonObjectPrivateQSG::setGeoShape(const QGeoShape &shape) -{ - if (shape == m_path) - return; - - m_path = QGeoPathEager(shape); - markSourceDirty(); - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); - emit static_cast<QMapPolygonObject *>(q)->pathChanged(); -} - -// This is called both when data changes and when viewport changes. -// so handle both cases (sourceDirty, !sourceDirty) -void QMapPolygonObjectPrivateQSG::updateGeometry() -{ - if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator) - return; - - if (m_path.perimeter().length() == 0) { // Possibly cleared - m_geometry.clear(); - m_borderGeometry.clear(); - return; - } - const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection()); - if (m_geometry.isSourceDirty() || m_borderGeometry.isSourceDirty()) { - // This works a bit differently than MapPolygon: - // the "screen bounds" aren't needed, so update only sources, - // regardless of the color, as color changes won't trigger polish(), - // and remember to flag m_dataChanged, that is in principle the same as - // sourceDirty_, but in practice is cleared in two different codepaths. - // sourceDirty_ is cleared in any case, dataChanged only if the primitive - // is effectively visible (e.g., not transparent or border not null) - m_geometry.setPreserveGeometry(true, m_path.boundingGeoRectangle().topLeft()); - m_borderGeometry.setPreserveGeometry(true, m_path.boundingGeoRectangle().topLeft()); - m_geometry.m_dataChanged = m_borderGeometry.m_dataChanged = true; - m_geometry.updateSourcePoints(*m_map, m_path); - m_borderGeometry.updateSourcePoints(*m_map, m_path); - m_leftBoundMercator = p.geoToMapProjection(m_geometry.origin()); - } - m_geometry.markScreenDirty(); // ToDo: this needs refactor. It's useless, remove screenDirty_ altogether. - m_borderGeometry.markScreenDirty(); - m_borderGeometry.m_wrapOffset = m_geometry.m_wrapOffset = p.projectionWrapFactor(m_leftBoundMercator) + 1; -} - -QSGNode *QMapPolygonObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow * /*window*/) -{ - if (!m_rootNode || !oldNode) { - m_rootNode = new QDeclarativePolygonMapItemPrivateOpenGL::RootNode(); - m_node = new MapPolygonNodeGL(); - m_rootNode->appendChildNode(m_node); - m_polylinenode = new MapPolylineNodeOpenGLExtruded(); - m_rootNode->appendChildNode(m_polylinenode); - m_rootNode->markDirty(QSGNode::DirtyNodeAdded); - *visibleNode = static_cast<VisibleNode *>(m_rootNode); - if (oldNode) - delete oldNode; - } else { - m_rootNode = static_cast<QDeclarativePolygonMapItemPrivateOpenGL::RootNode *>(oldNode); - } - - const QMatrix4x4 &combinedMatrix = m_map->geoProjection().qsgTransform(); - const QDoubleVector3D &cameraCenter = m_map->geoProjection().centerMercator(); - - if (m_borderGeometry.isScreenDirty()) { - /* Do the border update first */ - m_polylinenode->update(borderColor(), - float(borderWidth()), - &m_borderGeometry, - combinedMatrix, - cameraCenter, - Qt::SquareCap, - true); - m_borderGeometry.setPreserveGeometry(false); - m_borderGeometry.markClean(); - } - if (m_geometry.isScreenDirty()) { - m_node->update(fillColor(), - &m_geometry, - combinedMatrix, - cameraCenter); - m_geometry.setPreserveGeometry(false); - m_geometry.markClean(); - } - - if (!m_polylinenode->isSubtreeBlocked() || !m_node->isSubtreeBlocked()) { - m_rootNode->setSubtreeBlocked(false); - root->appendChildNode(m_rootNode); - return m_rootNode; - } else { - m_rootNode->setSubtreeBlocked(true); - // If the object is currently invisible, but not gone, - // it is reasonable to assume it will become visible again. - // However, better not to retain unused data. - delete m_rootNode; - m_rootNode = nullptr; - m_node = nullptr; - m_polylinenode = nullptr; - *visibleNode = nullptr; - return nullptr; - } -} - -void QMapPolygonObjectPrivateQSG::markSourceDirty() -{ - m_geometry.markSourceDirty(); - m_borderGeometry.markSourceDirty(); -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h b/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h deleted file mode 100644 index 8965bc7a..00000000 --- a/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPPOLYGONOBJECTQSG_P_P_H -#define QMAPPOLYGONOBJECTQSG_P_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/qmappolygonobject_p.h> -#include <QtLocation/private/qmappolygonobject_p_p.h> -#include <QtLocation/private/qqsgmapobject_p.h> -#include <QtLocation/private/qdeclarativepolygonmapitem_p_p.h> -#include <QtCore/qscopedvaluerollback.h> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapPolygonObjectPrivateQSG : public QMapPolygonObjectPrivateDefault, public QQSGMapObject -{ -public: - QMapPolygonObjectPrivateQSG(QGeoMapObject *q); - QMapPolygonObjectPrivateQSG(const QMapPolygonObjectPrivate &other); - ~QMapPolygonObjectPrivateQSG() override; - - QList<QDoubleVector2D> projectPath(); - - // QQSGMapObject - void markSourceDirty(); - void updateGeometry() override; - QSGNode *updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) override; - - // QGeoMapPolygonPrivate interface - void setPath(const QList<QGeoCoordinate> &path) override; - void setFillColor(const QColor &color) override; - void setBorderColor(const QColor &color) override; - void setBorderWidth(qreal width) override; - - // QGeoMapObjectPrivate - QGeoMapObjectPrivate *clone() override; - void setGeoShape(const QGeoShape &shape) override; - - // Data Members - QDoubleVector2D m_leftBoundMercator; - QGeoMapPolygonGeometryOpenGL m_geometry; - QGeoMapPolylineGeometryOpenGL m_borderGeometry; - QDeclarativePolygonMapItemPrivateOpenGL::RootNode *m_rootNode = nullptr; - MapPolygonNodeGL *m_node = nullptr; - MapPolylineNodeOpenGLExtruded *m_polylinenode = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QMAPPOLYGONOBJECTQSG_P_P_H diff --git a/src/location/labs/qsg/qmappolylineobjectqsg.cpp b/src/location/labs/qsg/qmappolylineobjectqsg.cpp deleted file mode 100644 index bce2db3a..00000000 --- a/src/location/labs/qsg/qmappolylineobjectqsg.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmappolylineobjectqsg_p_p.h" -#include <QtQuick/qsgnode.h> -#include <QtQuick/qsgsimplerectnode.h> - -QT_BEGIN_NAMESPACE - -/* - Note: never use q, since this class is also used inside QMapRouteObjectPrivateQSG! -*/ - -QMapPolylineObjectPrivateQSG::QMapPolylineObjectPrivateQSG(QGeoMapObject *q) - : QMapPolylineObjectPrivateDefault(q) -{ - -} - -QMapPolylineObjectPrivateQSG::QMapPolylineObjectPrivateQSG(const QMapPolylineObjectPrivate &other) - : QMapPolylineObjectPrivateDefault(other) -{ - // rest of the data already cloned by the *Default copy constructor, but necessary - // update operations triggered only by setters overrides - markSourceDirty(); - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -QMapPolylineObjectPrivateQSG::~QMapPolylineObjectPrivateQSG() -{ - if (m_map) - m_map->removeMapObject(q); -} - -QList<QDoubleVector2D> QMapPolylineObjectPrivateQSG::projectPath() const -{ - QList<QDoubleVector2D> geopathProjected_; - if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator) - return geopathProjected_; - - const QGeoProjectionWebMercator &p = - static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection()); - geopathProjected_.reserve(m_path.path().size()); - for (const QGeoCoordinate &c : m_path.path()) - geopathProjected_ << p.geoToMapProjection(c); - return geopathProjected_; -} - -void QMapPolylineObjectPrivateQSG::updateGeometry() -{ - if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator) - return; - - if (m_path.path().length() == 0) { // Possibly cleared - m_borderGeometry.clear(); - return; - } - - const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection()); - if (m_borderGeometry.isSourceDirty()) { - m_borderGeometry.setPreserveGeometry(true, m_path.boundingGeoRectangle().topLeft()); - m_borderGeometry.m_dataChanged = true; - m_borderGeometry.updateSourcePoints(*m_map, m_path); - m_leftBoundMercator = p.geoToMapProjection(m_borderGeometry.origin()); - } - m_borderGeometry.markScreenDirty(); - m_borderGeometry.m_wrapOffset = p.projectionWrapFactor(m_leftBoundMercator) + 1; -} - -/*! - \internal -*/ -unsigned int QMapPolylineObjectPrivateQSG::zoomForLOD(int zoom) const -{ - // LOD Threshold currently fixed to 12 for MapPolylineObject(QSG). - // ToDo: Consider allowing to change this via DynamicParameter. - if (zoom >= 12) - return 30; - return uint(zoom); -} - -QSGNode *QMapPolylineObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow * /*window*/) -{ - if (!m_polylinenode || !oldNode) { - m_polylinenode = new MapPolylineNodeOpenGLExtruded(); - *visibleNode = static_cast<VisibleNode *>(m_polylinenode); - if (oldNode) - delete oldNode; - } else { - m_polylinenode = static_cast<MapPolylineNodeOpenGLExtruded *>(oldNode); - } - - const QMatrix4x4 &combinedMatrix = m_map->geoProjection().qsgTransform(); - const QDoubleVector3D &cameraCenter = m_map->geoProjection().centerMercator(); - - if (m_borderGeometry.isScreenDirty()) { - /* Do the border update first */ - m_polylinenode->update(color(), - float(width()), - &m_borderGeometry, - combinedMatrix, - cameraCenter, - Qt::SquareCap, - true, - zoomForLOD(int(m_map->cameraData().zoomLevel()))); - m_borderGeometry.setPreserveGeometry(false); - m_borderGeometry.markClean(); - } - - if (!m_polylinenode->isSubtreeBlocked() ) { - m_polylinenode->setSubtreeBlocked(false); - root->appendChildNode(m_polylinenode); - return m_polylinenode; - } else { - delete m_polylinenode; - m_polylinenode = nullptr; - *visibleNode = nullptr; - return nullptr; - } -} - -QList<QGeoCoordinate> QMapPolylineObjectPrivateQSG::path() const -{ - return m_path.path(); -} - -void QMapPolylineObjectPrivateQSG::setPath(const QList<QGeoCoordinate> &path) -{ - m_path.setPath(path); - markSourceDirty(); - updateGeometry(); - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapPolylineObjectPrivateQSG::setColor(const QColor &color) -{ - QMapPolylineObjectPrivateDefault::setColor(color); - - if (m_map) - emit m_map->sgNodeChanged(); -} - -void QMapPolylineObjectPrivateQSG::setWidth(qreal width) -{ - QMapPolylineObjectPrivateDefault::setWidth(width); - - if (m_map) - emit m_map->sgNodeChanged(); -} - -QGeoMapObjectPrivate *QMapPolylineObjectPrivateQSG::clone() -{ - return new QMapPolylineObjectPrivateQSG(static_cast<QMapPolylineObjectPrivate &>(*this)); -} - -QGeoShape QMapPolylineObjectPrivateQSG::geoShape() const -{ - return m_path; -} - -void QMapPolylineObjectPrivateQSG::markSourceDirty() -{ - m_borderGeometry.markSourceDirty(); -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h b/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h deleted file mode 100644 index b5fdddb3..00000000 --- a/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPPOLYLINEOBJECTOBJECTSOVERLAY_H -#define QMAPPOLYLINEOBJECTOBJECTSOVERLAY_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 <QtCore/qscopedvaluerollback.h> - -#include <QtLocation/private/qlocationglobal_p.h> -#include <QtLocation/private/qmappolylineobject_p_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> -#include <QtLocation/private/qmappolylineobject_p.h> -#include <QtLocation/private/qqsgmapobject_p.h> -#include <QtPositioning/private/qgeopath_p.h> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapPolylineObjectPrivateQSG : public QMapPolylineObjectPrivateDefault, public QQSGMapObject -{ -public: - QMapPolylineObjectPrivateQSG(QGeoMapObject *q); - QMapPolylineObjectPrivateQSG(const QMapPolylineObjectPrivate &other); - ~QMapPolylineObjectPrivateQSG() override; - - QList<QDoubleVector2D> projectPath() const; - - // QQSGMapObject - void markSourceDirty(); - void updateGeometry() override; - QSGNode *updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) override; - - // QGeoMapPolylinePrivate interface - QList<QGeoCoordinate> path() const override; - void setPath(const QList<QGeoCoordinate> &path) override; - void setColor(const QColor &color) override; - void setWidth(qreal width) override; - - // QGeoMapObjectPrivate - QGeoMapObjectPrivate *clone() override; - QGeoShape geoShape() const override; - - unsigned int zoomForLOD(int zoom) const; - - // Data Members - QDoubleVector2D m_leftBoundMercator; - QGeoMapPolylineGeometryOpenGL m_borderGeometry; - MapPolylineNodeOpenGLExtruded *m_polylinenode = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QMAPPOLYLINEOBJECTOBJECTSOVERLAY_H diff --git a/src/location/labs/qsg/qmaprouteobjectqsg.cpp b/src/location/labs/qsg/qmaprouteobjectqsg.cpp deleted file mode 100644 index 23d2f1f9..00000000 --- a/src/location/labs/qsg/qmaprouteobjectqsg.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmaprouteobjectqsg_p_p.h" - -QT_BEGIN_NAMESPACE - -QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(QGeoMapObject *q) - : QMapRouteObjectPrivate(q) -{ - std::unique_ptr<QMapPolylineObjectPrivateQSG> poly(new QMapPolylineObjectPrivateQSG(q)); - m_polyline.swap(poly); - m_polyline->m_componentCompleted = true; -} - -QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivate &other) - : QMapRouteObjectPrivate(other) -{ - std::unique_ptr<QMapPolylineObjectPrivateQSG> poly(new QMapPolylineObjectPrivateQSG(other.q)); - m_polyline.swap(poly); - m_polyline->m_componentCompleted = true; - setRoute(other.declarativeGeoRoute()); -} - -QMapRouteObjectPrivateQSG::~QMapRouteObjectPrivateQSG() -{ - if (m_map) - m_map->removeMapObject(q); -} - -void QMapRouteObjectPrivateQSG::updateGeometry() -{ - m_polyline->updateGeometry(); -} - -QSGNode *QMapRouteObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) -{ - return m_polyline->updateMapObjectNode(oldNode, visibleNode, root, window); -} - -void QMapRouteObjectPrivateQSG::setRoute(const QDeclarativeGeoRoute *route) -{ - const QList<QGeoCoordinate> &path = route->route().path(); - m_polyline->setColor(QColor("deepskyblue")); // ToDo: support MapParameters for this - m_polyline->setWidth(4); - m_polyline->setPath(path); // SGNodeChanged emitted by m_polyline -} - -QGeoMapObjectPrivate *QMapRouteObjectPrivateQSG::clone() -{ - return new QMapRouteObjectPrivateQSG(static_cast<QMapRouteObjectPrivate &>(*this)); -} - -void QMapRouteObjectPrivateQSG::setMap(QGeoMap *map) -{ - QGeoMapObjectPrivate::setMap(map); - m_polyline->setMap(map); -} - - -void QMapRouteObjectPrivateQSG::setVisible(bool visible) -{ - m_visible = visible; - m_polyline->setVisible(visible); -} - -QGeoShape QMapRouteObjectPrivateQSG::geoShape() const -{ - return m_polyline->geoShape(); -} - -QT_END_NAMESPACE diff --git a/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h b/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h deleted file mode 100644 index 497f9206..00000000 --- a/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMAPROUTEOBJECTQSG_P_P_H -#define QMAPROUTEOBJECTQSG_P_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/qmappolylineobjectqsg_p_p.h> -#include <QtLocation/private/qmaprouteobject_p_p.h> -#include <QtLocation/private/qdeclarativegeoroute_p.h> -#include <QtLocation/private/qmaprouteobject_p.h> -#include <QtLocation/private/qqsgmapobject_p.h> -#include <QtCore/qscopedvaluerollback.h> -#include <QtCore/qscopedpointer.h> - -QT_BEGIN_NAMESPACE - -class Q_LOCATION_PRIVATE_EXPORT QMapRouteObjectPrivateQSG : public QMapRouteObjectPrivate, public QQSGMapObject -{ -public: - QMapRouteObjectPrivateQSG(QGeoMapObject *q); - QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivate &other); - ~QMapRouteObjectPrivateQSG() override; - - // QQSGMapObject - void updateGeometry() override; - QSGNode *updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window) override; - - // QMapRouteObjectPrivate interface - void setRoute(const QDeclarativeGeoRoute *route) override; - - // QGeoMapObjectPrivate interface - QGeoMapObjectPrivate *clone() override; - void setMap(QGeoMap *map) override; - void setVisible(bool visible) override; - QGeoShape geoShape() const override; - - // Data Members - std::unique_ptr<QMapPolylineObjectPrivateQSG> m_polyline; -}; - -QT_END_NAMESPACE - -#endif // QMAPROUTEOBJECTQSG_P_P_H diff --git a/src/location/labs/qsg/qqsgmapobject.cpp b/src/location/labs/qsg/qqsgmapobject.cpp deleted file mode 100644 index 2ba5c8e8..00000000 --- a/src/location/labs/qsg/qqsgmapobject.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqsgmapobject_p.h" -#include <QDebug> - -QT_BEGIN_NAMESPACE - -QQSGMapObject::QQSGMapObject() -{ - -} - -QQSGMapObject::~QQSGMapObject() -{ - -} - -QSGNode *QQSGMapObject::updateMapObjectNode(QSGNode *oldNode, - VisibleNode ** /*visibleNode*/, - QSGNode * /*root*/, - QQuickWindow * /*window*/) -{ - delete oldNode; - return nullptr; -} - -void QQSGMapObject::updateGeometry() -{ - -} - -QT_END_NAMESPACE - - diff --git a/src/location/labs/qsg/qqsgmapobject_p.h b/src/location/labs/qsg/qqsgmapobject_p.h deleted file mode 100644 index 2dc80c69..00000000 --- a/src/location/labs/qsg/qqsgmapobject_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQSGMAPOBJECT_H -#define QQSGMAPOBJECT_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 <QtQuick/QSGOpacityNode> -#include <QtLocation/private/qgeomapobject_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickWindow; -class Q_LOCATION_PRIVATE_EXPORT QQSGMapObject -{ -public: - QQSGMapObject(); - virtual ~QQSGMapObject(); - - virtual QSGNode *updateMapObjectNode(QSGNode *oldNode, - VisibleNode **visibleNode, - QSGNode *root, - QQuickWindow *window); - virtual void updateGeometry(); -}; - -QT_END_NAMESPACE - -#endif // QQSGMAPOBJECT_H diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp index 0318d5f1..54ba9bbb 100644 --- a/src/location/maps/qgeomap.cpp +++ b/src/location/maps/qgeomap.cpp @@ -42,8 +42,6 @@ #include "qgeocameracapabilities_p.h" #include "qgeomappingmanagerengine_p.h" #include "qdeclarativegeomapitembase_p.h" -#include "qgeomapobject_p.h" -#include "qgeomapobject_p_p.h" #include <QDebug> #include <QRectF> @@ -56,10 +54,7 @@ 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) @@ -288,31 +283,6 @@ void QGeoMap::clearMapItems() d->m_mapItems.clear(); } -/*! - Fills obj with a backend-specific pimpl. -*/ -bool QGeoMap::createMapObjectImplementation(QGeoMapObject *obj) -{ - Q_D(QGeoMap); - QExplicitlySharedDataPointer<QGeoMapObjectPrivate> pimpl = - QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(d->createMapObjectImplementation(obj)); - if (pimpl.constData()) - return obj->setImplementation(pimpl); - return false; -} - -/*! - To be called in ~QGeoMapObjectPrivate overrides, if needed -*/ -void QGeoMap::removeMapObject(QGeoMapObject * /*obj*/) -{ -} - -QList<QObject *> QGeoMap::mapObjectsAt(const QGeoCoordinate &/*coordinate*/) const -{ - return QList<QObject *>(); -} - void QGeoMap::setItemToWindowTransform(const QTransform &itemToWindowTransform) { Q_D(QGeoMap); @@ -334,12 +304,6 @@ QRectF QGeoMap::visibleArea() const return d->visibleArea(); } -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) }"); @@ -424,17 +388,6 @@ void QGeoMapPrivate::removeMapItem(QDeclarativeGeoMapItemBase *item) Q_UNUSED(item); } -QGeoMapObjectPrivate *QGeoMapPrivate::createMapObjectImplementation(QGeoMapObject *obj) -{ - Q_UNUSED(obj); - return nullptr; -} - -QList<QGeoMapObject *> QGeoMapPrivate::mapObjects() const -{ - return QList<QGeoMapObject *>(); -} - double QGeoMapPrivate::mapWidth() const { if (m_geoProjection->projectionType() == QGeoProjection::ProjectionWebMercator) diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h index db9ca2d2..e51c4900 100644 --- a/src/location/maps/qgeomap_p.h +++ b/src/location/maps/qgeomap_p.h @@ -70,7 +70,6 @@ class QSGNode; class QQuickWindow; class QGeoMapParameter; class QDeclarativeGeoMapItemBase; -class QGeoMapObject; class QDeclarativeGeoMap; class Q_LOCATION_PRIVATE_EXPORT QGeoMap : public QObject @@ -144,10 +143,6 @@ public: void removeMapItem(QDeclarativeGeoMapItemBase *item); void clearMapItems(); - virtual 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); @@ -158,8 +153,6 @@ public: virtual bool fitViewportToGeoRectangle(const QGeoRectangle &rectangle, const QMargins &borders); virtual void setCopyrightVisible(bool visible); - virtual void removeMapObject(QGeoMapObject *obj); - virtual QList<QObject *> mapObjectsAt(const QGeoCoordinate &coordinate) const; virtual void setItemToWindowTransform(const QTransform &itemToWindowTransform); void setVisibleArea(const QRectF &visibleArea); diff --git a/src/location/maps/qgeomap_p_p.h b/src/location/maps/qgeomap_p_p.h index eaa62989..0a986343 100644 --- a/src/location/maps/qgeomap_p_p.h +++ b/src/location/maps/qgeomap_p_p.h @@ -69,7 +69,6 @@ class QGeoMap; class QGeoMapController; class QGeoMapParameter; class QDeclarativeGeoMapItemBase; -class QGeoMapObjectPrivate; class Q_LOCATION_PRIVATE_EXPORT QGeoMapPrivate : public QObjectPrivate { @@ -83,7 +82,6 @@ public: const QGeoCameraCapabilities &cameraCapabilities() const; static const QGeoMapPrivate *get(const QGeoMap &map); - virtual QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj); protected: /* Hooks into the actual map implementations */ @@ -94,8 +92,6 @@ protected: virtual void addMapItem(QDeclarativeGeoMapItemBase *item); virtual void removeMapItem(QDeclarativeGeoMapItemBase *item); - 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() diff --git a/src/location/quickmapitems/qdeclarativegeomap.cpp b/src/location/quickmapitems/qdeclarativegeomap.cpp index 38c554f4..3f47463c 100644 --- a/src/location/quickmapitems/qdeclarativegeomap.cpp +++ b/src/location/quickmapitems/qdeclarativegeomap.cpp @@ -46,7 +46,6 @@ #include "qgeocameracapabilities_p.h" #include "qgeomap_p.h" #include "qdeclarativegeomapparameter_p.h" -#include "qgeomapobject_p.h" #include "qgeoprojection_p.h" #include <QtPositioning/QGeoCircle> #include <QtPositioning/QGeoRectangle> @@ -265,9 +264,6 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap() delete m_copyrights.data(); m_copyrights.clear(); - for (auto obj: qAsConst(m_pendingMapObjects)) - obj->setMap(nullptr); // worst case: going to be setMap(nullptr)'d twice - delete m_map; // map objects get reset here } @@ -367,9 +363,6 @@ void QDeclarativeGeoMap::initialize() // So, emit visibleRegionChanged() separately, as // the effective visible region becomes available only now. - for (const auto &obj : qAsConst(m_pendingMapObjects)) - obj->setMap(m_map); - m_initialized = true; if (visibleAreaHasChanged) @@ -913,9 +906,6 @@ bool QDeclarativeGeoMap::addMapChild(QObject *child) if (mapItem) return addMapItem_real(mapItem); - QGeoMapObject *mapObject = qobject_cast<QGeoMapObject *>(child); - if (mapObject) - addMapObject(mapObject); // this emits mapObjectsChanged, != mapItemsChanged return false; } @@ -934,9 +924,6 @@ bool QDeclarativeGeoMap::removeMapChild(QObject *child) if (mapItem) return removeMapItem_real(mapItem); - QGeoMapObject *mapObject = qobject_cast<QGeoMapObject *>(child); - if (mapObject) - removeMapObject(mapObject); // this emits mapObjectsChanged, != mapItemsChanged return false; } @@ -1888,75 +1875,6 @@ 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/quickmapitems/qdeclarativegeomap_p.h b/src/location/quickmapitems/qdeclarativegeomap_p.h index cd3b6254..bb376d9f 100644 --- a/src/location/quickmapitems/qdeclarativegeomap_p.h +++ b/src/location/quickmapitems/qdeclarativegeomap_p.h @@ -188,12 +188,6 @@ public: Q_INVOKABLE void clearMapParameters(); QList<QObject *> mapParameters(); - void addMapObject(QGeoMapObject *object); // Not invokable as currently meant to be used through a main MapObjectView - 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; @@ -237,7 +231,6 @@ Q_SIGNALS: void copyrightsImageChanged(const QImage ©rightsImage); void copyrightsChanged(const QString ©rightsHtml); void mapReadyChanged(bool ready); - Q_REVISION(11) void mapObjectsChanged(); void visibleAreaChanged(); Q_REVISION(14) void visibleRegionChanged(); @@ -318,7 +311,6 @@ private: bool m_initialized = false; bool m_sgNodeHasChanged = false; QList<QDeclarativeGeoMapParameter *> m_mapParameters; - QList<QGeoMapObject*> m_pendingMapObjects; // Used only in the initialization phase QGeoCameraCapabilities m_cameraCapabilities; qreal m_userMinimumZoomLevel = Q_QNAN; qreal m_userMaximumZoomLevel = Q_QNAN; diff --git a/src/plugins/geoservices/esri/CMakeLists.txt b/src/plugins/geoservices/esri/CMakeLists.txt index 97e8574a..b2efbd5e 100644 --- a/src/plugins/geoservices/esri/CMakeLists.txt +++ b/src/plugins/geoservices/esri/CMakeLists.txt @@ -32,9 +32,3 @@ qt_internal_extend_target(GeoServiceProviderFactoryEsriPlugin SOURCES ${plugin_resource_files} ) - -qt_internal_extend_target(GeoServiceProviderFactoryEsriPlugin - CONDITION QT_FEATURE_location_labs_plugin - DEFINES - LOCATIONLABS -) diff --git a/src/plugins/geoservices/esri/geotiledmap_esri.h b/src/plugins/geoservices/esri/geotiledmap_esri.h index 0f62d961..47a0ca34 100644 --- a/src/plugins/geoservices/esri/geotiledmap_esri.h +++ b/src/plugins/geoservices/esri/geotiledmap_esri.h @@ -41,12 +41,7 @@ #define GEOTILEDMAPESRI_H #include <QtLocation/private/qgeotiledmap_p.h> -#ifdef LOCATIONLABS -#include <QtLocation/private/qgeotiledmaplabs_p.h> -typedef QGeoTiledMapLabs Map; -#else typedef QGeoTiledMap Map; -#endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/geoservices/itemsoverlay/CMakeLists.txt b/src/plugins/geoservices/itemsoverlay/CMakeLists.txt index f06f3119..978b449b 100644 --- a/src/plugins/geoservices/itemsoverlay/CMakeLists.txt +++ b/src/plugins/geoservices/itemsoverlay/CMakeLists.txt @@ -13,9 +13,3 @@ qt_internal_add_plugin(QGeoServiceProviderFactoryItemsOverlayPlugin DEFINES QT_NO_FOREACH ) - -qt_internal_extend_target(QGeoServiceProviderFactoryItemsOverlayPlugin - CONDITION QT_FEATURE_location_labs_plugin - DEFINES - LOCATIONLABS -) diff --git a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp index 7eb45faa..4455ad9b 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp +++ b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp @@ -44,16 +44,6 @@ #include <QtQuick/qsgrectanglenode.h> #include <QtQuick/qquickwindow.h> -#ifdef LOCATIONLABS -#include <QtLocation/private/qmappolylineobjectqsg_p_p.h> -#include <QtLocation/private/qmappolygonobjectqsg_p_p.h> -#include <QtLocation/private/qmapcircleobjectqsg_p_p.h> -#include <QtLocation/private/qmaprouteobjectqsg_p_p.h> -#include <QtLocation/private/qmapiconobjectqsg_p_p.h> -#include <QtLocation/private/qdeclarativepolylinemapitem_p.h> -#include <QtLocation/private/qgeomapobjectqsgsupport_p.h> -#endif - QT_BEGIN_NAMESPACE class QGeoMapItemsOverlayPrivate : public QGeoMapPrivate @@ -63,16 +53,6 @@ public: QGeoMapItemsOverlayPrivate(QGeoMappingManagerEngineItemsOverlay *engine, QGeoMapItemsOverlay *map); virtual ~QGeoMapItemsOverlayPrivate(); -#ifdef LOCATIONLABS - QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj) override; - QList<QGeoMapObject *> mapObjects() const override; - void removeMapObject(QGeoMapObject *obj); - void updateMapObjects(QSGNode *root, QQuickWindow *window); - QList<QObject *>mapObjectsAt(const QGeoCoordinate &coordinate) const; - - QGeoMapObjectQSGSupport m_qsgSupport; -#endif - void updateObjectsGeometry(); void setVisibleArea(const QRectF &visibleArea) override; @@ -103,57 +83,6 @@ QGeoMap::Capabilities QGeoMapItemsOverlay::capabilities() const | SupportsAnchoringCoordinate); } -bool QGeoMapItemsOverlay::createMapObjectImplementation(QGeoMapObject *obj) -{ -#ifndef LOCATIONLABS - Q_UNUSED(obj); - return false; -#else - Q_D(QGeoMapItemsOverlay); - return d->m_qsgSupport.createMapObjectImplementation(obj, d); -#endif -} - -QSGNode *QGeoMapItemsOverlay::updateSceneGraph(QSGNode *node, QQuickWindow *window) -{ -#ifndef LOCATIONLABS - Q_UNUSED(window); - return node; -#else - Q_D(QGeoMapItemsOverlay); - - QSGRectangleNode *mapRoot = static_cast<QSGRectangleNode *>(node); - if (!mapRoot) - mapRoot = window->createRectangleNode(); - - mapRoot->setRect(QRect(0, 0, viewportWidth(), viewportHeight())); - mapRoot->setColor(QColor(0,0,0,0)); - - d->updateMapObjects(mapRoot, window); - return mapRoot; -#endif -} - -void QGeoMapItemsOverlay::removeMapObject(QGeoMapObject *obj) -{ -#ifndef LOCATIONLABS - Q_UNUSED(obj); -#else - Q_D(QGeoMapItemsOverlay); - d->removeMapObject(obj); -#endif -} - -QList<QObject *> QGeoMapItemsOverlay::mapObjectsAt(const QGeoCoordinate &coordinate) const -{ -#ifdef LOCATIONLABS - Q_D(const QGeoMapItemsOverlay); - return d->mapObjectsAt(coordinate); -#else - return QGeoMap::mapObjectsAt(coordinate); -#endif -} - void QGeoMapItemsOverlayPrivate::setVisibleArea(const QRectF &visibleArea) { Q_Q(QGeoMapItemsOverlay); @@ -172,75 +101,23 @@ QRectF QGeoMapItemsOverlayPrivate::visibleArea() const return m_visibleArea; } +QSGNode *QGeoMapItemsOverlay::updateSceneGraph(QSGNode *node, QQuickWindow *) +{ + return node; +} + QGeoMapItemsOverlayPrivate::QGeoMapItemsOverlayPrivate(QGeoMappingManagerEngineItemsOverlay *engine, QGeoMapItemsOverlay *map) : QGeoMapPrivate(engine, new QGeoProjectionWebMercator) { -#ifndef LOCATIONLABS Q_UNUSED(map); -#else - m_qsgSupport.m_map = map; -#endif } QGeoMapItemsOverlayPrivate::~QGeoMapItemsOverlayPrivate() { } -#ifdef LOCATIONLABS -QGeoMapObjectPrivate *QGeoMapItemsOverlayPrivate::createMapObjectImplementation(QGeoMapObject *obj) -{ - return m_qsgSupport.createMapObjectImplementationPrivate(obj); -} - -QList<QGeoMapObject *> QGeoMapItemsOverlayPrivate::mapObjects() const -{ - return m_qsgSupport.mapObjects(); -} - -void QGeoMapItemsOverlayPrivate::removeMapObject(QGeoMapObject *obj) -{ - m_qsgSupport.removeMapObject(obj); -} - -void QGeoMapItemsOverlayPrivate::updateMapObjects(QSGNode *root, QQuickWindow *window) -{ - m_qsgSupport.updateMapObjects(root, window); -} - -QList<QObject *> QGeoMapItemsOverlayPrivate::mapObjectsAt(const QGeoCoordinate &coordinate) const -{ - // ToDo: use a space partitioning strategy - QList<QObject *> res; - for (const auto o: mapObjects()) { - // explicitly handle lines - bool contains = false; - if (o->type() == QGeoMapObject::PolylineType ) { - QMapPolylineObject *mpo = static_cast<QMapPolylineObject *>(o); - qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate); - QGeoPath path = o->geoShape(); - path.setWidth(mpp * mpo->border()->width()); - contains = path.contains(coordinate); - } else if (o->type() == QGeoMapObject::RouteType) { - qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate); - QGeoPath path = o->geoShape(); - path.setWidth(mpp * 4); // MapRouteObjectQSG has a hardcoded 4 pixels width; - contains = path.contains(coordinate); - } else { - contains = o->geoShape().contains(coordinate); - } - - if (contains) - res.append(o); - } - return res; -} -#endif - void QGeoMapItemsOverlayPrivate::updateObjectsGeometry() { -#ifdef LOCATIONLABS - m_qsgSupport.updateObjectsGeometry(); -#endif } void QGeoMapItemsOverlayPrivate::changeViewportSize(const QSize &/*size*/) diff --git a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h index 77a2cbd7..03e3d9a4 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h +++ b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h @@ -57,9 +57,6 @@ public: virtual ~QGeoMapItemsOverlay(); QGeoMap::Capabilities capabilities() const override; - bool createMapObjectImplementation(QGeoMapObject *obj) override; - void removeMapObject(QGeoMapObject *obj) override; - QList<QObject *> mapObjectsAt(const QGeoCoordinate &coordinate) const override; protected: QSGNode *updateSceneGraph(QSGNode *node, QQuickWindow *window) override; diff --git a/src/plugins/geoservices/mapbox/CMakeLists.txt b/src/plugins/geoservices/mapbox/CMakeLists.txt index 10b886bb..16f01c81 100644 --- a/src/plugins/geoservices/mapbox/CMakeLists.txt +++ b/src/plugins/geoservices/mapbox/CMakeLists.txt @@ -32,9 +32,3 @@ qt_internal_extend_target(QGeoServiceProviderFactoryMapboxPlugin SOURCES ${plugin_resource_files} ) - -qt_internal_extend_target(QGeoServiceProviderFactoryMapboxPlugin - CONDITION QT_FEATURE_location_labs_plugin - DEFINES - LOCATIONLABS -) diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp index 5208e687..7ec90dd8 100644 --- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp @@ -44,12 +44,7 @@ #include <QtLocation/private/qgeomaptype_p.h> #include <QtLocation/private/qgeotiledmap_p.h> #include "qgeofiletilecachemapbox.h" -#ifdef LOCATIONLABS -#include <QtLocation/private/qgeotiledmaplabs_p.h> -typedef QGeoTiledMapLabs Map; -#else typedef QGeoTiledMap Map; -#endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/geoservices/nokia/CMakeLists.txt b/src/plugins/geoservices/nokia/CMakeLists.txt index 342d3a31..e110adcf 100644 --- a/src/plugins/geoservices/nokia/CMakeLists.txt +++ b/src/plugins/geoservices/nokia/CMakeLists.txt @@ -45,9 +45,3 @@ qt_internal_extend_target(QGeoServiceProviderFactoryNokiaPlugin SOURCES ${plugin_resource_files} ) - -qt_internal_extend_target(QGeoServiceProviderFactoryNokiaPlugin - CONDITION QT_FEATURE_location_labs_plugin - DEFINES - LOCATIONLABS -) diff --git a/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h b/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h index 549c9699..0a9458db 100644 --- a/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h +++ b/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h @@ -43,12 +43,7 @@ #include "qgeotiledmap_p.h" #include <QtGui/QImage> #include <QtCore/QPointer> -#ifdef LOCATIONLABS -#include <QtLocation/private/qgeotiledmaplabs_p.h> -typedef QGeoTiledMapLabs Map; -#else typedef QGeoTiledMap Map; -#endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/geoservices/osm/CMakeLists.txt b/src/plugins/geoservices/osm/CMakeLists.txt index 4cc55042..f7f54c78 100644 --- a/src/plugins/geoservices/osm/CMakeLists.txt +++ b/src/plugins/geoservices/osm/CMakeLists.txt @@ -25,9 +25,3 @@ qt_internal_add_plugin(QGeoServiceProviderFactoryOsmPlugin DEFINES QT_NO_FOREACH ) - -qt_internal_extend_target(QGeoServiceProviderFactoryOsmPlugin - CONDITION QT_FEATURE_location_labs_plugin - DEFINES - LOCATIONLABS -) diff --git a/src/plugins/geoservices/osm/qgeotiledmaposm.h b/src/plugins/geoservices/osm/qgeotiledmaposm.h index 02c80eac..809277ba 100644 --- a/src/plugins/geoservices/osm/qgeotiledmaposm.h +++ b/src/plugins/geoservices/osm/qgeotiledmaposm.h @@ -43,12 +43,7 @@ #include "qgeotileproviderosm.h" #include <QtLocation/private/qgeotiledmap_p.h> -#ifdef LOCATIONLABS -#include <QtLocation/private/qgeotiledmaplabs_p.h> -typedef QGeoTiledMapLabs Map; -#else typedef QGeoTiledMap Map; -#endif QT_BEGIN_NAMESPACE diff --git a/tests/manual/mapobjects_tester/main.qml b/tests/manual/mapobjects_tester/main.qml index 3651a382..b5c6218a 100644 --- a/tests/manual/mapobjects_tester/main.qml +++ b/tests/manual/mapobjects_tester/main.qml @@ -74,52 +74,7 @@ Window { id: map rotation: win.rotation gesture.enabled: true - objectName: "map1" - anchors { - bottom: parent.bottom - top: parent.top - left: parent.left - right: parent.horizontalCenter - } - - onCenterChanged: syncMaps(map, map2, "center") - onTiltChanged: syncMaps(map, map2, "tilt") - onBearingChanged: syncMaps(map, map2, "bearing") - onZoomLevelChanged: syncMaps(map, map2, "zoomLevel") - onFieldOfViewChanged: syncMaps(map, map2, "fieldOfView") - - opacity: 1.0 - color: 'transparent' - plugin: osm - center: initialCenter - activeMapType: map.supportedMapTypes[2] - zoomLevel: initialZL - z : parent.z + 1 - copyrightsVisible: false - - Component.onCompleted: { - var o = movComponent.createObject(map1MainMOV) - map1MainMOV.addMapObject(o); - } - MapObjectView { - id: map1MainMOV - } - - MouseArea { - anchors.fill: parent - onClicked: (mouse) => { - mouse.accepted = false - var crd = map.toCoordinate(Qt.point(mouse.x, mouse.y)) - var s = crd.toString(0) - console.log("Clicked on ",s) - } - } - } - Map { - id: map2 - rotation: win.rotation - gesture.enabled: true - objectName: "map2" + objectName: "map" anchors { bottom: parent.bottom top: parent.top @@ -127,12 +82,6 @@ Window { right: parent.right } - onCenterChanged: syncMaps(map2, map, "center") - onTiltChanged: syncMaps(map2, map, "tilt") - onBearingChanged: syncMaps(map2, map, "bearing") - onZoomLevelChanged: syncMaps(map2, map, "zoomLevel") - onFieldOfViewChanged: syncMaps(map2, map, "fieldOfView") - color: 'transparent' plugin: osm activeMapType: map.supportedMapTypes[2] @@ -141,12 +90,12 @@ Window { copyrightsVisible: false Component.onCompleted: { - var o = migComponent.createObject(map2) + var o = migComponent.createObject(map) o.glPolygons = Qt.binding(function() {return switchPolygons2.checked}) o.glPolylines = Qt.binding(function() {return switchPolylines2.currentText}) o.glCircles = Qt.binding(function() {return switchCircles2.checked}) o.glRectangles = Qt.binding(function() {return switchRectangles2.checked}) - map2.addMapItemGroup(o); + map.addMapItemGroup(o); } C2.Switch { @@ -403,114 +352,6 @@ Window { } } - Component { - id: movComponent - MapObjectView { - id: polyGroup - MapPolylineObject { - id: tstPolyLine // to verify the polygon stays where it's supposed to - line.color: 'black' - objectName: parent.objectName + "black" - line.width: 1 - path: [ - { latitude: 76.9965, longitude: -175.012 }, - { latitude: 26.9965, longitude: -175.012 } - ] - } - - MapPolylineObject { - id: timeline - line.color: "red" - objectName: parent.objectName + "timeline" - line.width: 4 - path: [ - { latitude: 90, longitude: 180 }, - { latitude: -90, longitude: -180 } - ] - } - - MapPolygonObject { - id: poly1 - color: "red" - objectName: parent.objectName + "red" - path: [ - { latitude: 55, longitude: 170 }, - { latitude: 66.9965, longitude: -175.012 }, - { latitude: 55, longitude: -160 }, - { latitude: 40, longitude: -165 }, - { latitude: 45, longitude: 178 } - ] - } - - MapPolygonObject { - id: selfIntersectingPolygon - color: 'darkmagenta' - objectName: parent.objectName + "darkmagenta" - path: [ - { latitude: 19, longitude: 49 }, - { latitude: 18, longitude: 49 }, - { latitude: 18, longitude: 51 }, - { latitude: 20, longitude: 51 }, - { latitude: 20, longitude: 50 }, - { latitude: 18.5, longitude: 50 }, - { latitude: 18.5, longitude: 52 }, - { latitude: 19, longitude: 52 } - ] - } - - MapPolygonObject { - id: poly2 - color: "green" - border.color: "black" - border.width: 8 - objectName: parent.objectName + "green" - path: [ - { latitude: -45, longitude: -170 }, - { latitude: -55, longitude: -155 }, - { latitude: -45, longitude: -130 }, - { latitude: -35, longitude: -155 } - ] - } - - MapPolygonObject { - id: poly3 - color: Qt.rgba(0, 191.0/255.0, 1, 0.3) //"deepskyblue" - objectName: parent.objectName + "deepskyblue" - path: [ - { latitude: 65, longitude: -20 }, - { latitude: 75, longitude: 140 }, - { latitude: 65, longitude: 80 }, - { latitude: 55, longitude: -30 } - ] - } - - MapCircleObject { - center: QtPositioning.coordinate(52, 0) - radius: sliRadius.value - color: 'deepskyblue' - border.width: 6 - border.color: 'firebrick' - } - - MapPolylineObject { - id: longPolyline - line.color: "firebrick" - objectName: parent.objectName + "longPolyline" - line.width: 10 - path: longPolyPath - } - - MapCircleObject { - id: circle1 - border.color: 'deepskyblue' - border.width: 26 - center: QtPositioning.coordinate(17, 44); - radius: 200*1000 - color: "firebrick" - } - } - } - property var longPolyPath C2.Slider { |