From f3bd8f1d0d0769ca2b7bfdfef70840d7f13d1160 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 24 Mar 2021 10:22:45 +0100 Subject: QGeoPath: update the API to use qsizetype instead of int [ChangeLog][QtPositioning][QGeoPath] Use qsizetype instead of int in public API Change-Id: I536873ceaa75c827a4e3e4caf17cfa574be9dc8b Reviewed-by: Alex Blasche --- src/positioning/qgeopath.cpp | 30 +++++++++++++++--------------- src/positioning/qgeopath.h | 12 ++++++------ src/positioning/qgeopath_p.h | 18 +++++++++--------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp index ad2c4ffe..aeec2315 100644 --- a/src/positioning/qgeopath.cpp +++ b/src/positioning/qgeopath.cpp @@ -297,7 +297,7 @@ QGeoPath QGeoPath::translated(double degreesLatitude, double degreesLongitude) c and the first (closed loop). To retrieve the length for the path, use 0 for \a indexFrom and \l QGeoPath::size() - 1 for \a indexTo. */ -double QGeoPath::length(int indexFrom, int indexTo) const +double QGeoPath::length(qsizetype indexFrom, qsizetype indexTo) const { Q_D(const QGeoPath); return d->length(indexFrom, indexTo); @@ -308,7 +308,7 @@ double QGeoPath::length(int indexFrom, int indexTo) const \since 5.10 */ -int QGeoPath::size() const +qsizetype QGeoPath::size() const { Q_D(const QGeoPath); return d->size(); @@ -326,7 +326,7 @@ void QGeoPath::addCoordinate(const QGeoCoordinate &coordinate) /*! Inserts \a coordinate at the specified \a index. */ -void QGeoPath::insertCoordinate(int index, const QGeoCoordinate &coordinate) +void QGeoPath::insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate) { Q_D(QGeoPath); d->insertCoordinate(index, coordinate); @@ -335,7 +335,7 @@ void QGeoPath::insertCoordinate(int index, const QGeoCoordinate &coordinate) /*! Replaces the path element at the specified \a index with \a coordinate. */ -void QGeoPath::replaceCoordinate(int index, const QGeoCoordinate &coordinate) +void QGeoPath::replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate) { Q_D(QGeoPath); d->replaceCoordinate(index, coordinate); @@ -344,7 +344,7 @@ void QGeoPath::replaceCoordinate(int index, const QGeoCoordinate &coordinate) /*! Returns the coordinate at \a index . */ -QGeoCoordinate QGeoPath::coordinateAt(int index) const +QGeoCoordinate QGeoPath::coordinateAt(qsizetype index) const { Q_D(const QGeoPath); return d->coordinateAt(index); @@ -371,7 +371,7 @@ void QGeoPath::removeCoordinate(const QGeoCoordinate &coordinate) /*! Removes element at position \a index from the path. */ -void QGeoPath::removeCoordinate(int index) +void QGeoPath::removeCoordinate(qsizetype index) { Q_D(QGeoPath); d->removeCoordinate(index); @@ -489,7 +489,7 @@ bool QGeoPathPrivate::lineContains(const QGeoCoordinate &coordinate) const if (a.x() < m_leftBoundWrapped) a.setX(a.x() + m_leftBoundWrapped); // unwrap X } - for (int i = 1; i < m_path.size(); i++) { + for (qsizetype i = 1; i < m_path.size(); i++) { b = QWebMercator::coordToMercator(m_path[i]); if (b.x() < m_leftBoundWrapped) b.setX(b.x() + m_leftBoundWrapped); // unwrap X @@ -541,7 +541,7 @@ void QGeoPathPrivate::setWidth(const qreal &width) m_width = width; } -double QGeoPathPrivate::length(int indexFrom, int indexTo) const +double QGeoPathPrivate::length(qsizetype indexFrom, qsizetype indexTo) const { if (path().isEmpty()) return 0.0; @@ -552,19 +552,19 @@ double QGeoPathPrivate::length(int indexFrom, int indexTo) const double len = 0.0; // TODO: consider calculating the length of the actual rhumb line segments // instead of the shortest path from A to B. - for (int i = indexFrom; i < indexTo; i++) + for (qsizetype i = indexFrom; i < indexTo; i++) len += m_path[i].distanceTo(m_path[i+1]); if (wrap) len += m_path.last().distanceTo(m_path.first()); return len; } -int QGeoPathPrivate::size() const +qsizetype QGeoPathPrivate::size() const { return m_path.size(); } -QGeoCoordinate QGeoPathPrivate::coordinateAt(int index) const +QGeoCoordinate QGeoPathPrivate::coordinateAt(qsizetype index) const { if (index < 0 || index >= m_path.size()) return QGeoCoordinate(); @@ -627,7 +627,7 @@ void QGeoPathPrivate::addCoordinate(const QGeoCoordinate &coordinate) markDirty(); } -void QGeoPathPrivate::insertCoordinate(int index, const QGeoCoordinate &coordinate) +void QGeoPathPrivate::insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate) { if (index < 0 || index > m_path.size() || !coordinate.isValid()) return; @@ -635,7 +635,7 @@ void QGeoPathPrivate::insertCoordinate(int index, const QGeoCoordinate &coordina markDirty(); } -void QGeoPathPrivate::replaceCoordinate(int index, const QGeoCoordinate &coordinate) +void QGeoPathPrivate::replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate) { if (index < 0 || index >= m_path.size() || !coordinate.isValid()) return; @@ -645,11 +645,11 @@ void QGeoPathPrivate::replaceCoordinate(int index, const QGeoCoordinate &coordin void QGeoPathPrivate::removeCoordinate(const QGeoCoordinate &coordinate) { - int index = m_path.lastIndexOf(coordinate); + qsizetype index = m_path.lastIndexOf(coordinate); removeCoordinate(index); } -void QGeoPathPrivate::removeCoordinate(int index) +void QGeoPathPrivate::removeCoordinate(qsizetype index) { if (index < 0 || index >= m_path.size()) return; diff --git a/src/positioning/qgeopath.h b/src/positioning/qgeopath.h index 654c9c32..dc5052af 100644 --- a/src/positioning/qgeopath.h +++ b/src/positioning/qgeopath.h @@ -81,15 +81,15 @@ 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 double length(qsizetype indexFrom = 0, qsizetype indexTo = -1) const; + Q_INVOKABLE qsizetype 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); - Q_INVOKABLE QGeoCoordinate coordinateAt(int index) const; + Q_INVOKABLE void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate); + Q_INVOKABLE void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate); + Q_INVOKABLE QGeoCoordinate coordinateAt(qsizetype index) const; Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate) const; Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate); - Q_INVOKABLE void removeCoordinate(int index); + Q_INVOKABLE void removeCoordinate(qsizetype index); Q_INVOKABLE QString toString() const; diff --git a/src/positioning/qgeopath_p.h b/src/positioning/qgeopath_p.h index 18cd3ab1..3b7a1777 100644 --- a/src/positioning/qgeopath_p.h +++ b/src/positioning/qgeopath_p.h @@ -75,12 +75,12 @@ inline static void computeBBox(const QList &m_path, QList &path() const; virtual bool lineContains(const QGeoCoordinate &coordinate) const; virtual qreal width() const; - virtual double length(int indexFrom, int indexTo) const; - virtual int size() const; - virtual QGeoCoordinate coordinateAt(int index) const; + virtual double length(qsizetype indexFrom, qsizetype indexTo) const; + virtual qsizetype size() const; + virtual QGeoCoordinate coordinateAt(qsizetype index) const; virtual bool containsCoordinate(const QGeoCoordinate &coordinate) const; virtual void setWidth(const qreal &width); @@ -199,10 +199,10 @@ public: virtual void setPath(const QList &path); virtual void clearPath(); virtual void addCoordinate(const QGeoCoordinate &coordinate); - virtual void insertCoordinate(int index, const QGeoCoordinate &coordinate); - virtual void replaceCoordinate(int index, const QGeoCoordinate &coordinate); + virtual void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate); + virtual void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate); virtual void removeCoordinate(const QGeoCoordinate &coordinate); - virtual void removeCoordinate(int index); + virtual void removeCoordinate(qsizetype index); virtual void computeBoundingBox(); virtual void markDirty(); -- cgit v1.2.1