summaryrefslogtreecommitdiff
path: root/src/imports/positioning/positioning.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-01-05 15:40:59 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-01-08 14:07:26 +0100
commit8bf0a15bfc124fbb664592d4c3f29973fc23262e (patch)
tree62d0dc2f89f6631dea511ba591c3b694d2e0e3ce /src/imports/positioning/positioning.cpp
parent7765577cca78f1789f8685bea245e93f697fd125 (diff)
downloadqtlocation-8bf0a15bfc124fbb664592d4c3f29973fc23262e.tar.gz
Make QtLocation work after internal valuetype changes in QtQML
The value type wrapper code was completely removed. Instead QGeoShape & derived classes and QGeoCoordinate use Q_GADGET to advertise their meta data which in turn allows QtQML to dynamically discover the types when needed. This implies that the above C++ classes become larger as the meta data is permanently added. On the positive side all QML value type wrapper were removed which reduces the QML plugin size. At the same time it becomes significantly easier to use those types in other QML plugins such as the QtLocation one. Unfortunately this change comes with an unavoidable behavior change as well. Previously is was possible to set a width and height on an invalid QML rectangle. In the case of an invalid rect it was made valid (setting center to 0,0) before setting the height or width. The QGeoRectangle class explicitly aborts calls to setHeight() and setWidth() in case of an invalid rect. From now on the C++ class behavior is used in QML too. This was the reason for the change to tst_map_routing.qml in this patch. Incidentally the documentation always referred to the QGeoRectangle documentation and thus always stated the now new behavior. Documentation for the value types and the relevant behavior changes will be re-added in a later commit. Each Gadget must be registered using QMetaType::registerComparators<T>() to enable == and != operators in QML. Unfortunately QMetaType requires the operator< which does not make any sense for the value types touched by this patch. Right now, a warning is printed. Attempts will be made to remove the operator< requirement in QMetaType. Otherwise the warning has to be removed before the release as they are printed very often. [ChangeLog][QtPositioning][Important Behavior Changes] The QML rectangle type ignores setting of the height and width if the rectangle is invalid. Previously the property setter changed the rectangle center to QGeoCoordinate(0,0) before setting the height and width of a previously invalid rectangle. Change-Id: Iab98ede58066ce03b2b4e0ce03ed85ba7ecb1020 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/imports/positioning/positioning.cpp')
-rw-r--r--src/imports/positioning/positioning.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/imports/positioning/positioning.cpp b/src/imports/positioning/positioning.cpp
index d7791eb0..3efe7a2b 100644
--- a/src/imports/positioning/positioning.cpp
+++ b/src/imports/positioning/positioning.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -31,7 +31,6 @@
**
****************************************************************************/
-#include "locationvaluetypeprovider.h"
#include <QtPositioning/private/qdeclarativegeoaddress_p.h>
#include <QtPositioning/private/qdeclarativegeolocation_p.h>
@@ -39,12 +38,7 @@
#include "qdeclarativepositionsource_p.h"
#include "qdeclarativeposition_p.h"
-#include "qdeclarativegeoshape.h"
-#include "qdeclarativegeorectangle.h"
-#include "qdeclarativegeocircle.h"
-#include "qdeclarativecoordinate_p.h"
#include "qdeclarativegeocoordinateanimation_p.h"
-
#include "locationsingleton.h"
#include <QtCore/QVariantAnimation>
@@ -71,12 +65,6 @@ static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine)
return new LocationSingleton;
}
-static LocationValueTypeProvider *getValueTypeProvider()
-{
- static LocationValueTypeProvider provider;
- return &provider;
-}
-
class QtPositioningDeclarativeModule: public QQmlExtensionPlugin
{
Q_OBJECT
@@ -95,18 +83,22 @@ public:
int minor = 0;
qRegisterMetaType<QGeoCoordinate>("QGeoCoordinate");
+ QMetaType::registerComparators<QGeoCoordinate>();
qRegisterMetaType<QGeoAddress>("QGeoAddress");
qRegisterMetaType<QGeoRectangle>("QGeoRectangle");
+ QMetaType::registerComparators<QGeoRectangle>();
qRegisterMetaType<QGeoCircle>("QGeoCircle");
+ QMetaType::registerComparators<QGeoCircle>();
qRegisterMetaType<QGeoLocation>("QGeoLocation");
+ qRegisterMetaType<QGeoShape>();
+ QMetaType::registerComparators<QGeoShape>();
qRegisterAnimationInterpolator<QGeoCoordinate>(geoCoordinateInterpolator);
- QQml_addValueTypeProvider(getValueTypeProvider());
// Register the 5.0 types
// 5.0 is silent and not advertised
qmlRegisterSingletonType<LocationSingleton >(uri, major, minor, "QtPositioning", singleton_type_factory);
- qmlRegisterValueTypeEnums<GeoShapeValueType >(uri, major, minor, "GeoShape");
+ qmlRegisterValueTypeEnums<QGeoShape >(uri, major, minor, "GeoShape");
qmlRegisterType<QDeclarativePosition >(uri, major, minor, "Position");
qmlRegisterType<QDeclarativePositionSource >(uri, major, minor, "PositionSource");
qmlRegisterType<QDeclarativeGeoAddress >(uri, major, minor, "Address");