diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2012-07-27 12:58:48 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-24 05:28:08 +0200 |
commit | 1549d59e448550f05c5bd1ea6a9da5d1e78c7f26 (patch) | |
tree | a4163bbe7adcb9eeec31d8d9b12399f2cd3cb5cc /src/imports/location/location.cpp | |
parent | 5c8ad55eefd482bdb91d314502289df82c1bc9ad (diff) | |
download | qtlocation-1549d59e448550f05c5bd1ea6a9da5d1e78c7f26.tar.gz |
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 <amos.choy@nokia.com>
Diffstat (limited to 'src/imports/location/location.cpp')
-rw-r--r-- | src/imports/location/location.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
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 <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> -#include <qqmlpropertymap.h> -#include <QDebug> +#include <QtQml/private/qqmlvaluetype_p.h> +#include <QtQml/private/qqmlglobal_p.h> +#include <QtQml/private/qqmlmetatype_p.h> + +#include <QtCore/QDebug> 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<LocationSingleton>(uri, 5, 0, "QtLocation", singleton_type_factory); + + QQml_addValueTypeProvider(getValueTypeProvider()); + QQmlMetaType::registerCustomStringConverter(qMetaTypeId<QGeoCoordinate>(), stringToCoordinate); + qmlRegisterType<QDeclarativePosition>(uri, 5, 0, "Position"); qmlRegisterType<QDeclarativePositionSource>(uri, 5, 0, "PositionSource"); - qmlRegisterType<QDeclarativeCoordinate>(uri, 5, 0, "Coordinate"); qmlRegisterUncreatableType<QDeclarativeGeoShape>(uri, 5, 0, "GeoShape", QCoreApplication::translate(CONTEXT_NAME, NOT_INSTANTIABLE_BY_DEVELOPER).arg("(Positioning)GeoShape")); qmlRegisterType<QDeclarativeGeoRectangle>(uri, 5, 0, "GeoRectangle"); qmlRegisterType<QDeclarativeGeoCircle>(uri, 5, 0, "GeoCircle"); |