diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-01-05 15:40:59 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-01-08 14:07:26 +0100 |
commit | 8bf0a15bfc124fbb664592d4c3f29973fc23262e (patch) | |
tree | 62d0dc2f89f6631dea511ba591c3b694d2e0e3ce /tests/auto/qgeocoordinate | |
parent | 7765577cca78f1789f8685bea245e93f697fd125 (diff) | |
download | qtlocation-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 'tests/auto/qgeocoordinate')
-rw-r--r-- | tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp b/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp index 142873dd..a47a75d4 100644 --- a/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp +++ b/tests/auto/qgeocoordinate/tst_qgeocoordinate.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 test suite of the Qt Toolkit. @@ -84,6 +84,12 @@ private: }; private slots: + void initTestcase() + { + qRegisterMetaType<QGeoCoordinate>(); + QMetaType::registerComparators<QGeoCoordinate>(); + } + void constructor() { QGeoCoordinate c; @@ -281,6 +287,9 @@ private slots: QFETCH(bool, result); QCOMPARE(c1 == c2, result); + QVariant v1 = QVariant::fromValue(c1); + QVariant v2 = QVariant::fromValue(c2); + QCOMPARE(v2 == v1, result); } void comparison_data() |