summaryrefslogtreecommitdiffstats
path: root/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-04 11:58:35 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-15 14:40:23 +0200
commita6c48812eff4e1aa9b05ea4b811de357242c5588 (patch)
treea0524fa87eb6c77b3b0f0d9cb47b88e0655a8e97 /src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
parent366a6379fb80e8c223ae57b2fd791ffdfeacdbf3 (diff)
Change QJSValue properties to QList<QGeoCoordinate/Rectangle>
The QML engine is able to operate on lists of gadgets, there is no need for using private APIs to operate on QJSValue. For the time being, this breaks a QML construct like path[0].longitude = 0 This no longer changes the value of path[0].latitude in place. Instead, use var path0 = path[0] path0.longitude = ... path[0] = path0 This is consistent with other properties that have type list<gadget>, as QML operates on copies of values, not on references. Adapt the test case accordingly. Since support for value-initializing properties of type list<gadget> requires plumbing in the QML engine, and registration of conversion routines from QVariantMap to QGeoCoordinate, augment the test. Remove the now unnecessary toList/fromList conversion functions, and the dependency to private QtQml libraries. Fixes: QTBUG-105241 Change-Id: I8f248c457a6de27a3b2680bdc948c5683ebc7fa0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativegeoroutemodel.cpp')
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutemodel.cpp41
1 files changed, 5 insertions, 36 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
index d4b453b7..64595ef2 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
@@ -45,7 +45,6 @@
#include <QtCore/QCoreApplication>
#include <QtQml/QQmlEngine>
#include <QtQml/qqmlinfo.h>
-#include <QtQml/private/qqmlengine_p.h>
#include <QtLocation/QGeoRoutingManager>
#include <QtPositioning/QGeoRectangle>
#include "qdeclarativegeomapparameter_p.h"
@@ -944,47 +943,17 @@ void QDeclarativeGeoRouteQuery::setWaypoints(const QVariantList &value)
\sa addExcludedArea, removeExcludedArea, clearExcludedAreas
*/
-QJSValue QDeclarativeGeoRouteQuery::excludedAreas() const
+QList<QGeoRectangle> QDeclarativeGeoRouteQuery::excludedAreas() const
{
- QQmlContext *context = QQmlEngine::contextForObject(parent());
- QQmlEngine *engine = context->engine();
- QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
-
- QV4::Scope scope(v4);
- QV4::Scoped<QV4::ArrayObject> excludedAreasArray(scope, v4->newArrayObject(request_.excludeAreas().length()));
- for (int i = 0; i < request_.excludeAreas().length(); ++i) {
- const QGeoRectangle &r = request_.excludeAreas().at(i);
-
- QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(r)));
- excludedAreasArray->put(i, cv);
- }
-
- return QJSValuePrivate::fromReturnedValue(excludedAreasArray.asReturnedValue());
+ return request_.excludeAreas();
}
-void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value)
+void QDeclarativeGeoRouteQuery::setExcludedAreas(const QList<QGeoRectangle> &value)
{
- if (!value.isArray())
- return;
-
- QList<QGeoRectangle> excludedAreasList;
- quint32 length = value.property(QStringLiteral("length")).toUInt();
- for (quint32 i = 0; i < length; ++i) {
- bool ok;
- QGeoRectangle r = parseRectangle(value.property(i), &ok);
-
- if (!ok || !r.isValid()) {
- qmlWarning(this) << QStringLiteral("Unsupported area type");
- return;
- }
-
- excludedAreasList.append(r);
- }
-
- if (request_.excludeAreas() == excludedAreasList)
+ if (request_.excludeAreas() == value)
return;
- request_.setExcludeAreas(excludedAreasList);
+ request_.setExcludeAreas(value);
if (complete_) {
emit excludedAreasChanged();