summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-03-24 10:22:45 +0100
committerIvan Solovev <ivan.solovev@qt.io>2021-03-25 12:42:40 +0100
commitf3bd8f1d0d0769ca2b7bfdfef70840d7f13d1160 (patch)
tree2d5eee3830c8936ca8daba866951c9778c914252
parent400cc8967f0c1430941aecece632fefa6e436e63 (diff)
downloadqtlocation-f3bd8f1d0d0769ca2b7bfdfef70840d7f13d1160.tar.gz
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 <alexander.blasche@qt.io>
-rw-r--r--src/positioning/qgeopath.cpp30
-rw-r--r--src/positioning/qgeopath.h12
-rw-r--r--src/positioning/qgeopath_p.h18
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<QGeoCoordinate> &m_path, QList<double
}
m_minLati = m_maxLati = m_path.at(0).latitude();
- int minId = 0;
- int maxId = 0;
+ qsizetype minId = 0;
+ qsizetype maxId = 0;
m_deltaXs.resize(m_path.size());
m_deltaXs[0] = m_minX = m_maxX = 0.0;
- for (int i = 1; i < m_path.size(); i++) {
+ for (qsizetype i = 1; i < m_path.size(); i++) {
const QGeoCoordinate &geoFrom = m_path.at(i-1);
const QGeoCoordinate &geoTo = m_path.at(i);
double longiFrom = geoFrom.longitude();
@@ -189,9 +189,9 @@ public:
virtual const QList<QGeoCoordinate> &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<QGeoCoordinate> &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();