diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-12-01 12:10:21 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-12-05 10:15:12 +0000 |
commit | a080df7b8810dd89121a20b1b5750015ab1f9f2d (patch) | |
tree | 1e25e6b0f820d8705a022fb4139ec1082675ebec | |
parent | 9a901aa63b73d2c6b17ca9dd1c1a1823b160cc7d (diff) | |
download | qtlocation-a080df7b8810dd89121a20b1b5750015ab1f9f2d.tar.gz |
Make QGeoPath::path a qvariantlist property
Change-Id: I1f21d25832c7eb87d4a68a89e556f5c859498c2d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/positioning/qgeopath.cpp | 34 | ||||
-rw-r--r-- | src/positioning/qgeopath.h | 5 |
2 files changed, 36 insertions, 3 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp index 5e7a4077..6fd02d77 100644 --- a/src/positioning/qgeopath.cpp +++ b/src/positioning/qgeopath.cpp @@ -176,6 +176,9 @@ bool QGeoPath::operator!=(const QGeoPath &other) const return !(*d == *other.d_func()); } +/*! + Sets all the elements of the path. +*/ void QGeoPath::setPath(const QList<QGeoCoordinate> &path) { Q_D(QGeoPath); @@ -183,14 +186,41 @@ void QGeoPath::setPath(const QList<QGeoCoordinate> &path) } /*! - Returns all the elements. Equivalent to QGeoShape::center(). - The center coordinate, in case of a QGeoPath, is the center of its bounding box. + Returns all the elements of the path. */ const QList<QGeoCoordinate> &QGeoPath::path() const { Q_D(const QGeoPath); return d->path(); } +/*! + Sets all the elements of the path. + + \internal +*/ +void QGeoPath::setVariantPath(const QVariantList &path) +{ + Q_D(QGeoPath); + QList<QGeoCoordinate> p; + for (const auto &c: path) { + if (c.canConvert<QGeoCoordinate>()) + p << c.value<QGeoCoordinate>(); + } + d->setPath(p); +} +/*! + Returns all the elements of the path. + + \internal +*/ +QVariantList QGeoPath::variantPath() const +{ + Q_D(const QGeoPath); + QVariantList p; + for (const auto &c: d->path()) + p << QVariant::fromValue(c); + return p; +} void QGeoPath::setWidth(const qreal &width) { diff --git a/src/positioning/qgeopath.h b/src/positioning/qgeopath.h index ad41c23c..c80d224a 100644 --- a/src/positioning/qgeopath.h +++ b/src/positioning/qgeopath.h @@ -41,6 +41,7 @@ #define QGEOPATH_H #include <QtPositioning/QGeoShape> +#include <QVariantList> QT_BEGIN_NAMESPACE @@ -50,7 +51,7 @@ class QGeoPathPrivate; class Q_POSITIONING_EXPORT QGeoPath : public QGeoShape { Q_GADGET - Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath) + Q_PROPERTY(QVariantList path READ variantPath WRITE setVariantPath) Q_PROPERTY(qreal width READ width WRITE setWidth) public: @@ -71,6 +72,8 @@ public: void setPath(const QList<QGeoCoordinate> &path); const QList<QGeoCoordinate> &path() const; + void setVariantPath(const QVariantList &path); + QVariantList variantPath() const; void setWidth(const qreal &width); qreal width() const; |