summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-14 15:26:46 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-20 13:41:56 +0200
commitc7ae3541cbdda1453a32288ead37382cb7d1b863 (patch)
tree3a6735748dfeb3a3da75c878cb6f8c2b85680dc0
parentca18c1ff0317b85b51f4ef0e888b29f083ae90a9 (diff)
Cleanup: de-virtualize QGeoRouteSegmentPrivate
The possibility to override this type in plugins is not used anywhere, and overcomplicates the code. There isn't even a way to create a QGeoRouteSegment with a reimplementation of the private. So remove this; if this is really needed for anything, then we can bring it back later. Change-Id: I34ad55d0ddf29cafc53e90e2a987c3faf904b437 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 69e0dea5de987d5b6e684b721b322b0495921981) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/location/maps/qgeoroutesegment.cpp159
-rw-r--r--src/location/maps/qgeoroutesegment_p.h79
2 files changed, 40 insertions, 198 deletions
diff --git a/src/location/maps/qgeoroutesegment.cpp b/src/location/maps/qgeoroutesegment.cpp
index 5eba28cd..19e464b3 100644
--- a/src/location/maps/qgeoroutesegment.cpp
+++ b/src/location/maps/qgeoroutesegment.cpp
@@ -45,12 +45,6 @@
QT_BEGIN_NAMESPACE
-template<>
-QGeoRouteSegmentPrivate *QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate>::clone()
-{
- return d->clone();
-}
-
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QGeoRouteSegmentPrivate)
/*!
@@ -78,7 +72,7 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QGeoRouteSegmentPrivate)
setTravelTime(), setDistance(), setPath() or setManeuver() is called.
*/
QGeoRouteSegment::QGeoRouteSegment()
- : d_ptr(new QGeoRouteSegmentPrivateDefault()) {}
+ : d_ptr(new QGeoRouteSegmentPrivate()) {}
/*!
Constructs a route segment object from the contents of \a other.
@@ -263,88 +257,75 @@ QGeoManeuver QGeoRouteSegment::maneuver() const
/*******************************************************************************
*******************************************************************************/
-QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate() {}
-
-QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate(const QGeoRouteSegmentPrivate &other)
- : QSharedData(other), m_nextSegment(other.m_nextSegment) {}
-
-QGeoRouteSegmentPrivate::~QGeoRouteSegmentPrivate()
-{
- m_nextSegment.reset();
-}
-
-bool QGeoRouteSegmentPrivate::operator ==(const QGeoRouteSegmentPrivate &other) const
-{
- return equals(other);
-}
+QGeoRouteSegmentPrivate::QGeoRouteSegmentPrivate() = default;
-bool QGeoRouteSegmentPrivate::equals(const QGeoRouteSegmentPrivate &other) const
+bool operator==(const QGeoRouteSegmentPrivate &lhs, const QGeoRouteSegmentPrivate &rhs)
{
- return ((valid() == other.valid())
- && (travelTime() == other.travelTime())
- && (distance() == other.distance())
- && (path() == other.path())
- && (maneuver() == other.maneuver()));
+ return lhs.m_valid == rhs.m_valid
+ && lhs.m_travelTime == rhs.m_travelTime
+ && lhs.m_distance == rhs.m_distance
+ && lhs.m_path == rhs.m_path
+ && lhs.m_maneuver == rhs.m_maneuver;
}
bool QGeoRouteSegmentPrivate::valid() const
{
- return false;
+ return m_valid;
}
void QGeoRouteSegmentPrivate::setValid(bool valid)
{
- Q_UNUSED(valid);
+ m_valid = valid;
}
bool QGeoRouteSegmentPrivate::isLegLastSegment() const
{
- return false;
+ return m_legLastSegment;
}
void QGeoRouteSegmentPrivate::setLegLastSegment(bool lastSegment)
{
- Q_UNUSED(lastSegment);
+ m_legLastSegment = lastSegment;
}
int QGeoRouteSegmentPrivate::travelTime() const
{
- return 0;
+ return m_travelTime;
}
void QGeoRouteSegmentPrivate::setTravelTime(int travelTime)
{
- Q_UNUSED(travelTime);
+ m_travelTime = travelTime;
}
qreal QGeoRouteSegmentPrivate::distance() const
{
- return 0;
+ return m_distance;
}
void QGeoRouteSegmentPrivate::setDistance(qreal distance)
{
- Q_UNUSED(distance);
+ m_distance = distance;
}
QList<QGeoCoordinate> QGeoRouteSegmentPrivate::path() const
{
- return QList<QGeoCoordinate>();
+ return m_path;
}
void QGeoRouteSegmentPrivate::setPath(const QList<QGeoCoordinate> &path)
{
- Q_UNUSED(path);
+ m_path = path;
}
QGeoManeuver QGeoRouteSegmentPrivate::maneuver() const
{
- return QGeoManeuver();
+ return m_maneuver;
}
void QGeoRouteSegmentPrivate::setManeuver(const QGeoManeuver &maneuver)
{
- Q_UNUSED(maneuver);
+ m_maneuver = maneuver;
}
QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> QGeoRouteSegmentPrivate::nextRouteSegment() const
@@ -362,106 +343,6 @@ QGeoRouteSegmentPrivate *QGeoRouteSegmentPrivate::get(QGeoRouteSegment &segment)
return segment.d_ptr.data();
}
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoRouteSegmentPrivateDefault::QGeoRouteSegmentPrivateDefault()
- : m_valid(false),
- m_travelTime(0),
- m_distance(0.0)
-{
-
-}
-
-QGeoRouteSegmentPrivateDefault::QGeoRouteSegmentPrivateDefault(const QGeoRouteSegmentPrivateDefault &other)
- : QGeoRouteSegmentPrivate(other),
- m_valid(other.m_valid),
- m_travelTime(other.m_travelTime),
- m_distance(other.m_distance),
- m_path(other.m_path),
- m_maneuver(other.m_maneuver)
-{
-
-}
-
-QGeoRouteSegmentPrivateDefault::~QGeoRouteSegmentPrivateDefault()
-{
-
-}
-
-QGeoRouteSegmentPrivate *QGeoRouteSegmentPrivateDefault::clone()
-{
- return new QGeoRouteSegmentPrivateDefault(*this);
-}
-
-bool QGeoRouteSegmentPrivateDefault::operator ==(const QGeoRouteSegmentPrivateDefault &other) const
-{
- return QGeoRouteSegmentPrivate::operator ==(other);
-}
-
-bool QGeoRouteSegmentPrivateDefault::valid() const
-{
- return m_valid;
-}
-
-void QGeoRouteSegmentPrivateDefault::setValid(bool valid)
-{
- m_valid = valid;
-}
-
-bool QGeoRouteSegmentPrivateDefault::isLegLastSegment() const
-{
- return m_legLastSegment;
-}
-
-void QGeoRouteSegmentPrivateDefault::setLegLastSegment(bool lastSegment)
-{
- m_legLastSegment = lastSegment;
-}
-
-int QGeoRouteSegmentPrivateDefault::travelTime() const
-{
- return m_travelTime;
-}
-
-void QGeoRouteSegmentPrivateDefault::setTravelTime(int travelTime)
-{
- m_travelTime = travelTime;
-}
-
-qreal QGeoRouteSegmentPrivateDefault::distance() const
-{
- return m_distance;
-}
-
-void QGeoRouteSegmentPrivateDefault::setDistance(qreal distance)
-{
- m_distance = distance;
-}
-
-QList<QGeoCoordinate> QGeoRouteSegmentPrivateDefault::path() const
-{
- return m_path;
-}
-
-void QGeoRouteSegmentPrivateDefault::setPath(const QList<QGeoCoordinate> &path)
-{
- m_path = path;
-}
-
-QGeoManeuver QGeoRouteSegmentPrivateDefault::maneuver() const
-{
- return m_maneuver;
-}
-
-void QGeoRouteSegmentPrivateDefault::setManeuver(const QGeoManeuver &maneuver)
-{
- m_maneuver = maneuver;
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
QT_END_NAMESPACE
#include "moc_qgeoroutesegment.cpp"
diff --git a/src/location/maps/qgeoroutesegment_p.h b/src/location/maps/qgeoroutesegment_p.h
index 3807d4b8..42cc428c 100644
--- a/src/location/maps/qgeoroutesegment_p.h
+++ b/src/location/maps/qgeoroutesegment_p.h
@@ -68,77 +68,38 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoRouteSegmentPrivate : public QSharedData
{
public:
QGeoRouteSegmentPrivate();
- QGeoRouteSegmentPrivate(const QGeoRouteSegmentPrivate &other);
- virtual ~QGeoRouteSegmentPrivate();
- virtual QGeoRouteSegmentPrivate *clone() = 0;
-
- bool operator ==(const QGeoRouteSegmentPrivate &other) const;
-
- virtual bool valid() const;
- virtual void setValid(bool valid);
-
- virtual bool isLegLastSegment() const;
- virtual void setLegLastSegment(bool lastSegment);
-
- virtual int travelTime() const;
- virtual void setTravelTime(int travelTime);
-
- virtual qreal distance() const;
- virtual void setDistance(qreal distance);
-
- virtual QList<QGeoCoordinate> path() const;
- virtual void setPath(const QList<QGeoCoordinate> &path);
-
- virtual QGeoManeuver maneuver() const;
- virtual void setManeuver(const QGeoManeuver &maneuver);
-
- virtual QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> nextRouteSegment() const;
- virtual void setNextRouteSegment(const QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> &next);
-
- QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> m_nextSegment;
static QGeoRouteSegmentPrivate *get(QGeoRouteSegment &segment);
-protected:
- virtual bool equals(const QGeoRouteSegmentPrivate &other) const;
-};
-
-
-
-class Q_LOCATION_PRIVATE_EXPORT QGeoRouteSegmentPrivateDefault : public QGeoRouteSegmentPrivate
-{
-public:
- QGeoRouteSegmentPrivateDefault();
- QGeoRouteSegmentPrivateDefault(const QGeoRouteSegmentPrivateDefault &other);
- ~QGeoRouteSegmentPrivateDefault();
- QGeoRouteSegmentPrivate *clone() override;
-
- bool operator ==(const QGeoRouteSegmentPrivateDefault &other) const;
-
- bool valid() const override;
- void setValid(bool valid) override;
+ bool valid() const;
+ void setValid(bool valid);
- bool isLegLastSegment() const override;
- void setLegLastSegment(bool lastSegment) override;
+ bool isLegLastSegment() const;
+ void setLegLastSegment(bool lastSegment);
- int travelTime() const override;
- void setTravelTime(int travelTime) override;
+ int travelTime() const;
+ void setTravelTime(int travelTime);
- qreal distance() const override;
- void setDistance(qreal distance) override;
+ qreal distance() const;
+ void setDistance(qreal distance);
- QList<QGeoCoordinate> path() const override;
- void setPath(const QList<QGeoCoordinate> &path) override;
+ QList<QGeoCoordinate> path() const;
+ void setPath(const QList<QGeoCoordinate> &path);
- QGeoManeuver maneuver() const override;
- void setManeuver(const QGeoManeuver &maneuver) override;
+ QGeoManeuver maneuver() const;
+ void setManeuver(const QGeoManeuver &maneuver);
+ QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> nextRouteSegment() const;
+ void setNextRouteSegment(const QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> &next);
- bool m_valid;
+ QExplicitlySharedDataPointer<QGeoRouteSegmentPrivate> m_nextSegment;
+ bool m_valid = false;
bool m_legLastSegment = false;
- int m_travelTime;
- qreal m_distance;
+ int m_travelTime = 0;
+ qreal m_distance = 0.0;
QList<QGeoCoordinate> m_path;
QGeoManeuver m_maneuver;
+
+ friend bool operator==(const QGeoRouteSegmentPrivate &lhs, const QGeoRouteSegmentPrivate &rhs);
};
QT_END_NAMESPACE