summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-06-09 11:44:42 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-06-20 10:46:12 +0000
commit6ae64c4172e02666ecd049b251aa70e656956da1 (patch)
tree40223eed5262a57603101f4f61215ebde0de9fce
parent1815cda49f19c8a2387f80315c9d2f56c3b1d237 (diff)
downloadqtlocation-6ae64c4172e02666ecd049b251aa70e656956da1.tar.gz
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 <simon.hausmann@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp20
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h5
2 files changed, 24 insertions, 1 deletions
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 <QtQml/QQmlInfo>
+#include <QtQml/QQmlEngine>
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<QDeclarativeGeoServiceProviderParameter> 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);