summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-08-30 15:07:08 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-01 12:03:44 +0000
commit6f1d4706abdc5bb2287c601792b6d1d846baaed8 (patch)
tree24cc31155d6a8f4ac39e507c9b32f2c5ff08c790
parent3954800847f13b622d3b2d914cb28b823da361a6 (diff)
downloadqtlocation-6f1d4706abdc5bb2287c601792b6d1d846baaed8.tar.gz
Remove QDeclarativeGeoManeuver
Register the QGeoManeuver type directly as the RouteManeuver QML type, and use it in QDeclarativeGeoRouteSegment. The type is now uncreatable. It wasn't in Qt 5.15, but since there is no setter-API that is exposed to QML (QDeclarativeGeoRouteSegment::maneuver is a read-only property tagged as CONSTANT), there is no point in creating a RouteManeuver object in QML anyway. The QML tests can get a default-created QGeoManeuever from an empty route segment. Document the C++ properties via \property, move the QML type documentation into the qgeomaneuver.cpp file, and unify the language. Note: The QML type should be routeManeuver, as value types should start with a lower-case character. If we make that change, it will be in a separate, compatibility-breaking commit for all the value types. Change-Id: I277e7011f2082e2da9e0141db9bad0a60a524c88 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit da10ee9b67aaf0c9218c2b891efa06b323866470) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/imports/location/location.cpp7
-rw-r--r--src/location/CMakeLists.txt1
-rw-r--r--src/location/declarativemaps/qdeclarativegeomaneuver.cpp232
-rw-r--r--src/location/declarativemaps/qdeclarativegeomaneuver_p.h121
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroute_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutesegment.cpp7
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutesegment_p.h7
-rw-r--r--src/location/maps/qgeomaneuver.cpp176
-rw-r--r--src/location/maps/qgeomaneuver.h9
-rw-r--r--tests/auto/declarative_location_core/tst_routing.qml5
-rw-r--r--tests/auto/qgeomaneuver/tst_qgeomaneuver.h1
11 files changed, 153 insertions, 414 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 9b6cf66b..c4ac695a 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -44,7 +44,6 @@
#include <QtLocation/private/qdeclarativegeoroute_p.h>
#include <QtLocation/private/qdeclarativegeoroutemodel_p.h>
#include <QtLocation/private/qdeclarativegeocodemodel_p.h>
-#include <QtLocation/private/qdeclarativegeomaneuver_p.h>
#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
#include <QtLocation/private/qdeclarativegeomapquickitem_p.h>
#include <QtLocation/private/qdeclarativegeomapitemview_p.h>
@@ -116,7 +115,8 @@ public:
qmlRegisterType<QDeclarativeGeoRouteQuery >(uri, major, minor, "RouteQuery");
qmlRegisterType<QDeclarativeGeoRoute >(uri, major, minor, "Route"); // data type
qmlRegisterType<QDeclarativeGeoRouteSegment >(uri, major, minor, "RouteSegment");
- qmlRegisterType<QDeclarativeGeoManeuver >(uri, major, minor, "RouteManeuver");
+ qmlRegisterUncreatableType<QGeoManeuver >(uri, major, minor, "RouteManeuver",
+ QStringLiteral("RouteManeuver is not intended instantiable by developer."));
qmlRegisterUncreatableType<QGeoMapPinchEvent >(uri, major, minor, "MapPinchEvent",
QStringLiteral("(Map)PinchEvent is not intended instantiable by developer."));
qmlRegisterUncreatableType<QQuickGeoMapGestureArea>(uri, major, minor, "MapGestureArea",
@@ -164,8 +164,6 @@ public:
QStringLiteral("(Map)GestureArea is not intended instantiable by developer."));
// Register the 5.8 types
- minor = 8;
- qmlRegisterType<QDeclarativeGeoManeuver>(uri, major, minor, "RouteManeuver");
// Register the 5.9 types
minor = 9;
@@ -176,7 +174,6 @@ public:
// Register the 5.11 types
minor = 11;
qmlRegisterAnonymousType<QGeoMapObject>(uri, major);
- qmlRegisterType<QDeclarativeGeoManeuver, 11>(uri, major, minor, "RouteManeuver");
qmlRegisterType<QDeclarativeGeoMap, 11>(uri, major, minor, "Map");
qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 11>(uri, major, minor, "GeoMapItemBase",
QStringLiteral("GeoMapItemBase is not intended instantiable by developer."));
diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt
index 3a2e5571..4d548c80 100644
--- a/src/location/CMakeLists.txt
+++ b/src/location/CMakeLists.txt
@@ -126,7 +126,6 @@ qt_internal_add_module(Location
declarativemaps/qdeclarativepolygonmapitem.cpp
declarativemaps/qdeclarativepolygonmapitem_p.h
declarativemaps/qdeclarativepolygonmapitem_p_p.h
- declarativemaps/qdeclarativegeomaneuver.cpp declarativemaps/qdeclarativegeomaneuver_p.h
declarativemaps/qdeclarativegeoroute.cpp declarativemaps/qdeclarativegeoroute_p.h
declarativemaps/qdeclarativegeoroutemodel.cpp declarativemaps/qdeclarativegeoroutemodel_p.h
declarativemaps/qgeosimplify.cpp declarativemaps/qgeosimplify_p.h
diff --git a/src/location/declarativemaps/qdeclarativegeomaneuver.cpp b/src/location/declarativemaps/qdeclarativegeomaneuver.cpp
deleted file mode 100644
index 9c17c8ac..00000000
--- a/src/location/declarativemaps/qdeclarativegeomaneuver.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativegeomaneuver_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype RouteManeuver
- \instantiates QDeclarativeGeoManeuver
- \inqmlmodule QtLocation
- \ingroup qml-QtLocation5-routing
- \since QtLocation 5.5
-
- \brief The RouteManeuver type represents the information relevant to the
- point at which two RouteSegments meet.
-
- RouteSegment instances can be thought of as edges on a routing
- graph, with RouteManeuver instances as optional labels attached to the
- vertices of the graph.
-
- The most interesting information held in a RouteManeuver instance is
- normally the textual navigation to provide and the position at which to
- provide it, accessible by \l instructionText and \l position respectively.
-
- \section1 Example
-
- The following QML snippet demonstrates how to print information about a
- route maneuver:
-
- \snippet declarative/routing.qml QtQuick import
- \snippet declarative/maps.qml QtLocation import
- \codeline
- \snippet declarative/routing.qml RouteManeuver
-*/
-
-QDeclarativeGeoManeuver::QDeclarativeGeoManeuver(QObject *parent)
- : QObject(parent)
-{
-}
-
-QDeclarativeGeoManeuver::QDeclarativeGeoManeuver(const QGeoManeuver &maneuver, QObject *parent)
- : QObject(parent),
- maneuver_(maneuver)
-{
-}
-
-QDeclarativeGeoManeuver::~QDeclarativeGeoManeuver() {}
-
-/*!
- \qmlproperty bool RouteManeuver::valid
-
- This read-only property holds whether this maneuver is valid or not.
-
- Invalid maneuvers are used when there is no information
- that needs to be attached to the endpoint of a QGeoRouteSegment instance.
-*/
-
-bool QDeclarativeGeoManeuver::valid() const
-{
- return maneuver_.isValid();
-}
-
-/*!
- \qmlproperty coordinate RouteManeuver::position
-
- This read-only property holds where the \l instructionText should be displayed.
-
-*/
-
-QGeoCoordinate QDeclarativeGeoManeuver::position() const
-{
- return maneuver_.position();
-}
-
-/*!
- \qmlproperty string RouteManeuver::instructionText
-
- This read-only property holds textual navigation instruction.
-*/
-
-QString QDeclarativeGeoManeuver::instructionText() const
-{
- return maneuver_.instructionText();
-}
-
-/*!
- \qmlproperty enumeration RouteManeuver::direction
-
- Describes the change in direction associated with the instruction text
- that is associated with a RouteManeuver.
-
- \list
- \li RouteManeuver.NoDirection - There is no direction associated with the instruction text
- \li RouteManeuver.DirectionForward - The instruction indicates that the direction of travel does not need to change
- \li RouteManeuver.DirectionBearRight - The instruction indicates that the direction of travel should bear to the right
- \li RouteManeuver.DirectionLightRight - The instruction indicates that a light turn to the right is required
- \li RouteManeuver.DirectionRight - The instruction indicates that a turn to the right is required
- \li RouteManeuver.DirectionHardRight - The instruction indicates that a hard turn to the right is required
- \li RouteManeuver.DirectionUTurnRight - The instruction indicates that a u-turn to the right is required
- \li RouteManeuver.DirectionUTurnLeft - The instruction indicates that a u-turn to the left is required
- \li RouteManeuver.DirectionHardLeft - The instruction indicates that a hard turn to the left is required
- \li RouteManeuver.DirectionLeft - The instruction indicates that a turn to the left is required
- \li RouteManeuver.DirectionLightLeft - The instruction indicates that a light turn to the left is required
- \li RouteManeuver.DirectionBearLeft - The instruction indicates that the direction of travel should bear to the left
- \endlist
-*/
-
-QDeclarativeGeoManeuver::Direction QDeclarativeGeoManeuver::direction() const
-{
- return QDeclarativeGeoManeuver::Direction(maneuver_.direction());
-}
-
-/*!
- \qmlproperty int RouteManeuver::timeToNextInstruction
-
- This read-only property holds the estimated time it will take to travel
- from the point at which the associated instruction was issued and the
- point that the next instruction should be issued, in seconds.
-*/
-
-int QDeclarativeGeoManeuver::timeToNextInstruction() const
-{
- return maneuver_.timeToNextInstruction();
-}
-
-/*!
- \qmlproperty real RouteManeuver::distanceToNextInstruction
-
- This read-only property holds the distance, in meters, between the point at which
- the associated instruction was issued and the point that the next instruction should
- be issued.
-*/
-
-qreal QDeclarativeGeoManeuver::distanceToNextInstruction() const
-{
- return maneuver_.distanceToNextInstruction();
-}
-
-/*!
- \qmlproperty coordinate RouteManeuver::waypoint
-
- This property holds the waypoint associated with this maneuver.
- All maneuvers do not have a waypoint associated with them, this
- can be checked with \l waypointValid.
-
-*/
-
-QGeoCoordinate QDeclarativeGeoManeuver::waypoint() const
-{
- return maneuver_.waypoint();
-}
-
-/*!
- \qmlproperty Object RouteManeuver::extendedAttributes
-
- This property holds the extended attributes of the maneuver and is a map.
- These attributes are plugin specific, and can be empty.
-
- Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation}
- for what attributes are supported and how they should be used.
-
- Note, due to limitations of the QQmlPropertyMap, it is not possible
- to declaratively specify the attributes in QML, assignment of attributes keys
- and values can only be accomplished by JavaScript.
-
- \since QtLocation 5.11
-*/
-QQmlPropertyMap *QDeclarativeGeoManeuver::extendedAttributes() const
-{
- if (!m_extendedAttributes) {
- QDeclarativeGeoManeuver *self = const_cast<QDeclarativeGeoManeuver *>(this);
- self->m_extendedAttributes = new QQmlPropertyMap(self);
- // Fill it
- const QStringList keys = maneuver_.extendedAttributes().keys();
- for (const QString &key: keys) {
- self->m_extendedAttributes->insert(key,
- maneuver_.extendedAttributes().value(key));
- }
- }
- return m_extendedAttributes;
-}
-
-/*!
- \qmlproperty bool RouteManeuver::waypointValid
-
- This read-only property holds whether this \l waypoint, associated with this
- maneuver, is valid or not.
-*/
-
-bool QDeclarativeGeoManeuver::waypointValid() const
-{
- return maneuver_.waypoint().isValid();
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomaneuver_p.h b/src/location/declarativemaps/qdeclarativegeomaneuver_p.h
deleted file mode 100644
index 22aebcbf..00000000
--- a/src/location/declarativemaps/qdeclarativegeomaneuver_p.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEGEOMANEUVER_H
-#define QDECLARATIVEGEOMANEUVER_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtLocation/private/qlocationglobal_p.h>
-#include <QtLocation/qgeomaneuver.h>
-#include <QtQml/QQmlPropertyMap>
-#include <QtPositioning/QGeoCoordinate>
-
-#include <QObject>
-
-
-QT_BEGIN_NAMESPACE
-
-class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoManeuver : public QObject
-{
- Q_OBJECT
- Q_ENUMS(Direction)
-
- Q_PROPERTY(bool valid READ valid CONSTANT)
- Q_PROPERTY(QGeoCoordinate position READ position CONSTANT)
- Q_PROPERTY(QString instructionText READ instructionText CONSTANT)
- Q_PROPERTY(Direction direction READ direction CONSTANT)
- Q_PROPERTY(int timeToNextInstruction READ timeToNextInstruction CONSTANT)
- Q_PROPERTY(qreal distanceToNextInstruction READ distanceToNextInstruction CONSTANT)
- Q_PROPERTY(QGeoCoordinate waypoint READ waypoint CONSTANT)
- Q_PROPERTY(bool waypointValid READ waypointValid CONSTANT)
- Q_PROPERTY(QObject *extendedAttributes READ extendedAttributes NOTIFY extendedAttributesChanged REVISION 11)
-
-public:
- enum Direction {
- NoDirection = QGeoManeuver::NoDirection,
- DirectionForward = QGeoManeuver::DirectionForward,
- DirectionBearRight = QGeoManeuver::DirectionBearRight,
- DirectionLightRight = QGeoManeuver::DirectionLightRight,
- DirectionRight = QGeoManeuver::DirectionRight,
- DirectionHardRight = QGeoManeuver::DirectionHardRight,
- DirectionUTurnRight = QGeoManeuver::DirectionUTurnRight,
- DirectionUTurnLeft = QGeoManeuver::DirectionUTurnLeft,
- DirectionHardLeft = QGeoManeuver::DirectionHardLeft,
- DirectionLeft = QGeoManeuver::DirectionLeft,
- DirectionLightLeft = QGeoManeuver::DirectionLightLeft,
- DirectionBearLeft = QGeoManeuver::DirectionBearLeft
- };
-
- explicit QDeclarativeGeoManeuver(QObject *parent = 0);
- QDeclarativeGeoManeuver(const QGeoManeuver &maneuver, QObject *parent = 0);
- ~QDeclarativeGeoManeuver();
-
- bool valid() const;
- bool waypointValid() const;
-
- QGeoCoordinate position() const;
- QString instructionText() const;
- Direction direction() const;
- int timeToNextInstruction() const;
- qreal distanceToNextInstruction() const;
- QGeoCoordinate waypoint() const;
- QQmlPropertyMap *extendedAttributes() const;
-
-Q_SIGNALS:
- void extendedAttributesChanged(); //in practice is never emitted since parameters cannot be re-assigned
- //the declaration is needed to avoid warnings about non-notifyable properties
-
-private:
- QGeoManeuver maneuver_;
- QQmlPropertyMap *m_extendedAttributes = nullptr;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/declarativemaps/qdeclarativegeoroute_p.h b/src/location/declarativemaps/qdeclarativegeoroute_p.h
index a53f38a8..4e64949b 100644
--- a/src/location/declarativemaps/qdeclarativegeoroute_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoroute_p.h
@@ -56,6 +56,7 @@
#include <QtCore/QObject>
#include <QtQml/QQmlListProperty>
+#include <QtQml/QQmlPropertyMap>
#include <QtLocation/QGeoRoute>
Q_MOC_INCLUDE(<QtLocation/private/qdeclarativegeoroutemodel_p.h>)
diff --git a/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp b/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp
index d6cd3cf8..7a910f85 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp
@@ -41,6 +41,7 @@
#include <QtQml/QQmlEngine>
#include <QtQml/private/qqmlengine_p.h>
+#include <QtPositioning/QGeoCoordinate>
QT_BEGIN_NAMESPACE
@@ -78,7 +79,6 @@ QT_BEGIN_NAMESPACE
QDeclarativeGeoRouteSegment::QDeclarativeGeoRouteSegment(QObject *parent)
: QObject(parent)
{
- maneuver_ = new QDeclarativeGeoManeuver(this);
}
QDeclarativeGeoRouteSegment::QDeclarativeGeoRouteSegment(const QGeoRouteSegment &segment,
@@ -86,7 +86,6 @@ QDeclarativeGeoRouteSegment::QDeclarativeGeoRouteSegment(const QGeoRouteSegment
: QObject(parent),
segment_(segment)
{
- maneuver_ = new QDeclarativeGeoManeuver(segment_.maneuver(), this);
}
QDeclarativeGeoRouteSegment::~QDeclarativeGeoRouteSegment() {}
@@ -125,9 +124,9 @@ qreal QDeclarativeGeoRouteSegment::distance() const
of this route segment.
*/
-QDeclarativeGeoManeuver *QDeclarativeGeoRouteSegment::maneuver() const
+QGeoManeuver QDeclarativeGeoRouteSegment::maneuver() const
{
- return maneuver_;
+ return segment_.maneuver();
}
/*!
diff --git a/src/location/declarativemaps/qdeclarativegeoroutesegment_p.h b/src/location/declarativemaps/qdeclarativegeoroutesegment_p.h
index fdb09cc0..a531b022 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutesegment_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoroutesegment_p.h
@@ -52,11 +52,11 @@
//
#include <QtLocation/private/qlocationglobal_p.h>
-#include <QtLocation/private/qdeclarativegeomaneuver_p.h>
#include <QtCore/QObject>
#include <QtQml/qjsvalue.h>
#include <QtLocation/QGeoRouteSegment>
+#include <QtLocation/QGeoManeuver>
QT_BEGIN_NAMESPACE
@@ -67,7 +67,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRouteSegment : public QObject
Q_PROPERTY(int travelTime READ travelTime CONSTANT)
Q_PROPERTY(qreal distance READ distance CONSTANT)
Q_PROPERTY(QJSValue path READ path CONSTANT)
- Q_PROPERTY(QDeclarativeGeoManeuver *maneuver READ maneuver CONSTANT)
+ Q_PROPERTY(QGeoManeuver maneuver READ maneuver CONSTANT)
public:
explicit QDeclarativeGeoRouteSegment(QObject *parent = 0);
@@ -77,11 +77,10 @@ public:
int travelTime() const;
qreal distance() const;
QJSValue path() const;
- QDeclarativeGeoManeuver *maneuver() const;
+ QGeoManeuver maneuver() const;
private:
QGeoRouteSegment segment_;
- QDeclarativeGeoManeuver *maneuver_;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomaneuver.cpp b/src/location/maps/qgeomaneuver.cpp
index e427e0e1..f50f6c8d 100644
--- a/src/location/maps/qgeomaneuver.cpp
+++ b/src/location/maps/qgeomaneuver.cpp
@@ -75,6 +75,34 @@ QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoManeuverPrivate)
*/
/*!
+ \qmltype RouteManeuver
+ \inqmlmodule QtLocation
+ \ingroup qml-QtLocation5-routing
+ \since QtLocation 5.5
+
+ \brief The RouteManeuver type represents the information relevant to the
+ point at which two RouteSegments meet.
+
+ RouteSegment instances can be thought of as edges on a routing
+ graph, with RouteManeuver instances as optional labels attached to the
+ vertices of the graph.
+
+ The most interesting information held in a RouteManeuver instance is
+ normally the textual navigation to provide and the position at which to
+ provide it, accessible by \l instructionText and \l position respectively.
+
+ \section1 Example
+
+ The following QML snippet demonstrates how to print information about a
+ route maneuver:
+
+ \snippet declarative/routing.qml QtQuick import
+ \snippet declarative/maps.qml QtLocation import
+ \codeline
+ \snippet declarative/routing.qml RouteManeuver
+*/
+
+/*!
\enum QGeoManeuver::InstructionDirection
Describes the change in direction associated with the instruction text
@@ -171,7 +199,17 @@ bool QGeoManeuver::isEqual(const QGeoManeuver &other) const
}
/*!
- Returns whether this maneuver is valid or not.
+ \qmlproperty bool RouteManeuver::valid
+
+ This read-only property holds whether this maneuver is valid or not.
+
+ Invalid maneuvers are used when there is no information
+ that needs to be attached to the endpoint of a QGeoRouteSegment instance.
+*/
+
+/*!
+ \property QGeoManeuver::valid
+ \brief whether this maneuver is valid or not.
Invalid maneuvers are used when there is no information
that needs to be attached to the endpoint of a QGeoRouteSegment instance.
@@ -182,8 +220,15 @@ bool QGeoManeuver::isValid() const
}
/*!
- Sets the position where instructionText() should be displayed to \a
- position.
+ \qmlproperty coordinate RouteManeuver::position
+
+ This read-only property holds where the \l instructionText should be displayed.
+
+*/
+
+/*!
+ \property QGeoManeuver::position
+ \brief the position where \l instructionText should be displayed.
*/
void QGeoManeuver::setPosition(const QGeoCoordinate &position)
{
@@ -191,16 +236,20 @@ void QGeoManeuver::setPosition(const QGeoCoordinate &position)
d_ptr->setPosition(position);
}
-/*!
- Returns the position where instructionText() should be displayed.
-*/
QGeoCoordinate QGeoManeuver::position() const
{
return d_ptr->position();
}
/*!
- Sets the textual navigation instructions to \a instructionText.
+ \qmlproperty string RouteManeuver::instructionText
+
+ This read-only property holds textual navigation instruction.
+*/
+
+/*!
+ \property QGeoManeuver::instructionText
+ \brief the textual navigation instructions.
*/
void QGeoManeuver::setInstructionText(const QString &instructionText)
{
@@ -208,17 +257,36 @@ void QGeoManeuver::setInstructionText(const QString &instructionText)
d_ptr->setText(instructionText);
}
-/*!
- Returns the textual navigation instructions.
-*/
QString QGeoManeuver::instructionText() const
{
return d_ptr->text();
}
/*!
- Sets the direction associated with the associated instruction to \a
- direction.
+ \qmlproperty enumeration RouteManeuver::direction
+
+ Describes the change in direction associated with the instruction text
+ that is associated with a RouteManeuver.
+
+ \list
+ \li RouteManeuver.NoDirection - There is no direction associated with the instruction text
+ \li RouteManeuver.DirectionForward - The instruction indicates that the direction of travel does not need to change
+ \li RouteManeuver.DirectionBearRight - The instruction indicates that the direction of travel should bear to the right
+ \li RouteManeuver.DirectionLightRight - The instruction indicates that a light turn to the right is required
+ \li RouteManeuver.DirectionRight - The instruction indicates that a turn to the right is required
+ \li RouteManeuver.DirectionHardRight - The instruction indicates that a hard turn to the right is required
+ \li RouteManeuver.DirectionUTurnRight - The instruction indicates that a u-turn to the right is required
+ \li RouteManeuver.DirectionUTurnLeft - The instruction indicates that a u-turn to the left is required
+ \li RouteManeuver.DirectionHardLeft - The instruction indicates that a hard turn to the left is required
+ \li RouteManeuver.DirectionLeft - The instruction indicates that a turn to the left is required
+ \li RouteManeuver.DirectionLightLeft - The instruction indicates that a light turn to the left is required
+ \li RouteManeuver.DirectionBearLeft - The instruction indicates that the direction of travel should bear to the left
+ \endlist
+*/
+
+/*!
+ \property QGeoManeuver::direction
+ \brief the direction associated with the associated instruction.
*/
void QGeoManeuver::setDirection(QGeoManeuver::InstructionDirection direction)
{
@@ -226,18 +294,24 @@ void QGeoManeuver::setDirection(QGeoManeuver::InstructionDirection direction)
d_ptr->setDirection(direction);
}
-/*!
- Returns the direction associated with the associated instruction.
-*/
QGeoManeuver::InstructionDirection QGeoManeuver::direction() const
{
return d_ptr->direction();
}
/*!
- Sets the estimated time it will take to travel from the point at which the
- associated instruction was issued and the point that the next instruction
- should be issued, in seconds, to \a secs.
+ \qmlproperty int RouteManeuver::timeToNextInstruction
+
+ This read-only property holds the estimated time, in seconds, that it will take
+ to travel from the point at which the associated instruction was issued
+ to the point at which the next instruction should be issued, in seconds.
+*/
+
+/*!
+ \property QGeoManeuver::timeToNextInstruction
+ \brief the estimated time, in seconds, that it will take to travel from the
+ point at which the associated instruction was issued to the point at which the
+ next instruction should be issued.
*/
void QGeoManeuver::setTimeToNextInstruction(int secs)
{
@@ -245,20 +319,23 @@ void QGeoManeuver::setTimeToNextInstruction(int secs)
d_ptr->setTimeToNextInstruction(secs);
}
-/*!
- Returns the estimated time it will take to travel from the point at which
- the associated instruction was issued and the point that the next
- instruction should be issued, in seconds.
-*/
int QGeoManeuver::timeToNextInstruction() const
{
return d_ptr->timeToNextInstruction();
}
/*!
- Sets the distance, in meters, between the point at which the associated
- instruction was issued and the point that the next instruction should be
- issued to \a distance.
+ \qmlproperty real RouteManeuver::distanceToNextInstruction
+
+ This read-only property holds the distance, in meters, between the point at which
+ the associated instruction was issued and the point that the next instruction should
+ be issued.
+*/
+
+/*!
+ \property QGeoManeuver::distanceToNextInstruction
+ \brief the distance, in meters, between the point at which this instruction was
+ issued, and the point at which the next instruction should be issued.
*/
void QGeoManeuver::setDistanceToNextInstruction(qreal distance)
{
@@ -266,18 +343,24 @@ void QGeoManeuver::setDistanceToNextInstruction(qreal distance)
d_ptr->setDistanceToNextInstruction(distance);
}
-/*!
- Returns the distance, in meters, between the point at which the associated
- instruction was issued and the point that the next instruction should be
- issued.
-*/
qreal QGeoManeuver::distanceToNextInstruction() const
{
return d_ptr->distanceToNextInstruction();
}
/*!
- Sets the waypoint associated with this maneuver to \a coordinate.
+ \qmlproperty coordinate RouteManeuver::waypoint
+
+ This property holds the waypoint associated with this maneuver.
+ Not all maneuvers have a waypoint associated with them.
+*/
+
+/*!
+ \property QGeoManeuver::waypoint
+ \brief the waypoint associated with this maneuver.
+
+ If there is not waypoint associated with this maneuver, then this
+ property holds an invalid QGeoCoordinate.
*/
void QGeoManeuver::setWaypoint(const QGeoCoordinate &coordinate)
{
@@ -285,33 +368,38 @@ void QGeoManeuver::setWaypoint(const QGeoCoordinate &coordinate)
d_ptr->setWaypoint(coordinate);
}
-/*!
- Returns the waypoint associated with this maneuver.
-
- If there is not waypoint associated with this maneuver an invalid
- QGeoCoordinate will be returned.
-*/
QGeoCoordinate QGeoManeuver::waypoint() const
{
return d_ptr->waypoint();
}
/*!
- Sets the extended attributes \a extendedAttributes associated with this maneuver.
+ \qmlproperty Object RouteManeuver::extendedAttributes
+
+ This property holds the extended attributes of the maneuver and is a map.
+ These attributes are plugin specific, and can be empty.
+
+ Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation}
+ for what attributes are supported and how they should be used.
+
+ Note, due to limitations of the QQmlPropertyMap, it is not possible
+ to declaratively specify the attributes in QML, assignment of attributes keys
+ and values can only be accomplished by JavaScript.
\since QtLocation 5.11
*/
+
+/*!
+ \property QGeoManeuver::extendedAttributes
+ \brief the extended attributes associated with this maneuver.
+ \since QtLocation 5.11
+*/
void QGeoManeuver::setExtendedAttributes(const QVariantMap &extendedAttributes)
{
d_ptr->setValid(true);
d_ptr->setExtendedAttributes(extendedAttributes);
}
-/*!
- Returns the extended attributes associated with this maneuver.
-
- \since QtLocation 5.11
-*/
QVariantMap QGeoManeuver::extendedAttributes() const
{
return d_ptr->extendedAttributes();
diff --git a/src/location/maps/qgeomaneuver.h b/src/location/maps/qgeomaneuver.h
index 389c8824..d6856b24 100644
--- a/src/location/maps/qgeomaneuver.h
+++ b/src/location/maps/qgeomaneuver.h
@@ -42,6 +42,7 @@
#include <QtCore/QObject>
#include <QtCore/qshareddata.h>
+#include <QtQml/qqml.h>
#include <QtLocation/qlocationglobal.h>
QT_BEGIN_NAMESPACE
@@ -64,6 +65,9 @@ class Q_LOCATION_EXPORT QGeoManeuver
Q_PROPERTY(qreal distanceToNextInstruction READ distanceToNextInstruction CONSTANT)
Q_PROPERTY(QGeoCoordinate waypoint READ waypoint CONSTANT)
Q_PROPERTY(QVariantMap extendedAttributes READ extendedAttributes CONSTANT)
+
+ QML_NAMED_ELEMENT(RouteManeuver)
+
public:
enum InstructionDirection {
NoDirection,
@@ -124,6 +128,11 @@ private:
bool isEqual(const QGeoManeuver &other) const;
};
+Q_DECLARE_SHARED(QGeoManeuver)
+
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QGeoManeuver)
+Q_DECLARE_METATYPE(QGeoManeuver::InstructionDirection)
+
#endif
diff --git a/tests/auto/declarative_location_core/tst_routing.qml b/tests/auto/declarative_location_core/tst_routing.qml
index 0c30fb43..2540a54c 100644
--- a/tests/auto/declarative_location_core/tst_routing.qml
+++ b/tests/auto/declarative_location_core/tst_routing.qml
@@ -78,7 +78,6 @@ Item {
TestCase {
name: "RouteManeuver RouteSegment and MapRoute"
RouteSegment {id: emptySegment}
- RouteManeuver {id: emptyManeuver}
// TODO enable when we have map route
//MapRoute {id: emptyMapRoute}
@@ -136,14 +135,16 @@ Item {
}
function test_routesegment_defaults() {
+ let emptyManeuver = emptySegment.maneuver
compare(emptySegment.travelTime, 0)
compare(emptySegment.distance, 0)
compare(emptySegment.path.length, 0)
compare(emptySegment.maneuver.valid, emptyManeuver.valid)
compare(emptySegment.maneuver.instructionText, emptyManeuver.instructionText)
- compare(emptySegment.maneuver.waypointValid, emptyManeuver.waypointValid)
+ compare(emptySegment.maneuver.waypoint.valid, emptyManeuver.waypoint.valid)
}
function test_maneuver_defaults() {
+ let emptyManeuver = emptySegment.maneuver
compare(emptyManeuver.valid, false)
compare(emptyManeuver.instructionText, "")
compare(emptyManeuver.direction, RouteManeuver.NoDirection)
diff --git a/tests/auto/qgeomaneuver/tst_qgeomaneuver.h b/tests/auto/qgeomaneuver/tst_qgeomaneuver.h
index 87168838..41c704e8 100644
--- a/tests/auto/qgeomaneuver/tst_qgeomaneuver.h
+++ b/tests/auto/qgeomaneuver/tst_qgeomaneuver.h
@@ -67,7 +67,6 @@ private Q_SLOTS:
};
Q_DECLARE_METATYPE( QList<double>);
-Q_DECLARE_METATYPE (QGeoManeuver::InstructionDirection);
#endif // TST_QGEOMANEUVER_H