diff options
Diffstat (limited to 'src/imports/location/declarativeplaces')
5 files changed, 38 insertions, 64 deletions
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp index 11ebcdd6..6f89b6ab 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp @@ -48,10 +48,10 @@ #include <QtLocation/QPlaceManager> #include <QtLocation/QPlaceSearchRequest> #include <QtLocation/QPlaceSearchReply> +#include <QtLocation/QGeoCircle> QDeclarativeSearchModelBase::QDeclarativeSearchModelBase(QObject *parent) -: QAbstractListModel(parent), m_plugin(0), m_reply(0), m_searchArea(0), m_complete(false), - m_status(Null) +: QAbstractListModel(parent), m_plugin(0), m_reply(0), m_complete(false), m_status(Null) { } @@ -84,20 +84,35 @@ void QDeclarativeSearchModelBase::setPlugin(QDeclarativeGeoServiceProvider *plug /*! \internal */ -QDeclarativeGeoShape *QDeclarativeSearchModelBase::searchArea() const +QVariant QDeclarativeSearchModelBase::searchArea() const { - return m_searchArea; + QGeoShape s = m_request.searchArea(); + if (s.type() == QGeoShape::RectangleType) + return QVariant::fromValue(QGeoRectangle(s)); + else if (s.type() == QGeoShape::CircleType) + return QVariant::fromValue(QGeoCircle(s)); + else + return QVariant::fromValue(s); } /*! \internal */ -void QDeclarativeSearchModelBase::setSearchArea(QDeclarativeGeoShape *searchArea) +void QDeclarativeSearchModelBase::setSearchArea(const QVariant &searchArea) { - if (m_searchArea == searchArea) + QGeoShape s; + + 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>(); + + if (m_request.searchArea() == s) return; - m_searchArea = searchArea; + m_request.setSearchArea(s); emit searchAreaChanged(); } @@ -195,7 +210,6 @@ void QDeclarativeSearchModelBase::update() return; } - updateSearchRequest(); m_reply = sendQuery(placeManager, m_request); if (!m_reply) { clearData(); @@ -256,17 +270,6 @@ void QDeclarativeSearchModelBase::clearData(bool suppressSignal) /*! \internal */ -void QDeclarativeSearchModelBase::updateSearchRequest() -{ - if (m_searchArea) - m_request.setSearchArea(m_searchArea->shape()); - else - m_request.setSearchArea(QGeoShape()); -} - -/*! - \internal -*/ void QDeclarativeSearchModelBase::classBegin() { } diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h index 34fb8763..67d31542 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h +++ b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h @@ -56,14 +56,13 @@ class QPlaceManager; class QPlaceSearchRequest; class QPlaceSearchReply; class QDeclarativePlace; -class QDeclarativeGeoShape; class QDeclarativeSearchModelBase : public QAbstractListModel, public QQmlParserStatus { Q_OBJECT Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) - Q_PROPERTY(QDeclarativeGeoShape *searchArea READ searchArea WRITE setSearchArea NOTIFY searchAreaChanged) + Q_PROPERTY(QVariant searchArea READ searchArea WRITE setSearchArea NOTIFY searchAreaChanged) Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged) Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) @@ -86,8 +85,8 @@ public: QDeclarativeGeoServiceProvider *plugin() const; void setPlugin(QDeclarativeGeoServiceProvider *plugin); - QDeclarativeGeoShape *searchArea() const; - void setSearchArea(QDeclarativeGeoShape *searchArea); + QVariant searchArea() const; + void setSearchArea(const QVariant &searchArea); int offset() const; void setOffset(int offset); @@ -106,7 +105,6 @@ public: Q_INVOKABLE QString errorString() const; virtual void clearData(bool suppressSignal = false); - virtual void updateSearchRequest(); // From QQmlParserStatus virtual void classBegin(); @@ -136,8 +134,6 @@ protected: QPlaceReply *m_reply; private: - QDeclarativeGeoShape *m_searchArea; - bool m_complete; Status m_status; QString m_errorString; diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp index 87194ad3..42afc88b 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp @@ -205,14 +205,14 @@ QT_USE_NAMESPACE */ /*! - \qmlproperty GeoShape PlaceSearchModel::searchArea + \qmlproperty variant PlaceSearchModel::searchArea This property holds the search area. The search result returned by the model will be within the search area. - If this property is set to a \l GeoCircle its \l {GeoCircle::radius}{radius} property - may be left unset, in which case the \l Plugin will choose an appropriate radius for the - search. + If this property is set to a \l {QtLocation5::geocircle}{geocircle} its + \l {QtLocation5::geocircle}{radius} property may be left unset, in which case the \l Plugin + will choose an appropriate radius for the search. Support for specifying a search area can vary according to the \l plugin backend implementation. For example, some may support a search center only while others may only @@ -271,18 +271,10 @@ QT_USE_NAMESPACE \c PlaceSearchModel.Error and the model cleared. \code - GeoCircle { - id: searchLocation - center { - latitude: 10 - longitude: 10 - } - } - PlaceSearchModel { id: model plugin: backendPlugin - searchArea : searchLocation + searchArea: QtLocation.circle(QtLocation.coordinate(10, 10)) ... } @@ -291,8 +283,8 @@ QT_USE_NAMESPACE onClicked: { model.searchTerm = "pizza"; model.categories = null; //not searching by any category - searchLocation.center.latitude = -27.5 - searchLocation.center.longitude = 153 + model.searchArea.center.latitude = -27.5; + model.searchArea.center.longitude = 153; model.update(); } } diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp index ca963e30..8f15d170 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp @@ -111,9 +111,9 @@ QT_USE_NAMESPACE This property holds the search area. Search suggestion results returned by the model will be relevant to the given search area. - If this property is set to a \l GeoCircle its \l {GeoCircle::radius}{radius} property - may be left unset, in which case the \l Plugin will choose an appropriate radius for the - search. + If this property is set to a \l {QtLocation5::geocircle}{geocircle} its + \l {QtLocation5::geocircle}{radius} property may be left unset, in which case the \l Plugin + will choose an appropriate radius for the search. */ /*! @@ -169,18 +169,10 @@ QT_USE_NAMESPACE This example shows use of the model \code - GeoCircle { - id: searchLocation - center { - latitude: 10 - longitude: 10 - } - } - PlaceSeachSuggestionModel { id: model plugin: backendPlugin - searchArea: searchLocation + searchArea: QtLocation.circle(QtLocation.coordinate(10, 10)) ... } @@ -188,8 +180,8 @@ QT_USE_NAMESPACE ... onClicked: { model.searchTerm = "piz" - searchLocation.center.latitude = -27.5 - searchLocation.cetner.longitude = 153 + model.searchArea.center.latitude = -27.5; + model.searchArea.cetner.longitude = 153; model.update(); } } @@ -287,14 +279,6 @@ void QDeclarativeSearchSuggestionModel::clearData(bool suppressSignal) /*! \internal */ -void QDeclarativeSearchSuggestionModel::updateSearchRequest() -{ - QDeclarativeSearchModelBase::updateSearchRequest(); -} - -/*! - \internal -*/ int QDeclarativeSearchSuggestionModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel_p.h index 0ff6bcd3..786b71f9 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel_p.h @@ -68,7 +68,6 @@ public: QStringList suggestions() const; void clearData(bool suppressSignal = false); - void updateSearchRequest(); // From QAbstractListModel int rowCount(const QModelIndex &parent) const; |