diff options
Diffstat (limited to 'src/location')
-rw-r--r-- | src/location/doc/snippets/places/requesthandler.h | 6 | ||||
-rw-r--r-- | src/location/doc/src/places.qdoc | 2 | ||||
-rw-r--r-- | src/location/places/qplacesearchreply.cpp | 62 | ||||
-rw-r--r-- | src/location/places/qplacesearchreply.h | 9 | ||||
-rw-r--r-- | src/location/places/qplacesearchrequest.cpp | 28 | ||||
-rw-r--r-- | src/location/places/qplacesearchrequest.h | 2 |
6 files changed, 67 insertions, 42 deletions
diff --git a/src/location/doc/snippets/places/requesthandler.h b/src/location/doc/snippets/places/requesthandler.h index 92e1a935..8771d294 100644 --- a/src/location/doc/snippets/places/requesthandler.h +++ b/src/location/doc/snippets/places/requesthandler.h @@ -100,7 +100,6 @@ public: { //! [Search paging] QPlaceSearchRequest searchRequest; - searchRequest.setOffset(10); //specify the index of the first result searchRequest.setLimit(15); //specify how many results are to be retrieved. //! [Search paging] } @@ -220,9 +219,8 @@ public: //closer places have greater weighting in the ranking of results. searchRequest.setRelevanceHint(QPlaceSearchRequest::DistanceHint); - //use offset and limit to provide pagination. - //this retrieves the next 5 items from the 10th index - searchRequest.setOffset(9); + //use limit to adjust pagination. + //this limits the number of place results to 5 per page. searchRequest.setLimit(5); //provide some categories to narrow down search diff --git a/src/location/doc/src/places.qdoc b/src/location/doc/src/places.qdoc index 62a6d0d5..74a25b79 100644 --- a/src/location/doc/src/places.qdoc +++ b/src/location/doc/src/places.qdoc @@ -248,7 +248,7 @@ Any places similar to the given place are retrieved. \section3 Paging - If the plugin supports paging, limit and offset parameters may be provided to the search request. + If the plugin supports paging, the limit parameter may be provided to the search request. \snippet places/requesthandler.h Search paging \section2 Fetching Place Details diff --git a/src/location/places/qplacesearchreply.cpp b/src/location/places/qplacesearchreply.cpp index 26829607..9d89748a 100644 --- a/src/location/places/qplacesearchreply.cpp +++ b/src/location/places/qplacesearchreply.cpp @@ -39,23 +39,23 @@ ** ****************************************************************************/ -#include "qplacesearchreply.h" -#include "qplacereply_p.h" - +#include <QtLocation/QPlaceSearchRequest> +#include <QtLocation/QPlaceSearchReply> +#include <QtLocation/QPlaceProposedSearchResult> +#include <QtLocation/private/qplacereply_p.h> QT_BEGIN_NAMESPACE + class QPlaceSearchReplyPrivate : public QPlaceReplyPrivate { public: QPlaceSearchReplyPrivate(){} QList<QPlaceSearchResult> results; QPlaceSearchRequest searchRequest; + QPlaceSearchRequest previousPageRequest; + QPlaceSearchRequest nextPageRequest; }; -QT_END_NAMESPACE - -QT_USE_NAMESPACE - /*! \class QPlaceSearchReply \inmodule QtLocation @@ -121,6 +121,30 @@ QPlaceSearchRequest QPlaceSearchReply::request() const } /*! + Returns a place search request which can be used to request the previous page of search + results. An empty place search request is returned if there is no previous page of results. + + \sa nextPageRequest(), setPreviousPageRequest() +*/ +QPlaceSearchRequest QPlaceSearchReply::previousPageRequest() const +{ + Q_D(const QPlaceSearchReply); + return d->previousPageRequest; +} + +/*! + Returns a place search request which can be used to request the next page of search results. An + empty place search request is returned if there is no next page of results. + + \sa previousPageRequest(), setNextPageRequest() +*/ +QPlaceSearchRequest QPlaceSearchReply::nextPageRequest() const +{ + Q_D(const QPlaceSearchReply); + return d->nextPageRequest; +} + +/*! Sets the search \a request used to generate this reply. */ void QPlaceSearchReply::setRequest(const QPlaceSearchRequest &request) @@ -128,3 +152,27 @@ void QPlaceSearchReply::setRequest(const QPlaceSearchRequest &request) Q_D(QPlaceSearchReply); d->searchRequest = request; } + +/*! + Sets the previous page of search results request to \a previous. + + \sa previousPageRequest() +*/ +void QPlaceSearchReply::setPreviousPageRequest(const QPlaceSearchRequest &previous) +{ + Q_D(QPlaceSearchReply); + d->previousPageRequest = previous; +} + +/*! + Sets the next page of search results request to \a next. + + \sa nextPageRequest() +*/ +void QPlaceSearchReply::setNextPageRequest(const QPlaceSearchRequest &next) +{ + Q_D(QPlaceSearchReply); + d->nextPageRequest = next; +} + +QT_END_NAMESPACE diff --git a/src/location/places/qplacesearchreply.h b/src/location/places/qplacesearchreply.h index 4266b988..51cb315f 100644 --- a/src/location/places/qplacesearchreply.h +++ b/src/location/places/qplacesearchreply.h @@ -44,11 +44,12 @@ #include <QtLocation/QPlaceReply> #include <QtLocation/QPlaceSearchResult> -#include <QtLocation/QPlaceSearchRequest> QT_BEGIN_NAMESPACE +class QPlaceSearchResult; class QPlaceSearchReplyPrivate; + class Q_LOCATION_EXPORT QPlaceSearchReply : public QPlaceReply { Q_OBJECT @@ -61,9 +62,15 @@ public: QList<QPlaceSearchResult> results() const; QPlaceSearchRequest request() const; + QPlaceSearchRequest previousPageRequest() const; + QPlaceSearchRequest nextPageRequest() const; + protected: void setResults(const QList<QPlaceSearchResult> &results); void setRequest(const QPlaceSearchRequest &request); + void setPreviousPageRequest(const QPlaceSearchRequest &previous); + void setNextPageRequest(const QPlaceSearchRequest &next); + private: Q_DISABLE_COPY(QPlaceSearchReply) Q_DECLARE_PRIVATE(QPlaceSearchReply) diff --git a/src/location/places/qplacesearchrequest.cpp b/src/location/places/qplacesearchrequest.cpp index c5878b22..81cfeba4 100644 --- a/src/location/places/qplacesearchrequest.cpp +++ b/src/location/places/qplacesearchrequest.cpp @@ -68,7 +68,6 @@ public: QLocation::VisibilityScope visibilityScope; QPlaceSearchRequest::RelevanceHint relevanceHint; int limit; - int offset; QVariant searchContext; }; @@ -76,7 +75,7 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate() : QSharedData(), visibilityScope(QLocation::UnspecifiedVisibility), relevanceHint(QPlaceSearchRequest::UnspecifiedHint), - limit(-1), offset(0) + limit(-1) { } @@ -89,7 +88,6 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate(const QPlaceSearchRequest visibilityScope(other.visibilityScope), relevanceHint(other.relevanceHint), limit(other.limit), - offset(other.offset), searchContext(other.searchContext) { } @@ -108,7 +106,6 @@ QPlaceSearchRequestPrivate &QPlaceSearchRequestPrivate::operator=(const QPlaceSe visibilityScope = other.visibilityScope; relevanceHint = other.relevanceHint; limit = other.limit; - offset = other.offset; searchContext = other.searchContext; } @@ -124,14 +121,12 @@ bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &ot visibilityScope == other.visibilityScope && relevanceHint == other.relevanceHint && limit == other.limit && - offset == other.offset && searchContext == other.searchContext; } void QPlaceSearchRequestPrivate::clear() { limit = -1; - offset = 0; searchTerm.clear(); categories.clear(); searchArea = QGeoShape(); @@ -429,27 +424,6 @@ void QPlaceSearchRequest::setLimit(int limit) } /*! - Returns the offset index of the first item that is to be retrieved. - - The default offset is 0. -*/ -int QPlaceSearchRequest::offset() const -{ - Q_D(const QPlaceSearchRequest); - return d->offset; -} - -/*! - Sets the starting index of the first item to be retrieved - to \a offset. -*/ -void QPlaceSearchRequest::setOffset(int offset) -{ - Q_D(QPlaceSearchRequest); - d->offset = offset; -} - -/*! Clears the search request. */ void QPlaceSearchRequest::clear() diff --git a/src/location/places/qplacesearchrequest.h b/src/location/places/qplacesearchrequest.h index 65ca3fe0..34a6a1dd 100644 --- a/src/location/places/qplacesearchrequest.h +++ b/src/location/places/qplacesearchrequest.h @@ -94,8 +94,6 @@ public: RelevanceHint relevanceHint() const; void setRelevanceHint(RelevanceHint hint); - int offset() const; - void setOffset(int offset); int limit() const; void setLimit(int limit); |