summaryrefslogtreecommitdiff
path: root/src/location/declarativemaps/qdeclarativepolygonmapitem.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/qdeclarativepolygonmapitem.cpp
parent20c21955c2ccfd2bf5ec285b8b488f3bf89c269b (diff)
downloadqtlocation-723b69ecd818e42cf3f0b63e69872edc847be549.tar.gz
Move QML/Cpp list conversions into locationvaluetypehelper
Change-Id: Iee7f48f7d24b40a2824775654030397617c40640 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativepolygonmapitem.cpp')
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp29
1 files changed, 2 insertions, 27 deletions
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<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 QDeclarativePolygonMapItem::setPath(const QJSValue &value)
@@ -401,19 +388,7 @@ void QDeclarativePolygonMapItem::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);
- }
+ QList<QGeoCoordinate> pathList = toList(this, value);
// Equivalent to QDeclarativePolylineMapItem::setPathFromGeoList
if (geopath_.path() == pathList)