diff options
Diffstat (limited to 'src/positioningquick')
21 files changed, 0 insertions, 4942 deletions
diff --git a/src/positioningquick/CMakeLists.txt b/src/positioningquick/CMakeLists.txt deleted file mode 100644 index 28375160..00000000 --- a/src/positioningquick/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# Generated from positioningquick.pro. - -##################################################################### -## PositioningQuick Module: -##################################################################### - -qt_internal_add_qml_module(PositioningQuick - URI QtPositioning - VERSION ${CMAKE_PROJECT_VERSION} - PLUGIN_TARGET positioningquickplugin - NO_GENERATE_PLUGIN_SOURCE - NO_PLUGIN_OPTIONAL - CLASS_NAME QtPositioningDeclarativeModule - SOURCES - qdeclarativegeoaddress_p.h qdeclarativegeoaddress.cpp - qdeclarativegeolocation_p.h qdeclarativegeolocation.cpp - qdeclarativepluginparameter_p.h qdeclarativepluginparameter.cpp - qdeclarativeposition_p.h qdeclarativeposition.cpp - qdeclarativepositionsource_p.h qdeclarativepositionsource.cpp - qquickgeocoordinateanimation_p.h qquickgeocoordinateanimation.cpp - locationsingleton_p.h locationsingleton.cpp - qquickgeocoordinateanimation_p_p.h - qpositioningquickglobal.h - qpositioningquickglobal_p.h - qpositioningquickmodule_p.h - LIBRARIES - Qt::PositioningPrivate - Qt::QuickPrivate - PUBLIC_LIBRARIES - Qt::Core - Qt::Positioning - Qt::Qml - Qt::Quick - PRIVATE_MODULE_INTERFACE - Qt::PositioningPrivate - Qt::QuickPrivate -) - -qt_internal_extend_target(positioningquickplugin - SOURCES - positioningplugin.cpp - LIBRARIES - Qt::PositioningQuickPrivate - Qt::Quick -) - diff --git a/src/positioningquick/locationsingleton.cpp b/src/positioningquick/locationsingleton.cpp deleted file mode 100644 index 81ca3eda..00000000 --- a/src/positioningquick/locationsingleton.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 "locationsingleton_p.h" -#include <QtPositioning/private/qwebmercator_p.h> -#include <QtPositioning/private/qdoublevector2d_p.h> -#include <QDebug> - -static QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok) -{ - QGeoCoordinate c; - - if (value.isObject()) { - if (value.hasProperty(QStringLiteral("latitude"))) - c.setLatitude(value.property(QStringLiteral("latitude")).toNumber()); - if (value.hasProperty(QStringLiteral("longitude"))) - c.setLongitude(value.property(QStringLiteral("longitude")).toNumber()); - if (value.hasProperty(QStringLiteral("altitude"))) - c.setAltitude(value.property(QStringLiteral("altitude")).toNumber()); - - if (ok) - *ok = true; - } else if (ok) { - *ok = false; - } - - return c; -} - - -/*! - \qmltype QtPositioning - \inqmlmodule QtPositioning - \since 5.2 - - \brief The QtPositioning global object provides useful functions for working with location-based - types in QML. - - \qml - import QtPositioning - - Item { - property var coordinate: QtPositioning.coordinate(-27.5, 153.1) - } - \endqml -*/ - -LocationSingleton::LocationSingleton(QObject *parent) -: QObject(parent) -{ -} - -/*! - \qmlmethod coordinate ::QtPositioning::coordinate() - - Constructs an invalid coordinate. - -*/ -QGeoCoordinate LocationSingleton::coordinate() const -{ - return QGeoCoordinate(); -} - -/*! - \qmlmethod coordinate QtPositioning::coordinate(real latitude, real longitude, real altitude) const - - Constructs a coordinate with the specified \a latitude, \a longitude and optional \a altitude. - Both \a latitude and \a longitude must be valid, otherwise an invalid coordinate is returned. - - \sa {coordinate} -*/ -QGeoCoordinate LocationSingleton::coordinate(double latitude, double longitude, double altitude) const -{ - return QGeoCoordinate(latitude, longitude, altitude); -} - -/*! - \qmlmethod geoshape QtPositioning::shape() const - - Constructs an invalid geoshape. - - \sa {geoshape} -*/ -QGeoShape LocationSingleton::shape() const -{ - return QGeoShape(); -} - -/*! - \qmlmethod georectangle QtPositioning::rectangle() const - - Constructs an invalid georectangle. - - \sa {georectangle} -*/ -QGeoRectangle LocationSingleton::rectangle() const -{ - return QGeoRectangle(); -} - -/*! - \qmlmethod georectangle QtPositioning::rectangle(coordinate center, real width, real height) const - - Constructs a georectangle centered at \a center with a width of \a width degrees and a hight of - \a height degrees. - - \sa {georectangle} -*/ -QGeoRectangle LocationSingleton::rectangle(const QGeoCoordinate ¢er, - double width, double height) const -{ - return QGeoRectangle(center, width, height); -} - -/*! - \qmlmethod georectangle QtPositioning::rectangle(coordinate topLeft, coordinate bottomRight) const - - Constructs a georectangle with its top left corner positioned at \a topLeft and its bottom - right corner positioned at \a {bottomRight}. - - \sa {georectangle} -*/ -QGeoRectangle LocationSingleton::rectangle(const QGeoCoordinate &topLeft, - const QGeoCoordinate &bottomRight) const -{ - return QGeoRectangle(topLeft, bottomRight); -} - -/*! - \qmlmethod georectangle QtLocation5::QtLocation::rectangle(list<coordinate> coordinates) const - - Constructs a georectangle from the list of coordinates, the returned list is the smallest possible - containing all the coordinates. - - \sa {georectangle} -*/ -QGeoRectangle LocationSingleton::rectangle(const QVariantList &coordinates) const -{ - QList<QGeoCoordinate> internalCoordinates; - for (int i = 0; i < coordinates.size(); i++) { - if (coordinates.at(i).canConvert<QGeoCoordinate>()) - internalCoordinates << coordinates.at(i).value<QGeoCoordinate>(); - } - return QGeoRectangle(internalCoordinates); -} - -/*! - \qmlmethod geocircle QtPositioning::circle() const - - Constructs an invalid geocircle. - - \sa {geocircle} -*/ -QGeoCircle LocationSingleton::circle() const -{ - return QGeoCircle(); -} - -/*! - \qmlmethod geocircle QtPositioning::circle(coordinate center, real radius) const - - Constructs a geocircle centered at \a center with a radius of \a radius meters. -*/ -QGeoCircle LocationSingleton::circle(const QGeoCoordinate ¢er, qreal radius) const -{ - return QGeoCircle(center, radius); -} - -/*! - \qmlmethod geopath QtPositioning::path() const - - Constructs an empty geopath. - - \sa {geopath} - \since 5.9 -*/ -QGeoPath LocationSingleton::path() const -{ - return QGeoPath(); -} - -/*! - \qmlmethod geopath QtPositioning::path(list<coordinate> coordinates, real width) const - - Constructs a geopath from coordinates and width. - - \sa {geopath} - \since 5.9 -*/ -QGeoPath LocationSingleton::path(const QJSValue &value, qreal width) const -{ - QList<QGeoCoordinate> pathList; - - if (value.isArray()) { - quint32 length = value.property(QStringLiteral("length")).toUInt(); - for (quint32 i = 0; i < length; ++i) { - bool ok = false; - QGeoCoordinate c = parseCoordinate(value.property(i), &ok); - - if (!ok || !c.isValid()) { - pathList.clear(); // aborting - break; - } - - pathList.append(c); - } - } - - return QGeoPath(pathList, width); -} - -/*! - \qmlmethod geopolygon QtPositioning::polygon() const - - Constructs an empty polygon. - - \sa {geopolygon} - \since 5.10 -*/ -QGeoPolygon LocationSingleton::polygon() const -{ - return QGeoPolygon(); -} - -/*! - \qmlmethod geopolygon QtPositioning::polygon(list<coordinate> coordinates) const - - Constructs a polygon from coordinates. - - \sa {geopolygon} - \since 5.10 -*/ -QGeoPolygon LocationSingleton::polygon(const QVariantList &coordinates) const -{ - QList<QGeoCoordinate> internalCoordinates; - for (int i = 0; i < coordinates.size(); i++) { - if (coordinates.at(i).canConvert<QGeoCoordinate>()) - internalCoordinates << coordinates.at(i).value<QGeoCoordinate>(); - } - return QGeoPolygon(internalCoordinates); -} - -/*! - \qmlmethod geopolygon QtPositioning::polygon(list<coordinate> perimeter, list<list<coordinate>> holes) const - - Constructs a polygon from coordinates for perimeter and inner holes. - - \sa {geopolygon} - \since 5.12 -*/ -QGeoPolygon LocationSingleton::polygon(const QVariantList &perimeter, const QVariantList &holes) const -{ - QList<QGeoCoordinate> internalCoordinates; - for (int i = 0; i < perimeter.size(); i++) { - if (perimeter.at(i).canConvert<QGeoCoordinate>()) - internalCoordinates << perimeter.at(i).value<QGeoCoordinate>(); - } - QGeoPolygon poly(internalCoordinates); - - for (int i = 0; i < holes.size(); i++) { - if (holes.at(i).metaType().id() == QMetaType::QVariantList) { - QList<QGeoCoordinate> hole; - const QVariantList &holeData = holes.at(i).toList(); - for (int j = 0; j < holeData.size(); j++) { - if (holeData.at(j).canConvert<QGeoCoordinate>()) - hole << holeData.at(j).value<QGeoCoordinate>(); - } - if (hole.size()) - poly.addHole(hole); - } - } - - return poly; -} - -/*! - \qmlmethod geocircle QtPositioning::shapeToCircle(geoshape shape) const - - Converts \a shape to a geocircle. - - \sa {geocircle} - \since 5.5 -*/ -QGeoCircle LocationSingleton::shapeToCircle(const QGeoShape &shape) const -{ - return QGeoCircle(shape); -} - -/*! - \qmlmethod georectangle QtPositioning::shapeToRectangle(geoshape shape) const - - Converts \a shape to a georectangle. - - \sa {georectangle} - \since 5.5 -*/ -QGeoRectangle LocationSingleton::shapeToRectangle(const QGeoShape &shape) const -{ - return QGeoRectangle(shape); -} - -/*! - \qmlmethod geopath QtPositioning::shapeToPath(geoshape shape) const - - Converts \a shape to a geopath. - - \sa {geopath} - \since 5.9 -*/ -QGeoPath LocationSingleton::shapeToPath(const QGeoShape &shape) const -{ - return QGeoPath(shape); -} - -/*! - \qmlmethod geopolygon QtPositioning::shapeToPolygon(geoshape shape) const - - Converts \a shape to a polygon. - - \sa {geopolygon} - \since 5.10 -*/ -QGeoPolygon LocationSingleton::shapeToPolygon(const QGeoShape &shape) const -{ - return QGeoPolygon(shape); -} - -/*! - \qmlmethod coordinate QtPositioning::mercatorToCoord(point mercator) const - - Converts a \a mercator coordinate into a latitude-longitude coordinate. - - \sa {coordToMercator} - \since 5.12 -*/ -QGeoCoordinate LocationSingleton::mercatorToCoord(const QPointF &mercator) const -{ - return QWebMercator::mercatorToCoord(QDoubleVector2D(mercator.x(), mercator.y())); -} - -/*! - \qmlmethod point QtPositioning::coordToMercator(coordinate coord) const - - Converts a coordinate \a coord into a mercator coordinate and returns it. - \sa {mercatorToCoord} - \since 5.12 -*/ -QPointF LocationSingleton::coordToMercator(const QGeoCoordinate &coord) const -{ - return QWebMercator::coordToMercator(coord).toPointF(); -} diff --git a/src/positioningquick/locationsingleton_p.h b/src/positioningquick/locationsingleton_p.h deleted file mode 100644 index 75459cb1..00000000 --- a/src/positioningquick/locationsingleton_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 LOCATIONSINGLETON_H -#define LOCATIONSINGLETON_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 <QtCore/QObject> -#include <QtCore/qnumeric.h> -#include <QtPositioning/QGeoCoordinate> -#include <QtPositioning/QGeoShape> -#include <QtPositioning/QGeoRectangle> -#include <QtPositioning/QGeoCircle> -#include <QtPositioning/QGeoPath> -#include <QtPositioning/QGeoPolygon> -#include <QtQml/QJSValue> -#include <QVariant> -#include <QPointF> -#include <QQmlEngine> -#include <QtPositioningQuick/private/qpositioningquickglobal_p.h> - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT LocationSingleton : public QObject -{ - Q_OBJECT - QML_NAMED_ELEMENT(QtPositioning) - QML_SINGLETON - QML_ADDED_IN_VERSION(5, 0) - -public: - explicit LocationSingleton(QObject *parent = 0); - - Q_INVOKABLE QGeoCoordinate coordinate() const; - Q_INVOKABLE QGeoCoordinate coordinate(double latitude, double longitude, - double altitude = qQNaN()) const; - - Q_INVOKABLE QGeoShape shape() const; - - Q_INVOKABLE QGeoRectangle rectangle() const; - Q_INVOKABLE QGeoRectangle rectangle(const QGeoCoordinate ¢er, - double width, double height) const; - Q_INVOKABLE QGeoRectangle rectangle(const QGeoCoordinate &topLeft, - const QGeoCoordinate &bottomRight) const; - Q_INVOKABLE QGeoRectangle rectangle(const QVariantList &coordinates) const; - - Q_INVOKABLE QGeoCircle circle() const; - Q_INVOKABLE QGeoCircle circle(const QGeoCoordinate ¢er, qreal radius = -1.0) const; - - Q_INVOKABLE QGeoPath path() const; - Q_INVOKABLE QGeoPath path(const QJSValue &value, qreal width = 0.0) const; - - Q_INVOKABLE QGeoPolygon polygon() const; - Q_INVOKABLE QGeoPolygon polygon(const QVariantList &value) const; - Q_INVOKABLE QGeoPolygon polygon(const QVariantList &perimeter, const QVariantList &holes) const; - - Q_INVOKABLE QGeoCircle shapeToCircle(const QGeoShape &shape) const; - Q_INVOKABLE QGeoRectangle shapeToRectangle(const QGeoShape &shape) const; - Q_INVOKABLE QGeoPath shapeToPath(const QGeoShape &shape) const; - Q_INVOKABLE QGeoPolygon shapeToPolygon(const QGeoShape &shape) const; - - Q_REVISION(5, 12) Q_INVOKABLE QGeoCoordinate mercatorToCoord(const QPointF &mercator) const; - Q_REVISION(5, 12) Q_INVOKABLE QPointF coordToMercator(const QGeoCoordinate &coord) const; -}; - -#endif // LOCATIONSINGLETON_H diff --git a/src/positioningquick/positioningplugin.cpp b/src/positioningquick/positioningplugin.cpp deleted file mode 100644 index 91a9c943..00000000 --- a/src/positioningquick/positioningplugin.cpp +++ /dev/null @@ -1,555 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 <private/qpositioningquickglobal_p.h> -#include <QtPositioningQuick/private/qquickgeocoordinateanimation_p.h> -#include <QtCore/QVariantAnimation> -#include <QtQml/QQmlEngineExtensionPlugin> - -QT_BEGIN_NAMESPACE - -/*! - \qmlbasictype coordinate - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-basictypes - \since 5.2 - - \brief The coordinate type represents and stores a geographic position. - - This type is a QML representation of \l QGeoCoordinate and represents a geographic - position in the form of \l {latitude}, \l longitude and \l altitude attributes. - The \l latitude attribute specifies the number of - decimal degrees above and below the equator. A positive latitude indicates the Northern - Hemisphere and a negative latitude indicates the Southern Hemisphere. The \l longitude - attribute specifies the number of decimal degrees east and west. A positive longitude - indicates the Eastern Hemisphere and a negative longitude indicates the Western Hemisphere. - The \l altitude attribute specifies the number of meters above sea level. Together, these - attributes specify a 3-dimensional position anywhere on or near the Earth's surface. - - The \l isValid attribute can be used to test if a coordinate is valid. A coordinate is - considered valid if it has a valid latitude and longitude. A valid altitude is not required. - The latitude must be between -90 and 90 inclusive and the longitude must be between -180 and - 180 inclusive. - - The \c coordinate type is used by many other types in the Qt Location module, for specifying - the position of an object on a Map, the current position of a device and many other tasks. - They also feature a number of important utility methods that make otherwise complex - calculations simple to use, such as \l {atDistanceAndAzimuth}(). - - \section1 Accuracy - - The latitude, longitude and altitude attributes stored in the coordinate type are represented - as doubles, giving them approximately 16 decimal digits of precision -- enough to specify - micrometers. The calculations performed in coordinate's methods such as \l {azimuthTo}() and - \l {distanceTo}() also use doubles for all intermediate values, but the inherent inaccuracies in - their spherical Earth model dominate the amount of error in their output. - - \section1 Example Usage - - Use properties of type \l var to store a \c {coordinate}. To create a \c coordinate use - one of the methods described below. In all cases, specifying the \l altitude attribute is - optional. - - To create a \c coordinate value, use the \l{QtPositioning::coordinate}{QtPositioning.coordinate()} - function: - - \qml - import QtPositioning - - Location { coordinate: QtPositioning.coordinate(-27.5, 153.1) } - \endqml - - or as separate \l latitude, \l longitude and \l altitude components: - - \qml - Location { - coordinate { - latitude: -27.5 - longitude: 153.1 - } - } - \endqml - - When integrating with C++, note that any QGeoCoordinate value passed into QML from C++ is - automatically converted into a \c coordinate value, and vice-versa. - - \section1 Properties - - \section2 latitude - - \code - real latitude - \endcode - - This property holds the latitude value of the geographical position - (decimal degrees). A positive latitude indicates the Northern Hemisphere, - and a negative latitude indicates the Southern Hemisphere. - If the property has not been set, its default value is NaN. - - For more details see the \l {QGeoCoordinate::latitude} property - - \section2 longitude - - \code - real longitude - \endcode - - This property holds the longitude value of the geographical position - (decimal degrees). A positive longitude indicates the Eastern Hemisphere, - and a negative longitude indicates the Western Hemisphere - If the property has not been set, its default value is NaN. - - For more details see the \l {QGeoCoordinate::longitude} property - - \section2 altitude - - \code - real altitude - \endcode - - This property holds the altitude value (meters above sea level). - If the property has not been set, its default value is NaN. - - For more details see the \l {QGeoCoordinate::altitude} property - - \section2 isValid - - \code - bool isValid - \endcode - - This property holds the current validity of the coordinate. Coordinates - are considered valid if they have been set with a valid latitude and - longitude (altitude is not required). - - The latitude must be between -90 to 90 inclusive to be considered valid, - and the longitude must be between -180 to 180 inclusive to be considered - valid. - - This is a read-only property. - - \section1 Methods - - \section2 distanceTo() - - \code - real distanceTo(coordinate other) - \endcode - - Returns the distance (in meters) from this coordinate to the coordinate specified by \a other. - Altitude is not used in the calculation. - - This calculation returns the great-circle distance between the two coordinates, with an - assumption that the Earth is spherical for the purpose of this calculation. - - \section2 azimuthTo() - - \code - real azimuth(coordinate other) - \endcode - - Returns the azimuth (or bearing) in degrees from this coordinate to the coordinate specified by - \a other. Altitude is not used in the calculation. - - There is an assumption that the Earth is spherical for the purpose of this calculation. - - \section2 atDistanceAndAzimuth() - - \code - coordinate atDistanceAndAzimuth(real distance, real azimuth) - \endcode - - Returns the coordinate that is reached by traveling \a distance metres from this coordinate at - \a azimuth degrees along a great-circle. - - There is an assumption that the Earth is spherical for the purpose of this calculation. -*/ - -/*! - \qmlbasictype geoshape - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-basictypes - \since 5.2 - - \brief A geoshape type represents an abstract geographic area. - - This type is a QML representation of \l QGeoShape which is an abstract geographic area. - It includes attributes and methods common to all geographic areas. To create objects - that represent a valid geographic area use \l {georectangle} or \l {geocircle}. - - The \l isValid attribute can be used to test if the geoshape represents a valid geographic - area. - - The \l isEmpty attribute can be used to test if the geoshape represents a region with a - geometrical area of 0. - - The \l {contains}() method can be used to test if a \l {coordinate} is - within the geoshape. - - \section1 Example Usage - - Use properties of type \l var to store a \c {geoshape}. To create a \c geoshape use one - of the methods described below. - - To create a \c geoshape value, specify it as a "shape()" string: - - \qml - import QtPositioning - - Item { - property var region: "shape()" - } - \endqml - - or with the \l {QtPositioning::shape}{QtPositioning.shape()} function: - - \qml - import QtPositioning - - Item { - property var region: QtPositioning.shape() - } - \endqml - - When integrating with C++, note that any QGeoShape value passed into QML from C++ is - automatically converted into a \c geoshape value, and vice-versa. - - \section1 Properties - - \section2 isEmpty - - \code - bool isEmpty - \endcode - - Returns whether this geoshape is empty. An empty geoshape is a region which has - a geometrical area of 0. - - \section2 isValid - - \code - bool isValid - \endcode - - Returns whether this geoshape is valid. - - A geoshape is considered to be invalid if some of the data that is required to - unambiguously describe the geoshape has not been set or has been set to an - unsuitable value. - - \section2 type - - \code - ShapeType type - \endcode - - Returns the current type of the shape. - - \list - \li \c GeoShape.UnknownType - The shape's type is not known. - \li \c GeoShape.RectangleType - The shape is a \l georectangle. - \li \c GeoShape.CircleType - The shape is a \l geocircle. - \li \c GeoShape.PathType - The shape is a \l geopath. (Since Qt 5.9) - \li \c GeoShape.PolygonType - The shape is a \l geopolygon. (Since Qt 5.10) - \endlist - - This QML property was introduced by Qt 5.5. - - \section1 Methods - - \section2 contains() - - \code - bool contains(coordinate coord) - \endcode - - Returns true if the \l {QtPositioning::coordinate}{coordinate} specified by \a coord is within - this geoshape; Otherwise returns false. -*/ - -/*! - \qmlbasictype georectangle - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-basictypes - \since 5.2 - - \brief The georectangle type represents a rectangular geographic area. - - The \c georectangle type is a \l {geoshape} that represents a - rectangular geographic area. The type is direct representation of a \l QGeoRectangle. - It is defined by a pair of \l {coordinate}{coordinates} which represent the top-left - and bottom-right corners of the \c {georectangle}. The coordinates are accessible - from the \l topLeft and \l bottomRight attributes. - - A \c georectangle is considered invalid if the top-left or bottom-right coordinates are invalid - or if the top-left coordinate is south of the bottom-right coordinate. - - The coordinates of the four corners of the \c georectangle can be accessed with the - \l {topLeft}, \l {topRight}, \l {bottomLeft} and \l {bottomRight} attributes. The \l center - attribute can be used to get the coordinate of the center of the \c georectangle. The \l width - and \l height attributes can be used to get the width and height of the \c georectangle in - degrees. Setting one of these attributes will cause the other attributes to be adjusted - accordingly. - - \section1 Limitations - - A \c georectangle can never cross the poles. - - If the height or center of a \c georectangle is adjusted such that it would cross one of the - poles the height is modified such that the \c georectangle touches but does not cross the pole - and that the center coordinate is still in the center of the \c georectangle. - - \section1 Example Usage - - Use properties of type \l var to store a \c {georectangle}. To create a \c georectangle - value, use the \l {QtPositioning::rectangle}{QtPositioning.rectangle()} function: - - \qml - import QtPositioning - - Item { - property var region: QtPositioning.rectangle(QtPositioning.coordinate(-27.5, 153.1), QtPositioning.coordinate(-27.6, 153.2)) - } - \endqml - - When integrating with C++, note that any QGeoRectangle value passed into QML from C++ is - automatically converted into a \c georectangle value, and vice-versa. - - \section1 Properties - - \section2 bottomLeft - - \code - coordinate bottomLeft - \endcode - - This property holds the bottom left coordinate of this georectangle. - - \section2 bottomRight - - \code - coordinate bottomRight - \endcode - - This property holds the bottom right coordinate of this georectangle. - - \section2 center - - \code - coordinate center - \endcode - - This property holds the center coordinate of this georectangle. For more details - see \l {QGeoRectangle::setCenter()}. - - \section2 height - - \code - double height - \endcode - - This property holds the height of this georectangle (in degrees). For more details - see \l {QGeoRectangle::setHeight()}. - - \note If the georectangle is invalid, it is not possible to set the height. QtPositioning - releases prior to Qt 5.5 permitted the setting of the height even on invalid georectangles. - - \section2 topLeft - - \code - coordinate topLeft - \endcode - - This property holds the top left coordinate of this georectangle. - - \section2 topRight - - \code - coordinate topRight - \endcode - - This property holds the top right coordinate of this georectangle. - - \section2 width - - \code - double width - \endcode - - This property holds the width of this georectangle (in degrees). For more details - see \l {QGeoRectangle::setWidth()}. - - \note If the georectangle is invalid, it is not possible to set the width. QtPositioning - releases prior to Qt 5.5 permitted the setting of the width even on invalid georectangles. -*/ - -/*! - \qmlbasictype geocircle - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-basictypes - \since 5.2 - - \brief The geocircle type represents a circular geographic area. - - The \c geocircle type is a \l {geoshape} that represents a circular - geographic area. It is a direct representation of a \l QGeoCircle and is defined - in terms of a \l {coordinate} which specifies the \l center of the circle and - a qreal which specifies the \l radius of the circle in meters. - - The circle is considered invalid if the \l center coordinate is invalid or if - the \l radius is less than zero. - - \section1 Example Usage - - Use properties of type \l var to store a \c {geocircle}. To create a \c geocircle value, - use the \l {QtPositioning::circle}{QtPositioning.circle()} function: - - \qml - import QtPositioning - - Item { - property var region: QtPositioning.circle(QtPositioning.coordinate(-27.5, 153.1), 1000) - } - \endqml - - When integrating with C++, note that any QGeoCircle value passed into QML from C++ is - automatically converted into a \c geocircle value, and vise-versa. - - \section1 Properties - - \section2 center - - \code - coordinate radius - \endcode - - This property holds the coordinate of the center of the geocircle. - - \section2 radius - - \code - real radius - \endcode - - This property holds the radius of the geocircle in meters. - - The default value for the radius is -1 indicating an invalid geocircle area. -*/ - -/*! - \qmlbasictype geopath - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-basictypes - \since 5.9 - - \brief The geopath type represents a geographic path. - - The \c geopath type is a \l {geoshape} that represents a geographic - path. It is a direct representation of a \l QGeoPath and is defined - in terms of a \l {path} which holds the list of geo coordinates in the - path. - - The path is considered invalid if it is empty. - - When integrating with C++, note that any QGeoPath value passed into QML from C++ is - automatically converted into a \c geopath value, and vice versa. - - \section1 Properties - - \section2 path - - This property holds the list of coordinates defining the path. - - \section2 width - - This property holds the width of the path in meters. This is currently only used - when calling the \l {contains}() method. - - The default value for the width is 0. -*/ - -/*! - \qmlbasictype geopolygon - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-basictypes - \since 5.10 - - \brief The geopolygon type represents a geographic polygon. - - The \c geopolygon type is a \l [QML] geoshape that represents a geographic - polygon. It is a direct representation of QGeoPolygon and is defined in - terms of a \l path which holds a list of geo coordinates in the polygon. - - The polygon is considered invalid if its path holds less than three - coordinates. - - When integrating with C++, note that any QGeoPolygon value passed into QML - is automatically converted into a \c geopolygon, and vice versa. - - \section1 Properties - - \section2 path - - This property holds the list of coordinates defining the polygon. -*/ - -class QtPositioningDeclarativeModule: public QQmlEngineExtensionPlugin -{ - Q_OBJECT - - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - QtPositioningDeclarativeModule(QObject *parent = 0) : QQmlEngineExtensionPlugin(parent) - { - volatile auto registration = &qml_register_types_QtPositioning; - Q_UNUSED(registration) - } -}; - -void QtPositioningDeclarative_initializeModule() -{ - qRegisterAnimationInterpolator<QGeoCoordinate>(q_coordinateInterpolator); -} - -Q_CONSTRUCTOR_FUNCTION(QtPositioningDeclarative_initializeModule) - -QT_END_NAMESPACE - -#include "positioningplugin.moc" diff --git a/src/positioningquick/positioningquick.pro b/src/positioningquick/positioningquick.pro deleted file mode 100644 index 75bd68a3..00000000 --- a/src/positioningquick/positioningquick.pro +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = QtPositioningQuick -QT = quick-private positioning-private qml-private core-private -CONFIG += simd optimize_full - -INCLUDEPATH += $$PWD - -SOURCES += $$files(*.cpp) -HEADERS += $$files(*.h) - -load(qt_module) diff --git a/src/positioningquick/qdeclarativegeoaddress.cpp b/src/positioningquick/qdeclarativegeoaddress.cpp deleted file mode 100644 index 9954a7b7..00000000 --- a/src/positioningquick/qdeclarativegeoaddress.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 "qdeclarativegeoaddress_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Address - \inqmlmodule QtPositioning - \since 5.2 - - \brief The Address QML type represents a specific location as a street address. - - An Address is used as a unit of data for queries such as (Reverse) Geocoding - or Places searches -- many of these operations either accept an Address - or return one. - - Not all properties of an Address are necessarily available or relevant - in all parts of the world and all locales. The \l district, \l state and - \l county properties are particularly area-specific for many data sources, - and often only one or two of these are available or useful. - - The Address has a \l text property which holds a formatted string. It - is the recommended way to display an address to the user and typically - takes the format of an address as found on an envelope, but this is not always - the case. The \l text may be automatically generated from constituent - address properties such as \l street, \l city and and so on, but can also - be explicitly assigned. See \l text for details. - - \section2 Example Usage - - The following code snippet shows the declaration of an Address object. - - \code - Address { - id: address - street: "53 Brandl St" - city: "Eight Mile Plains" - country: "Australia" - countryCode: "AUS" - } - \endcode - - This could then be used, for example, as the value of a geocoding query, - to get an exact longitude and latitude for the address. - - \sa {QGeoAddress} -*/ - -QDeclarativeGeoAddress::QDeclarativeGeoAddress(QObject *parent) : - QObject(parent) -{ -} - -QDeclarativeGeoAddress::QDeclarativeGeoAddress(const QGeoAddress &address, QObject *parent) : - QObject(parent), m_address(address) -{ -} - -/*! - \qmlproperty QGeoAddress QtPositioning::Address::address - - For details on how to use this property to interface between C++ and QML see - "\l {Address - QGeoAddress} {Interfaces between C++ and QML Code}". -*/ -QGeoAddress QDeclarativeGeoAddress::address() const -{ - return m_address; -} - -void QDeclarativeGeoAddress::setAddress(const QGeoAddress &address) -{ - // Elaborate but takes care of emiting needed signals - setText(address.text()); - setCountry(address.country()); - setCountryCode(address.countryCode()); - setState(address.state()); - setCounty(address.county()); - setCity(address.city()); - setDistrict(address.district()); - setStreet(address.street()); - setStreetNumber(address.streetNumber()); - setPostalCode(address.postalCode()); - m_address = address; -} - -/*! - \qmlproperty string QtPositioning::Address::text - - This property holds the address as a single formatted string. It is the recommended - string to use to display the address to the user. It typically takes the format of - an address as found on an envelope, but this is not always necessarily the case. - - The address \c text is either automatically generated or explicitly assigned, - this can be determined by checking \l isTextGenerated. - - If an empty string is assigned to \c text, then \l isTextGenerated will be set - to true and \c text will return a string which is locally formatted according to - \l countryCode and based on the properties of the address. Modifying the address - properties such as \l street, \l city and so on may cause the contents of \c text to - change. - - If a non-empty string is assigned to \c text, then \l isTextGenerated will be - set to false and \c text will always return the explicitly assigned string. - Modifying address properties will not affect the \c text property. -*/ -QString QDeclarativeGeoAddress::text() const -{ - return m_address.text(); -} - -void QDeclarativeGeoAddress::setText(const QString &address) -{ - QString oldText = m_address.text(); - bool oldIsTextGenerated = m_address.isTextGenerated(); - m_address.setText(address); - - if (oldText != m_address.text()) - emit textChanged(); - if (oldIsTextGenerated != m_address.isTextGenerated()) - emit isTextGeneratedChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::country - - This property holds the country of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::country() const -{ - return m_address.country(); -} - -void QDeclarativeGeoAddress::setCountry(const QString &country) -{ - if (m_address.country() == country) - return; - QString oldText = m_address.text(); - m_address.setCountry(country); - emit countryChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::countryCode - - This property holds the country code of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::countryCode() const -{ - return m_address.countryCode(); -} - -void QDeclarativeGeoAddress::setCountryCode(const QString &countryCode) -{ - if (m_address.countryCode() == countryCode) - return; - QString oldText = m_address.text(); - m_address.setCountryCode(countryCode); - emit countryCodeChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::state - - This property holds the state of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::state() const -{ - return m_address.state(); -} - -void QDeclarativeGeoAddress::setState(const QString &state) -{ - if (m_address.state() == state) - return; - QString oldText = m_address.text(); - m_address.setState(state); - emit stateChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::county - - This property holds the county of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::county() const -{ - return m_address.county(); -} - -void QDeclarativeGeoAddress::setCounty(const QString &county) -{ - if (m_address.county() == county) - return; - QString oldText = m_address.text(); - m_address.setCounty(county); - emit countyChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::city - - This property holds the city of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::city() const -{ - return m_address.city(); -} - -void QDeclarativeGeoAddress::setCity(const QString &city) -{ - if (m_address.city() == city) - return; - QString oldText = m_address.text(); - m_address.setCity(city); - emit cityChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::district - - This property holds the district of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::district() const -{ - return m_address.district(); -} - -void QDeclarativeGeoAddress::setDistrict(const QString &district) -{ - if (m_address.district() == district) - return; - QString oldText = m_address.text(); - m_address.setDistrict(district); - emit districtChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::street - - This property holds the street of the address. - - \note Before Qt6 this property could also contain things like a unit number, - a building name, or anything else that might be used to distinguish one - address from another. Since Qt6 use \l{QtPositioning::Address::}{streetNumber} - property for such information. -*/ -QString QDeclarativeGeoAddress::street() const -{ - return m_address.street(); -} - -void QDeclarativeGeoAddress::setStreet(const QString &street) -{ - if (m_address.street() == street) - return; - QString oldText = m_address.text(); - m_address.setStreet(street); - emit streetChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::streetNumber - \since QtPositioning 6.2 - - This property holds the street number of the address like a unit number, - a building name, or anything else that might be used to distinguish one - address from another. -*/ -QString QDeclarativeGeoAddress::streetNumber() const -{ - return m_address.streetNumber(); -} - -void QDeclarativeGeoAddress::setStreetNumber(const QString &streetNumber) -{ - if (m_address.streetNumber() == streetNumber) - return; - QString oldText = m_address.text(); - m_address.setStreetNumber(streetNumber); - emit streetNumberChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty string QtPositioning::Address::postalCode - - This property holds the postal code of the address as a single formatted string. -*/ -QString QDeclarativeGeoAddress::postalCode() const -{ - return m_address.postalCode(); -} - -void QDeclarativeGeoAddress::setPostalCode(const QString &postalCode) -{ - if (m_address.postalCode() == postalCode) - return; - QString oldText = m_address.text(); - m_address.setPostalCode(postalCode); - emit postalCodeChanged(); - - if (m_address.isTextGenerated() && oldText != m_address.text()) - emit textChanged(); -} - -/*! - \qmlproperty bool QtPositioning::Address::isTextGenerated - - This property holds a boolean that if true, indicates that \l text is automatically - generated from address properties. If false, it indicates that the \l text has been - explicitly assigned. - -*/ -bool QDeclarativeGeoAddress::isTextGenerated() const -{ - return m_address.isTextGenerated(); -} - -QT_END_NAMESPACE diff --git a/src/positioningquick/qdeclarativegeoaddress_p.h b/src/positioningquick/qdeclarativegeoaddress_p.h deleted file mode 100644 index d98be2e4..00000000 --- a/src/positioningquick/qdeclarativegeoaddress_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QDECLARATIVEGEOADDRESS_P_H -#define QDECLARATIVEGEOADDRESS_P_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 <QtCore/QObject> -#include <QtPositioning/QGeoAddress> -#include <QtPositioningQuick/private/qpositioningquickglobal_p.h> -#include <QQmlEngine> - -QT_BEGIN_NAMESPACE - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativeGeoAddress : public QObject -{ - Q_OBJECT - QML_NAMED_ELEMENT(Address) - QML_ADDED_IN_VERSION(5, 0) - - Q_PROPERTY(QGeoAddress address READ address WRITE setAddress) - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged) - Q_PROPERTY(QString countryCode READ countryCode WRITE setCountryCode NOTIFY countryCodeChanged) - Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(QString county READ county WRITE setCounty NOTIFY countyChanged) - Q_PROPERTY(QString city READ city WRITE setCity NOTIFY cityChanged) - Q_PROPERTY(QString district READ district WRITE setDistrict NOTIFY districtChanged) - Q_PROPERTY(QString street READ street WRITE setStreet NOTIFY streetChanged) - Q_PROPERTY(QString streetNumber READ streetNumber WRITE setStreetNumber - NOTIFY streetNumberChanged REVISION(6, 2)) - Q_PROPERTY(QString postalCode READ postalCode WRITE setPostalCode NOTIFY postalCodeChanged) - Q_PROPERTY(bool isTextGenerated READ isTextGenerated NOTIFY isTextGeneratedChanged) - -public: - explicit QDeclarativeGeoAddress(QObject *parent = 0); - QDeclarativeGeoAddress(const QGeoAddress &address, QObject *parent = 0); - QGeoAddress address() const; - void setAddress(const QGeoAddress &address); - - QString text() const; - void setText(const QString &address); - - QString country() const; - void setCountry(const QString &country); - QString countryCode() const; - void setCountryCode(const QString &countryCode); - QString state() const; - void setState(const QString &state); - QString county() const; - void setCounty(const QString &county); - QString city() const; - void setCity(const QString &city); - QString district() const; - void setDistrict(const QString &district); - QString street() const; - void setStreet(const QString &street); - QString streetNumber() const; - void setStreetNumber(const QString &streetNumber); - QString postalCode() const; - void setPostalCode(const QString &postalCode); - bool isTextGenerated() const; - -Q_SIGNALS: - void textChanged(); - void countryChanged(); - void countryCodeChanged(); - void stateChanged(); - void countyChanged(); - void cityChanged(); - void districtChanged(); - void streetChanged(); - void streetNumberChanged(); - void postalCodeChanged(); - void isTextGeneratedChanged(); - -private: - QGeoAddress m_address; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEGEOADDRESS_P_H diff --git a/src/positioningquick/qdeclarativegeolocation.cpp b/src/positioningquick/qdeclarativegeolocation.cpp deleted file mode 100644 index b62ab7ca..00000000 --- a/src/positioningquick/qdeclarativegeolocation.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 "qdeclarativegeolocation_p.h" - -QT_USE_NAMESPACE - -/*! - \qmltype Location - \inqmlmodule QtPositioning - \since 5.2 - - \brief The Location type holds location data. - - Location types represent a geographic "location", in a human sense. This - consists of a specific \l {coordinate}, an \l {address} and a - \l {boundingShape}{bounding shape}. - The \l {boundingShape}{bounding shape} represents the recommended region - to display when viewing this location. - - The Location type is most commonly seen as the contents of a search - model such as the GeocodeModel. When a GeocodeModel returns the list of - locations found for a given query, it represents these as Location objects. - - \section2 Example Usage - - The following example shows a simple Location object being declared: - - \code - Location { - coordinate { - latitude: -27.3 - longitude: 153.1 - } - address: Address { - ... - } - } - \endcode -*/ - -/*! - \qmlproperty VariantMap QDeclarativeGeoLocation::extendedAttributes - - This property holds the extended attributes for this Location. - Extended attributes are backend-dependent and can be location-dependent. - - \since 5.13 -*/ - -QDeclarativeGeoLocation::QDeclarativeGeoLocation(QObject *parent) -: QObject(parent) - -{ - setLocation(QGeoLocation()); -} - -QDeclarativeGeoLocation::QDeclarativeGeoLocation(const QGeoLocation &src, QObject *parent) -: QObject(parent) -{ - setLocation(src); -} - -QDeclarativeGeoLocation::~QDeclarativeGeoLocation() -{ -} - -/*! - \qmlproperty QGeoLocation QtPositioning::Location::location - - For details on how to use this property to interface between C++ and QML see - "\l {Location - QGeoLocation} {Interfaces between C++ and QML Code}". - - \note This property updates the whole geo location information, so using it - will result in breaking of all the bindings for all other properties. -*/ -void QDeclarativeGeoLocation::setLocation(const QGeoLocation &src) -{ - if (m_address && m_address->parent() == this) { - m_address->setAddress(src.address()); - } else if (!m_address || m_address->parent() != this) { - m_address.setValue(new QDeclarativeGeoAddress(src.address(), this)); - m_address.notify(); - } - - setCoordinate(src.coordinate()); - setBoundingShape(src.boundingShape()); - setExtendedAttributes(src.extendedAttributes()); -} - -QGeoLocation QDeclarativeGeoLocation::location() const -{ - QGeoLocation retValue; - retValue.setAddress(m_address ? m_address->address() : QGeoAddress()); - retValue.setCoordinate(m_coordinate); - retValue.setBoundingShape(m_boundingShape); - retValue.setExtendedAttributes(m_extendedAttributes); - return retValue; -} - -/*! - \qmlproperty Address QtPositioning::Location::address - - This property holds the address of the location which can be use to retrieve address details of the location. -*/ -void QDeclarativeGeoLocation::setAddress(QDeclarativeGeoAddress *address) -{ - m_address.removeBindingUnlessInWrapper(); - if (m_address == address) - return; - - // implicitly deleting m_address.value() will force the QML bindings to - // be reevaluated by the QML engine. So we defer the deletion of the old - // address until a new value is assigned to the m_address. - QDeclarativeGeoAddress *oldAddress = nullptr; - if (m_address && m_address->parent() == this) - oldAddress = m_address.value(); - - m_address.setValueBypassingBindings(address); - m_address.notify(); - delete oldAddress; -} - -QBindable<QDeclarativeGeoAddress *> QDeclarativeGeoLocation::bindableAddress() -{ - return QBindable<QDeclarativeGeoAddress *>(&m_address); -} - -QDeclarativeGeoAddress *QDeclarativeGeoLocation::address() const -{ - return m_address; -} - -/*! - \qmlproperty coordinate QtPositioning::Location::coordinate - - This property holds the exact geographical coordinate of the location which can be used to retrieve the latitude, longitude and altitude of the location. - - \note this property's changed() signal is currently emitted only if the - whole object changes, not if only the contents of the object change. -*/ -void QDeclarativeGeoLocation::setCoordinate(const QGeoCoordinate coordinate) -{ - m_coordinate = coordinate; -} - -QBindable<QGeoCoordinate> QDeclarativeGeoLocation::bindableCoordinate() -{ - return QBindable<QGeoCoordinate>(&m_coordinate); -} - -QGeoCoordinate QDeclarativeGeoLocation::coordinate() const -{ - return m_coordinate; -} - -/*! - \since QtPositioning 6.2 - - \qmlproperty geoshape QtPositioning::Location::boundingShape - - This property holds the recommended region to use when displaying the location. - For example, a building's location may have a region centered around the building, - but the region is large enough to show it's immediate surrounding geographical - context. - - \note This property's changed() signal is currently emitted only if the - whole object changes, not if only the contents of the object change. - - \note This property was introduced in Qt6 instead of boundingBox property. - It returns a \l geoshape instead of a \l georectangle. - Use \l QGeoShape::boundingGeoRectangle() to obtain a bounding - \l georectangle for the shape. - - If you need to convert the returned shape to a specific type, use the - \c type property of \l geoshape together with convenience - methods from \l [QML]{QtPositioning} like - \l {QtPositioning::shapeToRectangle}{QtPositioning.shapeToRectangle()}. -*/ -void QDeclarativeGeoLocation::setBoundingShape(const QGeoShape &boundingShape) -{ - m_boundingShape = boundingShape; -} - -QBindable<QGeoShape> QDeclarativeGeoLocation::bindableBoundingShape() -{ - return QBindable<QGeoShape>(&m_boundingShape); -} - -QVariantMap QDeclarativeGeoLocation::extendedAttributes() const -{ - return m_extendedAttributes; -} - -void QDeclarativeGeoLocation::setExtendedAttributes(const QVariantMap &attributes) -{ - m_extendedAttributes = attributes; -} - -QBindable<QVariantMap> QDeclarativeGeoLocation::bindableExtendedAttributes() -{ - return QBindable<QVariantMap>(&m_extendedAttributes); -} - -QGeoShape QDeclarativeGeoLocation::boundingShape() const -{ - return m_boundingShape; -} diff --git a/src/positioningquick/qdeclarativegeolocation_p.h b/src/positioningquick/qdeclarativegeolocation_p.h deleted file mode 100644 index c1083952..00000000 --- a/src/positioningquick/qdeclarativegeolocation_p.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QDECLARATIVEGEOLOCATION_P_H -#define QDECLARATIVEGEOLOCATION_P_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 <QtCore/QObject> -#include <QtCore/QVariantMap> -#include <QtCore/private/qproperty_p.h> -#include <QtPositioning/QGeoLocation> -#include <QtPositioning/QGeoShape> -#include <QtPositioningQuick/private/qdeclarativegeoaddress_p.h> -#include <QtPositioningQuick/private/qpositioningquickglobal_p.h> - -QT_BEGIN_NAMESPACE - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativeGeoLocation : public QObject -{ - Q_OBJECT - QML_NAMED_ELEMENT(Location) - QML_ADDED_IN_VERSION(5, 0) - - Q_PROPERTY(QGeoLocation location READ location WRITE setLocation) - Q_PROPERTY(QDeclarativeGeoAddress *address READ address WRITE setAddress BINDABLE - bindableAddress) - Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate BINDABLE - bindableCoordinate) - Q_PROPERTY(QGeoShape boundingShape READ boundingShape WRITE setBoundingShape BINDABLE - bindableBoundingShape REVISION(6, 2)) - Q_PROPERTY(QVariantMap extendedAttributes READ extendedAttributes WRITE setExtendedAttributes - BINDABLE bindableExtendedAttributes REVISION(5, 13)) - -public: - explicit QDeclarativeGeoLocation(QObject *parent = 0); - explicit QDeclarativeGeoLocation(const QGeoLocation &src, QObject *parent = 0); - ~QDeclarativeGeoLocation(); - - QGeoLocation location() const; - void setLocation(const QGeoLocation &src); - - QDeclarativeGeoAddress *address() const; - void setAddress(QDeclarativeGeoAddress *address); - QBindable<QDeclarativeGeoAddress *> bindableAddress(); - - QGeoCoordinate coordinate() const; - void setCoordinate(const QGeoCoordinate coordinate); - QBindable<QGeoCoordinate> bindableCoordinate(); - - QGeoShape boundingShape() const; - void setBoundingShape(const QGeoShape &boundingShape); - QBindable<QGeoShape> bindableBoundingShape(); - - QVariantMap extendedAttributes() const; - void setExtendedAttributes(const QVariantMap &attributes); - QBindable<QVariantMap> bindableExtendedAttributes(); - -private: - Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QDeclarativeGeoLocation, QDeclarativeGeoAddress *, m_address, - &QDeclarativeGeoLocation::setAddress, nullptr) - Q_OBJECT_BINDABLE_PROPERTY(QDeclarativeGeoLocation, QGeoShape, m_boundingShape) - Q_OBJECT_BINDABLE_PROPERTY(QDeclarativeGeoLocation, QGeoCoordinate, m_coordinate) - Q_OBJECT_BINDABLE_PROPERTY(QDeclarativeGeoLocation, QVariantMap, m_extendedAttributes) -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVELOCATION_P_H diff --git a/src/positioningquick/qdeclarativepluginparameter.cpp b/src/positioningquick/qdeclarativepluginparameter.cpp deleted file mode 100644 index 0092777f..00000000 --- a/src/positioningquick/qdeclarativepluginparameter.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativepluginparameter_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype PluginParameter - \inqmlmodule QtPositioning - \ingroup qml-QtPositioning5-common - \since QtPositioning 5.14 - - \brief The PluginParameter type describes a parameter for a - \omit - plugin, either geoservice \l Plugin, or - \endomit - position plugin. - - The PluginParameter object is used to provide a parameter of some kind - to a plugin. Typically, these parameters contain details like an application - token for access to a service, or a proxy server to use for network access, - or the serial port to which a serial GPS receiver is connected. - - To set such a parameter, declare a PluginParameter inside an element that - accepts plugin parameters as configuration objects, such as a - \omit - \l Plugin object, or a - \endomit - \l PositionSource object, and set values for its \l{name} and \l{value} - properties. A list of valid parameter names for each plugin is available - from the - \omit - \l {Qt Location#Plugin References and Parameters}{plugin reference pages} - for geoservice plugins, and - \endomit - \l {Qt Positioning plugins#Default plugins}{default plugins page} for - position plugins. - - \section2 Example Usage - - The following example shows the instantiation of the - \l {Qt Positioning NMEA plugin}{NMEA} plugin with the \e nmea.source - parameter that specifies the data source. - - \code - PositionSource { - name: "nmea" - PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" } - } - \endcode -*/ - -/*! - \qmlproperty string PluginParameter::name - - This property holds the name of the plugin parameter as a single formatted string. - This property is a write-once property. -*/ - -/*! - \qmlproperty QVariant PluginParameter::value - - This property holds the value of the plugin parameter which support different types of values (variant). - This property is a write-once property. -*/ - -QDeclarativePluginParameter::QDeclarativePluginParameter(QObject *parent) - : QObject(parent) {} - -QDeclarativePluginParameter::~QDeclarativePluginParameter() {} - -void QDeclarativePluginParameter::setName(const QString &name) -{ - if (!name_.isEmpty() || name.isEmpty()) - return; - - name_ = name; - - emit nameChanged(name_); - if (value_.isValid()) - emit initialized(); -} - -QString QDeclarativePluginParameter::name() const -{ - return name_; -} - -void QDeclarativePluginParameter::setValue(const QVariant &value) -{ - if (value_.isValid() || !value.isValid() || value.isNull()) - return; - - value_ = value; - - emit valueChanged(value_); - if (!name_.isEmpty()) - emit initialized(); -} - -QVariant QDeclarativePluginParameter::value() const -{ - return value_; -} - -bool QDeclarativePluginParameter::isInitialized() const -{ - return !name_.isEmpty() && value_.isValid(); -} - -QT_END_NAMESPACE diff --git a/src/positioningquick/qdeclarativepluginparameter_p.h b/src/positioningquick/qdeclarativepluginparameter_p.h deleted file mode 100644 index 2d3b8e2a..00000000 --- a/src/positioningquick/qdeclarativepluginparameter_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPLUGINPARAMETER_P_H -#define QDECLARATIVEPLUGINPARAMETER_P_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 <QtPositioningQuick/private/qpositioningquickglobal_p.h> -#include <QtQml/qqml.h> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> - -QT_BEGIN_NAMESPACE - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativePluginParameter : public QObject -{ - Q_OBJECT - QML_NAMED_ELEMENT(PluginParameter) - QML_ADDED_IN_VERSION(5, 14) - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) - -public: - explicit QDeclarativePluginParameter(QObject *parent = 0); - ~QDeclarativePluginParameter(); - - void setName(const QString &name); - QString name() const; - - void setValue(const QVariant &value); - QVariant value() const; - - bool isInitialized() const; - -Q_SIGNALS: - void nameChanged(const QString &name); - void valueChanged(const QVariant &value); - void initialized(); - -private: - QString name_; - QVariant value_; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativePluginParameter) - -#endif // QDECLARATIVEPLUGINPARAMETER_P_H diff --git a/src/positioningquick/qdeclarativeposition.cpp b/src/positioningquick/qdeclarativeposition.cpp deleted file mode 100644 index 515fef9d..00000000 --- a/src/positioningquick/qdeclarativeposition.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd. -** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 <QtCore/QtNumeric> -#include "qdeclarativeposition_p.h" -#include <QtQml/qqml.h> -#include <qnmeapositioninfosource.h> -#include <QFile> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Position - //! \instantiates QDeclarativePosition - \inqmlmodule QtPositioning - \since 5.2 - - \brief The Position type holds positional data at a particular point in time, - such as coordinate (longitude, latitude, altitude) and speed. - - The Position type holds values related to geographic location such as - a \l coordinate (longitude, latitude, and altitude), the \l timestamp when - the Position was obtained, the \l speed at that time, and the accuracy of - the data. - - Primarily, it is used in the \l{PositionSource::position}{position} property - of a \l{PositionSource}, as the basic unit of data available from the system - location data source. - - Not all properties of a Position object are necessarily valid or available - (for example latitude and longitude may be valid, but speed update has not been - received or set manually). As a result, corresponding "valid" properties - are available (for example \l{coordinate} and \l{longitudeValid}, \l{latitudeValid} - etc) to discern whether the data is available and valid in this position - update. - - Position objects are read-only and can only be produced by a PositionSource. - - \section2 Example Usage - - See the example given for the \l{PositionSource} type, or the - \l{geoflickr}{GeoFlickr} example application. - - \sa PositionSource, coordinate -*/ - -namespace -{ - -bool equalOrNaN(qreal a, qreal b) -{ - return a == b || (qIsNaN(a) && qIsNaN(b)); -} - -bool exclusiveNaN(qreal a, qreal b) -{ - return qIsNaN(a) != qIsNaN(b); -} - -} - -QDeclarativePosition::QDeclarativePosition(QObject *parent) -: QObject(parent) -{ -} - -QDeclarativePosition::~QDeclarativePosition() -{ -} - -void QDeclarativePosition::setPosition(const QGeoPositionInfo &info) -{ - // timestamp - const QDateTime pTimestamp = m_info.timestamp(); - const QDateTime timestamp = info.timestamp(); - const bool timestampChanged = pTimestamp != timestamp; - - // coordinate - const QGeoCoordinate pCoordinate = m_info.coordinate(); - const QGeoCoordinate coordinate = info.coordinate(); - const bool coordinateChanged = pCoordinate != coordinate; - const bool latitudeValidChanged = exclusiveNaN(pCoordinate.latitude(), coordinate.latitude()); - const bool longitudeValidChanged = - exclusiveNaN(pCoordinate.longitude(), coordinate.longitude()); - const bool altitudeValidChanged = exclusiveNaN(pCoordinate.altitude(), coordinate.altitude()); - - // direction - const qreal pDirection = m_info.attribute(QGeoPositionInfo::Direction); - const qreal direction = info.attribute(QGeoPositionInfo::Direction); - const bool directionChanged = !equalOrNaN(pDirection, direction); - const bool directionValidChanged = exclusiveNaN(pDirection, direction); - - // ground speed - const qreal pSpeed = m_info.attribute(QGeoPositionInfo::GroundSpeed); - const qreal speed = info.attribute(QGeoPositionInfo::GroundSpeed); - const bool speedChanged = !equalOrNaN(pSpeed, speed); - const bool speedValidChanged = exclusiveNaN(pSpeed, speed); - - // vertical speed - const qreal pVerticalSpeed = m_info.attribute(QGeoPositionInfo::VerticalSpeed); - const qreal verticalSpeed = info.attribute(QGeoPositionInfo::VerticalSpeed); - const bool verticalSpeedChanged = !equalOrNaN(pVerticalSpeed, verticalSpeed); - const bool verticalSpeedValidChanged = exclusiveNaN(pVerticalSpeed, verticalSpeed); - - // magnetic variation - const qreal pMagneticVariation = m_info.attribute(QGeoPositionInfo::MagneticVariation); - const qreal magneticVariation = info.attribute(QGeoPositionInfo::MagneticVariation); - const bool magneticVariationChanged = !equalOrNaN(pMagneticVariation, magneticVariation); - const bool magneticVariationValidChanged = exclusiveNaN(pMagneticVariation, magneticVariation); - - // horizontal accuracy - const qreal pHorizontalAccuracy = m_info.attribute(QGeoPositionInfo::HorizontalAccuracy); - const qreal horizontalAccuracy = info.attribute(QGeoPositionInfo::HorizontalAccuracy); - const bool horizontalAccuracyChanged = !equalOrNaN(pHorizontalAccuracy, horizontalAccuracy); - const bool horizontalAccuracyValidChanged = - exclusiveNaN(pHorizontalAccuracy, horizontalAccuracy); - - // vertical accuracy - const qreal pVerticalAccuracy = m_info.attribute(QGeoPositionInfo::VerticalAccuracy); - const qreal verticalAccuracy = info.attribute(QGeoPositionInfo::VerticalAccuracy); - const bool verticalAccuracyChanged = !equalOrNaN(pVerticalAccuracy, verticalAccuracy); - const bool verticalAccuracyValidChanged = exclusiveNaN(pVerticalAccuracy, verticalAccuracy); - - m_info = info; - - if (timestampChanged) - m_computedTimestamp.notify(); - - if (coordinateChanged) - m_computedCoordinate.notify(); - if (latitudeValidChanged) - m_computedLatitudeValid.notify(); - if (longitudeValidChanged) - m_computedLongitudeValid.notify(); - if (altitudeValidChanged) - m_computedAltitudeValid.notify(); - - if (directionChanged) - m_computedDirection.notify(); - if (directionValidChanged) - m_computedDirectionValid.notify(); - - if (speedChanged) - m_computedSpeed.notify(); - if (speedValidChanged) - m_computedSpeedValid.notify(); - - if (verticalSpeedChanged) - m_computedVerticalSpeed.notify(); - if (verticalSpeedValidChanged) - m_computedVerticalSpeedValid.notify(); - - if (horizontalAccuracyChanged) - m_computedHorizontalAccuracy.notify(); - if (horizontalAccuracyValidChanged) - m_computedHorizontalAccuracyValid.notify(); - - if (verticalAccuracyChanged) - m_computedVerticalAccuracy.notify(); - if (verticalAccuracyValidChanged) - m_computedVerticalAccuracyValid.notify(); - - if (magneticVariationChanged) - m_computedMagneticVariation.notify(); - if (magneticVariationValidChanged) - m_computedMagneticVariationValid.notify(); -} - -const QGeoPositionInfo &QDeclarativePosition::position() const -{ - return m_info; -} - -QBindable<bool> QDeclarativePosition::bindableLatitudeValid() const -{ - return QBindable<bool>(&m_computedLatitudeValid); -} - -QBindable<bool> QDeclarativePosition::bindableLongitudeValid() const -{ - return QBindable<bool>(&m_computedLongitudeValid); -} - -QBindable<bool> QDeclarativePosition::bindableAltitudeValid() const -{ - return QBindable<bool>(&m_computedAltitudeValid); -} - -QBindable<QGeoCoordinate> QDeclarativePosition::bindableCoordinate() const -{ - return QBindable<QGeoCoordinate>(&m_computedCoordinate); -} - -QBindable<QDateTime> QDeclarativePosition::bindableTimestamp() const -{ - return QBindable<QDateTime>(&m_computedTimestamp); -} - -QBindable<double> QDeclarativePosition::bindableSpeed() const -{ - return QBindable<double>(&m_computedSpeed); -} - -QBindable<bool> QDeclarativePosition::bindableSpeedValid() const -{ - return QBindable<bool>(&m_computedSpeedValid); -} - -QBindable<qreal> QDeclarativePosition::bindableHorizontalAccuracy() const -{ - return QBindable<qreal>(&m_computedHorizontalAccuracy); -} - -QBindable<qreal> QDeclarativePosition::binableVerticalAccuracy() const -{ - return QBindable<qreal>(&m_computedVerticalAccuracy); -} - -QBindable<bool> QDeclarativePosition::bindableHorizontalAccuracyValid() const -{ - return QBindable<bool>(&m_computedHorizontalAccuracyValid); -} - -QBindable<bool> QDeclarativePosition::bindableVerticalAccuracyValid() const -{ - return QBindable<bool>(&m_computedVerticalAccuracyValid); -} - -QBindable<bool> QDeclarativePosition::bindableDirectionValid() const -{ - return QBindable<bool>(&m_computedDirectionValid); -} - -QBindable<double> QDeclarativePosition::bindableDirection() const -{ - return QBindable<double>(&m_computedDirection); -} - -QBindable<bool> QDeclarativePosition::bindableVerticalSpeedValid() const -{ - return QBindable<bool>(&m_computedVerticalSpeedValid); -} - -QBindable<double> QDeclarativePosition::bindableVerticalSpeed() const -{ - return QBindable<double>(&m_computedVerticalSpeed); -} - -QBindable<double> QDeclarativePosition::bindableMagneticVariation() const -{ - return QBindable<double>(&m_computedMagneticVariation); -} - -QBindable<bool> QDeclarativePosition::bindableMagneticVariationValid() const -{ - return QBindable<bool>(&m_computedMagneticVariationValid); -} - -/*! - \qmlproperty coordinate Position::coordinate - - This property holds the latitude, longitude, and altitude value of the Position. - - It is a read-only property. - - \sa longitudeValid, latitudeValid, altitudeValid -*/ -QGeoCoordinate QDeclarativePosition::coordinate() const -{ - return m_computedCoordinate.value(); -} - -QGeoCoordinate QDeclarativePosition::coordinateActualCalculation() const -{ - return m_info.coordinate(); -} - -/*! - \qmlproperty bool Position::latitudeValid - - This property is true if coordinate's latitude has been set - (to indicate whether that data has been received or not, as every update - does not necessarily contain all data). - - \sa coordinate -*/ -bool QDeclarativePosition::isLatitudeValid() const -{ - return m_computedLatitudeValid.value(); -} - -bool QDeclarativePosition::isLatitudeValidActualCalculation() const -{ - return !qIsNaN(m_info.coordinate().latitude()); -} - -/*! - \qmlproperty bool Position::longitudeValid - - This property is true if coordinate's longitude has been set - (to indicate whether that data has been received or not, as every update - does not necessarily contain all data). - - \sa coordinate -*/ -bool QDeclarativePosition::isLongitudeValid() const -{ - return m_computedLongitudeValid.value(); -} - -bool QDeclarativePosition::isLongitudeValidActualCalculation() const -{ - return !qIsNaN(m_info.coordinate().longitude()); -} - -/*! - \qmlproperty bool Position::speedValid - - This property is true if \l speed has been set - (to indicate whether that data has been received or not, as every update - does not necessarily contain all data). - - \sa speed -*/ -bool QDeclarativePosition::isSpeedValid() const -{ - return m_computedSpeedValid.value(); -} - -bool QDeclarativePosition::isSpeedValidActualCalculation() const -{ - return !qIsNaN(m_info.attribute(QGeoPositionInfo::GroundSpeed)); -} - -/*! - \qmlproperty bool Position::altitudeValid - - This property is true if coordinate's altitude has been set - (to indicate whether that data has been received or not, as every update - does not necessarily contain all data). - - \sa coordinate -*/ -bool QDeclarativePosition::isAltitudeValid() const -{ - return m_computedAltitudeValid.value(); -} - -bool QDeclarativePosition::isAltitudeValidActualCalculation() const -{ - return !qIsNaN(m_info.coordinate().altitude()); -} - -/*! - \qmlproperty double Position::speed - - This property holds the value of speed (groundspeed, meters / second). - - It is a read-only property. - - \sa speedValid, coordinate -*/ -double QDeclarativePosition::speed() const -{ - return m_computedSpeed.value(); -} - -double QDeclarativePosition::speedActualCalculation() const -{ - return m_info.attribute(QGeoPositionInfo::GroundSpeed); -} - -/*! - \qmlproperty real Position::horizontalAccuracy - - This property holds the horizontal accuracy of the coordinate (in meters). - - \sa horizontalAccuracyValid, coordinate -*/ -qreal QDeclarativePosition::horizontalAccuracy() const -{ - return m_computedHorizontalAccuracy.value(); -} - -qreal QDeclarativePosition::horizontalAccuracyActualCalculation() const -{ - return m_info.attribute(QGeoPositionInfo::HorizontalAccuracy); -} - -/*! - \qmlproperty bool Position::horizontalAccuracyValid - - This property is true if \l horizontalAccuracy has been set - (to indicate whether that data has been received or not, as every update - does not necessarily contain all data). - - \sa horizontalAccuracy -*/ -bool QDeclarativePosition::isHorizontalAccuracyValid() const -{ - return m_computedHorizontalAccuracyValid.value(); -} - -bool QDeclarativePosition::isHorizontalAccuracyValidActualCalculation() const -{ - return !qIsNaN(m_info.attribute(QGeoPositionInfo::HorizontalAccuracy)); -} - -/*! - \qmlproperty real Position::verticalAccuracy - - This property holds the vertical accuracy of the coordinate (in meters). - - \sa verticalAccuracyValid, coordinate -*/ -qreal QDeclarativePosition::verticalAccuracy() const -{ - return m_computedVerticalAccuracy.value(); -} - -qreal QDeclarativePosition::verticalAccuracyActualCalculation() const -{ - return m_info.attribute(QGeoPositionInfo::VerticalAccuracy); -} - -/*! - \qmlproperty bool Position::verticalAccuracyValid - - This property is true if \l verticalAccuracy has been set - (to indicate whether that data has been received or not, as every update - does not necessarily contain all data). - - \sa verticalAccuracy -*/ -bool QDeclarativePosition::isVerticalAccuracyValid() const -{ - return m_computedVerticalAccuracyValid.value(); -} - -bool QDeclarativePosition::isVerticalAccuracyValidActualCalculation() const -{ - return !qIsNaN(m_info.attribute(QGeoPositionInfo::VerticalAccuracy)); -} - -/*! - \qmlproperty date Position::timestamp - - This property holds the timestamp when this position - was received. If the property has not been set, it is invalid. - - It is a read-only property. -*/ -QDateTime QDeclarativePosition::timestamp() const -{ - return m_computedTimestamp.value(); -} - -QDateTime QDeclarativePosition::timestampActualCalculation() const -{ - return m_info.timestamp(); -} - -/*! - \qmlproperty bool Position::directionValid - \since Qt Positioning 5.3 - - This property is true if \l direction has been set (to indicate whether that data has been - received or not, as every update does not necessarily contain all data). - - \sa direction -*/ -bool QDeclarativePosition::isDirectionValid() const -{ - return m_computedDirectionValid.value(); -} - -bool QDeclarativePosition::isDirectionValidActualCalculation() const -{ - return !qIsNaN(m_info.attribute(QGeoPositionInfo::Direction)); -} - -/*! - \qmlproperty double Position::direction - \since Qt Positioning 5.3 - - This property holds the value of the direction of travel in degrees from true north. - - It is a read-only property. - - \sa directionValid -*/ -double QDeclarativePosition::direction() const -{ - return m_computedDirection.value(); -} - -double QDeclarativePosition::directionActualCalculation() const -{ - return m_info.attribute(QGeoPositionInfo::Direction); -} - -/*! - \qmlproperty bool Position::verticalSpeedValid - \since Qt Positioning 5.3 - - This property is true if \l verticalSpeed has been set (to indicate whether that data has been - received or not, as every update does not necessarily contain all data). - - \sa verticalSpeed -*/ -bool QDeclarativePosition::isVerticalSpeedValid() const -{ - return m_computedVerticalSpeedValid.value(); -} - -bool QDeclarativePosition::isVerticalSpeedValidActualCalculation() const -{ - return !qIsNaN(m_info.attribute(QGeoPositionInfo::VerticalSpeed)); -} - -/*! - \qmlproperty double Position::verticalSpeed - \since Qt Positioning 5.3 - - This property holds the value of the vertical speed in meters per second. - - It is a read-only property. - - \sa verticalSpeedValid -*/ -double QDeclarativePosition::verticalSpeed() const -{ - return m_computedVerticalSpeed.value(); -} - -double QDeclarativePosition::verticalSpeedActualCalculation() const -{ - return m_info.attribute(QGeoPositionInfo::VerticalSpeed); -} - -/*! - \qmlproperty bool Position::magneticVariationValid - \since Qt Positioning 5.4 - - This property is true if \l magneticVariation has been set (to indicate whether that data has been - received or not, as every update does not necessarily contain all data). - - \sa magneticVariation -*/ -bool QDeclarativePosition::isMagneticVariationValid() const -{ - return m_computedMagneticVariationValid.value(); -} - -bool QDeclarativePosition::isMagneticVariationValidActualCalculation() const -{ - return !qIsNaN(m_info.attribute(QGeoPositionInfo::MagneticVariation)); -} - -/*! - \qmlproperty double Position::magneticVariation - \since Qt Positioning 5.4 - - This property holds the angle between the horizontal component of the - magnetic field and true north, in degrees. Also known as magnetic - declination. A positive value indicates a clockwise direction from - true north and a negative value indicates a counter-clockwise direction. - - It is a read-only property. - - \sa magneticVariationValid -*/ -double QDeclarativePosition::magneticVariation() const -{ - return m_computedMagneticVariation.value(); -} - -double QDeclarativePosition::magneticVariationActualCalculation() const -{ - return m_info.attribute(QGeoPositionInfo::MagneticVariation); -} - -QT_END_NAMESPACE diff --git a/src/positioningquick/qdeclarativeposition_p.h b/src/positioningquick/qdeclarativeposition_p.h deleted file mode 100644 index 174828bf..00000000 --- a/src/positioningquick/qdeclarativeposition_p.h +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd. -** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QDECLARATIVEPOSITION_H -#define QDECLARATIVEPOSITION_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 <QtPositioningQuick/private/qpositioningquickglobal_p.h> -#include <QtPositioning/QGeoPositionInfo> -#include <QtCore/QObject> -#include <QtCore/QDateTime> -#include <QtQml/qqml.h> - -QT_BEGIN_NAMESPACE - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativePosition : public QObject -{ - Q_OBJECT - QML_NAMED_ELEMENT(Position) - QML_ADDED_IN_VERSION(5, 0) - - Q_PROPERTY(bool latitudeValid READ isLatitudeValid BINDABLE bindableLatitudeValid) - Q_PROPERTY(bool longitudeValid READ isLongitudeValid BINDABLE bindableLongitudeValid) - Q_PROPERTY(bool altitudeValid READ isAltitudeValid BINDABLE bindableAltitudeValid) - Q_PROPERTY(QGeoCoordinate coordinate READ coordinate BINDABLE bindableCoordinate) - Q_PROPERTY(QDateTime timestamp READ timestamp BINDABLE bindableTimestamp) - Q_PROPERTY(double speed READ speed BINDABLE bindableSpeed) - Q_PROPERTY(bool speedValid READ isSpeedValid BINDABLE bindableSpeedValid) - Q_PROPERTY(qreal horizontalAccuracy READ horizontalAccuracy BINDABLE bindableHorizontalAccuracy) - Q_PROPERTY(qreal verticalAccuracy READ verticalAccuracy BINDABLE binableVerticalAccuracy) - Q_PROPERTY(bool horizontalAccuracyValid READ isHorizontalAccuracyValid BINDABLE - bindableHorizontalAccuracyValid) - Q_PROPERTY(bool verticalAccuracyValid READ isVerticalAccuracyValid BINDABLE - bindableVerticalAccuracyValid) - - Q_PROPERTY(bool directionValid READ isDirectionValid BINDABLE bindableDirectionValid - REVISION(5, 1)) - Q_PROPERTY(double direction READ direction BINDABLE bindableDirection REVISION(5, 1)) - Q_PROPERTY(bool verticalSpeedValid READ isVerticalSpeedValid BINDABLE bindableVerticalSpeedValid - REVISION(5, 1)) - Q_PROPERTY(double verticalSpeed READ verticalSpeed BINDABLE bindableVerticalSpeed - REVISION(5, 1)) - - Q_PROPERTY(double magneticVariation READ magneticVariation BINDABLE bindableMagneticVariation - REVISION(5, 2)) - Q_PROPERTY(bool magneticVariationValid READ isMagneticVariationValid BINDABLE - bindableMagneticVariationValid REVISION(5, 2)) - -public: - explicit QDeclarativePosition(QObject *parent = 0); - ~QDeclarativePosition(); - - bool isLatitudeValid() const; - bool isLongitudeValid() const; - bool isAltitudeValid() const; - QDateTime timestamp() const; - double speed() const; - bool isSpeedValid() const; - QGeoCoordinate coordinate() const; - bool isHorizontalAccuracyValid() const; - qreal horizontalAccuracy() const; - bool isVerticalAccuracyValid() const; - qreal verticalAccuracy() const; - - bool isDirectionValid() const; - double direction() const; - - bool isVerticalSpeedValid() const; - double verticalSpeed() const; - - bool isMagneticVariationValid() const; - double magneticVariation() const; - - void setPosition(const QGeoPositionInfo &info); - const QGeoPositionInfo &position() const; - - QBindable<bool> bindableLatitudeValid() const; - QBindable<bool> bindableLongitudeValid() const; - QBindable<bool> bindableAltitudeValid() const; - QBindable<QGeoCoordinate> bindableCoordinate() const; - QBindable<QDateTime> bindableTimestamp() const; - QBindable<double> bindableSpeed() const; - QBindable<bool> bindableSpeedValid() const; - QBindable<qreal> bindableHorizontalAccuracy() const; - QBindable<qreal> binableVerticalAccuracy() const; - QBindable<bool> bindableHorizontalAccuracyValid() const; - QBindable<bool> bindableVerticalAccuracyValid() const; - QBindable<bool> bindableDirectionValid() const; - QBindable<double> bindableDirection() const; - QBindable<bool> bindableVerticalSpeedValid() const; - QBindable<double> bindableVerticalSpeed() const; - QBindable<double> bindableMagneticVariation() const; - QBindable<bool> bindableMagneticVariationValid() const; - -private: - bool isLatitudeValidActualCalculation() const; - bool isLongitudeValidActualCalculation() const; - bool isAltitudeValidActualCalculation() const; - QGeoCoordinate coordinateActualCalculation() const; - QDateTime timestampActualCalculation() const; - double speedActualCalculation() const; - bool isSpeedValidActualCalculation() const; - qreal horizontalAccuracyActualCalculation() const; - qreal verticalAccuracyActualCalculation() const; - bool isHorizontalAccuracyValidActualCalculation() const; - bool isVerticalAccuracyValidActualCalculation() const; - bool isDirectionValidActualCalculation() const; - double directionActualCalculation() const; - bool isVerticalSpeedValidActualCalculation() const; - double verticalSpeedActualCalculation() const; - double magneticVariationActualCalculation() const; - bool isMagneticVariationValidActualCalculation() const; - - QGeoPositionInfo m_info; - - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedLatitudeValid, - &QDeclarativePosition::isLatitudeValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedLongitudeValid, - &QDeclarativePosition::isLongitudeValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedAltitudeValid, - &QDeclarativePosition::isAltitudeValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, QGeoCoordinate, m_computedCoordinate, - &QDeclarativePosition::coordinateActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, QDateTime, m_computedTimestamp, - &QDeclarativePosition::timestampActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedSpeed, - &QDeclarativePosition::speedActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedSpeedValid, - &QDeclarativePosition::isSpeedValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, qreal, m_computedHorizontalAccuracy, - &QDeclarativePosition::horizontalAccuracyActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, qreal, m_computedVerticalAccuracy, - &QDeclarativePosition::verticalAccuracyActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedHorizontalAccuracyValid, - &QDeclarativePosition::isHorizontalAccuracyValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedVerticalAccuracyValid, - &QDeclarativePosition::isVerticalAccuracyValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedDirectionValid, - &QDeclarativePosition::isDirectionValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedDirection, - &QDeclarativePosition::directionActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedVerticalSpeedValid, - &QDeclarativePosition::isVerticalSpeedValidActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedVerticalSpeed, - &QDeclarativePosition::verticalSpeedActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedMagneticVariation, - &QDeclarativePosition::magneticVariationActualCalculation) - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedMagneticVariationValid, - &QDeclarativePosition::isMagneticVariationValidActualCalculation) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativePosition) - -#endif diff --git a/src/positioningquick/qdeclarativepositionsource.cpp b/src/positioningquick/qdeclarativepositionsource.cpp deleted file mode 100644 index 5a84c788..00000000 --- a/src/positioningquick/qdeclarativepositionsource.cpp +++ /dev/null @@ -1,913 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 "qdeclarativepositionsource_p.h" -#include "qdeclarativeposition_p.h" - -#include <QtCore/QCoreApplication> -#include <QtQml/qqmlinfo.h> -#include <QtQml/qqml.h> -#include <qdeclarativepluginparameter_p.h> -#include <QFile> -#include <QtNetwork/QTcpSocket> -#include <QTimer> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype PositionSource - //! \instantiates QDeclarativePositionSource - \inqmlmodule QtPositioning - \since 5.2 - - \brief The PositionSource type provides the device's current position. - - The PositionSource type provides information about the user device's - current position. The position is available as a \l{Position} type, which - contains all the standard parameters typically available from GPS and other - similar systems, including longitude, latitude, speed and accuracy details. - - As different position sources are available on different platforms and - devices, these are categorized by their basic type (Satellite, NonSatellite, - and AllPositioningMethods). The available methods for the current platform - can be enumerated in the \l{supportedPositioningMethods} property. - - To indicate which methods are suitable for your application, set the - \l{preferredPositioningMethods} property. If the preferred methods are not - available, the default source of location data for the platform will be - chosen instead. If no default source is available (because none are installed - for the runtime platform, or because it is disabled), the \l{valid} property - will be set to false. - - The \l updateInterval property can then be used to indicate how often your - application wishes to receive position updates. The \l{start}(), - \l{stop}() and \l{update}() methods can be used to control the operation - of the PositionSource, as well as the \l{active} property, which when set - is equivalent to calling \l{start}() or \l{stop}(). - - When the PositionSource is active, position updates can be retrieved - either by simply using the \l{position} property in a binding (as the - value of another item's property), or by providing an implementation of - the \c {onPositionChanged} signal-handler. - - \section2 Example Usage - - The following example shows a simple PositionSource used to receive - updates every second and print the longitude and latitude out to - the console. - - \code - PositionSource { - id: src - updateInterval: 1000 - active: true - - onPositionChanged: { - var coord = src.position.coordinate; - console.log("Coordinate:", coord.longitude, coord.latitude); - } - } - \endcode - - The \l{geoflickr}{GeoFlickr} example application shows how to use - a PositionSource in your application to retrieve local data for users - from a REST web service. - - \section2 Controlling Operation State - - As it's mentioned above, PositionSource provides two ways to control its - operation state: - - \list - \li By using the \l active \l {Qt Bindable Properties}{bindable} property. - \li By using \l start() and \l stop() methods. - \endlist - - \note It's very important not to mix these approaches. If a bindable - \l active property is used to control the PositionSource object, but later - \l start() or \l stop() is called from the other part of the code, the - binding is broken, which may result in, for example, a UI element that is - not connected to any underlying object anymore. - - Consider the following example of \b {bad code} where the \c active property - is bound to the CheckBox state, and calling \l stop() in the \c onClicked - signal handler breaks that binding. - - \qml - Window { - width: 640 - height: 480 - visible: true - - PositionSource { - id: posSource - name: "geoclue2" - active: cb.checked - } - - Column { - anchors.centerIn: parent - spacing: 20 - CheckBox { - id: cb - } - Button { - id: btn - text: "Stop" - onClicked: { - posSource.stop() - } - } - } - } - \endqml - - Once the \e Stop button is clicked, \l stop() is executed, and the binding - for the \l active property is broken. At this point the CheckBox UI element - is no longer controlling the PositionSource object. - - A straightforward fix in this case is to update the CheckBox state from - the \c onClicked handler. As soon as the CheckBox is unchecked, the - \l active property will be notified, and the PositionSource object's state - will update accordingly. The UI will also be in a consistent state. - - \qml - Button { - id: btn - text: "Stop" - onClicked: { - cb.checked = false - } - } - \endqml - - \note Using \l update() to request a single position update \e {does not} - have any effect on the \l active property's bindings, so they can be used - together without any problems. - - \sa {QtPositioning::Position}, {QGeoPositionInfoSource}, {PluginParameter}, - {Qt Bindable Properties} - -*/ - -QDeclarativePositionSource::QDeclarativePositionSource() -{ - m_position.setValueBypassingBindings(new QDeclarativePosition(this)); -} - -QDeclarativePositionSource::~QDeclarativePositionSource() -{ - delete m_positionSource; -} - - -/*! - \qmlproperty string PositionSource::name - - This property holds the unique internal name for the plugin currently - providing position information. - - Setting the property causes the PositionSource to use a particular positioning provider. If - the PositionSource is active at the time that the name property is changed, it will become - inactive. If the specified positioning provider cannot be loaded the position source will - become invalid. - - Changing the name property may cause the \l {updateInterval}, \l {supportedPositioningMethods} - and \l {preferredPositioningMethods} properties to change as well. -*/ - - -QString QDeclarativePositionSource::name() const -{ - return m_sourceName; -} - -void QDeclarativePositionSource::setName(const QString &newName) -{ - m_sourceName.removeBindingUnlessInWrapper(); - if (m_positionSource && m_positionSource->sourceName() == newName) - return; - - if (newName.isEmpty() && m_defaultSourceUsed) - return; // previously attached to a default source, now requesting the same. - - const QString previousName = name(); - - if (!m_componentComplete || !m_parametersInitialized) { - if (previousName != newName) { - m_sourceName.setValueBypassingBindings(newName); - m_sourceName.notify(); - } - return; - } - - // tryAttach() will update the m_sourceName correctly - tryAttach(newName, false); -} - -QBindable<QString> QDeclarativePositionSource::bindableName() -{ - return QBindable<QString>(&m_sourceName); -} - -QBindable<QDeclarativePosition *> QDeclarativePositionSource::bindablePosition() const -{ - return QBindable<QDeclarativePosition *>(&m_position); -} - -/*! - \internal -*/ -void QDeclarativePositionSource::tryAttach(const QString &newName, bool useFallback) -{ - const QString previousName = name(); - const bool sourceExisted = (m_positionSource != nullptr); - - int previousUpdateInterval = updateInterval(); - PositioningMethods previousPositioningMethods = supportedPositioningMethods(); - PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods(); - - m_defaultSourceUsed = false; - - if (newName.isEmpty()) { - setSource(QGeoPositionInfoSource::createDefaultSource(parameterMap(), this)); - m_defaultSourceUsed = true; - } else { - setSource(QGeoPositionInfoSource::createSource(newName, parameterMap(), this)); - if (!m_positionSource && useFallback) { - setSource(QGeoPositionInfoSource::createDefaultSource(parameterMap(), this)); - m_defaultSourceUsed = true; - } - } - - if (m_positionSource) { - m_sourceName.setValueBypassingBindings(m_positionSource->sourceName()); - - connect(m_positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)), - this, SLOT(positionUpdateReceived(QGeoPositionInfo))); - connect(m_positionSource, SIGNAL(errorOccurred(QGeoPositionInfoSource::Error)), - this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); - - m_positionSource->setUpdateInterval(m_updateInterval); - m_positionSource->setPreferredPositioningMethods( - static_cast<QGeoPositionInfoSource::PositioningMethods>(int(m_preferredPositioningMethods))); - - const QGeoPositionInfo &lastKnown = m_positionSource->lastKnownPosition(); - if (lastKnown.isValid()) - setPosition(lastKnown); - } else { - m_sourceName.setValueBypassingBindings(newName); - m_defaultSourceUsed = false; - if (m_active) { - // We do not want to break the binding here, because we just want to - // give the user an opportunity to select another plugin and keep - // working. - m_active.setValueBypassingBindings(false); - m_active.notify(); - } - } - - if (previousUpdateInterval != updateInterval()) - emit updateIntervalChanged(); - - if (previousPreferredPositioningMethods != preferredPositioningMethods()) - emit preferredPositioningMethodsChanged(); - - if (previousPositioningMethods != supportedPositioningMethods()) - notifySupportedPositioningMethodsChanged(); - - const bool sourceCurrentlyExists = (m_positionSource != nullptr); - if (sourceExisted != sourceCurrentlyExists) { - m_isValid.notify(); - emit validityChanged(); - } - - if (m_active) { // implies m_positionSource - if (!sourceExisted) { - // delay ensures all properties have been set - QTimer::singleShot(0, this, [this]() { executeStart(); }); - } else { - // New source is set. It should be inactive by default. - // But we do not want to break the binding. - m_active.setValueBypassingBindings(false); - m_active.notify(); - } - } - - if (previousName != m_sourceName) - m_sourceName.notify(); -} - -/*! - \qmlproperty bool PositionSource::valid - - This property is true if the PositionSource object has acquired a valid - backend plugin to provide data. If false, other methods on the PositionSource - will have no effect. - - Applications should check this property to determine whether positioning is - available and enabled on the runtime platform, and react accordingly. -*/ -bool QDeclarativePositionSource::isValid() const -{ - return m_isValid.value(); -} - -QBindable<bool> QDeclarativePositionSource::bindableIsValid() const -{ - return QBindable<bool>(&m_isValid); -} - -bool QDeclarativePositionSource::isValidActualComputation() const -{ - return m_positionSource != nullptr; -} - -void QDeclarativePositionSource::handleUpdateTimeout() -{ - // notify will be called by the calling method - m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::UpdateTimeoutError); - - if (!m_active) - return; - - if (m_singleUpdate) { - m_singleUpdate = false; - - if (!m_regularUpdates) { - // only singleUpdate based timeouts change activity - // continuous updates may resume again - // (see QGeoPositionInfoSource::startUpdates()) - m_active.setValueBypassingBindings(false); - m_active.notify(); - } - } -} - -/*! - \internal -*/ -void QDeclarativePositionSource::onParameterInitialized() -{ - m_parametersInitialized = true; - for (QDeclarativePluginParameter *p: qAsConst(m_parameters)) { - if (!p->isInitialized()) { - m_parametersInitialized = false; - break; - } - } - - // If here, componentComplete has been called. - if (m_parametersInitialized) - tryAttach(m_sourceName.value()); -} - -void QDeclarativePositionSource::notifySupportedPositioningMethodsChanged() -{ - m_supportedPositioningMethods.notify(); - emit supportedPositioningMethodsChanged(); -} - -void QDeclarativePositionSource::setPosition(const QGeoPositionInfo &pi) -{ - m_position.value()->setPosition(pi); - m_position.notify(); - emit positionChanged(); -} - -void QDeclarativePositionSource::setSource(QGeoPositionInfoSource *source) -{ - if (m_positionSource) - delete m_positionSource; - - if (!source) { - m_positionSource = nullptr; - } else { - m_positionSource = source; - connect(m_positionSource, &QGeoPositionInfoSource::supportedPositioningMethodsChanged, - this, &QDeclarativePositionSource::notifySupportedPositioningMethodsChanged); - } -} - -bool QDeclarativePositionSource::parametersReady() -{ - for (const QDeclarativePluginParameter *p: qAsConst(m_parameters)) { - if (!p->isInitialized()) - return false; - } - return true; -} - -/*! - \internal -*/ -QVariantMap QDeclarativePositionSource::parameterMap() const -{ - QVariantMap map; - - for (int i = 0; i < m_parameters.size(); ++i) { - QDeclarativePluginParameter *parameter = m_parameters.at(i); - map.insert(parameter->name(), parameter->value()); - } - - return map; -} - -/*! - \internal -*/ -void QDeclarativePositionSource::setUpdateInterval(int updateInterval) -{ - if (m_positionSource) { - int previousUpdateInterval = m_positionSource->updateInterval(); - - m_updateInterval = updateInterval; - - if (previousUpdateInterval != updateInterval) { - m_positionSource->setUpdateInterval(updateInterval); - if (previousUpdateInterval != m_positionSource->updateInterval()) - emit updateIntervalChanged(); - } - } else { - if (m_updateInterval != updateInterval) { - m_updateInterval = updateInterval; - emit updateIntervalChanged(); - } - } -} - -/*! - \qmlproperty int PositionSource::updateInterval - - This property holds the desired interval between updates (milliseconds). - - \sa {QGeoPositionInfoSource::updateInterval()} -*/ - -int QDeclarativePositionSource::updateInterval() const -{ - if (!m_positionSource) - return m_updateInterval; - - return m_positionSource->updateInterval(); -} - -/*! - \qmlproperty enumeration PositionSource::supportedPositioningMethods - - This property holds the supported positioning methods of the - current source. - - \list - \li PositionSource.NoPositioningMethods - No positioning methods supported (no source). - \li PositionSource.SatellitePositioningMethods - Satellite-based positioning methods such as GPS are supported. - \li PositionSource.NonSatellitePositioningMethods - Non-satellite-based methods are supported. - \li PositionSource.AllPositioningMethods - Both satellite-based and non-satellite positioning methods are supported. - \endlist - -*/ - -QDeclarativePositionSource::PositioningMethods -QDeclarativePositionSource::supportedPositioningMethods() const -{ - return m_supportedPositioningMethods.value(); -} - -QDeclarativePositionSource::PositioningMethods -QDeclarativePositionSource::supportedMethodsActualComputation() const -{ - if (m_positionSource) { - return static_cast<QDeclarativePositionSource::PositioningMethods>( - int(m_positionSource->supportedPositioningMethods())); - } - return QDeclarativePositionSource::NoPositioningMethods; -} - -QBindable<QDeclarativePositionSource::PositioningMethods> -QDeclarativePositionSource::bindableSupportedPositioningMethods() const -{ - return QBindable<PositioningMethods>(&m_supportedPositioningMethods); -} - -/*! - \qmlproperty enumeration PositionSource::preferredPositioningMethods - - This property holds the preferred positioning methods of the - current source. - - \list - \li PositionSource.NoPositioningMethods - No positioning method is preferred. - \li PositionSource.SatellitePositioningMethods - Satellite-based positioning methods such as GPS should be preferred. - \li PositionSource.NonSatellitePositioningMethods - Non-satellite-based methods should be preferred. - \li PositionSource.AllPositioningMethods - Any positioning methods are acceptable. - \endlist - -*/ - -void QDeclarativePositionSource::setPreferredPositioningMethods(PositioningMethods methods) -{ - if (m_positionSource) { - PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods(); - - m_preferredPositioningMethods = methods; - - if (previousPreferredPositioningMethods != methods) { - m_positionSource->setPreferredPositioningMethods( - static_cast<QGeoPositionInfoSource::PositioningMethods>(int(methods))); - if (previousPreferredPositioningMethods != m_positionSource->preferredPositioningMethods()) - emit preferredPositioningMethodsChanged(); - } - } else { - if (m_preferredPositioningMethods != methods) { - m_preferredPositioningMethods = methods; - emit preferredPositioningMethodsChanged(); - } - } -} - -QDeclarativePositionSource::PositioningMethods QDeclarativePositionSource::preferredPositioningMethods() const -{ - if (m_positionSource) { - return static_cast<QDeclarativePositionSource::PositioningMethods>( - int(m_positionSource->preferredPositioningMethods())); - } - return m_preferredPositioningMethods; -} - -/*! - \qmlmethod PositionSource::start() - - Requests updates from the location source. - Uses \l updateInterval if set, default interval otherwise. - If there is no source available, this method has no effect. - - \note Calling this method breaks the bindings of - \l {PositionSource::}{active} property. - - \sa stop, update, active -*/ - -void QDeclarativePositionSource::start() -{ - if (m_positionSource) { - m_active.removeBindingUnlessInWrapper(); - executeStart(); - } -} - -/*! - \qmlmethod PositionSource::update(int timeout) - - A convenience method to request single update from the location source. - If there is no source available, this method has no effect. - - If the position source is not active, it will be activated for as - long as it takes to receive an update, or until the request times - out. The request timeout period is source-specific. - - The \a timeout is specified in milliseconds. If the \a timeout is zero - (the default value), it defaults to a reasonable timeout period as - appropriate for the source. - - \sa start, stop, active -*/ - -void QDeclarativePositionSource::update(int timeout) -{ - if (m_positionSource) { - m_singleUpdate = true; - if (!m_active) { - // Questionable: we do not want this method to break the binding. - // Mostly because it can be called while the updates are already - // running. - m_active.setValueBypassingBindings(true); - m_active.notify(); - } - // Use default timeout value. Set active before calling the - // update request because on some platforms there may - // be results immediately. - m_positionSource->requestUpdate(timeout); - } -} - -/*! - \qmlmethod PositionSource::stop() - - Stops updates from the location source. - If there is no source available or it is not active, - this method has no effect. - - \note Calling this method breaks the bindings of - \l {PositionSource::}{active} property. - - \sa start, update, active -*/ - -void QDeclarativePositionSource::stop() -{ - if (m_positionSource) { - m_positionSource->stopUpdates(); - m_regularUpdates = false; - // Try to break the binding even if we do not actually need to update - // the active state. The m_active can be updated later, when the - // single update request finishes. - m_active.removeBindingUnlessInWrapper(); - if (m_active && !m_singleUpdate) { - m_active.setValueBypassingBindings(false); - m_active.notify(); - } - } -} - -/*! - \qmlproperty bool PositionSource::active - - This property indicates whether the position source is active. - Setting this property to false equals calling \l stop, and - setting this property true equals calling \l start. - - \sa start, stop, update -*/ -void QDeclarativePositionSource::setActive(bool active) -{ - // We need to remove binding, if this method is called explicitly. - // Other changes to m_active are done inside start() and stop() methods. - m_active.removeBindingUnlessInWrapper(); - if (active == m_active) - return; - - if (active) { - // delay ensures all properties have been set - QTimer::singleShot(0, this, [this]() { executeStart(); }); - } else { - stop(); - } -} - -bool QDeclarativePositionSource::isActive() const -{ - return m_active; -} - -/*! - \qmlproperty Position PositionSource::position - - This property holds the last known positional data. - It is a read-only property. - - The Position type has different positional member variables, - whose validity can be checked with appropriate validity functions - (for example sometimes an update does not have speed or altitude data). - - However, whenever a \c {positionChanged} signal has been received, at least - position::coordinate::latitude, position::coordinate::longitude, and position::timestamp can - be assumed to be valid. - - \sa start, stop, update -*/ - -QDeclarativePosition *QDeclarativePositionSource::position() -{ - return m_position.value(); -} - -void QDeclarativePositionSource::positionUpdateReceived(const QGeoPositionInfo &update) -{ - setPosition(update); - - if (m_singleUpdate && m_active) { - // we need to reset m_singleUpdate because we got one - m_singleUpdate = false; - if (!m_regularUpdates) { - // but we change the active state only if the regular updates are - // also stopped - m_active.setValueBypassingBindings(false); - m_active.notify(); - } - } -} - - -/*! - \qmlproperty enumeration PositionSource::sourceError - - This property holds the error which last occurred with the PositionSource. - - \list - \li PositionSource.AccessError - The connection setup to the remote positioning backend failed because the - application lacked the required privileges. - \li PositionSource.ClosedError - The positioning backend closed the connection, which happens for example in case - the user is switching location services to off. As soon as the location service is re-enabled - regular updates will resume. - \li PositionSource.NoError - No error has occurred. - \li PositionSource.UnknownSourceError - An unidentified error occurred. - \li PositionSource.UpdateTimeoutError - The current position could not be - retrieved within the specified timeout, or this PositionSource determined - that it will not be able to provide further regular updates. - \endlist - -*/ - -QDeclarativePositionSource::SourceError QDeclarativePositionSource::sourceError() const -{ - return m_sourceError; -} - -QBindable<QDeclarativePositionSource::SourceError> -QDeclarativePositionSource::bindableSourceError() const -{ - return QBindable<QDeclarativePositionSource::SourceError>(&m_sourceError); -} - -QGeoPositionInfoSource *QDeclarativePositionSource::positionSource() const -{ - return m_positionSource; -} - -/*! - \qmlproperty list<PluginParameter> PositionSource::parameters - \qmldefault - - This property holds the list of plugin parameters. - - \since QtPositioning 5.14 -*/ -QQmlListProperty<QDeclarativePluginParameter> QDeclarativePositionSource::parameters() -{ - return QQmlListProperty<QDeclarativePluginParameter>(this, - 0, - parameter_append, - parameter_count, - parameter_at, - parameter_clear); -} - -/*! - \internal -*/ -void QDeclarativePositionSource::parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *parameter) -{ - QDeclarativePositionSource *p = static_cast<QDeclarativePositionSource *>(prop->object); - p->m_parameters.append(parameter); -} - -/*! - \internal -*/ -qsizetype QDeclarativePositionSource::parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop) -{ - return static_cast<QDeclarativePositionSource *>(prop->object)->m_parameters.count(); -} - -/*! - \internal -*/ -QDeclarativePluginParameter *QDeclarativePositionSource::parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, qsizetype index) -{ - return static_cast<QDeclarativePositionSource *>(prop->object)->m_parameters[index]; -} - -/*! - \internal -*/ -void QDeclarativePositionSource::parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop) -{ - QDeclarativePositionSource *p = static_cast<QDeclarativePositionSource *>(prop->object); - p->m_parameters.clear(); -} - -void QDeclarativePositionSource::executeStart() -{ - if (m_positionSource) { - m_positionSource->startUpdates(); - - // If this method is called directly from start(), the binding is - // already broken there (for the consistency with stop()). - // If this method is called by a timer, started in setActive(), we do - // not need to break the binding, because it was already done (if - // needed). - - m_regularUpdates = true; - if (!m_active) { - m_active.setValueBypassingBindings(true); - m_active.notify(); - } - } -} - -void QDeclarativePositionSource::componentComplete() -{ - m_componentComplete = true; - m_parametersInitialized = true; - for (QDeclarativePluginParameter *p: qAsConst(m_parameters)) { - if (!p->isInitialized()) { - m_parametersInitialized = false; - connect(p, &QDeclarativePluginParameter::initialized, - this, &QDeclarativePositionSource::onParameterInitialized); - } - } - - if (m_parametersInitialized) - tryAttach(m_sourceName.value()); -} - -/*! - \qmlmethod bool PositionSource::setBackendProperty(string name, Variant value) - - Sets the backend-specific property named \a name to \a value. - Returns true on success, false otherwise, including if called on an uninitialized PositionSource. - Supported backend-specific properties are listed and described in - \l {Qt Positioning plugins#Default plugins}. - - \since Qt Positioning 5.14 - - \sa backendProperty, QGeoPositionInfoSource::setBackendProperty -*/ -bool QDeclarativePositionSource::setBackendProperty(const QString &name, const QVariant &value) -{ - if (m_positionSource) - return m_positionSource->setBackendProperty(name, value); - return false; -} - -/*! - \qmlmethod Variant PositionSource::backendProperty(string name) - - Returns the value of the backend-specific property named \a name, if present. - Otherwise, including if called on an uninitialized PositionSource, the return value will be invalid. - Supported backend-specific properties are listed and described in - \l {Qt Positioning plugins#Default plugins}. - - \since Qt Positioning 5.14 - - \sa backendProperty, QGeoPositionInfoSource::setBackendProperty -*/ -QVariant QDeclarativePositionSource::backendProperty(const QString &name) const -{ - if (m_positionSource) - return m_positionSource->backendProperty(name); - return QVariant(); -} - -QBindable<bool> QDeclarativePositionSource::bindableActive() -{ - return QBindable<bool>(&m_active); -} - -/*! - \internal -*/ -void QDeclarativePositionSource::sourceErrorReceived(const QGeoPositionInfoSource::Error error) -{ - if (error == QGeoPositionInfoSource::AccessError) - m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::AccessError); - else if (error == QGeoPositionInfoSource::ClosedError) - m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::ClosedError); - else if (error == QGeoPositionInfoSource::UpdateTimeoutError) - handleUpdateTimeout(); // also sets m_sourceError - else if (error == QGeoPositionInfoSource::NoError) - return; //nothing to do - else - m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::UnknownSourceError); - - m_sourceError.notify(); - emit sourceErrorChanged(); -} - -QT_END_NAMESPACE diff --git a/src/positioningquick/qdeclarativepositionsource_p.h b/src/positioningquick/qdeclarativepositionsource_p.h deleted file mode 100644 index 5651a266..00000000 --- a/src/positioningquick/qdeclarativepositionsource_p.h +++ /dev/null @@ -1,222 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QDECLARATIVEPOSITIONSOURCE_H -#define QDECLARATIVEPOSITIONSOURCE_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 <QtPositioningQuick/private/qpositioningquickglobal_p.h> -#include <QtPositioningQuick/private/qdeclarativeposition_p.h> -#include <QtCore/QObject> -#include <QtNetwork/QAbstractSocket> -#include <QtQml/QQmlParserStatus> -#include <QtPositioning/qgeopositioninfosource.h> -#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h> -#include <QtCore/private/qproperty_p.h> - -QT_BEGIN_NAMESPACE - -class QFile; -class QTcpSocket; - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativePositionSource : public QObject, public QQmlParserStatus -{ - Q_OBJECT - QML_NAMED_ELEMENT(PositionSource) - QML_ADDED_IN_VERSION(5, 0) - - Q_PROPERTY(QDeclarativePosition *position READ position NOTIFY positionChanged - BINDABLE bindablePosition) - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged - BINDABLE bindableActive) - Q_PROPERTY(bool valid READ isValid NOTIFY validityChanged BINDABLE bindableIsValid) - Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval - NOTIFY updateIntervalChanged) - Q_PROPERTY(PositioningMethods supportedPositioningMethods READ supportedPositioningMethods - NOTIFY supportedPositioningMethodsChanged - BINDABLE bindableSupportedPositioningMethods) - Q_PROPERTY(PositioningMethods preferredPositioningMethods READ preferredPositioningMethods - WRITE setPreferredPositioningMethods NOTIFY preferredPositioningMethodsChanged) - Q_PROPERTY(SourceError sourceError READ sourceError NOTIFY sourceErrorChanged - BINDABLE bindableSourceError) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged BINDABLE bindableName) - Q_PROPERTY(QQmlListProperty<QDeclarativePluginParameter> parameters READ parameters REVISION(5, 14)) - Q_ENUMS(PositioningMethod) - - Q_CLASSINFO("DefaultProperty", "parameters") - Q_INTERFACES(QQmlParserStatus) - -public: - enum PositioningMethod { - NoPositioningMethods = QGeoPositionInfoSource::NoPositioningMethods, - SatellitePositioningMethods = QGeoPositionInfoSource::SatellitePositioningMethods, - NonSatellitePositioningMethods = QGeoPositionInfoSource::NonSatellitePositioningMethods, - AllPositioningMethods = QGeoPositionInfoSource::AllPositioningMethods - }; - - Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod) - Q_FLAGS(PositioningMethods) - - enum SourceError { - AccessError = QGeoPositionInfoSource::AccessError, - ClosedError = QGeoPositionInfoSource::ClosedError, - UnknownSourceError = QGeoPositionInfoSource::UnknownSourceError, - NoError = QGeoPositionInfoSource::NoError, - UpdateTimeoutError = QGeoPositionInfoSource::UpdateTimeoutError, - }; - Q_ENUMS(SourceError) - - QDeclarativePositionSource(); - ~QDeclarativePositionSource(); - void setUpdateInterval(int updateInterval); - void setActive(bool active); - void setPreferredPositioningMethods(PositioningMethods methods); - - QString name() const; - void setName(const QString &name); - - int updateInterval() const; - bool isActive() const; - bool isValid() const; - QDeclarativePosition *position(); - PositioningMethods supportedPositioningMethods() const; - PositioningMethods preferredPositioningMethods() const; - SourceError sourceError() const; - QGeoPositionInfoSource *positionSource() const; - QQmlListProperty<QDeclarativePluginParameter> parameters(); - QVariantMap parameterMap() const; - - // Virtuals from QQmlParserStatus - void classBegin() override { } - void componentComplete() override; - - Q_REVISION(5, 14) Q_INVOKABLE bool setBackendProperty(const QString &name, const QVariant &value); - Q_REVISION(5, 14) Q_INVOKABLE QVariant backendProperty(const QString &name) const; - - QBindable<PositioningMethods> bindableSupportedPositioningMethods() const; - QBindable<SourceError> bindableSourceError() const; - QBindable<bool> bindableIsValid() const; - QBindable<QString> bindableName(); - QBindable<QDeclarativePosition *> bindablePosition() const; - QBindable<bool> bindableActive(); - -public Q_SLOTS: - void update(int timeout = 0); - void start(); - void stop(); - -Q_SIGNALS: - void positionChanged(); - void activeChanged(); - void updateIntervalChanged(); - void supportedPositioningMethodsChanged(); - void preferredPositioningMethodsChanged(); - void sourceErrorChanged(); - void nameChanged(); - void validityChanged(); - -private Q_SLOTS: - void positionUpdateReceived(const QGeoPositionInfo &update); - void sourceErrorReceived(const QGeoPositionInfoSource::Error error); - void onParameterInitialized(); - void notifySupportedPositioningMethodsChanged(); - -private: - void handleUpdateTimeout(); - void setPosition(const QGeoPositionInfo &pi); - void setSource(QGeoPositionInfoSource *source); - bool parametersReady(); - void tryAttach(const QString &name, bool useFallback = true); - - static void parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *mapObject); - static qsizetype parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop); - static QDeclarativePluginParameter *parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, qsizetype index); - static void parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop); - - bool isValidActualComputation() const; - PositioningMethods supportedMethodsActualComputation() const; - - void executeStart(); - - QGeoPositionInfoSource *m_positionSource = nullptr; - PositioningMethods m_preferredPositioningMethods = AllPositioningMethods; - bool m_singleUpdate = false; - bool m_regularUpdates = false; - int m_updateInterval = 0; - QList<QDeclarativePluginParameter *> m_parameters; - bool m_componentComplete = false; - bool m_parametersInitialized = false; - - bool m_defaultSourceUsed = false; - Q_OBJECT_COMPAT_PROPERTY(QDeclarativePositionSource, QString, m_sourceName, - &QDeclarativePositionSource::setName, - &QDeclarativePositionSource::nameChanged) - - Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QDeclarativePositionSource, bool, m_active, - &QDeclarativePositionSource::setActive, - &QDeclarativePositionSource::activeChanged, false) - - Q_OBJECT_BINDABLE_PROPERTY(QDeclarativePositionSource, QDeclarativePosition *, m_position) - - Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QDeclarativePositionSource, SourceError, m_sourceError, - NoError) - - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePositionSource, PositioningMethods, - m_supportedPositioningMethods, - &QDeclarativePositionSource::supportedMethodsActualComputation) - - Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePositionSource, bool, m_isValid, - &QDeclarativePositionSource::isValidActualComputation) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativePositionSource) - -#endif diff --git a/src/positioningquick/qpositioningquickglobal.h b/src/positioningquick/qpositioningquickglobal.h deleted file mode 100644 index 214e4628..00000000 --- a/src/positioningquick/qpositioningquickglobal.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QPOSITIONINGQUICKGLOBAL_H -#define QPOSITIONINGQUICKGLOBAL_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 <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_POSITIONINGQUICK_LIB) -# define Q_POSITIONINGQUICK_EXPORT Q_DECL_EXPORT -# else -# define Q_POSITIONINGQUICK_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_POSITIONINGQUICK_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QPOSITIONINGQUICKGLOBAL_H diff --git a/src/positioningquick/qpositioningquickglobal_p.h b/src/positioningquick/qpositioningquickglobal_p.h deleted file mode 100644 index ce284106..00000000 --- a/src/positioningquick/qpositioningquickglobal_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QPOSITIONINGQUICKGLOBAL_P_H -#define QPOSITIONINGQUICKGLOBAL_P_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 "qpositioningquickglobal.h" - -QT_BEGIN_NAMESPACE - -#define Q_POSITIONINGQUICK_PRIVATE_EXPORT Q_POSITIONINGQUICK_EXPORT - -QT_END_NAMESPACE - -void Q_POSITIONINGQUICK_PRIVATE_EXPORT qml_register_types_QtPositioning(); - -#endif // QPOSITIONINGQUICKGLOBAL_P_H diff --git a/src/positioningquick/qpositioningquickmodule_p.h b/src/positioningquick/qpositioningquickmodule_p.h deleted file mode 100644 index 6d8aed91..00000000 --- a/src/positioningquick/qpositioningquickmodule_p.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QT_POSITIONINGQUICKMODULE_P_H -#define QT_POSITIONINGQUICKMODULE_P_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 <QtQml/qqml.h> -#include "qpositioningquickglobal_p.h" - -#include <QtPositioning/QGeoCoordinate> -#include <QtPositioning/QGeoAddress> -#include <QtPositioning/QGeoRectangle> -#include <QtPositioning/QGeoCircle> -#include <QtPositioning/QGeoPath> -#include <QtPositioning/QGeoPolygon> -#include <QtPositioning/QGeoLocation> -#include <QtPositioning/QGeoShape> -#include <QtPositioning/QGeoPositionInfo> -#include <QtPositioning/private/qgeocoordinateobject_p.h> - -QT_BEGIN_NAMESPACE - -struct QGeoCoordinateForeign -{ - Q_GADGET - QML_FOREIGN(QGeoCoordinate) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoAddressForeign -{ - Q_GADGET - QML_FOREIGN(QGeoAddress) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoRectangleForeign -{ - Q_GADGET - QML_FOREIGN(QGeoRectangle) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoCircleForeign -{ - Q_GADGET - QML_FOREIGN(QGeoCircle) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoPathForeign -{ - Q_GADGET - QML_FOREIGN(QGeoPath) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoPolygonForeign -{ - Q_GADGET - QML_FOREIGN(QGeoPolygon) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoLocationForeign -{ - Q_GADGET - QML_FOREIGN(QGeoLocation) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoShapeForeign -{ - Q_GADGET - QML_FOREIGN(QGeoShape) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoCoordinateObjectForeign -{ - Q_GADGET - QML_FOREIGN(QGeoCoordinateObject) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -struct QGeoPositionInfoForeign -{ - Q_GADGET - QML_FOREIGN(QGeoPositionInfo) - QML_ANONYMOUS - QML_ADDED_IN_VERSION(5, 0) -}; - -QT_END_NAMESPACE - -#endif // QT_POSITIONINGQUICKMODULE_P_H diff --git a/src/positioningquick/qquickgeocoordinateanimation.cpp b/src/positioningquick/qquickgeocoordinateanimation.cpp deleted file mode 100644 index 3f5cef8d..00000000 --- a/src/positioningquick/qquickgeocoordinateanimation.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 "qquickgeocoordinateanimation_p.h" -#include "qquickgeocoordinateanimation_p_p.h" -#include <QtQuick/private/qquickanimation_p_p.h> -#include <QtPositioning/private/qdoublevector2d_p.h> -#include <QtPositioning/private/qwebmercator_p.h> -#include <QtPositioning/private/qgeocoordinate_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype CoordinateAnimation - \inherits PropertyAnimation - \inqmlmodule QtPositioning - \since 5.3 - - \brief A PropertyAnimation for geo coordinate properties. - - A specialized \l{PropertyAnimation} that defines an animation - between two \l{coordinate}{coordinates}. - - By default, a \l{latitude} of the \l{coordinate} is animated in the direction of shortest - (geodesic) distance between those coordinates. Since CoordinateAnimation uses Mercator - map projection, the \l{latitude} animation is always between -90 and 90 degrees. - The \l{longitude} animation path is not limited and can go over 180 degrees - in both west and east directions. - - The \l{direction} property can be set to specify the direction in which the \l{longitude} - animation should occur. - - \sa {Animation and Transitions in Qt Quick} -*/ - -QVariant q_coordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress) -{ - if (from == to) { - if (progress < 0.5) { - return QVariant::fromValue(from); - } else { - return QVariant::fromValue(to); - } - } - - QGeoCoordinate result = QWebMercator::coordinateInterpolation(from, to, progress); - - return QVariant::fromValue(result); -} - -QVariant q_coordinateShortestInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress) -{ - const QGeoMercatorCoordinatePrivate* fromMercator = - static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&from)); - const QGeoMercatorCoordinatePrivate* toMercator = - static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&to)); - - double toX = toMercator->m_mercatorX; - double toY = toMercator->m_mercatorY; - double fromX = fromMercator->m_mercatorX; - double fromY = fromMercator->m_mercatorY; - double x; - if (0.5 < qAbs(toX - fromX)) { - // handle dateline crossing - double ex = toX; - double sx = fromX; - if (ex < sx) - sx -= 1.0; - else if (sx < ex) - ex -= 1.0; - - x = sx + (ex - sx) * progress; - - if (x < 0.0) - x += 1.0; - - } else { - x = fromX + (toX - fromX) * progress; - } - - double y = fromY + (toY - fromY) * progress; - - QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y)); - result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress); - return QVariant::fromValue(result); -} - -QVariant q_coordinateEastInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress) -{ - const QGeoMercatorCoordinatePrivate* fromMercator = - static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&from)); - const QGeoMercatorCoordinatePrivate* toMercator = - static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&to)); - - double toX = toMercator->m_mercatorX; - double toY = toMercator->m_mercatorY; - double fromX = fromMercator->m_mercatorX; - double fromY = fromMercator->m_mercatorY; - double diff = toX - fromX; - - while (diff < 0.0) { - toX += 1.0; - diff += 1.0; - } - - double x = fromX + (toX - fromX) * progress; - double y = fromY + (toY - fromY) * progress; - - while (x > 1.0) - x -= 1.0; - - QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y)); - result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress); - - return QVariant::fromValue(result); -} - -QVariant q_coordinateWestInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress) -{ - const QGeoMercatorCoordinatePrivate* fromMercator = - static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&from)); - const QGeoMercatorCoordinatePrivate* toMercator = - static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&to)); - - double toX = toMercator->m_mercatorX; - double toY = toMercator->m_mercatorY; - double fromX = fromMercator->m_mercatorX; - double fromY = fromMercator->m_mercatorY; - double diff = toX - fromX; - - while (diff > 0.0) { - toX -= 1.0; - diff -= 1.0; - } - - double x = fromX + (toX - fromX) * progress; - double y = fromY + (toY - fromY) * progress; - - while (x < 0.0) - x += 1.0; - - QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y)); - result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress); - - return QVariant::fromValue(result); -} - -QQuickGeoCoordinateAnimation::QQuickGeoCoordinateAnimation(QObject *parent) - : QQuickPropertyAnimation(*(new QQuickGeoCoordinateAnimationPrivate), parent) - -{ - Q_D(QQuickGeoCoordinateAnimation); - d->interpolatorType = qMetaTypeId<QGeoCoordinate>(); - d->defaultToInterpolatorType = true; - d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); -} - -QQuickGeoCoordinateAnimation::~QQuickGeoCoordinateAnimation() -{ -} - -/*! - \qmlproperty coordinate CoordinateAnimation::from - This property holds the coordinate where the animation should begin. -*/ -QGeoCoordinate QQuickGeoCoordinateAnimation::from() const -{ - Q_D(const QQuickGeoCoordinateAnimation); - return d->from.value<QGeoCoordinate>(); -} - -void QQuickGeoCoordinateAnimation::setFrom(const QGeoCoordinate &f) -{ - QGeoMercatorCoordinatePrivate *mercator = new QGeoMercatorCoordinatePrivate(); - QDoubleVector2D fromVector = QWebMercator::coordToMercator(f); - mercator->lat = f.latitude(); - mercator->lng = f.longitude(); - mercator->alt = f.altitude(); - mercator->m_mercatorX = fromVector.x(); - mercator->m_mercatorY = fromVector.y(); - QGeoCoordinate from(*mercator); - QQuickPropertyAnimation::setFrom(QVariant::fromValue(from)); -} - -/*! - \qmlproperty coordinate CoordinateAnimation::to - This property holds the coordinate where the animation should end. -*/ -QGeoCoordinate QQuickGeoCoordinateAnimation::to() const -{ - Q_D(const QQuickGeoCoordinateAnimation); - return d->to.value<QGeoCoordinate>(); -} - -void QQuickGeoCoordinateAnimation::setTo(const QGeoCoordinate &t) -{ - QGeoMercatorCoordinatePrivate *mercator = new QGeoMercatorCoordinatePrivate(); - QDoubleVector2D toVector = QWebMercator::coordToMercator(t); - mercator->lat = t.latitude(); - mercator->lng = t.longitude(); - mercator->alt = t.altitude(); - mercator->m_mercatorX = toVector.x(); - mercator->m_mercatorY = toVector.y(); - QGeoCoordinate to(*mercator); - QQuickPropertyAnimation::setTo(QVariant::fromValue(to)); -} - -/*! - \qmlproperty enumeration CoordinateAnimation::direction - This property holds the direction of the \l{longitude} animation of the \l{coordinate}. - - Possible values are: - - \list - \li CoordinateAnimation.Shortest (default) - the longitude animation goes in the direction - that produces the shortest animation path. - \li CoordinateAnimation.West - the longitude animation always goes into western direction - and may cross the date line. - \li CoordinateAnimation.East - the longitude animation always goes into eastern direction - and may cross the date line. - \endlist - \since 5.5 -*/ - - -QQuickGeoCoordinateAnimation::Direction QQuickGeoCoordinateAnimation::direction() const -{ - Q_D(const QQuickGeoCoordinateAnimation); - return d->m_direction.value(); -} - -void QQuickGeoCoordinateAnimation::setDirection(QQuickGeoCoordinateAnimation::Direction direction) -{ - Q_D( QQuickGeoCoordinateAnimation); - d->m_direction.removeBindingUnlessInWrapper(); - if (d->m_direction.value() == direction) - return; - - d->m_direction.setValueBypassingBindings(direction); - switch (direction) { - case West: - d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateWestInterpolator)); - break; - case East: - d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateEastInterpolator)); - break; - case Shortest: - default: - d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateShortestInterpolator)); - break; - } - d->m_direction.notify(); -} - -QBindable<QQuickGeoCoordinateAnimation::Direction> QQuickGeoCoordinateAnimation::bindableDirection() -{ - Q_D(QQuickGeoCoordinateAnimation); - return QBindable<Direction>(&d->m_direction); -} - -QT_END_NAMESPACE diff --git a/src/positioningquick/qquickgeocoordinateanimation_p.h b/src/positioningquick/qquickgeocoordinateanimation_p.h deleted file mode 100644 index 4cd8f567..00000000 --- a/src/positioningquick/qquickgeocoordinateanimation_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QQUICKGEOCOORDINATEANIMATION_P_H -#define QQUICKGEOCOORDINATEANIMATION_P_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 <QtPositioningQuick/private/qpositioningquickglobal_p.h> -#include <QtQuick/private/qquickanimation_p.h> -#include <QtPositioning/qgeocoordinate.h> - -QT_BEGIN_NAMESPACE - -class QQuickGeoCoordinateAnimationPrivate; - -class Q_POSITIONINGQUICK_PRIVATE_EXPORT QQuickGeoCoordinateAnimation : public QQuickPropertyAnimation -{ - Q_OBJECT - QML_NAMED_ELEMENT(CoordinateAnimation) - QML_ADDED_IN_VERSION(5, 3) - Q_DECLARE_PRIVATE(QQuickGeoCoordinateAnimation) - Q_PROPERTY(QGeoCoordinate from READ from WRITE setFrom) - Q_PROPERTY(QGeoCoordinate to READ to WRITE setTo) - Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged - BINDABLE bindableDirection) - -public: - enum Direction { - Shortest, - West, - East - }; - Q_ENUM(Direction) - - QQuickGeoCoordinateAnimation(QObject *parent=0); - ~QQuickGeoCoordinateAnimation(); - - QGeoCoordinate from() const; - void setFrom(const QGeoCoordinate &); - - QGeoCoordinate to() const; - void setTo(const QGeoCoordinate &); - - Direction direction() const; - void setDirection(Direction direction); - QBindable<Direction> bindableDirection(); - -Q_SIGNALS: - void directionChanged(); -}; - -QVariant Q_POSITIONINGQUICK_PRIVATE_EXPORT q_coordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress); - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickGeoCoordinateAnimation) - -#endif // QQUICKCOORDINATEANIMATION_P_H diff --git a/src/positioningquick/qquickgeocoordinateanimation_p_p.h b/src/positioningquick/qquickgeocoordinateanimation_p_p.h deleted file mode 100644 index c2d714b1..00000000 --- a/src/positioningquick/qquickgeocoordinateanimation_p_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPositioning 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 QQUICKGEOCOORDINATEANIMATION_P_P_H -#define QQUICKGEOCOORDINATEANIMATION_P_P_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 "qquickgeocoordinateanimation_p.h" -#include <QtQuick/private/qquickanimation_p_p.h> -#include <QtCore/private/qproperty_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickGeoCoordinateAnimationPrivate : public QQuickPropertyAnimationPrivate -{ - Q_DECLARE_PUBLIC(QQuickGeoCoordinateAnimation) -public: - void setDirection(QQuickGeoCoordinateAnimation::Direction direction) - { - q_func()->setDirection(direction); - } - void directionChanged() - { - Q_EMIT q_func()->directionChanged(); - } - - Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QQuickGeoCoordinateAnimationPrivate, - QQuickGeoCoordinateAnimation::Direction, m_direction, - &QQuickGeoCoordinateAnimationPrivate::setDirection, - &QQuickGeoCoordinateAnimationPrivate::directionChanged, - QQuickGeoCoordinateAnimation::Shortest) -}; - -QT_END_NAMESPACE - -#endif // QQUICKGEOCOORDINATEANIMATION_P_P_H |