diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-10 22:51:53 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-16 12:58:46 +0200 |
commit | 17ac23d7ada8a89cd36a71c74627f0d767049414 (patch) | |
tree | cb48383533691737502191550e20c8a189f9a6ee /src/location/declarativemaps/qdeclarativegeoroute_p.h | |
parent | f170e6edbd6960abd8bc0b269118211c515c8587 (diff) | |
download | qtlocation-17ac23d7ada8a89cd36a71c74627f0d767049414.tar.gz |
Merge QGeoRouteLeg into QGeoRoute
QGeoRouteLeg was a subclass of QGeoRoute. Since QGeoRoute is a value
type, subclassing is problematic, even though QGeoRouteLeg had no data
of its own and only added public getters for data already carried by
QGeoRoutePrivate.
But if every leg is a route, with documentation pointing out that some
route-specific getters never return anything, then it's easier to just
add leg-specific APIs to QGeoRoute. A route is then a group of other
routes. Those route legs point back at the overall route, and know of
index within the overall route. Those leg-specific APIs return -1 for
the index and an empty overall route if the route is not a leg within
an overall route.
This saves a separate type with its own QDeclarative* wrapper, without
losing any expressiveness.
Task-number: QTBUG-105206
Change-Id: I8844290d245ed79215e6c7893d972e0da96ed197
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativegeoroute_p.h')
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeoroute_p.h | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeoroute_p.h b/src/location/declarativemaps/qdeclarativegeoroute_p.h index c3e6262f..a54143cc 100644 --- a/src/location/declarativemaps/qdeclarativegeoroute_p.h +++ b/src/location/declarativemaps/qdeclarativegeoroute_p.h @@ -63,7 +63,6 @@ Q_MOC_INCLUDE(<QtLocation/private/qdeclarativegeoroutemodel_p.h>) QT_BEGIN_NAMESPACE class QDeclarativeGeoRouteQuery; -class QDeclarativeGeoRouteLeg; class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRoute : public QObject { @@ -75,8 +74,11 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRoute : public QObject Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged) Q_PROPERTY(QList<QGeoRouteSegment> segments READ segments CONSTANT) Q_PROPERTY(QDeclarativeGeoRouteQuery *routeQuery READ routeQuery REVISION 11) - Q_PROPERTY(QList<QDeclarativeGeoRouteLeg *> legs READ legs CONSTANT REVISION 12) + Q_PROPERTY(QList<QDeclarativeGeoRoute *> legs READ legs CONSTANT REVISION 12) Q_PROPERTY(QObject *extendedAttributes READ extendedAttributes CONSTANT REVISION 13) + Q_PROPERTY(int legIndex READ legIndex CONSTANT) + Q_PROPERTY(QDeclarativeGeoRoute *overallRoute READ overallRoute CONSTANT) + public: explicit QDeclarativeGeoRoute(QObject *parent = 0); @@ -91,6 +93,8 @@ public: void setPath(const QList<QGeoCoordinate> &value); QList<QGeoRouteSegment> segments(); + int legIndex() const; + QDeclarativeGeoRoute *overallRoute() const; void appendSegment(const QGeoRouteSegment &segment); void clearSegments(); @@ -98,7 +102,7 @@ public: int segmentsCount() const; const QGeoRoute &route() const; QDeclarativeGeoRouteQuery *routeQuery(); - QList<QDeclarativeGeoRouteLeg *> legs(); + QList<QDeclarativeGeoRoute *> legs(); QQmlPropertyMap *extendedAttributes() const; Q_INVOKABLE bool equals(QDeclarativeGeoRoute *other) const; @@ -112,31 +116,12 @@ private: QGeoRoute route_; QDeclarativeGeoRouteQuery *routeQuery_ = nullptr; QList<QGeoRouteSegment> segments_; - QList<QDeclarativeGeoRouteLeg *> legs_; + QList<QDeclarativeGeoRoute *> legs_; QQmlPropertyMap *m_extendedAttributes = nullptr; friend class QDeclarativeRouteMapItem; }; -class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRouteLeg : public QDeclarativeGeoRoute -{ - Q_OBJECT - - Q_PROPERTY(int legIndex READ legIndex CONSTANT) - Q_PROPERTY(QObject * overallRoute READ overallRoute CONSTANT) - -public: - explicit QDeclarativeGeoRouteLeg(QObject *parent = nullptr); - QDeclarativeGeoRouteLeg(const QGeoRouteLeg &routeLeg, QObject *parent = nullptr); - ~QDeclarativeGeoRouteLeg() override; - - int legIndex() const; - QObject *overallRoute() const; - -private: - QGeoRouteLeg m_routeLeg; -}; - QT_END_NAMESPACE #endif |