summaryrefslogtreecommitdiff
path: root/src/location/declarativemaps
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-09-12 13:47:02 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-09-24 12:25:11 +0000
commitd3bfcfaa9ac53885066689d540590035b3bc7976 (patch)
tree0aea03bbd28431d3a6e21f8ada1514d98e2ba4be /src/location/declarativemaps
parent760fb57148eaecbe35942a6ec21d96f5473f6b68 (diff)
downloadqtlocation-d3bfcfaa9ac53885066689d540590035b3bc7976.tar.gz
Add extended attributes to QGeoRoute/QDeclarativeGeoRoute
This to be able to push plugin-specific data for which an API is not yet available in these classes. Task-number: QTBUG-70502 Change-Id: Ie7d715a545f1174ae7c118bd1b269dca51282301 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/declarativemaps')
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroute.cpp29
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroute_p.h4
2 files changed, 33 insertions, 0 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeoroute.cpp b/src/location/declarativemaps/qdeclarativegeoroute.cpp
index 09ed46ab..64aeb656 100644
--- a/src/location/declarativemaps/qdeclarativegeoroute.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroute.cpp
@@ -352,6 +352,35 @@ QList<QObject *> QDeclarativeGeoRoute::legs()
}
/*!
+ \qmlproperty Object Route::extendedAttributes
+
+ This property holds the extended attributes of the route and is a map.
+ These attributes are plugin specific, and can be empty.
+
+ Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation}
+ for what attributes are supported and how they should be used.
+
+ Note, due to limitations of the QQmlPropertyMap, it is not possible
+ to declaratively specify the attributes in QML, assignment of attributes keys
+ and values can only be accomplished by JavaScript.
+
+ \since QtLocation 5.13
+*/
+QQmlPropertyMap *QDeclarativeGeoRoute::extendedAttributes() const
+{
+ if (!m_extendedAttributes) {
+ QDeclarativeGeoRoute *self = const_cast<QDeclarativeGeoRoute *>(this);
+ self->m_extendedAttributes = new QQmlPropertyMap(self);
+ // Fill it
+ const QVariantMap &xAttrs = route_.extendedAttributes();
+ const QStringList &keys = xAttrs.keys();
+ for (const QString &key: keys)
+ self->m_extendedAttributes->insert(key, xAttrs.value(key));
+ }
+ return m_extendedAttributes;
+}
+
+/*!
\qmlmethod bool QtLocation::Route::equals(Route other)
This method performs deep comparison.
diff --git a/src/location/declarativemaps/qdeclarativegeoroute_p.h b/src/location/declarativemaps/qdeclarativegeoroute_p.h
index 98d08e98..767e21ea 100644
--- a/src/location/declarativemaps/qdeclarativegeoroute_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoroute_p.h
@@ -69,6 +69,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRoute : public QObject
Q_PROPERTY(QQmlListProperty<QDeclarativeGeoRouteSegment> segments READ segments CONSTANT)
Q_PROPERTY(QDeclarativeGeoRouteQuery *routeQuery READ routeQuery REVISION 11)
Q_PROPERTY(QList<QObject *> legs READ legs CONSTANT REVISION 12)
+ Q_PROPERTY(QObject *extendedAttributes READ extendedAttributes CONSTANT REVISION 12)
public:
explicit QDeclarativeGeoRoute(QObject *parent = 0);
@@ -91,6 +92,7 @@ public:
const QGeoRoute &route() const;
QDeclarativeGeoRouteQuery *routeQuery();
QList<QObject *> legs();
+ QQmlPropertyMap *extendedAttributes() const;
Q_INVOKABLE bool equals(QDeclarativeGeoRoute *other) const;
@@ -111,6 +113,8 @@ private:
QList<QDeclarativeGeoRouteSegment *> segments_;
QList<QObject *> legs_;
bool segmentsDirty_ = true;
+ QQmlPropertyMap *m_extendedAttributes = nullptr;
+
friend class QDeclarativeRouteMapItem;
};