summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h1
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp3
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h1
-rw-r--r--src/location/places/qplacemanager.cpp14
-rw-r--r--src/location/places/qplacemanager.h6
-rw-r--r--src/location/places/qplacemanagerengine.h3
-rw-r--r--src/location/places/qplacesearchquery.cpp26
-rw-r--r--src/location/places/qplacesearchquery.h4
-rw-r--r--src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp10
-rw-r--r--src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h3
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp37
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h3
-rw-r--r--tests/auto/qgeosearchmanagerplugins/qgeoserviceproviderplugin_test.h1
-rw-r--r--tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp23
14 files changed, 99 insertions, 36 deletions
diff --git a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h
index e30bac89..cb23f634 100644
--- a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h
@@ -6,6 +6,7 @@
#include <QDeclarativeListProperty>
#include <qplacemanager.h>
+#include <qplacesearchquery.h>
#include "qdeclarativecoordinate_p.h"
#include "qdeclarativegeoboundingbox_p.h"
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index 1549c0ab..7b4f56d7 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -353,8 +353,7 @@ void QDeclarativeSearchResultModel::executeQuery()
cancelPreviousRequest();
m_queryParameters.setSearchArea(m_searchArea->area());
- connectNewResponse(placeManager->searchForPlaces(m_queryParameters,
- QPlaceManager::PublicScope));
+ connectNewResponse(placeManager->searchForPlaces(m_queryParameters));
}
/*!
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h
index a64ec9be..83dfcc7d 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h
@@ -6,6 +6,7 @@
#include <QDeclarativeListProperty>
#include <qplacemanager.h>
+#include <qplacesearchquery.h>
#include "qdeclarativegeoboundingarea_p.h"
#include "qdeclarativesearchresult_p.h"
diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp
index b53ea641..77bd14fd 100644
--- a/src/location/places/qplacemanager.cpp
+++ b/src/location/places/qplacemanager.cpp
@@ -159,19 +159,11 @@ QPlaceReviewReply *QPlaceManager::getReviews(const QGeoPlace &place, const QPlac
}
/*!
- Searches for places according to a given \a query and at the given \a scope.
+ Searches for places according to a given \a query.
*/
-QPlaceSearchReply *QPlaceManager::searchForPlaces(const QPlaceSearchQuery &query, VisibilityScope scope) const
+QPlaceSearchReply *QPlaceManager::searchForPlaces(const QPlaceSearchQuery &query) const
{
- return d->engine->searchForPlaces(query, scope);
-}
-
-/*!
- Returns the available scopes in which places can be searched
-*/
-QPlaceManager::VisibilityScopes QPlaceManager::supportedSearchVisibilityScopes() const
-{
- return d->engine->supportedSearchVisibilityScopes();
+ return d->engine->searchForPlaces(query);
}
/*!
diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h
index 4796ab19..f8cf8cd9 100644
--- a/src/location/places/qplacemanager.h
+++ b/src/location/places/qplacemanager.h
@@ -45,8 +45,8 @@
#include "qmobilityglobal.h"
#include "qplacemediaobject.h"
#include "qplacemediareply.h"
+#include "qplacequery.h"
#include "qplacereply.h"
-#include "qplacesearchquery.h"
#include "qplacesearchreply.h"
#include "qplacedetailsreply.h"
#include "qplacereviewreply.h"
@@ -59,6 +59,7 @@
QT_BEGIN_NAMESPACE
class QPlaceManagerEngine;
+class QPlaceSearchQuery;
class QPlaceManagerPrivate;
class Q_LOCATION_EXPORT QPlaceManager : public QObject
@@ -112,8 +113,7 @@ public:
QPlaceMediaReply *getMedia(const QGeoPlace &place, const QPlaceQuery &query) const;
- QPlaceSearchReply *searchForPlaces(const QPlaceSearchQuery &query, VisibilityScope scope) const;
- VisibilityScopes supportedSearchVisibilityScopes() const;
+ QPlaceSearchReply *searchForPlaces(const QPlaceSearchQuery &query) const;
QPlaceSearchReply *recommendations(const QGeoPlace &place, const QPlaceSearchQuery &query) const;
diff --git a/src/location/places/qplacemanagerengine.h b/src/location/places/qplacemanagerengine.h
index a436b4d8..e2d0187c 100644
--- a/src/location/places/qplacemanagerengine.h
+++ b/src/location/places/qplacemanagerengine.h
@@ -67,8 +67,7 @@ public:
virtual QPlaceReviewReply *getReviews(const QGeoPlace &place, const QPlaceQuery &query) = 0;
- virtual QPlaceSearchReply *searchForPlaces(const QPlaceSearchQuery &query, QPlaceManager::VisibilityScope scope) = 0;
- virtual QPlaceManager::VisibilityScopes supportedSearchVisibilityScopes() const = 0;
+ virtual QPlaceSearchReply *searchForPlaces(const QPlaceSearchQuery &query) = 0;
virtual QPlaceSearchReply *recommendations(const QGeoPlace &place, const QPlaceSearchQuery &query) = 0;
virtual QPlaceTextPredictionReply *textPredictions(const QPlaceSearchQuery &query) = 0;
diff --git a/src/location/places/qplacesearchquery.cpp b/src/location/places/qplacesearchquery.cpp
index c315ee12..bc61b59d 100644
--- a/src/location/places/qplacesearchquery.cpp
+++ b/src/location/places/qplacesearchquery.cpp
@@ -58,6 +58,7 @@ public:
QList<QPlaceCategory> categories;
QGeoBoundingArea *searchArea;
int dymNumber;
+ QPlaceManager::VisibilityScopes scope;
};
QT_END_NAMESPACE
@@ -67,7 +68,8 @@ QT_USE_NAMESPACE
QPlaceSearchQueryPrivate::QPlaceSearchQueryPrivate()
: QSharedData(),
dymNumber(0),
- searchArea(0)
+ searchArea(0),
+ scope(QPlaceManager::NoScope)
{
}
@@ -80,6 +82,7 @@ QPlaceSearchQueryPrivate::QPlaceSearchQueryPrivate(const QPlaceSearchQueryPrivat
if (other.searchArea)
this->searchArea = other.searchArea->clone();
this->dymNumber = other.dymNumber;
+ this->scope = other.scope;
}
QPlaceSearchQueryPrivate::~QPlaceSearchQueryPrivate()
@@ -107,6 +110,7 @@ bool QPlaceSearchQueryPrivate::operator==(const QPlaceSearchQueryPrivate &other)
&& this->categories == other.categories
&& this->dymNumber == other.dymNumber
&& searchAreaMatch
+ && this->scope == other.scope
);
}
@@ -247,6 +251,25 @@ void QPlaceSearchQuery::setDidYouMeanSuggestionNumber(const int &number)
}
/*!
+ Returns the visibility scope used when searching for places. The default value
+ is QPlaceManager::NoScope meaning no explicit scope has been assigned.
+ It is up to the manager implementation to decide what scope it searches
+ by default.
+*/
+QPlaceManager::VisibilityScopes QPlaceSearchQuery::visibilityScope() const
+{
+ return d->scope;
+}
+
+/*!
+ Sets the \a scope used when searching for places.
+*/
+void QPlaceSearchQuery::setVisibilityScope(QPlaceManager::VisibilityScopes scope)
+{
+ d->scope = scope;
+}
+
+/*!
Clears the parameters of the search query.
*/
void QPlaceSearchQuery::clear()
@@ -256,4 +279,5 @@ void QPlaceSearchQuery::clear()
d->categories.clear();
d->searchArea = 0;
d->dymNumber = 0;
+ d->scope = QPlaceManager::NoScope;
}
diff --git a/src/location/places/qplacesearchquery.h b/src/location/places/qplacesearchquery.h
index 8d0f0328..bfbbd668 100644
--- a/src/location/places/qplacesearchquery.h
+++ b/src/location/places/qplacesearchquery.h
@@ -47,6 +47,7 @@
#include "qmobilityglobal.h"
#include "qplacecategory.h"
#include "qplacequery.h"
+#include "qplacemanager.h"
#include <QString>
@@ -87,6 +88,9 @@ public:
int didYouMeanSuggestionNumber() const;
void setDidYouMeanSuggestionNumber(const int &number);
+ QPlaceManager::VisibilityScopes visibilityScope() const;
+ void setVisibilityScope(QPlaceManager::VisibilityScopes scope);
+
void clear();
private:
diff --git a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp
index 43952055..42fba6fb 100644
--- a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp
@@ -87,6 +87,16 @@ void QPlaceSearchReplyImpl::abort()
restReply->cancelProcessing();
}
+void QPlaceSearchReplyImpl::setError(QPlaceReply::Error errorId, const QString &errorString)
+{
+ QPlaceReply::setError(errorId, errorString);
+ emit error(this->error(), this->errorString());
+ emit processingError(this, this->error(), this->errorString());
+ setFinished(true);
+ emit finished();
+ emit processingFinished(this);
+}
+
void QPlaceSearchReplyImpl::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
diff --git a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h b/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h
index d55973f0..fbf37a2b 100644
--- a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h
+++ b/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h
@@ -70,7 +70,8 @@ Q_SIGNALS:
void processingFinished(QPlaceReply *reply);
void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage);
-private slots:
+public slots:
+ void setError(QPlaceReply::Error error, const QString &errorString);
void restError(QPlaceRestReply::Error error);
void resultReady(const QPlaceJSonParser::Error &error,
const QString &errorMessage);
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
index c7281adb..9746a0dc 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
@@ -60,12 +60,15 @@
#include "places/qplacerestreply.h"
QT_USE_NAMESPACE
+Q_DECLARE_METATYPE(QPlaceReply::Error)
QPlaceManagerEngineNokia::QPlaceManagerEngineNokia(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QPlaceManagerEngine(parameters)
{
+ qRegisterMetaType<QPlaceReply::Error>();
+
if (error)
*error = QGeoServiceProvider::NoError;
@@ -140,7 +143,7 @@ QPlaceReviewReply *QPlaceManagerEngineNokia::getReviews(const QGeoPlace &place,
return reply;
}
-QPlaceSearchReply *QPlaceManagerEngineNokia::searchForPlaces(const QPlaceSearchQuery &query, QPlaceManager::VisibilityScope scope)
+QPlaceSearchReply *QPlaceManagerEngineNokia::searchForPlaces(const QPlaceSearchQuery &query)
{
//TODO: handling of scope
QPlaceSearchReplyImpl *reply = NULL;
@@ -149,23 +152,31 @@ QPlaceSearchReply *QPlaceManagerEngineNokia::searchForPlaces(const QPlaceSearchQ
if (newQuery.categories().count()) {
newQuery.setSearchTerm(query.categories().at(0).name());
}
- QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendSearchRequest(newQuery);
- if (restReply) {
- reply = new QPlaceSearchReplyImpl(restReply, this);
- connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
- this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
- connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
- this, SLOT(processingFinished(QPlaceReply*)));
+ if ((query.visibilityScope() == QPlaceManager::NoScope
+ || query.visibilityScope() & QPlaceManager::PublicScope)) {
+
+ QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendSearchRequest(newQuery);
+
+ if (restReply) {
+ reply = new QPlaceSearchReplyImpl(restReply, this);
+ connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
+ this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
+ connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
+ this, SLOT(processingFinished(QPlaceReply*)));
+ }
+ } else {
+ reply = new QPlaceSearchReplyImpl(0,this);
+ QMetaObject::invokeMethod(reply,
+ "setError",
+ Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
+ Q_ARG(QString, "Searching for places with unsupported visibility scope"));
+
}
return reply;
}
-QPlaceManager::VisibilityScopes QPlaceManagerEngineNokia::supportedSearchVisibilityScopes() const
-{
- return QPlaceManager::PublicScope;
-}
-
QPlaceSearchReply *QPlaceManagerEngineNokia::recommendations(const QGeoPlace &place, const QPlaceSearchQuery &query)
{
QPlaceRecommendationReplyImpl *reply = NULL;
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
index 691eff02..113734f2 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
@@ -72,8 +72,7 @@ public:
QPlaceReviewReply *getReviews(const QGeoPlace &place, const QPlaceQuery &query);
- QPlaceSearchReply *searchForPlaces(const QPlaceSearchQuery &query, QPlaceManager::VisibilityScope scope);
- QPlaceManager::VisibilityScopes supportedSearchVisibilityScopes() const;
+ QPlaceSearchReply *searchForPlaces(const QPlaceSearchQuery &query);
QPlaceSearchReply *recommendations(const QGeoPlace &place, const QPlaceSearchQuery &query);
QPlaceTextPredictionReply *textPredictions(const QPlaceSearchQuery &query);
diff --git a/tests/auto/qgeosearchmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeosearchmanagerplugins/qgeoserviceproviderplugin_test.h
index 8b75b033..d1f28840 100644
--- a/tests/auto/qgeosearchmanagerplugins/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/qgeosearchmanagerplugins/qgeoserviceproviderplugin_test.h
@@ -60,7 +60,6 @@ public:
QGeoSearchManagerEngine* createSearchManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
-
};
#endif
diff --git a/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp b/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp
index 8a0f459a..38a9839b 100644
--- a/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp
+++ b/tests/auto/qplacesearchquery/tst_qplacesearchquery.cpp
@@ -22,6 +22,7 @@ private Q_SLOTS:
void boundingBoxTest();
void searchAreaTest();
void didYouMeanSuggestionNumberTest();
+ void visibilityScopeTest();
void operatorsTest();
};
@@ -128,6 +129,17 @@ void tst_QPlaceSearchQuery::didYouMeanSuggestionNumberTest()
QVERIFY2(testObj.didYouMeanSuggestionNumber() == 0, "Wrong cleared value returned");
}
+void tst_QPlaceSearchQuery::visibilityScopeTest()
+{
+ QPlaceSearchQuery query;
+ QVERIFY2(query.visibilityScope() == QPlaceManager::NoScope, "Wrong default value");
+ query.setVisibilityScope(QPlaceManager::PublicScope);
+ QCOMPARE(query.visibilityScope(), QPlaceManager::PublicScope);
+ query.setVisibilityScope(QPlaceManager::PublicAndPrivateScope);
+ QVERIFY(query.visibilityScope() & QPlaceManager::PublicScope);
+ QVERIFY(query.visibilityScope() & QPlaceManager::PrivateScope);
+}
+
void tst_QPlaceSearchQuery::operatorsTest()
{
QPlaceSearchQuery testObj;
@@ -172,6 +184,17 @@ void tst_QPlaceSearchQuery::operatorsTest()
testObj.setSearchArea(b4);
testObj2.setSearchArea(c4);
QVERIFY2(testObj != testObj2, "Circle and box identified as matching");
+
+ //test that identical visibility scopes match
+ testObj.clear();
+ testObj2.clear();
+ testObj.setVisibilityScope(QPlaceManager::PublicScope);
+ testObj2.setVisibilityScope(QPlaceManager::PublicScope);
+ QVERIFY2(testObj == testObj2, "Identical scopes not identified as matching");
+
+ //test that different scopes do not match
+ testObj2.setVisibilityScope(QPlaceManager::PublicScope | QPlaceManager::PrivateScope);
+ QVERIFY2(testObj != testObj2, "Different scopes identified as matching");
}
QTEST_APPLESS_MAIN(tst_QPlaceSearchQuery);