diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-02 16:40:45 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-08 13:27:40 +0200 |
commit | 983b9729f18b1ab1d4734663dc15b4f79ffb08fb (patch) | |
tree | c0f9d039ea5ae42cef59c80795d99fff3b98779a | |
parent | 3c086d26838138492e8afcd766bcbdbbc17657fe (diff) | |
download | qtlocation-983b9729f18b1ab1d4734663dc15b4f79ffb08fb.tar.gz |
Register QGeoManeuver declaratively
Amend da10ee9b67aaf0c9218c2b891efa06b323866470 to register QGeoManeuver
also via Foreign types (both as a value type and a namespace), using
declarative type registration and generated plugin sources. Rename the
QML type to routeManeuver to follow naming convention.
Pick-to: 6.2
Change-Id: I98257c0ef4389e4de225c933425740a82161d5df
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/imports/location/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/imports/location/location.cpp | 8 | ||||
-rw-r--r-- | src/imports/location/location.h | 78 | ||||
-rw-r--r-- | src/location/doc/snippets/declarative/routing.qml | 6 | ||||
-rw-r--r-- | src/location/doc/src/maps.qdoc | 4 | ||||
-rw-r--r-- | src/location/doc/src/plugins/mapbox.qdoc | 2 | ||||
-rw-r--r-- | src/location/doc/src/qml-maps.qdoc | 2 | ||||
-rw-r--r-- | src/location/maps/qgeomaneuver.cpp | 28 |
8 files changed, 105 insertions, 25 deletions
diff --git a/src/imports/location/CMakeLists.txt b/src/imports/location/CMakeLists.txt index 6c749d72..27db08a7 100644 --- a/src/imports/location/CMakeLists.txt +++ b/src/imports/location/CMakeLists.txt @@ -6,7 +6,7 @@ qt_internal_add_qml_module(declarative_location NO_PLUGIN_OPTIONAL CLASS_NAME QtLocationDeclarativeModule SOURCES - location.cpp + location.h location.cpp LIBRARIES Qt::LocationPrivate Qt::Quick diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index 5365e17b..59724305 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtLocation module of the Qt Toolkit. @@ -76,6 +76,8 @@ #include <QtCore/QDebug> +#include "location.h" + QT_BEGIN_NAMESPACE @@ -114,8 +116,6 @@ public: qmlRegisterType<QDeclarativeGeoRouteQuery >(uri, major, minor, "RouteQuery"); qmlRegisterType<QDeclarativeGeoRoute >(uri, major, minor, "Route"); // data type qmlRegisterType<QDeclarativeGeoRouteSegment >(uri, major, minor, "RouteSegment"); - 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", @@ -157,6 +157,7 @@ public: //TODO: this is broken QTBUG-50990 qmlRegisterUncreatableType<QDeclarativeGeoMapType, 1>(uri, major, minor, "MapType", QStringLiteral("MapType is not intended instantiable by developer.")); + minor = 6; //TODO: this is broken QTBUG-50990 qmlRegisterUncreatableType<QQuickGeoMapGestureArea, 1>(uri, major, minor, "MapGestureArea", @@ -230,3 +231,4 @@ public: QT_END_NAMESPACE #include "location.moc" +#include "moc_location.cpp" diff --git a/src/imports/location/location.h b/src/imports/location/location.h new file mode 100644 index 00000000..4f682626 --- /dev/null +++ b/src/imports/location/location.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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 QTLOCATION_QMLTYPES_H +#define QTLOCATION_QMLTYPES_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 <QGeoManeuver> + +#include <QtLocation/private/qgeomaptype_p.h> + +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +struct QGeoManeuverForeign +{ + Q_GADGET + QML_FOREIGN(QGeoManeuver) + QML_NAMED_ELEMENT(routeManeuver) +}; + +namespace QGeoManeuverForeignNamespace +{ + Q_NAMESPACE + QML_FOREIGN_NAMESPACE(QGeoManeuver) + QML_NAMED_ELEMENT(RouteManeuver) +}; + +QT_END_NAMESPACE + +#endif // QTLOCATION_QMLTYPES_H diff --git a/src/location/doc/snippets/declarative/routing.qml b/src/location/doc/snippets/declarative/routing.qml index ae564704..3027b22b 100644 --- a/src/location/doc/snippets/declarative/routing.qml +++ b/src/location/doc/snippets/declarative/routing.qml @@ -99,15 +99,15 @@ Item { Text { text: (1 + index) + "." } Text { text: hasManeuver ? modelData.maneuver.instructionText : "" } //! [Route Maneuver List2] - property RouteManeuver routeManeuver: modelData.maneuver + property routeManeuver routeManeuver: modelData.maneuver property RouteSegment routeSegment: modelData - //! [RouteManeuver] + //! [routeManeuver] Text { text: "Distance till next maneuver: " + routeManeuver.distanceToNextInstruction + " meters, estimated time: " + routeManeuver.timeToNextInstruction + " seconds." } - //! [RouteManeuver] + //! [routeManeuver] //! [RouteSegment] Text { diff --git a/src/location/doc/src/maps.qdoc b/src/location/doc/src/maps.qdoc index d929b125..edddbb4f 100644 --- a/src/location/doc/src/maps.qdoc +++ b/src/location/doc/src/maps.qdoc @@ -160,7 +160,7 @@ Routing is the determination of a navigable path from one point to another on a map. Given a map that is aware of features that aid or hinder navigation, such as bridges, waterways and so on, a series of segments that make up the journey can be constructed. If these \l {RouteSegment}s are simple then we can -add navigation information at the connecting points, \l {RouteManeuver}s, +add navigation information at the connecting points, \l {routeManeuver}s, between the segments. \b{Key Types} @@ -172,7 +172,7 @@ between the segments. \li \l{QtLocation::RouteSegment}{RouteSegment} \li The individual components of a route. \row - \li \l{QtLocation::RouteManeuver}{RouteManeuver} + \li \l{QtLocation::routeManeuver}{routeManeuver} \li The navigation information that joins segments. \row \li \l{QtLocation::RouteModel}{RouteModel} diff --git a/src/location/doc/src/plugins/mapbox.qdoc b/src/location/doc/src/plugins/mapbox.qdoc index 3933b107..572ba8f2 100644 --- a/src/location/doc/src/plugins/mapbox.qdoc +++ b/src/location/doc/src/plugins/mapbox.qdoc @@ -165,7 +165,7 @@ The following table lists optional parameters that can be passed to the Mapbox p \section1 Extra routing attributes -When using this plugin, the RouteManeuver objects in the returned route may contain additional extended attributes (see \l RouteManeuver::extendedAttributes), +When using this plugin, the routeManeuver objects in the returned route may contain additional extended attributes (see \l routeManeuver::extendedAttributes), where available. These attributes are described in detail in the official \l{https://www.mapbox.com/api-documentation/#stepmaneuver-object}{Mapbox direction API documentation}. */ diff --git a/src/location/doc/src/qml-maps.qdoc b/src/location/doc/src/qml-maps.qdoc index 5e9c1162..2b160487 100644 --- a/src/location/doc/src/qml-maps.qdoc +++ b/src/location/doc/src/qml-maps.qdoc @@ -131,7 +131,7 @@ To find a suitable route we will need to use a \l RouteQuery to define the selection criteria and adding any required waypoints. The \l RouteModel should return a list of \l {RouteSegment}s that defines the route to the destination complete with navigation advice at the joins between -segments, called \l {RouteManeuver}s +segments, called \l {routeManeuver}s There are many options that you can add to the query to narrow the criteria. The \l RouteQuery properties can include diff --git a/src/location/maps/qgeomaneuver.cpp b/src/location/maps/qgeomaneuver.cpp index f50f6c8d..a841e543 100644 --- a/src/location/maps/qgeomaneuver.cpp +++ b/src/location/maps/qgeomaneuver.cpp @@ -75,19 +75,19 @@ QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoManeuverPrivate) */ /*! - \qmltype RouteManeuver + \qmltype routeManeuver \inqmlmodule QtLocation \ingroup qml-QtLocation5-routing \since QtLocation 5.5 - \brief The RouteManeuver type represents the information relevant to the + \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 + graph, with routeManeuver instances as optional labels attached to the vertices of the graph. - The most interesting information held in a RouteManeuver instance is + 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. @@ -99,7 +99,7 @@ QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoManeuverPrivate) \snippet declarative/routing.qml QtQuick import \snippet declarative/maps.qml QtLocation import \codeline - \snippet declarative/routing.qml RouteManeuver + \snippet declarative/routing.qml routeManeuver */ /*! @@ -199,7 +199,7 @@ bool QGeoManeuver::isEqual(const QGeoManeuver &other) const } /*! - \qmlproperty bool RouteManeuver::valid + \qmlproperty bool routeManeuver::valid This read-only property holds whether this maneuver is valid or not. @@ -220,7 +220,7 @@ bool QGeoManeuver::isValid() const } /*! - \qmlproperty coordinate RouteManeuver::position + \qmlproperty coordinate routeManeuver::position This read-only property holds where the \l instructionText should be displayed. @@ -242,7 +242,7 @@ QGeoCoordinate QGeoManeuver::position() const } /*! - \qmlproperty string RouteManeuver::instructionText + \qmlproperty string routeManeuver::instructionText This read-only property holds textual navigation instruction. */ @@ -263,10 +263,10 @@ QString QGeoManeuver::instructionText() const } /*! - \qmlproperty enumeration RouteManeuver::direction + \qmlproperty enumeration routeManeuver::direction Describes the change in direction associated with the instruction text - that is associated with a RouteManeuver. + that is associated with a routeManeuver. \list \li RouteManeuver.NoDirection - There is no direction associated with the instruction text @@ -300,7 +300,7 @@ QGeoManeuver::InstructionDirection QGeoManeuver::direction() const } /*! - \qmlproperty int RouteManeuver::timeToNextInstruction + \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 @@ -325,7 +325,7 @@ int QGeoManeuver::timeToNextInstruction() const } /*! - \qmlproperty real RouteManeuver::distanceToNextInstruction + \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 @@ -349,7 +349,7 @@ qreal QGeoManeuver::distanceToNextInstruction() const } /*! - \qmlproperty coordinate RouteManeuver::waypoint + \qmlproperty coordinate routeManeuver::waypoint This property holds the waypoint associated with this maneuver. Not all maneuvers have a waypoint associated with them. @@ -374,7 +374,7 @@ QGeoCoordinate QGeoManeuver::waypoint() const } /*! - \qmlproperty Object RouteManeuver::extendedAttributes + \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. |