From 723b69ecd818e42cf3f0b63e69872edc847be549 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 12 Jan 2018 18:12:27 +0100 Subject: Move QML/Cpp list conversions into locationvaluetypehelper Change-Id: Iee7f48f7d24b40a2824775654030397617c40640 Reviewed-by: Alex Blasche --- .../declarativemaps/qdeclarativepolygonmapitem.cpp | 29 ++-------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'src/location/declarativemaps/qdeclarativepolygonmapitem.cpp') diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index 7460a376..8c7afc17 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -380,20 +380,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m */ QJSValue QDeclarativePolygonMapItem::path() const { - QQmlContext *context = QQmlEngine::contextForObject(this); - QQmlEngine *engine = context->engine(); - QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine); - - QV4::Scope scope(v4); - QV4::Scoped pathArray(scope, v4->newArrayObject(geopath_.path().length())); - for (int i = 0; i < geopath_.path().length(); ++i) { - const QGeoCoordinate &c = geopath_.coordinateAt(i); - - QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c))); - pathArray->putIndexed(i, cv); - } - - return QJSValue(v4, pathArray.asReturnedValue()); + return fromList(this, geopath_.path()); } void QDeclarativePolygonMapItem::setPath(const QJSValue &value) @@ -401,19 +388,7 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value) if (!value.isArray()) return; - QList pathList; - quint32 length = value.property(QStringLiteral("length")).toUInt(); - for (quint32 i = 0; i < length; ++i) { - bool ok; - QGeoCoordinate c = parseCoordinate(value.property(i), &ok); - - if (!ok || !c.isValid()) { - qmlWarning(this) << "Unsupported path type"; - return; - } - - pathList.append(c); - } + QList pathList = toList(this, value); // Equivalent to QDeclarativePolylineMapItem::setPathFromGeoList if (geopath_.path() == pathList) -- cgit v1.2.1