summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-09-25 10:36:42 +0300
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-03-21 10:47:12 +0000
commit8f0d2a042458195cebe28f3e80fe9522945b1a14 (patch)
tree7726894e23a5d10abc53956b3d35927062ac5f7d
parentbb109b86f54bd16b6193dc80889458e257b5dcc6 (diff)
downloadqtlocation-8f0d2a042458195cebe28f3e80fe9522945b1a14.tar.gz
Introduce MapPolylineObject and MapPolygonObject
Change-Id: I95b21a8df6e1de600b31ce2fbea55d0a31b31c7f Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/imports/locationlabs/locationlabs.cpp4
-rw-r--r--src/locationlabs/qmappolygonobject.cpp217
-rw-r--r--src/locationlabs/qmappolygonobject_p.h90
-rw-r--r--src/locationlabs/qmappolygonobject_p_p.h112
-rw-r--r--src/locationlabs/qmappolylineobject.cpp186
-rw-r--r--src/locationlabs/qmappolylineobject_p.h85
-rw-r--r--src/locationlabs/qmappolylineobject_p_p.h107
7 files changed, 801 insertions, 0 deletions
diff --git a/src/imports/locationlabs/locationlabs.cpp b/src/imports/locationlabs/locationlabs.cpp
index 22759b4e..1ae5d770 100644
--- a/src/imports/locationlabs/locationlabs.cpp
+++ b/src/imports/locationlabs/locationlabs.cpp
@@ -38,6 +38,8 @@
#include <QtLocationLabs/private/qmapobjectview_p.h>
#include <QtLocationLabs/private/qmaprouteobject_p.h>
#include <QtLocationLabs/private/qmapcircleobject_p.h>
+#include <QtLocationLabs/private/qmappolygonobject_p.h>
+#include <QtLocationLabs/private/qmappolylineobject_p.h>
//#include <QtLocationLabs/private/qdeclarativenavigator_p.h>
#include <QtQml/qqmlextensionplugin.h>
@@ -77,6 +79,8 @@ public:
qmlRegisterType<QMapObjectView>(uri, major, minor, "MapObjectView");
qmlRegisterType<QMapRouteObject>(uri, major, minor, "MapRouteObject");
qmlRegisterType<QMapCircleObject>(uri, major, minor, "MapCircleObject");
+ qmlRegisterType<QMapPolygonObject>(uri, major, minor, "MapPolygonObject");
+ qmlRegisterType<QMapPolylineObject>(uri, major, minor, "MapPolylineObject");
// Register the latest Qt version as QML type version
qmlRegisterModule(uri, QT_VERSION_MAJOR, QT_VERSION_MINOR);
diff --git a/src/locationlabs/qmappolygonobject.cpp b/src/locationlabs/qmappolygonobject.cpp
new file mode 100644
index 00000000..fd4c660a
--- /dev/null
+++ b/src/locationlabs/qmappolygonobject.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmappolygonobject_p.h"
+#include "qmappolygonobject_p_p.h"
+#include <QtLocation/private/locationvaluetypehelper_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QMapPolygonObjectPrivate::QMapPolygonObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q)
+{
+
+}
+
+QMapPolygonObjectPrivate::~QMapPolygonObjectPrivate()
+{
+
+}
+
+QMapPolygonObjectPrivateDefault::QMapPolygonObjectPrivateDefault(QGeoMapObject *q) : QMapPolygonObjectPrivate(q)
+{
+
+}
+
+QMapPolygonObjectPrivateDefault::QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivate &other) : QMapPolygonObjectPrivate(other.q)
+{
+ m_path = other.path();
+ m_borderColor = other.borderColor();
+ m_fillColor = other.fillColor();
+ m_borderWidth = other.borderWidth();
+}
+
+QMapPolygonObjectPrivateDefault::~QMapPolygonObjectPrivateDefault()
+{
+
+}
+
+QGeoMapObject::Type QMapPolygonObjectPrivate::type() const
+{
+ return QGeoMapObject::PolygonType;
+}
+
+QList<QGeoCoordinate> QMapPolygonObjectPrivateDefault::path() const
+{
+ return m_path;
+}
+
+void QMapPolygonObjectPrivateDefault::setPath(const QList<QGeoCoordinate> &path)
+{
+ m_path = path;
+}
+
+QColor QMapPolygonObjectPrivateDefault::fillColor() const
+{
+ return m_fillColor;
+}
+
+void QMapPolygonObjectPrivateDefault::setFillColor(const QColor &color)
+{
+ m_fillColor = color;
+}
+
+QColor QMapPolygonObjectPrivateDefault::borderColor() const
+{
+ return m_borderColor;
+}
+
+void QMapPolygonObjectPrivateDefault::setBorderColor(const QColor &color)
+{
+ m_borderColor = color;
+}
+
+qreal QMapPolygonObjectPrivateDefault::borderWidth() const
+{
+ return m_borderWidth;
+}
+
+void QMapPolygonObjectPrivateDefault::setBorderWidth(qreal width)
+{
+ m_borderWidth = width;
+}
+
+QGeoMapObjectPrivate *QMapPolygonObjectPrivateDefault::clone()
+{
+ return new QMapPolygonObjectPrivateDefault(static_cast<QMapPolygonObjectPrivate &>(*this));
+}
+
+bool QMapPolygonObjectPrivate::equals(const QGeoMapObjectPrivate &other) const
+{
+ if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used
+ return false;
+
+ const QMapPolygonObjectPrivate &o = static_cast<const QMapPolygonObjectPrivate &>(other);
+ return (QGeoMapObjectPrivate::equals(o)
+ && path() == o.path()
+ && borderColor() == o.borderColor()
+ && fillColor() == o.fillColor()
+ && borderWidth() == o.borderWidth());
+}
+
+
+
+
+QMapPolygonObject::QMapPolygonObject(QObject *parent)
+ : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapPolygonObjectPrivateDefault(this)), parent)
+{
+ QMapPolygonObjectPrivate *d = static_cast<QMapPolygonObjectPrivate*>(d_ptr.data());
+ d->setBorderColor(QColor(Qt::black)); // These are QDeclarativeMapLineProperties defaults
+ d->setBorderWidth(1.0);
+}
+
+QMapPolygonObject::~QMapPolygonObject()
+{}
+
+QVariantList QMapPolygonObject::path() const
+{
+ QVariantList p;
+ for (const QGeoCoordinate &c: static_cast<const QMapPolygonObjectPrivate *>(d_ptr.data())->path())
+ p << QVariant::fromValue(c);
+ return p;
+}
+
+void QMapPolygonObject::setPath(const QVariantList &path)
+{
+ QList<QGeoCoordinate> p;
+ bool ok = false;
+ for (const auto &c: path) {
+ const QGeoCoordinate coord = parseCoordinate(c, &ok);
+ if (ok)
+ p << coord;
+ }
+ auto pimpl = static_cast<QMapPolygonObjectPrivate *>(d_ptr.data());
+ if (p != pimpl->path()) {
+ pimpl->setPath(p);
+ emit pathChanged();
+ }
+}
+
+QColor QMapPolygonObject::color() const
+{
+ return static_cast<const QMapPolygonObjectPrivate*>(d_ptr.data())->fillColor();
+}
+
+QDeclarativeMapLineProperties *QMapPolygonObject::border()
+{
+ if (!m_border) {
+ m_border = new QDeclarativeMapLineProperties;
+ connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){
+ static_cast<QMapPolygonObjectPrivate*>(d_ptr.data())->setBorderColor(color);
+ });
+ connect(m_border, &QDeclarativeMapLineProperties::widthChanged, this, [this](qreal width){
+ static_cast<QMapPolygonObjectPrivate*>(d_ptr.data())->setBorderWidth(width);
+ });
+ }
+ return m_border;
+}
+
+void QMapPolygonObject::setColor(const QColor &fillColor)
+{
+ auto ptr = static_cast<QMapPolygonObjectPrivate*>(d_ptr.data());
+
+ if (ptr->fillColor() == fillColor)
+ return;
+
+ ptr->setFillColor(fillColor);
+ emit colorChanged();
+}
+
+void QMapPolygonObject::setMap(QGeoMap *map)
+{
+ QMapPolygonObjectPrivate *d = static_cast<QMapPolygonObjectPrivate *>(d_ptr.data());
+ if (d->m_map == map)
+ return;
+
+ QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected
+
+ if (!map) {
+ // Map was set, now it has ben re-set to NULL
+ d_ptr = new QMapPolygonObjectPrivateDefault(*d);
+ // Old pimpl deleted implicitly by QExplicitlySharedDataPointer
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/locationlabs/qmappolygonobject_p.h b/src/locationlabs/qmappolygonobject_p.h
new file mode 100644
index 00000000..f9fcaad7
--- /dev/null
+++ b/src/locationlabs/qmappolygonobject_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPPOLYGONOBJECT_P_H
+#define QMAPPOLYGONOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocationLabs/private/qlocationlabsglobal_p.h>
+#include <QtLocation/private/qgeomapobject_p.h>
+#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
+
+#include <QJSValue>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATIONLABS_PRIVATE_EXPORT QMapPolygonObject : public QGeoMapObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVariantList path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QDeclarativeMapLineProperties *border READ border CONSTANT)
+
+public:
+ QMapPolygonObject(QObject *parent = nullptr);
+ ~QMapPolygonObject() override;
+
+ QVariantList path() const;
+ void setPath(const QVariantList &path);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ QDeclarativeMapLineProperties *border();
+ void setMap(QGeoMap *map) override;
+
+signals:
+ void pathChanged();
+ void colorChanged();
+
+protected:
+ QDeclarativeMapLineProperties *m_border;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPPOLYGONOBJECT_P_H
diff --git a/src/locationlabs/qmappolygonobject_p_p.h b/src/locationlabs/qmappolygonobject_p_p.h
new file mode 100644
index 00000000..c2e1eb9c
--- /dev/null
+++ b/src/locationlabs/qmappolygonobject_p_p.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPPOLYGONOBJECT_P_P_H
+#define QMAPPOLYGONOBJECT_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocationLabs/private/qlocationlabsglobal_p.h>
+#include <QtLocation/private/qgeomapobject_p_p.h>
+#include <QGeoCoordinate>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATIONLABS_PRIVATE_EXPORT QMapPolygonObjectPrivate : public QGeoMapObjectPrivate
+{
+public:
+ QMapPolygonObjectPrivate(QGeoMapObject *q);
+ ~QMapPolygonObjectPrivate() override;
+
+ virtual QGeoMapObject::Type type() const override final;
+
+ virtual QList<QGeoCoordinate> path() const = 0;
+ virtual void setPath(const QList<QGeoCoordinate> &path) = 0;
+ virtual QColor fillColor() const = 0;
+ virtual void setFillColor(const QColor &color) = 0;
+ virtual QColor borderColor() const = 0;
+ virtual void setBorderColor(const QColor &color) = 0;
+ virtual qreal borderWidth() const = 0;
+ virtual void setBorderWidth(qreal width) = 0;
+
+ // QGeoMapObjectPrivate interface
+ bool equals(const QGeoMapObjectPrivate &other) const override;
+};
+
+class Q_LOCATIONLABS_PRIVATE_EXPORT QMapPolygonObjectPrivateDefault : public QMapPolygonObjectPrivate
+{
+public:
+ QMapPolygonObjectPrivateDefault(QGeoMapObject *q);
+ QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivate &other);
+ ~QMapPolygonObjectPrivateDefault() override;
+
+ // QMapPolygonObjectPrivate interface
+ QList<QGeoCoordinate> path() const override;
+ void setPath(const QList<QGeoCoordinate> &path) override;
+ QColor fillColor() const override;
+ void setFillColor(const QColor &color) override;
+ QColor borderColor() const override;
+ void setBorderColor(const QColor &color) override;
+ qreal borderWidth() const override;
+ void setBorderWidth(qreal width) override;
+
+ // QGeoMapObjectPrivate interface
+ QGeoMapObjectPrivate *clone() override;
+
+public:
+ QList<QGeoCoordinate> m_path;
+ QColor m_borderColor;
+ QColor m_fillColor = Qt::transparent;
+ qreal m_borderWidth = 0;
+
+private:
+ QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivateDefault &other) = delete;
+};
+
+QT_END_NAMESPACE
+
+
+#endif // QMAPPOLYGONOBJECT_P_P_H
diff --git a/src/locationlabs/qmappolylineobject.cpp b/src/locationlabs/qmappolylineobject.cpp
new file mode 100644
index 00000000..1e625c1f
--- /dev/null
+++ b/src/locationlabs/qmappolylineobject.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmappolylineobject_p.h"
+#include "qmappolylineobject_p_p.h"
+#include <QtLocation/private/locationvaluetypehelper_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QMapPolylineObjectPrivate::QMapPolylineObjectPrivate(QGeoMapObject *q) : QGeoMapObjectPrivate(q)
+{
+
+}
+
+QMapPolylineObjectPrivate::~QMapPolylineObjectPrivate()
+{
+
+}
+
+QGeoMapObject::Type QMapPolylineObjectPrivate::type() const
+{
+ return QGeoMapObject::PolylineType;
+}
+
+QMapPolylineObjectPrivateDefault::QMapPolylineObjectPrivateDefault(QGeoMapObject *q) : QMapPolylineObjectPrivate(q)
+{
+
+}
+
+QMapPolylineObjectPrivateDefault::QMapPolylineObjectPrivateDefault(const QMapPolylineObjectPrivate &other) : QMapPolylineObjectPrivate(other.q)
+{
+ m_path = other.path();
+ m_color = other.color();
+ m_width = other.width();
+}
+
+QMapPolylineObjectPrivateDefault::~QMapPolylineObjectPrivateDefault()
+{
+
+}
+
+QList<QGeoCoordinate> QMapPolylineObjectPrivateDefault::path() const
+{
+ return m_path;
+}
+
+void QMapPolylineObjectPrivateDefault::setPath(const QList<QGeoCoordinate> &path)
+{
+ m_path = path;
+}
+
+QColor QMapPolylineObjectPrivateDefault::color() const
+{
+ return m_color;
+}
+
+void QMapPolylineObjectPrivateDefault::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+qreal QMapPolylineObjectPrivateDefault::width() const
+{
+ return m_width;
+}
+
+void QMapPolylineObjectPrivateDefault::setWidth(qreal width)
+{
+ m_width = width;
+}
+
+bool QMapPolylineObjectPrivate::equals(const QGeoMapObjectPrivate &other) const
+{
+ if (other.type() != type()) // This check might be unnecessary, depending on how equals gets used
+ return false;
+
+ const QMapPolylineObjectPrivate &o = static_cast<const QMapPolylineObjectPrivate &>(other);
+ return (QGeoMapObjectPrivate::equals(o)
+ && path() == o.path()
+ && color() == o.color()
+ && width() == o.width());
+}
+
+QGeoMapObjectPrivate *QMapPolylineObjectPrivateDefault::clone()
+{
+ return new QMapPolylineObjectPrivateDefault(static_cast<QMapPolylineObjectPrivate &>(*this));
+}
+
+QMapPolylineObject::QMapPolylineObject(QObject *parent)
+ : QGeoMapObject(QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(new QMapPolylineObjectPrivateDefault(this)), parent)
+{
+ QMapPolylineObjectPrivate *d = static_cast<QMapPolylineObjectPrivate*>(d_ptr.data());
+ d->setColor(QColor(Qt::black)); // These are QDeclarativeMapLineProperties defaults
+ d->setWidth(1.0);
+}
+
+QMapPolylineObject::~QMapPolylineObject()
+{}
+
+QVariantList QMapPolylineObject::path() const
+{
+ QVariantList p;
+ for (const QGeoCoordinate &c: static_cast<const QMapPolylineObjectPrivate*>(d_ptr.data())->path())
+ p << QVariant::fromValue(c);
+ return p;
+}
+
+QDeclarativeMapLineProperties *QMapPolylineObject::border()
+{
+ if (!m_border) {
+ m_border = new QDeclarativeMapLineProperties;
+ connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){
+ static_cast<QMapPolylineObjectPrivate*>(d_ptr.data())->setColor(color);
+ });
+ connect(m_border, &QDeclarativeMapLineProperties::widthChanged, this, [this](qreal width){
+ static_cast<QMapPolylineObjectPrivate*>(d_ptr.data())->setWidth(width);
+ });
+ }
+ return m_border;
+}
+
+void QMapPolylineObject::setPath(const QVariantList &path)
+{
+ QList<QGeoCoordinate> p;
+ bool ok = false;
+ for (const auto &c: path) {
+ const QGeoCoordinate coord = parseCoordinate(c, &ok);
+ if (ok)
+ p << coord;
+ }
+ auto pimpl = static_cast<QMapPolylineObjectPrivate *>(d_ptr.data());
+ if (p != pimpl->path()) {
+ pimpl->setPath(p);
+ emit pathChanged();
+ }
+}
+
+void QMapPolylineObject::setMap(QGeoMap *map)
+{
+ QMapPolylineObjectPrivate *d = static_cast<QMapPolylineObjectPrivate *>(d_ptr.data());
+ if (d->m_map == map)
+ return;
+
+ QGeoMapObject::setMap(map); // This is where the specialized pimpl gets created and injected
+
+ if (!map) {
+ // Map was set, now it has ben re-set to NULL
+ d_ptr = new QMapPolylineObjectPrivateDefault(*d);
+ // Old pimpl deleted implicitly by QExplicitlySharedDataPointer
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/locationlabs/qmappolylineobject_p.h b/src/locationlabs/qmappolylineobject_p.h
new file mode 100644
index 00000000..fe844a5c
--- /dev/null
+++ b/src/locationlabs/qmappolylineobject_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPPOLYLINEOBJECT_P_H
+#define QMAPPOLYLINEOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocationLabs/private/qlocationlabsglobal_p.h>
+#include <QtLocation/private/qgeomapobject_p.h>
+#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
+
+#include <QJSValue>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATIONLABS_PRIVATE_EXPORT QMapPolylineObject : public QGeoMapObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVariantList path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(QDeclarativeMapLineProperties *line READ border CONSTANT)
+
+public:
+ QMapPolylineObject(QObject *parent = nullptr);
+ ~QMapPolylineObject() override;
+
+ QVariantList path() const;
+ void setPath(const QVariantList &path);
+
+ QDeclarativeMapLineProperties *border();
+ void setMap(QGeoMap *map) override;
+
+signals:
+ void pathChanged();
+
+protected:
+ QDeclarativeMapLineProperties *m_border = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPPOLYLINEOBJECT_P_H
diff --git a/src/locationlabs/qmappolylineobject_p_p.h b/src/locationlabs/qmappolylineobject_p_p.h
new file mode 100644
index 00000000..80eeb2cd
--- /dev/null
+++ b/src/locationlabs/qmappolylineobject_p_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPPOLYLINEOBJECT_P_P_H
+#define QMAPPOLYLINEOBJECT_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtLocationLabs/private/qlocationlabsglobal_p.h>
+#include <QtLocation/private/qgeomapobject_p_p.h>
+#include <QGeoCoordinate>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATIONLABS_PRIVATE_EXPORT QMapPolylineObjectPrivate : public QGeoMapObjectPrivate
+{
+public:
+ QMapPolylineObjectPrivate(QGeoMapObject *q);
+ ~QMapPolylineObjectPrivate() override;
+
+ virtual QGeoMapObject::Type type() const override final;
+
+ virtual QList<QGeoCoordinate> path() const = 0;
+ virtual void setPath(const QList<QGeoCoordinate> &path) = 0;
+ virtual QColor color() const = 0;
+ virtual void setColor(const QColor &color) = 0;
+ virtual qreal width() const = 0;
+ virtual void setWidth(qreal width) = 0;
+
+ // QGeoMapObjectPrivate interface
+ bool equals(const QGeoMapObjectPrivate &other) const override;
+};
+
+class Q_LOCATIONLABS_PRIVATE_EXPORT QMapPolylineObjectPrivateDefault : public QMapPolylineObjectPrivate
+{
+public:
+ QMapPolylineObjectPrivateDefault(QGeoMapObject *q);
+ QMapPolylineObjectPrivateDefault(const QMapPolylineObjectPrivate &other);
+ ~QMapPolylineObjectPrivateDefault() override;
+
+ // QGeoMapPolylinePrivate interface
+ QList<QGeoCoordinate> path() const override;
+ void setPath(const QList<QGeoCoordinate> &path) override;
+ QColor color() const override;
+ void setColor(const QColor &color) override;
+ qreal width() const override;
+ void setWidth(qreal width) override;
+
+ // QGeoMapObjectPrivate interface
+ QGeoMapObjectPrivate *clone() override;
+
+public:
+ QList<QGeoCoordinate> m_path;
+ QColor m_color;
+ qreal m_width = 0;
+
+private:
+ QMapPolylineObjectPrivateDefault(const QMapPolylineObjectPrivateDefault &other) = delete;
+};
+
+QT_END_NAMESPACE
+
+
+#endif // QMAPPOLYLINEOBJECT_P_P_H