summaryrefslogtreecommitdiffstats
path: root/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-01-12 18:12:27 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-01-22 19:17:44 +0000
commit723b69ecd818e42cf3f0b63e69872edc847be549 (patch)
treef5357708a73d52aa41d6d557e594f1f7ebe60f1a /src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
parent20c21955c2ccfd2bf5ec285b8b488f3bf89c269b (diff)
Move QML/Cpp list conversions into locationvaluetypehelper
Change-Id: Iee7f48f7d24b40a2824775654030397617c40640 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativepolylinemapitem.cpp')
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp31
1 files changed, 2 insertions, 29 deletions
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index a97271aa..7c1b922f 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -455,20 +455,7 @@ void QDeclarativePolylineMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
QJSValue QDeclarativePolylineMapItem::path() const
{
- QQmlContext *context = QQmlEngine::contextForObject(this);
- QQmlEngine *engine = context->engine();
- QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
-
- QV4::Scope scope(v4);
- QV4::Scoped<QV4::ArrayObject> 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 QDeclarativePolylineMapItem::setPath(const QJSValue &value)
@@ -476,21 +463,7 @@ void QDeclarativePolylineMapItem::setPath(const QJSValue &value)
if (!value.isArray())
return;
- QList<QGeoCoordinate> 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);
- }
-
- setPathFromGeoList(pathList);
+ setPathFromGeoList(toList(this, value));
}
/*!