summaryrefslogtreecommitdiff
path: root/src/location/declarativemaps
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/declarativemaps')
-rw-r--r--src/location/declarativemaps/locationvaluetypehelper.cpp30
-rw-r--r--src/location/declarativemaps/locationvaluetypehelper_p.h4
-rw-r--r--src/location/declarativemaps/qdeclarativegeocodemodel.cpp3
-rw-r--r--src/location/declarativemaps/qdeclarativegeomaneuver.cpp30
-rw-r--r--src/location/declarativemaps/qdeclarativegeomaneuver_p.h9
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp17
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemview.cpp2
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutemodel.cpp663
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutemodel_p.h131
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp5
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea.cpp2
11 files changed, 816 insertions, 80 deletions
diff --git a/src/location/declarativemaps/locationvaluetypehelper.cpp b/src/location/declarativemaps/locationvaluetypehelper.cpp
index 4f39e0b4..5f75e225 100644
--- a/src/location/declarativemaps/locationvaluetypehelper.cpp
+++ b/src/location/declarativemaps/locationvaluetypehelper.cpp
@@ -35,11 +35,14 @@
****************************************************************************/
#include "locationvaluetypehelper_p.h"
+#include <QVariantMap>
QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok)
{
QGeoCoordinate c;
+ if (ok)
+ *ok = false;
if (value.isObject()) {
if (value.hasProperty(QStringLiteral("latitude")))
@@ -56,6 +59,33 @@ QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok)
return c;
}
+QGeoCoordinate parseCoordinate(const QVariant &value, bool *ok)
+{
+ QGeoCoordinate c;
+ if (ok)
+ *ok = false;
+
+ if (value.canConvert<QGeoCoordinate>()) {
+ c = value.value<QGeoCoordinate>();
+ if (ok)
+ *ok = true;
+ } else if (value.type() == QVariant::Map) {
+ const QVariantMap &map = value.toMap();
+
+ if (map.contains(QStringLiteral("latitude")))
+ c.setLatitude(map.value(QStringLiteral("latitude")).toDouble());
+ if (map.contains(QStringLiteral("longitude")))
+ c.setLongitude(map.value(QStringLiteral("longitude")).toDouble());
+ if (map.contains(QStringLiteral("altitude")))
+ c.setAltitude(map.value(QStringLiteral("altitude")).toDouble());
+
+ if (ok)
+ *ok = c.isValid(); // Not considering the case where the map is valid but containing NaNs.
+ }
+
+ return c;
+}
+
QGeoRectangle parseRectangle(const QJSValue &value, bool *ok)
{
QGeoRectangle r;
diff --git a/src/location/declarativemaps/locationvaluetypehelper_p.h b/src/location/declarativemaps/locationvaluetypehelper_p.h
index 50038e88..09f3ab06 100644
--- a/src/location/declarativemaps/locationvaluetypehelper_p.h
+++ b/src/location/declarativemaps/locationvaluetypehelper_p.h
@@ -49,11 +49,13 @@
//
#include <QJSValue>
+#include <QVariant>
#include <QGeoCoordinate>
#include <QGeoRectangle>
#include <QGeoCircle>
-QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok);
+QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok = nullptr);
+QGeoCoordinate parseCoordinate(const QVariant &value, bool *ok = nullptr);
QGeoRectangle parseRectangle(const QJSValue &value, bool *ok);
QGeoCircle parseCircle(const QJSValue &value, bool *ok);
diff --git a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
index 3e2a1aea..b64b2545 100644
--- a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
@@ -42,6 +42,7 @@
#include <QtPositioning/QGeoCircle>
#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/QGeoCodingManager>
+#include <QtPositioning/QGeoPolygon>
QT_BEGIN_NAMESPACE
@@ -374,6 +375,8 @@ QVariant QDeclarativeGeocodeModel::bounds() const
return QVariant::fromValue(QGeoRectangle(boundingArea_));
else if (boundingArea_.type() == QGeoShape::CircleType)
return QVariant::fromValue(QGeoCircle(boundingArea_));
+ else if (boundingArea_.type() == QGeoShape::PolygonType)
+ return QVariant::fromValue(QGeoPolygon(boundingArea_));
else
return QVariant::fromValue(boundingArea_);
}
diff --git a/src/location/declarativemaps/qdeclarativegeomaneuver.cpp b/src/location/declarativemaps/qdeclarativegeomaneuver.cpp
index b1c67167..ef3639af 100644
--- a/src/location/declarativemaps/qdeclarativegeomaneuver.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomaneuver.cpp
@@ -185,6 +185,36 @@ QGeoCoordinate QDeclarativeGeoManeuver::waypoint() const
}
/*!
+ \qmlproperty Object RouteManeuver::extendedAttributes
+
+ This property holds the extended attributes of the maneuver and is a map.
+ These attributes are plugin specific, and can be empty.
+
+ Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation}
+ for what attributes are supported and how they should be used.
+
+ Note, due to limitations of the QQmlPropertyMap, it is not possible
+ to declaratively specify the attributes in QML, assignment of attributes keys
+ and values can only be accomplished by JavaScript.
+
+ \since QtLocation 5.11
+*/
+QQmlPropertyMap *QDeclarativeGeoManeuver::extendedAttributes() const
+{
+ if (!m_extendedAttributes) {
+ QDeclarativeGeoManeuver *self = const_cast<QDeclarativeGeoManeuver *>(this);
+ self->m_extendedAttributes = new QQmlPropertyMap(self);
+ // Fill it
+ const QStringList keys = maneuver_.extendedAttributes().keys();
+ for (const QString &key: keys) {
+ self->m_extendedAttributes->insert(key,
+ maneuver_.extendedAttributes().value(key));
+ }
+ }
+ return m_extendedAttributes;
+}
+
+/*!
\qmlproperty bool RouteManeuver::waypointValid
This read-only property holds whether this \l waypoint, associated with this
diff --git a/src/location/declarativemaps/qdeclarativegeomaneuver_p.h b/src/location/declarativemaps/qdeclarativegeomaneuver_p.h
index 0e957a1f..f321c133 100644
--- a/src/location/declarativemaps/qdeclarativegeomaneuver_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomaneuver_p.h
@@ -50,7 +50,7 @@
#include <QtLocation/private/qlocationglobal_p.h>
#include <QtLocation/qgeomaneuver.h>
-
+#include <QtQml/QQmlPropertyMap>
#include <QtPositioning/QGeoCoordinate>
#include <QObject>
@@ -71,6 +71,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoManeuver : public QObject
Q_PROPERTY(qreal distanceToNextInstruction READ distanceToNextInstruction CONSTANT)
Q_PROPERTY(QGeoCoordinate waypoint READ waypoint CONSTANT)
Q_PROPERTY(bool waypointValid READ waypointValid CONSTANT)
+ Q_PROPERTY(QObject *extendedAttributes READ extendedAttributes NOTIFY extendedAttributesChanged)
public:
enum Direction {
@@ -101,9 +102,15 @@ public:
int timeToNextInstruction() const;
qreal distanceToNextInstruction() const;
QGeoCoordinate waypoint() const;
+ QQmlPropertyMap *extendedAttributes() const;
+
+Q_SIGNALS:
+ void extendedAttributesChanged(); //in practice is never emitted since parameters cannot be re-assigned
+ //the declaration is needed to avoid warnings about non-notifyable properties
private:
QGeoManeuver maneuver_;
+ QQmlPropertyMap *m_extendedAttributes = nullptr;
};
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 9b19a0ac..34885f54 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -46,6 +46,7 @@
#include <QtPositioning/QGeoCircle>
#include <QtPositioning/QGeoRectangle>
#include <QtPositioning/QGeoPath>
+#include <QtPositioning/QGeoPolygon>
#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGRectangleNode>
#include <QtQuick/private/qquickwindow_p.h>
@@ -1341,22 +1342,22 @@ QGeoShape QDeclarativeGeoMap::visibleRegion() const
return m_visibleRegion;
const QList<QDoubleVector2D> &visibleRegion = m_map->geoProjection().visibleRegion();
- QGeoPath path;
+ QGeoPolygon poly;
for (int i = 0; i < visibleRegion.size(); ++i) {
const QDoubleVector2D &c = visibleRegion.at(i);
// If a segment spans more than half of the map longitudinally, split in 2.
if (i && qAbs(visibleRegion.at(i-1).x() - c.x()) >= 0.5) { // This assumes a segment is never >= 1.0 (whole map span)
QDoubleVector2D extraPoint = (visibleRegion.at(i-1) + c) * 0.5;
- path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint));
+ poly.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint));
}
- path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(c));
+ poly.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(c));
}
if (visibleRegion.size() >= 2 && qAbs(visibleRegion.last().x() - visibleRegion.first().x()) >= 0.5) {
QDoubleVector2D extraPoint = (visibleRegion.last() + visibleRegion.first()) * 0.5;
- path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint));
+ poly.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint));
}
- return path.boundingGeoRectangle();
+ return poly;
}
/*!
@@ -1480,6 +1481,8 @@ QQmlListProperty<QDeclarativeGeoMapType> QDeclarativeGeoMap::supportedMapTypes()
If the Plugin used for the Map does not support bearing, or if the map is tilted and \a coordinate happens
to be behind the camera, or if the map is not ready (see \l mapReady), calling this method will have no effect.
+ The release of this API with Qt 5.10 is a Technology Preview.
+
\since 5.10
*/
void QDeclarativeGeoMap::setBearing(qreal bearing, const QGeoCoordinate &coordinate)
@@ -1511,6 +1514,8 @@ void QDeclarativeGeoMap::setBearing(qreal bearing, const QGeoCoordinate &coordin
If the map is tilted, and \a coordinate happens to be behind the camera, or if the map is not ready
(see \l mapReady), calling this method will have no effect.
+ The release of this API with Qt 5.10 is a Technology Preview.
+
\sa center
\since 5.10
@@ -2266,7 +2271,7 @@ bool QDeclarativeGeoMap::sendTouchEvent(QTouchEvent *event)
auto touchPointGrabberItem = [touchDevice, windowPriv](const QTouchEvent::TouchPoint &point) -> QQuickItem* {
if (QQuickEventPoint *eventPointer = windowPriv->pointerEventInstance(touchDevice)->pointById(point.id()))
- return eventPointer->grabber();
+ return eventPointer->grabberItem();
return nullptr;
};
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
index d8c19528..24ed6700 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
@@ -378,7 +378,7 @@ void QDeclarativeGeoMapItemView::setAutoFitViewport(const bool &fitViewport)
*/
void QDeclarativeGeoMapItemView::fitViewport()
{
- if (!map_ || !fitViewport_ || m_repopulating)
+ if (!map_ || !map_->mapReady() || !fitViewport_ || m_repopulating)
return;
if (map_->mapItems().size() > 0)
diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
index 0383c0c4..8066d917 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
@@ -45,9 +45,63 @@
#include <QtQml/private/qqmlengine_p.h>
#include <QtLocation/QGeoRoutingManager>
#include <QtPositioning/QGeoRectangle>
+#include "qdeclarativegeomapparameter_p.h"
QT_BEGIN_NAMESPACE
+static bool compareFloats(qreal a, qreal b)
+{
+ return (qIsNaN(a) && qIsNaN(b))
+ || a == b;
+}
+
+static bool compareParameterList(const QList<QDeclarativeGeoMapParameter *> &a, const QList<QDeclarativeGeoMapParameter *> &b)
+{
+ if (a.size() != b.size())
+ return false;
+ if (a != b) {
+ for (int i = 0; i < a.size(); ++i) {
+ if (! (*a.at(i) == *b.at(i)))
+ return false;
+ }
+ }
+ return true;
+}
+
+static int findWaypoint(const QList<QDeclarativeGeoWaypoint *> &waypoints, const QDeclarativeGeoWaypoint *w)
+{
+ for (int i = waypoints.size() - 1; i >= 0; --i) {
+ if (waypoints.at(i) == w || *waypoints.at(i) == *w)
+ return i;
+ }
+ return -1;
+}
+
+static int findWaypoint(const QList<QDeclarativeGeoWaypoint *> &waypoints, const QGeoCoordinate &c)
+{
+ for (int i = waypoints.size() - 1; i >= 0; --i) {
+ if (waypoints.at(i)->coordinate() == c)
+ return i;
+ }
+ return -1;
+}
+
+static QList<QGeoCoordinate> waypointCoordinates(const QList<QDeclarativeGeoWaypoint *> &waypoints)
+{
+ QList<QGeoCoordinate> res;
+ for (const QDeclarativeGeoWaypoint *w: waypoints)
+ res << w->coordinate();
+ return res;
+}
+
+static QList<QVariantMap> waypointMetadata(const QList<QDeclarativeGeoWaypoint *> &waypoints)
+{
+ QList<QVariantMap> res;
+ for (QDeclarativeGeoWaypoint *w: waypoints)
+ res << w->metadata();
+ return res;
+}
+
/*!
\qmltype RouteModel
\instantiates QDeclarativeGeoRouteModel
@@ -653,7 +707,7 @@ void QDeclarativeGeoRouteModel::routingError(QGeoRouteReply *reply,
\brief The RouteQuery type is used to provide query parameters to a
RouteModel.
- A RouteQuery contains all the parameters necessary to make a request
+ A RouteQuery is used to pack all the parameters necessary to make a request
to a routing service, which can then populate the contents of a RouteModel.
These parameters describe key details of the route, such as \l waypoints to
@@ -665,6 +719,10 @@ void QDeclarativeGeoRouteModel::routingError(QGeoRouteReply *reply,
RouteModel's \l{RouteModel::query}{query} property, which can then begin
the retrieval process to populate the model.
+ Some plugins might allow or require specific parameters to operate.
+ In order to specify these plugin-specific parameters, MapParameter elements
+ can be nested inside a RouteQuery.
+
\section2 Example Usage
The following snipped shows an incomplete example of creating a RouteQuery
@@ -768,60 +826,93 @@ void QDeclarativeGeoRouteQuery::setNumberAlternativeRoutes(int numberAlternative
\qmlproperty list<coordinate> RouteQuery::waypoints
- The waypoint coordinates of the desired route.
+ The coordinates of the waypoints for the desired route.
The waypoints should be given in order from origin to destination.
Two or more coordinates are needed.
Waypoints can be set as part of the RouteQuery type declaration or
dynamically with the functions provided.
- \sa addWaypoint, removeWaypoint, clearWaypoints
+ When setting this property to a list of waypoints, each waypoint
+ can be either a \l coordinate or a \l Waypoint, interchangeably.
+ If a \l coordinate is passed, it will be internally converted to a
+ \l Waypoint.
+
+ This property, however, always contains a list of coordinates.
+
+ \sa waypointObjects, addWaypoint, removeWaypoint, clearWaypoints
*/
-QJSValue QDeclarativeGeoRouteQuery::waypoints()
+QVariantList QDeclarativeGeoRouteQuery::waypoints()
{
- QQmlContext *context = QQmlEngine::contextForObject(parent());
- QQmlEngine *engine = context->engine();
- QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
+ QVariantList res;
- QV4::Scope scope(v4);
- QV4::Scoped<QV4::ArrayObject> waypointArray(scope, v4->newArrayObject(request_.waypoints().length()));
- for (int i = 0; i < request_.waypoints().length(); ++i) {
- const QGeoCoordinate &c = request_.waypoints().at(i);
+ for (const auto &w : m_waypoints)
+ res << QVariant::fromValue(w->coordinate());
- QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c)));
- waypointArray->putIndexed(i, cv);
- }
+ return res;
+}
+
+/*!
+ \qmlmethod list<Waypoint> QtLocation::RouteQuery::waypointObjects()
+
+ This method can be used to retrieve the list of Waypoint objects
+ relative to RouteQuery::waypoints.
- return QJSValue(v4, waypointArray.asReturnedValue());
+ \sa waypointObjects, addWaypoint, removeWaypoint, clearWaypoints
+*/
+QVariantList QDeclarativeGeoRouteQuery::waypointObjects()
+{
+ QVariantList res;
+
+ for (const auto &w : m_waypoints)
+ res << QVariant::fromValue(w);
+
+ return res;
}
-void QDeclarativeGeoRouteQuery::setWaypoints(const QJSValue &value)
+void QDeclarativeGeoRouteQuery::setWaypoints(const QVariantList &value)
{
- if (!value.isArray())
- return;
+ QList<QDeclarativeGeoWaypoint *> waypointList;
+ bool allWaypoints = true;
+
+ for (const auto &w: value) {
+ // First, test if this is already a QDeclarativeGeoWaypoint
+ // From QVariant to QObject *
+ QDeclarativeGeoWaypoint *waypoint = nullptr;
+ QObject *obj = qvariant_cast<QObject *>(w);
+ waypoint = qobject_cast<QDeclarativeGeoWaypoint *>(obj);
+
+ if (waypoint) {
+ waypointList << waypoint;
+ continue;
+ }
- QList<QGeoCoordinate> waypointList;
- quint32 length = value.property(QStringLiteral("length")).toUInt();
- for (quint32 i = 0; i < length; ++i) {
- bool ok;
- QGeoCoordinate c = parseCoordinate(value.property(i), &ok);
+ // if here, w is not a Waypoint, so either a QGeoCoordinate or a variant map, so a waypoint has to be instantiated.
+ allWaypoints = false;
- if (!ok || !c.isValid()) {
- qmlWarning(this) << "Unsupported waypoint type";
+ QGeoCoordinate c = parseCoordinate(w);
+ if (!c.isValid()) {
+ qmlWarning(this) << QStringLiteral("Invalid waypoint");
+ flushWaypoints(waypointList);
return;
}
- waypointList.append(c);
+ waypoint = new QDeclarativeGeoWaypoint(this);
+ waypoint->setCoordinate(c);
+ waypointList << waypoint;
+
}
- if (request_.waypoints() == waypointList)
+ if (allWaypoints && m_waypoints == waypointList)
return;
- request_.setWaypoints(waypointList);
+ flushWaypoints(m_waypoints);
+ m_waypoints = waypointList;
+ for (const QDeclarativeGeoWaypoint *w: qAsConst(m_waypoints))
+ connect(w, &QDeclarativeGeoWaypoint::waypointDetailsChanged, this, &QDeclarativeGeoRouteQuery::waypointChanged);
- emit waypointsChanged();
- emit queryDetailsChanged();
+ waypointChanged();
}
/*!
@@ -864,7 +955,7 @@ void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value)
QGeoRectangle r = parseRectangle(value.property(i), &ok);
if (!ok || !r.isValid()) {
- qmlWarning(this) << "Unsupported area type";
+ qmlWarning(this) << QStringLiteral("Unsupported area type");
return;
}
@@ -876,8 +967,10 @@ void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value)
request_.setExcludeAreas(excludedAreasList);
- emit excludedAreasChanged();
- emit queryDetailsChanged();
+ if (complete_) {
+ emit excludedAreasChanged();
+ emit queryDetailsChanged();
+ }
}
/*!
@@ -933,8 +1026,10 @@ void QDeclarativeGeoRouteQuery::removeExcludedArea(const QGeoRectangle &area)
excludedAreas.removeAt(index);
request_.setExcludeAreas(excludedAreas);
- emit excludedAreasChanged();
- emit queryDetailsChanged();
+ if (complete_) {
+ emit excludedAreasChanged();
+ emit queryDetailsChanged();
+ }
}
/*!
@@ -952,8 +1047,10 @@ void QDeclarativeGeoRouteQuery::clearExcludedAreas()
request_.setExcludeAreas(QList<QGeoRectangle>());
- emit excludedAreasChanged();
- emit queryDetailsChanged();
+ if (complete_) {
+ emit excludedAreasChanged();
+ emit queryDetailsChanged();
+ }
}
/*!
@@ -961,24 +1058,43 @@ void QDeclarativeGeoRouteQuery::clearExcludedAreas()
Appends a coordinate to the list of waypoints. Same coordinate
can be set multiple times.
+ The \a coordinate argument can be a \l coordinate or a \l Waypoint.
+ If a \l coordinate is used, it will be internally converted to a
+ \l Waypoint.
\sa removeWaypoint, clearWaypoints
*/
-void QDeclarativeGeoRouteQuery::addWaypoint(const QGeoCoordinate &waypoint)
+void QDeclarativeGeoRouteQuery::addWaypoint(const QVariant &waypoint)
{
- if (!waypoint.isValid()) {
- qmlWarning(this) << QStringLiteral("Not adding invalid waypoint.");
+ QDeclarativeGeoWaypoint *w = nullptr;
+ QObject *obj = qvariant_cast<QObject *>(waypoint);
+ w = qobject_cast<QDeclarativeGeoWaypoint *>(obj);
+
+ if (w) {
+ if (! w->isValid()) {
+ qmlWarning(this) << QStringLiteral("Invalid waypoint");
+ return;
+ }
+
+ m_waypoints << w;
+ connect(w, &QDeclarativeGeoWaypoint::waypointDetailsChanged, this, &QDeclarativeGeoRouteQuery::waypointChanged);
+ waypointChanged();
return;
}
- QList<QGeoCoordinate> waypoints = request_.waypoints();
- waypoints.append(waypoint);
- request_.setWaypoints(waypoints);
+ // if here, waypoint is not a Waypoint, so either a QGeoCoordinate or a variant map, so a waypoint has to be instantiated.
- if (complete_) {
- emit waypointsChanged();
- emit queryDetailsChanged();
+ QGeoCoordinate c = parseCoordinate(waypoint);
+ if (!c.isValid()) {
+ qmlWarning(this) << QStringLiteral("Invalid coordinate as waypoint");
+ return;
}
+
+ w = new QDeclarativeGeoWaypoint(this);
+ w->setCoordinate(c);
+ m_waypoints << w;
+ connect(w, &QDeclarativeGeoWaypoint::waypointDetailsChanged, this, &QDeclarativeGeoRouteQuery::waypointChanged);
+ waypointChanged();
}
/*!
@@ -990,22 +1106,49 @@ void QDeclarativeGeoRouteQuery::addWaypoint(const QGeoCoordinate &waypoint)
\sa addWaypoint, clearWaypoints
*/
-void QDeclarativeGeoRouteQuery::removeWaypoint(const QGeoCoordinate &waypoint)
+void QDeclarativeGeoRouteQuery::removeWaypoint(const QVariant &waypoint)
{
- QList<QGeoCoordinate> waypoints = request_.waypoints();
+ QDeclarativeGeoWaypoint *w = nullptr;
+ QObject *obj = qvariant_cast<QObject *>(waypoint);
+ w = qobject_cast<QDeclarativeGeoWaypoint *>(obj);
- int index = waypoints.lastIndexOf(waypoint);
- if (index == -1) {
- qmlWarning(this) << QStringLiteral("Cannot remove nonexistent waypoint.");
+ if (w) {
+ if (!w->isValid()) {
+ qmlWarning(this) << QStringLiteral("Invalid waypoint");
+ return;
+ }
+
+ int idx = findWaypoint(m_waypoints, w);
+ if (idx >= 0) {
+ QDeclarativeGeoWaypoint *toRemove = m_waypoints.takeAt(idx);
+ toRemove->disconnect(this);
+ if (toRemove->parent() == this)
+ delete toRemove;
+
+ waypointChanged();
+ } else {
+ qmlWarning(this) << QStringLiteral("Cannot remove nonexistent waypoint.");
+ }
return;
}
- waypoints.removeAt(index);
+ QGeoCoordinate c = parseCoordinate(waypoint);
+ if (!c.isValid()) {
+ qmlWarning(this) << QStringLiteral("Invalid coordinate as waypoint");
+ return;
+ }
- request_.setWaypoints(waypoints);
+ int idx = findWaypoint(m_waypoints, c);
+ if (idx >= 0) {
+ QDeclarativeGeoWaypoint *toRemove = m_waypoints.takeAt(idx);
+ toRemove->disconnect(this);
+ if (toRemove->parent() == this)
+ delete toRemove;
- emit waypointsChanged();
- emit queryDetailsChanged();
+ waypointChanged();
+ } else {
+ qmlWarning(this) << QStringLiteral("Cannot remove nonexistent waypoint.");
+ }
}
/*!
@@ -1017,13 +1160,21 @@ void QDeclarativeGeoRouteQuery::removeWaypoint(const QGeoCoordinate &waypoint)
*/
void QDeclarativeGeoRouteQuery::clearWaypoints()
{
- if (request_.waypoints().isEmpty())
+ if (m_waypoints.isEmpty())
return;
- request_.setWaypoints(QList<QGeoCoordinate>());
+ flushWaypoints(m_waypoints);
+ waypointChanged();
+}
- emit waypointsChanged();
- emit queryDetailsChanged();
+void QDeclarativeGeoRouteQuery::flushWaypoints(QList<QDeclarativeGeoWaypoint *> &waypoints)
+{
+ for (const QDeclarativeGeoWaypoint *w : qAsConst(waypoints)) {
+ w->disconnect(this);
+ if (w->parent() == this) // w has been created internally as a result of adding a QGeoCoordinate
+ delete w;
+ }
+ waypoints.clear();
}
/*!
@@ -1285,8 +1436,23 @@ void QDeclarativeGeoRouteQuery::setRouteOptimizations(QDeclarativeGeoRouteQuery:
/*!
\internal
*/
-QGeoRouteRequest QDeclarativeGeoRouteQuery::routeRequest() const
+QGeoRouteRequest QDeclarativeGeoRouteQuery::routeRequest()
{
+ if (m_extraParametersChanged) {
+ m_extraParametersChanged = false;
+ // Update extra params into request
+ const QList<QDeclarativeGeoMapParameter *> params = quickChildren<QDeclarativeGeoMapParameter>();
+ QMap<QString, QVariantMap> extraParameters;
+ for (const QDeclarativeGeoMapParameter *p: params)
+ extraParameters[p->type()] = p->toVariantMap();
+ request_.setExtraParameters(extraParameters);
+ }
+ if (m_waypointsChanged) {
+ m_waypointsChanged = false;
+ // Update waypoints and metadata into request
+ request_.setWaypoints(waypointCoordinates(m_waypoints));
+ request_.setWaypointsMetadata(waypointMetadata(m_waypoints));
+ }
return request_;
}
@@ -1298,10 +1464,385 @@ void QDeclarativeGeoRouteQuery::excludedAreaCoordinateChanged()
}
}
+void QDeclarativeGeoRouteQuery::extraParameterChanged()
+{
+ m_extraParametersChanged = true;
+ if (complete_) {
+ emit extraParametersChanged();
+ emit queryDetailsChanged();
+ }
+}
+
+void QDeclarativeGeoRouteQuery::waypointChanged()
+{
+ m_waypointsChanged = true;
+ if (complete_) {
+ emit waypointsChanged();
+ emit queryDetailsChanged();
+ }
+}
+
+void QDeclarativeGeoRouteQuery::append(QQmlListProperty<QObject> *p, QObject *v)
+{
+ QDeclarativeGeoRouteQuery *query = static_cast<QDeclarativeGeoRouteQuery*>(p->object);
+ query->m_children.append(v);
+
+ QDeclarativeGeoMapParameter *param = qobject_cast<QDeclarativeGeoMapParameter *>(v);
+ if (param) {
+ query->m_extraParametersChanged = true;
+ query->connect(param, &QGeoMapParameter::propertyUpdated,
+ query, &QDeclarativeGeoRouteQuery::extraParameterChanged);
+ if (query->complete_) {
+ emit query->extraParametersChanged();
+ emit query->queryDetailsChanged();
+ }
+ }
+}
+
+int QDeclarativeGeoRouteQuery::count(QQmlListProperty<QObject> *p)
+{
+ return static_cast<QDeclarativeGeoRouteQuery*>(p->object)->m_children.count();
+}
+
+QObject *QDeclarativeGeoRouteQuery::at(QQmlListProperty<QObject> *p, int idx)
+{
+ return static_cast<QDeclarativeGeoRouteQuery*>(p->object)->m_children.at(idx);
+}
+
+void QDeclarativeGeoRouteQuery::clear(QQmlListProperty<QObject> *p)
+{
+ QDeclarativeGeoRouteQuery *query = static_cast<QDeclarativeGeoRouteQuery*>(p->object);
+ for (auto kid : qAsConst(query->m_children)) {
+ auto val = qobject_cast<QDeclarativeGeoMapParameter *>(kid);
+ if (val) {
+ val->disconnect(val, nullptr, query, nullptr);
+ query->m_extraParametersChanged = true;
+ }
+ }
+ query->m_children.clear();
+ if (query->m_extraParametersChanged && query->complete_) {
+ emit query->extraParametersChanged();
+ emit query->queryDetailsChanged();
+ }
+}
+
+QQmlListProperty<QObject> QDeclarativeGeoRouteQuery::declarativeChildren()
+{
+ return QQmlListProperty<QObject>(this, nullptr,
+ &QDeclarativeGeoRouteQuery::append,
+ &QDeclarativeGeoRouteQuery::count,
+ &QDeclarativeGeoRouteQuery::at,
+ &QDeclarativeGeoRouteQuery::clear);
+}
+
void QDeclarativeGeoRouteQuery::doCoordinateChanged()
{
m_excludedAreaCoordinateChanged = false;
- emit queryDetailsChanged();
+ if (complete_)
+ emit queryDetailsChanged();
+}
+
+/*!
+ \qmltype Waypoint
+ \instantiates QDeclarativeGeoWaypoint
+ \inqmlmodule QtLocation
+ \ingroup qml-QtLocation5-routing
+ \since Qt Location 5.11
+
+ \brief The Waypoint type provides a mean to specify a waypoint in a \l RouteQuery
+ in a more detailed way than by using a simple \l coordinate.
+
+ A Waypoint is a type that allows to specify properties of a waypoint in a \l RouteQuery,
+ such as the waypoint coordinate, or the angle of approach to the waypoint.
+
+ Additional information that are backend-specific can be specified by nesting \l MapParameter
+ elements.
+
+ Changing properties of the waypoint or of its nested MapParameteters will cause the containing
+ \l RouteQuery to emit the queryDetailsChanged signal.
+
+ \section2 Example Usage
+
+ The following snippet is two-part, showing firstly the declaration of
+ objects, and secondly a short piece of procedural code using it. We set
+ the routeModel's \l{autoUpdate} property to false, and call \l{update} once
+ the query is set up, to avoid useless extra requests halfway through the
+ set up of the query.
+
+ \code
+ Plugin {
+ id: aPlugin
+ name: "osm"
+ }
+
+ Waypoint {
+ id: waypointStart
+ coordinate: ...
+ bearing: ...
+ }
+ Waypoint {
+ id: waypointFinish
+ coordinate: ...
+ bearing: ...
+ }
+
+ RouteQuery {
+ id: aQuery
+ Component.onCompleted: {
+ travelModes = RouteQuery.CarTravel
+ addWaypoint(waypointStart)
+ var aWaypoint = Qt.createQmlObject ('import QtLocation 5.11; Waypoint { ... }', ...)
+ addWaypoint(aWaypoint)
+ addWaypoint(waypointFinish)
+ }
+ }
+
+ RouteModel {
+ id: routeModel
+ plugin: aPlugin
+ query: aQuery
+ autoUpdate: true
+ }
+ \endcode
+
+ \sa RouteQuery
+*/
+
+
+/*
+ *
+ At the time of adding this class (2017.11), 3 routing services are natively supported in Qt: Esri, Here and OSRM.
+ Waypoint documentation for each of these:
+ Esri: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000 , called "stop"
+ HERE: https://developer.here.com/documentation/routing/topics/resource-param-type-waypoint.html
+ OSRM: https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md , under Request Options
+ *
+ */
+
+
+static QGeoCoordinate convertWaypointToCoordinate(const QDeclarativeGeoWaypoint *value)
+{
+ return QGeoCoordinate(value);
+}
+
+struct WaypointVariantConversions
+{
+ WaypointVariantConversions()
+ {
+ QMetaType::registerConverter<QDeclarativeGeoWaypoint *, QGeoCoordinate>(convertWaypointToCoordinate);
+ }
+};
+
+Q_GLOBAL_STATIC(WaypointVariantConversions, initWaypointConversions)
+
+
+QDeclarativeGeoWaypoint::QDeclarativeGeoWaypoint(QObject *parent) : QGeoCoordinateObject(parent)
+{
+ initWaypointConversions();
+ connect(this, &QGeoCoordinateObject::coordinateChanged,
+ this, &QDeclarativeGeoWaypoint::waypointDetailsChanged);
+}
+
+QDeclarativeGeoWaypoint::~QDeclarativeGeoWaypoint()
+{
+
+}
+
+bool QDeclarativeGeoWaypoint::operator==(const QDeclarativeGeoWaypoint &other) const
+{
+ const QList<QDeclarativeGeoMapParameter *> params = quickChildren<QDeclarativeGeoMapParameter>();
+ const QList<QDeclarativeGeoMapParameter *> otherParams = other.quickChildren<QDeclarativeGeoMapParameter>();
+
+ return coordinate() == other.coordinate() &&
+ compareFloats(m_bearing, other.bearing()) &&
+ compareParameterList(params, otherParams);
+}
+
+/*!
+ \qmlproperty coordinate Waypoint::coordinate
+
+ The waypoint's coordinate. The default value is undefined.
+*/
+
+
+/*!
+ \qmlproperty real Waypoint::latitude
+
+ The latitude of the waypoint's coordinate. The default value is NaN.
+ Changing this property will affect the \l Waypoint::coordinate property as well.
+*/
+qreal QDeclarativeGeoWaypoint::latitude() const
+{
+ return m_coordinate.latitude();
+}
+
+void QDeclarativeGeoWaypoint::setLatitude(qreal latitude)
+{
+ if (compareFloats(latitude, m_coordinate.latitude()))
+ return;
+
+ m_coordinate.setLatitude(latitude);
+ if (m_complete) {
+ emit coordinateChanged();
+ emit waypointDetailsChanged();
+ }
+}
+
+/*!
+ \qmlproperty real Waypoint::longitude
+
+ The longitude of the waypoint's coordinate. The default value is NaN.
+ Changing this property will affect the \l Waypoint::coordinate property as well.
+*/
+qreal QDeclarativeGeoWaypoint::longitude() const
+{
+ return m_coordinate.longitude();
+}
+
+void QDeclarativeGeoWaypoint::setLongitude(qreal longitude)
+{
+ if (compareFloats(longitude, m_coordinate.longitude()))
+ return;
+
+ m_coordinate.setLongitude(longitude);
+ if (m_complete) {
+ emit coordinateChanged();
+ emit waypointDetailsChanged();
+ }
+}
+
+/*!
+ \qmlproperty real Waypoint::altitude
+
+ The altitude of the waypoint's coordinate. The default value is NaN.
+ Changing this property will affect the \l Waypoint::coordinate property as well.
+*/
+qreal QDeclarativeGeoWaypoint::altitude() const
+{
+ return m_coordinate.altitude();
+}
+
+void QDeclarativeGeoWaypoint::setAltitude(qreal altitude)
+{
+ if (compareFloats(altitude, m_coordinate.altitude()))
+ return;
+
+ m_coordinate.setAltitude(altitude);
+ if (m_complete) {
+ emit coordinateChanged();
+ emit waypointDetailsChanged();
+ }
+}
+
+bool QDeclarativeGeoWaypoint::isValid() const
+{
+ return m_coordinate.isValid();
+}
+
+/*!
+ \qmlproperty real Waypoint::bearing
+
+ The bearing specifying the angle of approach of the waypoint, that is the bearing with which the waypoint is to be approached.
+ This information may be used by the provider to filter the road segment the waypoint will be placed on, and,
+ depending on the provider and the \l {QGeoRouteRequest::TravelMode} {travel mode} used, to restrict the maneuvers
+ allowed at the waypoint, potentially making the provider calculating and returning a different route.
+
+ If set to NaN, this value will not be considered.
+
+ The default value is NaN.
+*/
+qreal QDeclarativeGeoWaypoint::bearing() const
+{
+ return m_bearing;
+}
+
+void QDeclarativeGeoWaypoint::setBearing(qreal bearing)
+{
+ if (compareFloats(bearing, m_bearing))
+ return;
+
+ m_bearing = bearing;
+
+ // Bearing is actually packed into QGeoRouteRequest::waypointMetadata() together with the extra parameters
+ m_metadataChanged = true;
+ if (m_complete) {
+ emit bearingChanged();
+ emit waypointDetailsChanged();
+ }
+}
+
+QVariantMap QDeclarativeGeoWaypoint::metadata()
+{
+ if (m_metadataChanged) {
+ m_metadataChanged = false;
+ m_metadata.clear();
+ // Update metadata
+ const QList<QDeclarativeGeoMapParameter *> params = quickChildren<QDeclarativeGeoMapParameter>();
+ QVariantMap extraParameters;
+ for (const QDeclarativeGeoMapParameter *p: params)
+ extraParameters[p->type()] = p->toVariantMap();
+ m_metadata[QStringLiteral("extra")] = extraParameters;
+ m_metadata[QStringLiteral("bearing")] = m_bearing;
+ }
+ return m_metadata;
+}
+
+void QDeclarativeGeoWaypoint::extraParameterChanged()
+{
+ m_metadataChanged = true;
+ if (m_complete) {
+ emit extraParametersChanged();
+ emit waypointDetailsChanged();
+ }
+}
+
+void QDeclarativeGeoWaypoint::append(QQmlListProperty<QObject> *p, QObject *v)
+{
+ QDeclarativeGeoWaypoint *waypoint = static_cast<QDeclarativeGeoWaypoint*>(p->object);
+ waypoint->m_children.append(v);
+
+ QDeclarativeGeoMapParameter *param = qobject_cast<QDeclarativeGeoMapParameter *>(v);
+ if (param) {
+ waypoint->connect(param, &QGeoMapParameter::propertyUpdated,
+ waypoint, &QDeclarativeGeoWaypoint::extraParameterChanged);
+ waypoint->extraParameterChanged();
+ }
+}
+
+int QDeclarativeGeoWaypoint::count(QQmlListProperty<QObject> *p)
+{
+ return static_cast<QDeclarativeGeoWaypoint*>(p->object)->m_children.count();
+}
+
+QObject *QDeclarativeGeoWaypoint::at(QQmlListProperty<QObject> *p, int idx)
+{
+ return static_cast<QDeclarativeGeoWaypoint*>(p->object)->m_children.at(idx);
+}
+
+void QDeclarativeGeoWaypoint::clear(QQmlListProperty<QObject> *p)
+{
+ QDeclarativeGeoWaypoint *waypoint = static_cast<QDeclarativeGeoWaypoint*>(p->object);
+ for (auto kid : qAsConst(waypoint->m_children)) {
+ auto val = qobject_cast<QDeclarativeGeoMapParameter *>(kid);
+ if (val) {
+ val->disconnect(waypoint);
+ waypoint->m_metadataChanged = true;
+ }
+ }
+ waypoint->m_children.clear();
+ if (waypoint->m_metadataChanged && waypoint->m_complete) {
+ emit waypoint->extraParametersChanged();
+ emit waypoint->waypointDetailsChanged();
+ }
+}
+
+QQmlListProperty<QObject> QDeclarativeGeoWaypoint::declarativeChildren()
+{
+ return QQmlListProperty<QObject>(this, nullptr,
+ &QDeclarativeGeoWaypoint::append,
+ &QDeclarativeGeoWaypoint::count,
+ &QDeclarativeGeoWaypoint::at,
+ &QDeclarativeGeoWaypoint::clear);
}
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h b/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h
index 18486ac8..5d8d1803 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h
@@ -53,6 +53,7 @@
#include <QtPositioning/QGeoCoordinate>
#include <QtPositioning/QGeoRectangle>
+#include <QtPositioning/private/qgeocoordinateobject_p.h>
#include <qgeorouterequest.h>
#include <qgeoroutereply.h>
@@ -185,6 +186,90 @@ private:
RouteError error_;
};
+
+
+// purpose of this class is to be convertible to a QGeoCoordinate (through QGeoWaypoint), but also
+// to behave like it, so that in QML source compatibility would be preserved. This is, however, not possible to achieve at the present.
+class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoWaypoint : public QGeoCoordinateObject, public QQmlParserStatus
+{
+ Q_OBJECT
+
+ Q_PROPERTY(double latitude READ latitude WRITE setLatitude STORED false)
+ Q_PROPERTY(double longitude READ longitude WRITE setLongitude STORED false)
+ Q_PROPERTY(double altitude READ altitude WRITE setAltitude STORED false)
+ Q_PROPERTY(bool isValid READ isValid STORED false)
+
+ Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> quickChildren READ declarativeChildren DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "quickChildren")
+
+public:
+ QDeclarativeGeoWaypoint(QObject *parent = 0);
+ virtual ~QDeclarativeGeoWaypoint();
+
+ bool operator==(const QDeclarativeGeoWaypoint &other) const;
+
+ qreal latitude() const;
+ void setLatitude(qreal latitude);
+
+ qreal longitude() const;
+ void setLongitude(qreal longitude);
+
+ qreal altitude() const;
+ void setAltitude(qreal altitude);
+
+ bool isValid() const;
+
+ qreal bearing() const;
+ void setBearing(qreal bearing);
+
+ template <typename T = QObject>
+ QList<T*> quickChildren() const
+ {
+ QList<T*> res;
+ for (auto kid : qAsConst(m_children)) {
+ auto val = qobject_cast<T*>(kid);
+ if (val)
+ res.push_back(val);
+ }
+ return res;
+ }
+
+ QVariantMap metadata();
+
+Q_SIGNALS:
+ void completed();
+ void waypointDetailsChanged();
+ void bearingChanged();
+ void extraParametersChanged();
+
+private Q_SLOTS:
+ void extraParameterChanged();
+
+protected:
+ // From QQmlParserStatus
+ void classBegin() override {}
+ void componentComplete() override { m_complete = true; emit completed(); }
+
+ // For quickChildren
+ static void append(QQmlListProperty<QObject> *p, QObject *v);
+ static int count(QQmlListProperty<QObject> *p);
+ static QObject *at(QQmlListProperty<QObject> *p, int idx);
+ static void clear(QQmlListProperty<QObject> *p);
+ QQmlListProperty<QObject> declarativeChildren();
+ QList<QObject*> m_children;
+
+ // other data members
+ bool m_metadataChanged = false;
+ bool m_complete = false;
+
+ qreal m_bearing = Q_QNAN;
+ QVariantMap m_metadata;
+};
+
+
+
+
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRouteQuery : public QObject, public QQmlParserStatus
{
Q_OBJECT
@@ -204,9 +289,11 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRouteQuery : public QObject, publ
Q_PROPERTY(RouteOptimizations routeOptimizations READ routeOptimizations WRITE setRouteOptimizations NOTIFY routeOptimizationsChanged)
Q_PROPERTY(SegmentDetail segmentDetail READ segmentDetail WRITE setSegmentDetail NOTIFY segmentDetailChanged)
Q_PROPERTY(ManeuverDetail maneuverDetail READ maneuverDetail WRITE setManeuverDetail NOTIFY maneuverDetailChanged)
- Q_PROPERTY(QJSValue waypoints READ waypoints WRITE setWaypoints NOTIFY waypointsChanged)
+ Q_PROPERTY(QVariantList waypoints READ waypoints WRITE setWaypoints NOTIFY waypointsChanged)
Q_PROPERTY(QJSValue excludedAreas READ excludedAreas WRITE setExcludedAreas NOTIFY excludedAreasChanged)
Q_PROPERTY(QList<int> featureTypes READ featureTypes NOTIFY featureTypesChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> quickChildren READ declarativeChildren DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "quickChildren")
Q_INTERFACES(QQmlParserStatus)
public:
@@ -218,7 +305,7 @@ public:
void classBegin() {}
void componentComplete();
- QGeoRouteRequest routeRequest() const;
+ QGeoRouteRequest routeRequest();
enum TravelMode {
CarTravel = QGeoRouteRequest::CarTravel,
@@ -279,16 +366,18 @@ public:
QList<int> featureTypes();
- QJSValue waypoints();
- void setWaypoints(const QJSValue &value);
+ QVariantList waypoints();
+ Q_INVOKABLE QVariantList waypointObjects();
+ void setWaypoints(const QVariantList &value);
// READ functions for list properties
QJSValue excludedAreas() const;
void setExcludedAreas(const QJSValue &value);
- Q_INVOKABLE void addWaypoint(const QGeoCoordinate &waypoint);
- Q_INVOKABLE void removeWaypoint(const QGeoCoordinate &waypoint);
+ Q_INVOKABLE void addWaypoint(const QVariant &w);
+ Q_INVOKABLE void removeWaypoint(const QVariant &waypoint);
Q_INVOKABLE void clearWaypoints();
+ void flushWaypoints(QList<QDeclarativeGeoWaypoint *> &waypoints);
Q_INVOKABLE void addExcludedArea(const QGeoRectangle &area);
Q_INVOKABLE void removeExcludedArea(const QGeoRectangle &area);
@@ -314,6 +403,18 @@ public:
void setRouteOptimizations(RouteOptimizations optimization);
RouteOptimizations routeOptimizations() const;
+ template <typename T = QObject>
+ QList<T*> quickChildren() const
+ {
+ QList<T*> res;
+ for (auto kid : qAsConst(m_children)) {
+ auto val = qobject_cast<T*>(kid);
+ if (val)
+ res.push_back(val);
+ }
+ return res;
+ }
+
Q_SIGNALS:
void numberAlternativeRoutesChanged();
void travelModesChanged();
@@ -327,9 +428,21 @@ Q_SIGNALS:
void segmentDetailChanged();
void queryDetailsChanged();
+ void extraParametersChanged();
private Q_SLOTS:
void excludedAreaCoordinateChanged();
+ void extraParameterChanged();
+ void waypointChanged();
+
+protected:
+ static void append(QQmlListProperty<QObject> *p, QObject *v);
+ static int count(QQmlListProperty<QObject> *p);
+ static QObject *at(QQmlListProperty<QObject> *p, int idx);
+ static void clear(QQmlListProperty<QObject> *p);
+
+ QQmlListProperty<QObject> declarativeChildren();
+ QList<QObject*> m_children;
private:
Q_INVOKABLE void doCoordinateChanged();
@@ -337,9 +450,13 @@ private:
QGeoRouteRequest request_;
bool complete_;
bool m_excludedAreaCoordinateChanged;
-
+ bool m_extraParametersChanged = false;
+ bool m_waypointsChanged = false;
+ QList<QDeclarativeGeoWaypoint *> m_waypoints;
};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QDeclarativeGeoWaypoint*)
+
#endif
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index 48f66423..7460a376 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -286,10 +286,10 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
if (e.isMoveTo() || i == ppi.elementCount() - 1
|| (qAbs(e.x - poly.front()[0]) < 0.1
&& qAbs(e.y - poly.front()[1]) < 0.1)) {
- Point p = { e.x, e.y };
+ Point p = {{ e.x, e.y }};
poly.push_back( p );
} else if (e.isLineTo()) {
- Point p = { e.x, e.y };
+ Point p = {{ e.x, e.y }};
poly.push_back( p );
} else {
qWarning("Unhandled element type in polygon painterpath");
@@ -374,6 +374,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m
This property holds the ordered list of coordinates which
define the polygon.
+ Having less than 3 different coordinates in the path results in undefined behavior.
\sa addCoordinate, removeCoordinate
*/
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
index b1878f00..2f095ee0 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp
+++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
@@ -552,7 +552,7 @@ QQuickGeoMapGestureArea::~QQuickGeoMapGestureArea()
\qmlproperty enumeration QtLocation::MapGestureArea::acceptedGestures
This property holds the gestures that will be active. By default
- the zoom, pan and flick gestures are enabled.
+ all gestures are enabled.
\list
\li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000).