From 1549d59e448550f05c5bd1ea6a9da5d1e78c7f26 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 27 Jul 2012 12:58:48 +1000 Subject: Convert Coordinate into a QML coordinate value type. This replaces the Coordinate QML element with a value type. A value type is a better fit for a coordinate. It is very similar to a vector3d except it has an explicit coordinate system and some utility functions. Declare QGeoCoordinate as a movable type. Update documentation. Change-Id: I758fa9dfd7154a4d60fb791fe553b9fee3164c2c Reviewed-by: abcd --- src/imports/location/location.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/imports/location/location.cpp') diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index 965b09fc..af93204a 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include "locationvaluetypeprovider.h" + #include "qdeclarativepositionsource_p.h" #include "qdeclarativeposition_p.h" @@ -83,16 +85,36 @@ #include "qdeclarativesearchsuggestionmodel_p.h" #include "error_messages.h" +#include "locationsingleton.h" + #include #include -#include -#include +#include +#include +#include + +#include QT_BEGIN_NAMESPACE +static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(jsEngine) + + return new LocationSingleton; +} + +static LocationValueTypeProvider *getValueTypeProvider() +{ + static LocationValueTypeProvider provider; + return &provider; +} + class QLocationDeclarativeModule: public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0" FILE "plugin.json") @@ -107,9 +129,13 @@ public: // @uri QtLocation 5.0 + qmlRegisterSingletonType(uri, 5, 0, "QtLocation", singleton_type_factory); + + QQml_addValueTypeProvider(getValueTypeProvider()); + QQmlMetaType::registerCustomStringConverter(qMetaTypeId(), stringToCoordinate); + qmlRegisterType(uri, 5, 0, "Position"); qmlRegisterType(uri, 5, 0, "PositionSource"); - qmlRegisterType(uri, 5, 0, "Coordinate"); qmlRegisterUncreatableType(uri, 5, 0, "GeoShape", QCoreApplication::translate(CONTEXT_NAME, NOT_INSTANTIABLE_BY_DEVELOPER).arg("(Positioning)GeoShape")); qmlRegisterType(uri, 5, 0, "GeoRectangle"); qmlRegisterType(uri, 5, 0, "GeoCircle"); -- cgit v1.2.1