diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-10-11 13:09:41 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-11-01 11:41:39 +0000 |
commit | a7d1e0bd6d4bf7c1035e32acd95daeef8af9edc8 (patch) | |
tree | 3b63673879ea86204688f0127352dc9371fe6cd9 /src/location/declarativeplaces | |
parent | 5c41bffd2ff58a8d55b3da1eaaebee90c327445a (diff) | |
download | qtlocation-a7d1e0bd6d4bf7c1035e32acd95daeef8af9edc8.tar.gz |
Allow searching along a QGeoRoute
The result will be backend-dependent. If a backend does not support
this, it will be the same as not specifying a search area.
The current approach does not expose any new public API, but also
does not allow specifying the distance from the route.
If this will become necessary, public API might have to be
extended.
Task-number: QTBUG-69649
Change-Id: I9230d502a6cdb55c620e3a57a0e78cdb6f8955a6
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/location/declarativeplaces')
-rw-r--r-- | src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp index b9f782cf..8bbe7f64 100644 --- a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp +++ b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp @@ -46,6 +46,8 @@ #include <QtLocation/QPlaceSearchReply> #include <QtPositioning/QGeoCircle> #include <QtPositioning/QGeoPolygon> +#include <QtLocation/private/qdeclarativegeoroute_p.h> +#include <QtLocation/private/qplacesearchrequest_p.h> QT_BEGIN_NAMESPACE @@ -102,18 +104,36 @@ QVariant QDeclarativeSearchModelBase::searchArea() const void QDeclarativeSearchModelBase::setSearchArea(const QVariant &searchArea) { QGeoShape s; - + QDeclarativeGeoRoute *route = nullptr; + bool routeSearchArea = false; if (searchArea.userType() == qMetaTypeId<QGeoRectangle>()) s = searchArea.value<QGeoRectangle>(); else if (searchArea.userType() == qMetaTypeId<QGeoCircle>()) s = searchArea.value<QGeoCircle>(); else if (searchArea.userType() == qMetaTypeId<QGeoShape>()) s = searchArea.value<QGeoShape>(); + else if (searchArea.type() == qMetaTypeId<QObject *>()) { + route = searchArea.value<QDeclarativeGeoRoute *>(); + if (!route) + return; + routeSearchArea = true; + } - if (m_request.searchArea() == s) + QPlaceSearchRequestPrivate *rp = QPlaceSearchRequestPrivate::get(m_request); + // Invalidating the other thing + if (routeSearchArea) + m_request.setSearchArea(QGeoShape()); + else + rp->routeSearchArea = QGeoRoute(); + + if (m_request.searchArea() == s + && (!route || rp->routeSearchArea == route->route())) return; - m_request.setSearchArea(s); + if (routeSearchArea) + rp->routeSearchArea = route->route(); + else + m_request.setSearchArea(s); emit searchAreaChanged(); } |