summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-05-30 15:28:14 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-06-07 11:12:51 +0000
commite8dedcd7c621715813b7b954bb7f64c88aa6523d (patch)
tree087f958ceaa0cb920eb889389afa291454ca09ab /src
parentf55629245259ba7364e258f92408823024423caa (diff)
downloadqtlocation-e8dedcd7c621715813b7b954bb7f64c88aa6523d.tar.gz
Add QGeoPath::size
A way to retrieve the size of the path is missing, as the path property turns out not to be accessible to QML. This patch adds a Q_INVOKABLE method to expose it. [ChangeLog][QtPositioning][QGeoPath] Add ::size() to QGeoPath to retrieve the number of coordinates in the path. Change-Id: Ifa7a640113cba71f23e36626a84c8b2fe473a07e Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/positioning/qgeopath.cpp16
-rw-r--r--src/positioning/qgeopath.h1
-rw-r--r--src/positioning/qgeopath_p.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index ad3536af..858dc0bd 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -247,6 +247,17 @@ double QGeoPath::length(int indexFrom, int indexTo) const
}
/*!
+ Returns the number of elements in the path.
+
+ \since 5.10
+*/
+int QGeoPath::size() const
+{
+ Q_D(const QGeoPath);
+ return d->size();
+}
+
+/*!
Appends \a coordinate to the path.
*/
void QGeoPath::addCoordinate(const QGeoCoordinate &coordinate)
@@ -415,6 +426,11 @@ double QGeoPathPrivate::length(int indexFrom, int indexTo) const
return len;
}
+int QGeoPathPrivate::size() const
+{
+ return m_path.size();
+}
+
/*!
Returns true if coordinate is present in m_path.
*/
diff --git a/src/positioning/qgeopath.h b/src/positioning/qgeopath.h
index 09a53a49..ad41c23c 100644
--- a/src/positioning/qgeopath.h
+++ b/src/positioning/qgeopath.h
@@ -78,6 +78,7 @@ public:
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
Q_INVOKABLE QGeoPath translated(double degreesLatitude, double degreesLongitude) const;
Q_INVOKABLE double length(int indexFrom = 0, int indexTo = -1) const;
+ Q_INVOKABLE int size() const;
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate);
Q_INVOKABLE void insertCoordinate(int index, const QGeoCoordinate &coordinate);
Q_INVOKABLE void replaceCoordinate(int index, const QGeoCoordinate &coordinate);
diff --git a/src/positioning/qgeopath_p.h b/src/positioning/qgeopath_p.h
index 2256796d..48334017 100644
--- a/src/positioning/qgeopath_p.h
+++ b/src/positioning/qgeopath_p.h
@@ -85,6 +85,7 @@ public:
qreal width() const;
void setWidth(const qreal &width);
double length(int indexFrom, int indexTo) const;
+ int size() const;
void addCoordinate(const QGeoCoordinate &coordinate);
void insertCoordinate(int index, const QGeoCoordinate &coordinate);
void replaceCoordinate(int index, const QGeoCoordinate &coordinate);