Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>

Conflicts:
	src/imports/location/qdeclarativegeoroute.cpp
	src/imports/location/qdeclarativegeoroutemodel.cpp
	src/imports/location/qdeclarativegeoroutesegment.cpp
	src/imports/location/qdeclarativepolygonmapitem.cpp
	src/imports/location/qdeclarativepolylinemapitem.cpp
	src/imports/positioning/locationvaluetypeprovider.cpp
	src/imports/positioning/locationvaluetypeprovider.h
	src/imports/positioning/positioning.cpp
	src/imports/positioning/qdeclarativecoordinate.cpp
	src/imports/positioning/qdeclarativecoordinate_p.h
	src/imports/positioning/qdeclarativegeocircle.cpp
	src/imports/positioning/qdeclarativegeocircle.h
	src/imports/positioning/qdeclarativegeorectangle.cpp
	src/imports/positioning/qdeclarativegeorectangle.h
	src/imports/positioning/qdeclarativegeoshape.cpp
	src/imports/positioning/qdeclarativegeoshape.h
	src/positioning/qgeocircle.cpp
	src/positioning/qgeocircle.h
	src/positioning/qgeocoordinate.h
	src/positioning/qgeorectangle.cpp
	src/positioning/qgeorectangle.h
	src/positioning/qgeoshape.cpp
	src/positioning/qgeoshape.h
	tests/auto/declarative_core/tst_map_routing.qml
	tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp
  • Loading branch information
Alex Blasche authored and martinjones committed Jun 24, 2016
1 parent 54a9b37 commit eb9adb6
Show file tree
Hide file tree
Showing 27 changed files with 150 additions and 1,898 deletions.
5 changes: 2 additions & 3 deletions src/imports/location/qdeclarativegeoroute.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 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 QtLocation module of the Qt Toolkit.
Expand Down Expand Up @@ -175,8 +175,7 @@ QJSValue QDeclarativeGeoRoute::path() const
for (int i = 0; i < route_.path().length(); ++i) {
const QGeoCoordinate &c = route_.path().at(i);

QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
QV4::ScopedValue cv(scope, QV8Engine::fromVariant(v4, QVariant::fromValue(c)));

pathArray->putIndexed(i, cv);
}
Expand Down
8 changes: 3 additions & 5 deletions src/imports/location/qdeclarativegeoroutemodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 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 QtLocation module of the Qt Toolkit.
Expand Down Expand Up @@ -806,8 +806,7 @@ QJSValue QDeclarativeGeoRouteQuery::waypoints()
for (int i = 0; i < request_.waypoints().length(); ++i) {
const QGeoCoordinate &c = request_.waypoints().at(i);

QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
QV4::ScopedValue cv(scope, QV8Engine::fromVariant(v4, QVariant::fromValue(c)));

waypointArray->putIndexed(i, cv);
}
Expand Down Expand Up @@ -865,8 +864,7 @@ QJSValue QDeclarativeGeoRouteQuery::excludedAreas() const
for (int i = 0; i < request_.excludeAreas().length(); ++i) {
const QGeoRectangle &r = request_.excludeAreas().at(i);

QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoRectangle>());
QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(r), vt));
QV4::ScopedValue cv(scope, QV8Engine::fromVariant(v4, QVariant::fromValue(r)));

excludedAreasArray->putIndexed(i, cv);
}
Expand Down
5 changes: 2 additions & 3 deletions src/imports/location/qdeclarativegeoroutesegment.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 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 QtLocation module of the Qt Toolkit.
Expand Down Expand Up @@ -161,8 +161,7 @@ QJSValue QDeclarativeGeoRouteSegment::path() const
for (int i = 0; i < segment_.path().length(); ++i) {
const QGeoCoordinate &c = segment_.path().at(i);

QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
QV4::ScopedValue cv(scope, QV8Engine::fromVariant(v4, QVariant::fromValue(c)));

pathArray->putIndexed(i, cv);
}
Expand Down
5 changes: 2 additions & 3 deletions src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 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 QtLocation module of the Qt Toolkit.
Expand Down Expand Up @@ -399,8 +399,7 @@ QJSValue QDeclarativePolygonMapItem::path() const
for (int i = 0; i < path_.length(); ++i) {
const QGeoCoordinate &c = path_.at(i);

QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
QV4::ScopedValue cv(scope, QV8Engine::fromVariant(v4, QVariant::fromValue(c)));

pathArray->putIndexed(i, cv);
}
Expand Down
5 changes: 2 additions & 3 deletions src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 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 QtLocation module of the Qt Toolkit.
Expand Down Expand Up @@ -507,8 +507,7 @@ QJSValue QDeclarativePolylineMapItem::path() const
for (int i = 0; i < path_.length(); ++i) {
const QGeoCoordinate &c = path_.at(i);

QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
QV4::ScopedValue cv(scope, QV8Engine::fromVariant(v4, QVariant::fromValue(c)));

pathArray->putIndexed(i, cv);
}
Expand Down
231 changes: 0 additions & 231 deletions src/imports/positioning/locationvaluetypeprovider.cpp

This file was deleted.

0 comments on commit eb9adb6

Please sign in to comment.