From 6ae64c4172e02666ecd049b251aa70e656956da1 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 9 Jun 2017 11:44:42 +0200 Subject: Fix for Plugin.required being readonly The documentation clearly states that this property should be writable but it's not. Task-number: QTBUG-57419 Change-Id: I1dc93d45ddf52f2e1eee9572f153f4f19916ca2a Reviewed-by: Simon Hausmann Reviewed-by: Alex Blasche --- .../qdeclarativegeoserviceprovider.cpp | 20 ++++++++++++++++++++ .../qdeclarativegeoserviceprovider_p.h | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp index 54f70c11..4b8b2d7c 100644 --- a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp +++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp @@ -36,6 +36,7 @@ #include "qdeclarativegeoserviceprovider_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -399,6 +400,19 @@ QDeclarativeGeoServiceProviderRequirements *QDeclarativeGeoServiceProvider::requ return required_; } +void QDeclarativeGeoServiceProvider::setRequirements(QDeclarativeGeoServiceProviderRequirements *req) +{ + if (!name().isEmpty() || !req) + return; + + if (required_ && *required_ == *req) + return; + + delete required_; + required_ = req; + QQmlEngine::setObjectOwnership(req, QQmlEngine::CppOwnership); // To prevent the engine from making this object disappear +} + /*! \qmlproperty stringlist Plugin::preferred @@ -732,6 +746,12 @@ bool QDeclarativeGeoServiceProviderRequirements::matches(const QGeoServiceProvid return true; } +bool QDeclarativeGeoServiceProviderRequirements::operator == (const QDeclarativeGeoServiceProviderRequirements &rhs) const +{ + return (mapping_ == rhs.mapping_ && routing_ == rhs.routing_ + && geocoding_ == rhs.geocoding_ && places_ == rhs.places_); +} + /******************************************************************************* *******************************************************************************/ diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h index bcf67124..426c6b4d 100644 --- a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h +++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h @@ -100,7 +100,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoServiceProvider : public QObject, Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QStringList availableServiceProviders READ availableServiceProviders CONSTANT) Q_PROPERTY(QQmlListProperty parameters READ parameters) - Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements) + Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements WRITE setRequirements) Q_PROPERTY(QStringList locales READ locales WRITE setLocales NOTIFY localesChanged) Q_PROPERTY(QStringList preferred READ preferred WRITE setPreferred NOTIFY preferredChanged) Q_PROPERTY(bool allowExperimental READ allowExperimental WRITE setAllowExperimental NOTIFY allowExperimentalChanged) @@ -182,6 +182,7 @@ public: QStringList availableServiceProviders(); QDeclarativeGeoServiceProviderRequirements *requirements() const; + void setRequirements(QDeclarativeGeoServiceProviderRequirements *req); QStringList preferred() const; void setPreferred(const QStringList &val); @@ -259,6 +260,8 @@ public: Q_INVOKABLE bool matches(const QGeoServiceProvider *provider) const; + bool operator == (const QDeclarativeGeoServiceProviderRequirements &rhs) const; + Q_SIGNALS: void mappingRequirementsChanged(const QDeclarativeGeoServiceProvider::MappingFeatures &features); void routingRequirementsChanged(const QDeclarativeGeoServiceProvider::RoutingFeatures &features); -- cgit v1.2.1