diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-29 11:23:01 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-08-03 15:02:26 +0200 |
commit | 9f40dfe98a7d7fc37e267160ce01a8e9dbd2282c (patch) | |
tree | 5444bebe0ceafeb002f100a539083fc64066d261 /src/location/maps/qgeoroute.h | |
parent | 117d4bf2bd04fb9702938233a00052b965c724a8 (diff) |
Modernize and clean up QGeoRoute(Leg)
Implement move semantics for QGeoRoute, make operators hidden friends,
and add noexcept to non-allocating functions.
Remove default-implemented constructors, operators, and destructor from
QGeoRouteLeg. That class would ideally go away so that we don't have to
subclass the QGeoRoute value type at all. The leg-data lives either way
in the QGeoRoutePrivate(Default), so making the design so that a route
can be a list of routes would remove the need for the Leg class.
However, that has repercussions to the QML types, tests, documentation
etc, and needs to be discussed further.
Pick-to: 6.2
Task-number: QTBUG-105206
Change-Id: I4c451a74fbf42e06b1580df46bbccca4b0de1723
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/location/maps/qgeoroute.h')
-rw-r--r-- | src/location/maps/qgeoroute.h | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/location/maps/qgeoroute.h b/src/location/maps/qgeoroute.h index ee1e8100..62d84b4b 100644 --- a/src/location/maps/qgeoroute.h +++ b/src/location/maps/qgeoroute.h @@ -50,20 +50,27 @@ QT_BEGIN_NAMESPACE class QGeoCoordinate; class QGeoRectangle; class QGeoRouteSegment; +class QGeoRouteLeg; class QGeoRoutePrivate; -class QGeoRouteLeg; +QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoRoutePrivate, Q_LOCATION_EXPORT) class Q_LOCATION_EXPORT QGeoRoute { public: QGeoRoute(); - QGeoRoute(const QGeoRoute &other); - ~QGeoRoute(); // ### Qt6: make this virtual + QGeoRoute(const QGeoRoute &other) noexcept; + QGeoRoute(QGeoRoute &&other) noexcept = default; + ~QGeoRoute(); - QGeoRoute &operator = (const QGeoRoute &other); + QGeoRoute &operator=(const QGeoRoute &other) noexcept; + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QGeoRoute) - bool operator == (const QGeoRoute &other) const; - bool operator != (const QGeoRoute &other) const; + void swap(QGeoRoute &other) noexcept { d_ptr.swap(other.d_ptr); } + + friend inline bool operator==(const QGeoRoute &lhs, const QGeoRoute &rhs) noexcept + { return lhs.isEqual(rhs); } + friend inline bool operator!=(const QGeoRoute &lhs, const QGeoRoute &rhs) noexcept + { return !lhs.isEqual(rhs); } void setRouteId(const QString &id); QString routeId() const; @@ -102,6 +109,8 @@ protected: private: QExplicitlySharedDataPointer<QGeoRoutePrivate> d_ptr; + bool isEqual(const QGeoRoute &other) const noexcept; + friend class QDeclarativeGeoRoute; friend class QGeoRoutePrivate; }; @@ -109,20 +118,13 @@ private: class Q_LOCATION_EXPORT QGeoRouteLeg: public QGeoRoute { public: - QGeoRouteLeg(); - QGeoRouteLeg(const QGeoRouteLeg &other); - QGeoRouteLeg &operator=(const QGeoRouteLeg &other) = default; - ~QGeoRouteLeg(); - void setLegIndex(int idx); int legIndex() const; void setOverallRoute(const QGeoRoute &route); QGeoRoute overallRoute() const; -protected: - QGeoRouteLeg(const QExplicitlySharedDataPointer<QGeoRoutePrivate> &dd); - +private: friend class QDeclarativeGeoRoute; friend class QGeoRoutePrivate; }; |