diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-05-20 11:30:13 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-05-26 13:29:26 +0000 |
commit | 9c61ad227761c9f83ea441c6a8db2d570a4009a3 (patch) | |
tree | 71320572d0be2d2c4d2ad5a96445567596b06602 /tests/auto | |
parent | 68115c86eb0bfbe3218ed4fa3af3b006720a8c43 (diff) | |
download | qtlocation-9c61ad227761c9f83ea441c6a8db2d570a4009a3.tar.gz |
Workaround for failing conversion between Q_GADGET's
QGeoRectangle and QGeoCircle are subclasses of QGeoShape. Before this
patch setting a QGeoShape property of a QML object is not possible
because the QGeoRectangle/QGeoCircle cannot be converted to a QGeoShape.
This patch addresses the problem by providing custom converters for
the above classes. It enables QVariant::convert() for the classes above.
Change-Id: I7daba5254dad0df598324432db3b1819e68648b6
Task-number: QTBUG-46232
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgeoshape/tst_qgeoshape.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qgeoshape/tst_qgeoshape.cpp b/tests/auto/qgeoshape/tst_qgeoshape.cpp index 301018a9..5f094010 100644 --- a/tests/auto/qgeoshape/tst_qgeoshape.cpp +++ b/tests/auto/qgeoshape/tst_qgeoshape.cpp @@ -59,6 +59,7 @@ private slots: void testArea(); void debug_data(); void debug(); + void conversions(); }; void tst_qgeoshape::testArea() @@ -111,5 +112,24 @@ void tst_qgeoshape::debug() QCOMPARE(tst_qgeoshape_debug, debugString); } +void tst_qgeoshape::conversions() +{ + QVariant varShape = QVariant::fromValue(QGeoShape()); + QVariant varRect = QVariant::fromValue(QGeoRectangle( + QGeoCoordinate(1, 1), + QGeoCoordinate(2, 2))); + QVariant varCircle = QVariant::fromValue(QGeoCircle(QGeoCoordinate(3, 3), 1000)); + + QVERIFY(varShape.canConvert<QGeoShape>()); + QVERIFY(varShape.canConvert<QGeoCircle>()); + QVERIFY(varShape.canConvert<QGeoRectangle>()); + QVERIFY(!varRect.canConvert<QGeoCircle>()); + QVERIFY(varRect.canConvert<QGeoRectangle>()); + QVERIFY(varRect.canConvert<QGeoShape>()); + QVERIFY(varCircle.canConvert<QGeoCircle>()); + QVERIFY(!varCircle.canConvert<QGeoRectangle>()); + QVERIFY(varCircle.canConvert<QGeoShape>()); +} + QTEST_MAIN(tst_qgeoshape) #include "tst_qgeoshape.moc" |