summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
authorabcd <amos.choy@nokia.com>2011-11-02 19:01:44 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-07 02:51:40 +0100
commitc3853d1eb5d2d20cc041abe705d92bce931d8888 (patch)
tree9a2da92f8972f3b2e4028e3d2b8a880a74f0eeaf /src/location
parent3e2e863b147e8d75a860893cc8f74f7729a7e041 (diff)
downloadqtlocation-c3853d1eb5d2d20cc041abe705d92bce931d8888.tar.gz
Docs for request classes + refactor
Documentation for the content and search request classes. There is no need for the request classes to inherit off a base request class. Currently the base class has limit and offset fields, but if for example there is an image submission request class the limit and offset become meaningless. The content reply class should have a field for the content request just like the search reply has a field for the search request. Change-Id: I8d9dfe8a31806c6bb3b31f66d1338c2999e27ce2 Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/location')
-rw-r--r--src/location/places/places.pri3
-rw-r--r--src/location/places/qplacecontentreply.cpp22
-rw-r--r--src/location/places/qplacecontentreply.h4
-rw-r--r--src/location/places/qplacecontentrequest.cpp139
-rw-r--r--src/location/places/qplacecontentrequest.h22
-rw-r--r--src/location/places/qplacecontentrequest_p.h14
-rw-r--r--src/location/places/qplacemanager.h1
-rw-r--r--src/location/places/qplacerequest.cpp194
-rw-r--r--src/location/places/qplacerequest.h99
-rw-r--r--src/location/places/qplacerequest_p.h81
-rw-r--r--src/location/places/qplacesearchrequest.cpp223
-rw-r--r--src/location/places/qplacesearchrequest.h23
12 files changed, 375 insertions, 450 deletions
diff --git a/src/location/places/places.pri b/src/location/places/places.pri
index 34978b6b..c13c77ac 100644
--- a/src/location/places/places.pri
+++ b/src/location/places/places.pri
@@ -19,7 +19,6 @@ PUBLIC_HEADERS += \
places/qplacesearchresult.h \
#request classes
places/qplacecontentrequest.h \
- places/qplacerequest.h \
places/qplacesearchrequest.h \
#reply classes
places/qplacereply.h \
@@ -45,7 +44,6 @@ PRIVATE_HEADERS += \
places/qplacesearchresult_p.h \
places/qplacereply_p.h \
places/qplacemanagerengine_p.h \
- places/qplacerequest_p.h \
places/qplacecontentrequest_p.h \
places/qplaceuser_p.h
@@ -69,7 +67,6 @@ SOURCES += \
places/qplacesearchresult.cpp \
#request classes
places/qplacecontentrequest.cpp \
- places/qplacerequest.cpp \
places/qplacesearchrequest.cpp \
#reply classes
places/qplacereply.cpp \
diff --git a/src/location/places/qplacecontentreply.cpp b/src/location/places/qplacecontentreply.cpp
index e1d7462b..1deb6137 100644
--- a/src/location/places/qplacecontentreply.cpp
+++ b/src/location/places/qplacecontentreply.cpp
@@ -52,6 +52,7 @@ public:
QPlaceContent::Collection contentCollection;
int totalCount;
+ QPlaceContentRequest contentRequest;
};
QT_END_NAMESPACE
@@ -66,6 +67,9 @@ QT_USE_NAMESPACE
\brief The QPlaceContentReply class manages a content retrieval operation started by an
instance of QPlaceManager.
+
+ See \l {Fetching Rich Content} for an example on how to use a content reply.
+ \sa QPlaceContentRequest
*/
/*!
@@ -129,3 +133,21 @@ void QPlaceContentReply::setTotalCount(int total)
Q_D(QPlaceContentReply);
d->totalCount = total;
}
+
+/*!
+ Returns the content request that was used to generate this reply.
+*/
+QPlaceContentRequest QPlaceContentReply::request() const
+{
+ Q_D(const QPlaceContentReply);
+ return d->contentRequest;
+}
+
+/*!
+ Sets the content \a request used to generate this this reply.
+*/
+void QPlaceContentReply::setRequest(const QPlaceContentRequest &request)
+{
+ Q_D(QPlaceContentReply);
+ d->contentRequest = request;
+}
diff --git a/src/location/places/qplacecontentreply.h b/src/location/places/qplacecontentreply.h
index dd25f476..25eb27a8 100644
--- a/src/location/places/qplacecontentreply.h
+++ b/src/location/places/qplacecontentreply.h
@@ -44,6 +44,7 @@
#include "qplacereply.h"
#include "qplacecontent.h"
+#include "qplacecontentrequest.h"
QT_BEGIN_HEADER
@@ -65,9 +66,12 @@ public:
int totalCount() const;
+ QPlaceContentRequest request() const;
+
protected:
void setContent(const QPlaceContent::Collection &content);
void setTotalCount(int total);
+ void setRequest(const QPlaceContentRequest &request);
\
private:
diff --git a/src/location/places/qplacecontentrequest.cpp b/src/location/places/qplacecontentrequest.cpp
index fdca36ef..0ed4f881 100644
--- a/src/location/places/qplacecontentrequest.cpp
+++ b/src/location/places/qplacecontentrequest.cpp
@@ -46,30 +46,33 @@
QT_BEGIN_NAMESPACE
QPlaceContentRequestPrivate::QPlaceContentRequestPrivate()
-: QPlaceRequestPrivate(QPlaceRequest::ContentRequest), contentType(QPlaceContent::InvalidType)
+: QSharedData(), contentType(QPlaceContent::InvalidType),
+ limit(-1), offset(0)
{
}
-QPlaceContentRequestPrivate::~QPlaceContentRequestPrivate()
+QPlaceContentRequestPrivate::QPlaceContentRequestPrivate(const QPlaceContentRequestPrivate &other)
+ : QSharedData(other), contentType(other.contentType),
+ limit(other.limit), offset(other.offset)
{
}
-QPlaceContentRequestPrivate::QPlaceContentRequestPrivate(const QPlaceContentRequestPrivate &other)
- : QPlaceRequestPrivate(other)
+QPlaceContentRequestPrivate::~QPlaceContentRequestPrivate()
{
- this->contentType = other.contentType;
}
-bool QPlaceContentRequestPrivate::compare(const QPlaceRequestPrivate *other) const
+bool QPlaceContentRequestPrivate::operator==(const QPlaceContentRequestPrivate &other) const
{
- const QPlaceContentRequestPrivate *od = static_cast<const QPlaceContentRequestPrivate *>(other);
- return contentType == od->contentType && QPlaceRequestPrivate::compare(other);
+ return contentType == other.contentType
+ && limit == other.limit
+ && offset == other.offset;
}
void QPlaceContentRequestPrivate::clear()
{
- QPlaceRequestPrivate::clear();
this->contentType = QPlaceContent::InvalidType;
+ limit = -1;
+ offset = 0;
}
/*!
@@ -78,31 +81,72 @@ void QPlaceContentRequestPrivate::clear()
\ingroup QtLocation-places
\since QtLocation 5.0
- \brief The QPlaceContentRequest class represents the query parameters of a content request.
+ \brief The QPlaceContentRequest class represents the parameters of a content request.
- The QPlaceContentRequest class represents a query parameters object, it currently
- specifies the type of content to be retrived.
+ The QPlaceContentRequest class is used in conjunction with a QPlaceManager to
+ retrieve rich content like images and reviews in a paginated fashion.
+ The following code would request a set of 5 images from the 10th index:
+
+ \snippet snippets/places/requesthandler.h Content request
+ \dots
+ \dots
+ \snippet snippets/places/requesthandler.h Content handler
+
+ \sa QPlaceContentReply
*/
/*!
- Default constructor. Constructs an new request object.
+ Constructs an new request object.
*/
QPlaceContentRequest::QPlaceContentRequest()
- : QPlaceRequest(new QPlaceContentRequestPrivate)
+ : d_ptr(new QPlaceContentRequestPrivate())
{
}
-Q_IMPLEMENT_COPY_CTOR(QPlaceContentRequest, QPlaceRequest)
+/*!
+ Constructs a copy of \a other.
+*/
+QPlaceContentRequest::QPlaceContentRequest(const QPlaceContentRequest &other)
+ : d_ptr(other.d_ptr)
+{
+}
/*!
- Destructor.
+ Destroys the request object
*/
QPlaceContentRequest::~QPlaceContentRequest()
{
}
-Q_IMPLEMENT_D_FUNC(QPlaceContentRequest)
+/*!
+ Assigns \a other to this content request and returns a reference
+ to this content request.
+*/
+QPlaceContentRequest &QPlaceContentRequest::operator= (const QPlaceContentRequest & other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns true if \a other is equal to this content request,
+ otherwise returns false.
+*/
+bool QPlaceContentRequest::operator== (const QPlaceContentRequest &other) const
+{
+ Q_D(const QPlaceContentRequest);
+ return *d == *other.d_func();
+}
+/*!
+ Returns true if \a other is not equal to this content request,
+ otherwise returns false.
+*/
+bool QPlaceContentRequest::operator!= (const QPlaceContentRequest &other) const
+{
+ Q_D(const QPlaceContentRequest);
+ return !(*d == *other.d_func());
+}
/*!
Returns the type of content to be requested, eg reviews or images
@@ -122,4 +166,65 @@ void QPlaceContentRequest::setContentType(QPlaceContent::Type type)
d->contentType = type;
}
+/*!
+ Returns the maximum number of content items to retrieve.
+
+ A negative value for limit means that it is undefined. It is left up to the backend
+ provider to choose an appropriate number of items to return.
+
+*/
+int QPlaceContentRequest::limit() const
+{
+ Q_D(const QPlaceContentRequest);
+ return d->limit;
+}
+
+/*!
+ Set the maximum number of content items to retrieve to
+ \a limit.
+*/
+void QPlaceContentRequest::setLimit(int limit)
+{
+ Q_D(QPlaceContentRequest);
+ d->limit = limit;
+}
+
+/*!
+ Returns the index of the first item that is to be retrieved.
+*/
+int QPlaceContentRequest::offset() const
+{
+ Q_D(const QPlaceContentRequest);
+ return d->offset;
+}
+
+/*!
+ Sets the starting index of the first item to be retrieved
+ to \a offset.
+*/
+void QPlaceContentRequest::setOffset(int offset)
+{
+ Q_D(QPlaceContentRequest);
+ d->offset = offset;
+}
+
+/*!
+ Clears the content request.
+*/
+void QPlaceContentRequest::clear()
+{
+ Q_D(QPlaceContentRequest);
+ d->clear();
+}
+
+inline QPlaceContentRequestPrivate* QPlaceContentRequest::d_func()
+{
+ return static_cast<QPlaceContentRequestPrivate *>(d_ptr.data());
+}
+
+inline const QPlaceContentRequestPrivate* QPlaceContentRequest::d_func() const
+{
+ return static_cast<const QPlaceContentRequestPrivate *>(d_ptr.constData());
+}
+
QT_END_NAMESPACE
diff --git a/src/location/places/qplacecontentrequest.h b/src/location/places/qplacecontentrequest.h
index a4333ee6..1a17beef 100644
--- a/src/location/places/qplacecontentrequest.h
+++ b/src/location/places/qplacecontentrequest.h
@@ -45,8 +45,6 @@
#include <QSharedDataPointer>
#include "qplacecontent.h"
-#include "qplacerequest.h"
-#include "placemacro.h"
QT_BEGIN_HEADER
@@ -56,18 +54,32 @@ QT_BEGIN_NAMESPACE
class QPlaceContentRequestPrivate;
-class Q_LOCATION_EXPORT QPlaceContentRequest : public QPlaceRequest
+class Q_LOCATION_EXPORT QPlaceContentRequest
{
public:
QPlaceContentRequest();
- Q_DECLARE_COPY_CTOR(QPlaceContentRequest, QPlaceRequest)
+ QPlaceContentRequest(const QPlaceContentRequest &other);
~QPlaceContentRequest();
+ QPlaceContentRequest& operator=(const QPlaceContentRequest &other);
+
+ bool operator==(const QPlaceContentRequest &other) const;
+ bool operator!=(const QPlaceContentRequest &other) const;
+
QPlaceContent::Type contentType() const;
void setContentType(QPlaceContent::Type type);
+ int offset() const;
+ void setOffset(int offset);
+ int limit() const;
+ void setLimit(int limit);
+
+ void clear();
+
private:
- Q_DECLARE_D_FUNC(QPlaceContentRequest)
+ QSharedDataPointer<QPlaceContentRequestPrivate> d_ptr;
+ inline QPlaceContentRequestPrivate *d_func();
+ inline const QPlaceContentRequestPrivate *d_func() const;
};
QT_END_NAMESPACE
diff --git a/src/location/places/qplacecontentrequest_p.h b/src/location/places/qplacecontentrequest_p.h
index 0795b3fe..0b9c52d8 100644
--- a/src/location/places/qplacecontentrequest_p.h
+++ b/src/location/places/qplacecontentrequest_p.h
@@ -42,24 +42,26 @@
#ifndef QPLACECONTENTREQUEST_P_H
#define QPLACECONTENTREQUEST_P_H
-#include "placemacro.h"
-#include "qplacecontent_p.h"
-#include "qplacerequest_p.h"
+#include <QtCore/QSharedData>
+#include "qplacecontent.h"
QT_BEGIN_NAMESPACE
-class QPlaceContentRequestPrivate : public QPlaceRequestPrivate
+class QPlaceContentRequestPrivate : public QSharedData
{
public:
QPlaceContentRequestPrivate();
QPlaceContentRequestPrivate(const QPlaceContentRequestPrivate &other);
~QPlaceContentRequestPrivate();
- bool compare(const QPlaceRequestPrivate *other) const;
- Q_DEFINE_PRIVATE_HELPER(QPlaceContentRequest, QPlaceRequest, QPlaceRequest::ContentRequest)
+ QPlaceContentRequestPrivate &operator=(const QPlaceContentRequestPrivate &other);
+ bool operator==(const QPlaceContentRequestPrivate &other) const;
+
void clear();
QPlaceContent::Type contentType;
+ int limit;
+ int offset;
};
QT_END_NAMESPACE
diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h
index 1d8995bd..29ef98d4 100644
--- a/src/location/places/qplacemanager.h
+++ b/src/location/places/qplacemanager.h
@@ -44,7 +44,6 @@
#include "qplacecontentreply.h"
#include "qplacecontentrequest.h"
-#include "qplacerequest.h"
#include "qplaceidreply.h"
#include "qplacereply.h"
#include "qplacedetailsreply.h"
diff --git a/src/location/places/qplacerequest.cpp b/src/location/places/qplacerequest.cpp
deleted file mode 100644
index 6209f966..00000000
--- a/src/location/places/qplacerequest.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplacerequest.h"
-#include "qplacerequest_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_CC_MWERKS)
-template<> QT_PREPEND_NAMESPACE(QPlaceRequestPrivate) *QSharedDataPointer<QT_PREPEND_NAMESPACE(QPlaceRequestPrivate)>::clone()
-{
- return d->clone();
-}
-#endif
-
-QPlaceRequestPrivate::QPlaceRequestPrivate(QPlaceRequest::Type type)
-: QSharedData(), offset(0), limit(-1), requestType(type)
-{
-}
-
-QPlaceRequestPrivate::QPlaceRequestPrivate(const QPlaceRequestPrivate &other)
- : QSharedData()
-{
- this->offset = other.offset;
- this->limit = other.limit;
-}
-
-QPlaceRequestPrivate::~QPlaceRequestPrivate()
-{
-}
-
-QPlaceRequestPrivate *QPlaceRequestPrivate::clone() const { return new QPlaceRequestPrivate(*this);}
-
-bool QPlaceRequestPrivate::compare(const QPlaceRequestPrivate *other) const
-{
- return (this->offset == other->offset
- && this->limit == other->limit);
-}
-
-void QPlaceRequestPrivate::clear()
-{
- this->offset =0;
- this->limit = -1;
-}
-
-/*!
- \class QPlaceQuery
- \inmodule QtLocation
- \ingroup QtLocation-places
- \since QtLocation 5.0
-
- \brief The QPlaceQuery class is the base class used for various search queries.
-*/
-
-/*!
- Default constructor. Constructs an new query object.
-*/
-QPlaceRequest::QPlaceRequest()
-: d_ptr(new QPlaceRequestPrivate(QPlaceRequest::Request))
-{
-}
-
-/*!
- Constructs a copy of \a other
-*/
-QPlaceRequest::QPlaceRequest(const QPlaceRequest &other)
- :d_ptr(other.d_ptr)
-{
-}
-
-/*!
- Destructor.
-*/
-QPlaceRequest::~QPlaceRequest()
-{
-}
-
-QPlaceRequest &QPlaceRequest::operator =(const QPlaceRequest &other) {
- d_ptr = other.d_ptr;
- return *this;
-}
-
-bool QPlaceRequest::operator==(const QPlaceRequest &other) const
-{
- if (!d_ptr)
- return !other.d_ptr;
-
- if (d_ptr->requestType != other.d_ptr->requestType)
- return false;
-
- return d_ptr->compare(other.d_ptr);
-}
-
-QPlaceRequest::Type QPlaceRequest::type() const
-{
- return d_ptr->requestType;
-}
-
-/*!
- Returns the offset. By default the offset is set to 0.
- The offset determines the first index which is retrieved, it is generally
- used in conjunction with limit() to facilitate paging.
-
- Negative offests are treated as an offset of 0;
-*/
-int QPlaceRequest::offset() const
-{
- return d_ptr->offset;
-}
-
-/*!
- Sets the \a offset.
-*/
-void QPlaceRequest::setOffset(int offset)
-{
- d_ptr->offset = offset;
-}
-
-/*!
- Returns the maximum number of places to be fetched. The default
- value of this limit is -1, indicating that the default limit of the
- backend should be used.
-*/
-int QPlaceRequest::limit() const
-{
- return d_ptr->limit;
-}
-
-/*!
- Sets the maximum number of places to be fetched to \a limit.
-
- A negative limit indicates that the default limit of the backend should used.
- If the backend maximum limit is less than \a limit, then only the
- backend maximum limit number of places are retrieved.
-
- (A limit of 0 will retrieve no places).
-*/
-void QPlaceRequest::setLimit(int limit)
-{
- d_ptr->limit = limit;
-}
-
-/*!
- Clears the parameters of the search query.
-*/
-void QPlaceRequest::clear()
-{
- d_ptr->clear();
-}
-
-QPlaceRequest::QPlaceRequest(QPlaceRequestPrivate *d)
- : d_ptr(d)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/places/qplacerequest.h b/src/location/places/qplacerequest.h
deleted file mode 100644
index 4fd531ff..00000000
--- a/src/location/places/qplacerequest.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLACEQUERY_H
-#define QPLACEQUERY_H
-
-#include <QtLocation/qlocationglobal.h>
-
-#include <QMetaType>
-#include <QSharedDataPointer>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QPlaceRequestPrivate;
-
-class Q_LOCATION_EXPORT QPlaceRequest
-{
-public:
- enum Type {
- Request,
- ContentRequest,
- SearchRequest
- };
-
- QPlaceRequest();
- QPlaceRequest(const QPlaceRequest &other);
- virtual ~QPlaceRequest();
-
- QPlaceRequest &operator=(const QPlaceRequest &other);
-
- bool operator==(const QPlaceRequest &other) const;
- bool operator!=(const QPlaceRequest &other) const {
- return !(other == *this);
- }
-
- int offset() const;
- void setOffset(int offset);
- int limit() const;
- void setLimit(int limit);
-
- QPlaceRequest::Type type() const;
-
- void clear();
-
-protected:
- explicit QPlaceRequest(QPlaceRequestPrivate *d);
- QSharedDataPointer<QPlaceRequestPrivate> d_ptr;
- friend class QPlaceRequestPrivate;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QPlaceRequest))
-
-QT_END_HEADER
-
-#endif
diff --git a/src/location/places/qplacerequest_p.h b/src/location/places/qplacerequest_p.h
deleted file mode 100644
index e731cf36..00000000
--- a/src/location/places/qplacerequest_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLACEREQUEST_P_H
-#define QPLACEREQUEST_P_H
-
-#include "qplacerequest.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPlaceRequestPrivate : public QSharedData
-{
-public:
- QPlaceRequestPrivate(QPlaceRequest::Type type);
- QPlaceRequestPrivate(const QPlaceRequestPrivate &other);
- virtual ~QPlaceRequestPrivate();
-
- virtual bool compare(const QPlaceRequestPrivate *other) const;
- virtual QPlaceRequestPrivate *clone() const;
- virtual void clear();
-
- /* Helper functions for C++ protection rules */
- static const QSharedDataPointer<QPlaceRequestPrivate>& extract_d(const QPlaceRequest& other) {return other.d_ptr;}
- int offset;
- int limit;
- QPlaceRequest::Type requestType;
-};
-
-#if defined(Q_CC_MWERKS)
-// This results in multiple symbol definition errors on all other compilers
-// but not having a definition here results in an attempt to use the unspecialized
-// clone (which fails because of the pure virtuals above)
-template<> QPlaceRequestPrivate *QSharedDataPointer<QPlaceRequestPrivate>::clone()
-{
- return d->clone();
-}
-#else
-template<> QPlaceRequestPrivate *QSharedDataPointer<QPlaceRequestPrivate>::clone();
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/places/qplacesearchrequest.cpp b/src/location/places/qplacesearchrequest.cpp
index 1e57f00e..2f974c19 100644
--- a/src/location/places/qplacesearchrequest.cpp
+++ b/src/location/places/qplacesearchrequest.cpp
@@ -39,22 +39,24 @@
**
****************************************************************************/
-#include "qplacerequest_p.h"
#include "qplacesearchrequest.h"
#include "qgeocoordinate.h"
#include "qgeoboundingarea.h"
+#include <QtCore/QSharedData>
+
QT_BEGIN_NAMESPACE
-class QPlaceSearchRequestPrivate : public QPlaceRequestPrivate
+class QPlaceSearchRequestPrivate : public QSharedData
{
public:
QPlaceSearchRequestPrivate();
QPlaceSearchRequestPrivate(const QPlaceSearchRequestPrivate &other);
~QPlaceSearchRequestPrivate();
- bool compare(const QPlaceRequestPrivate *other) const;
- Q_DEFINE_PRIVATE_HELPER(QPlaceSearchRequest, QPlaceRequest, QPlaceRequest::SearchRequest)
+ QPlaceSearchRequestPrivate &operator=(const QPlaceSearchRequestPrivate &other);
+ bool operator==(const QPlaceSearchRequestPrivate &other) const;
+
void clear();
QString searchTerm;
@@ -63,26 +65,33 @@ public:
int dymNumber;
QtLocation::VisibilityScope visibilityScope;
QPlaceSearchRequest::RelevanceHint relevanceHint;
+ int limit;
+ int offset;
};
QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate()
-: QPlaceRequestPrivate(QPlaceRequest::SearchRequest), searchArea(0), dymNumber(0),
- visibilityScope(QtLocation::UnspecifiedVisibility), relevanceHint(QPlaceSearchRequest::UnspecifiedHint)
+ : QSharedData(),
+ searchArea(0), dymNumber(0),
+ visibilityScope(QtLocation::UnspecifiedVisibility), relevanceHint(QPlaceSearchRequest::UnspecifiedHint),
+ limit(-1), offset(0)
{
}
QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate(const QPlaceSearchRequestPrivate &other)
-: QPlaceRequestPrivate(other)
+ : QSharedData(other),
+ searchTerm(other.searchTerm),
+ categories(other.categories),
+ dymNumber(other.dymNumber),
+ visibilityScope(other.visibilityScope),
+ relevanceHint(other.relevanceHint),
+ limit(other.limit),
+ offset(other.offset)
{
- this->searchTerm = other.searchTerm;
- this->categories = other.categories;
+
if (other.searchArea)
- this->searchArea = other.searchArea->clone();
+ searchArea = other.searchArea->clone();
else
- this->searchArea = 0;
- this->dymNumber = other.dymNumber;
- visibilityScope = other.visibilityScope;
- this->relevanceHint = other.relevanceHint;
+ searchArea = 0;
}
QPlaceSearchRequestPrivate::~QPlaceSearchRequestPrivate()
@@ -90,14 +99,28 @@ QPlaceSearchRequestPrivate::~QPlaceSearchRequestPrivate()
delete searchArea;
}
-bool QPlaceSearchRequestPrivate::compare(const QPlaceRequestPrivate *other) const
+QPlaceSearchRequestPrivate &QPlaceSearchRequestPrivate::operator=(const QPlaceSearchRequestPrivate &other)
+{
+ searchTerm = other.searchTerm;
+ categories = other.categories;
+ if (other.searchArea)
+ searchArea = other.searchArea->clone();
+ else
+ searchArea = 0;
+ dymNumber = other.dymNumber;
+ visibilityScope = other.visibilityScope;
+ relevanceHint = other.relevanceHint;
+ limit = other.limit;
+ offset = other.offset;
+}
+
+bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &other) const
{
- const QPlaceSearchRequestPrivate *od = static_cast<const QPlaceSearchRequestPrivate *>(other);
bool searchAreaMatch = false;
- if ((this->searchArea == 0) && (od->searchArea == 0)) {
+ if ((searchArea == 0) && (other.searchArea == 0)) {
searchAreaMatch = true;
- } else if (this->searchArea && od->searchArea) {
- if ((*this->searchArea) == (*od->searchArea))
+ } else if (searchArea && other.searchArea) {
+ if (*searchArea == *(other.searchArea))
searchAreaMatch = true;
else
searchAreaMatch = false;
@@ -106,18 +129,21 @@ bool QPlaceSearchRequestPrivate::compare(const QPlaceRequestPrivate *other) cons
}
return (
- this->searchTerm == od->searchTerm
- && this->categories == od->categories
- && this->dymNumber == od->dymNumber
+ searchTerm == other.searchTerm
+ && categories == other.categories
+ && dymNumber == other.dymNumber
&& searchAreaMatch
- && visibilityScope == od->visibilityScope
- && this->relevanceHint == od->relevanceHint
+ && visibilityScope == other.visibilityScope
+ && relevanceHint == other.relevanceHint
+ && limit == other.limit
+ && offset == other.offset
);
}
void QPlaceSearchRequestPrivate::clear()
{
- QPlaceRequestPrivate::clear();
+ limit = -1;
+ offset = 0;
searchTerm.clear();
categories.clear();
delete searchArea;
@@ -133,43 +159,97 @@ void QPlaceSearchRequestPrivate::clear()
\ingroup QtLocation-places
\since QtLocation 5.0
- \brief The QPlaceSearchRequest class represents the query parameters of a search request.
+ \brief The QPlaceSearchRequest class represents the set of parameters for a search request.
- The QPlaceSearchRequest class represents a query parameters object. Each
- QPlaceSearchRequest cointans search query parameters like search term.
+ A typical search request may look like the following:
+ \snippet snippets/places/requesthandler.h Search request
+
+ Note that specifying a search center can be done by setting a circular search area that has
+ a center but no radius. The default radius is set to -1, which indicates an undefined radius. The provider will
+ interpret this as being free to choose its own default radius.
+
+ The QPlaceSearchRequest will assume ownership of the bounding area and will be responsible
+ for its destruction.
+
+ The QPlaceSearchRequest is primarily used with the QPlaceManager to
+ \l {QPlaceManager::search()} {search for places}, however it is also
+ used to provide parameters for \l {QPlaceManager::textPredictions()}{generating text predictions}
+ and \l {QPlaceManager::recommendations()} {retreiving recommendations}. Note that depending on usage
+ some parameters may not be relevant, e.g. the relevance hint is not important for text predictions. However
+ in general most of the parameters are useful for each of these operations, eg for a recommendation, a search area
+ and categories can be useful in narrowing down recommendation candidates.
+
+ Also be aware that providers may vary by which parameters they support e.g. some providers may not support
+ paging while others do, some providers may honor relevance hints while others may completely ignore them.
*/
/*!
\enum QPlaceSearchRequest::RelevanceHint
Defines hints to help rank place results.
+ \value UnspecifiedHint
+ No explicit hint has been specified.
\value DistanceHint
- Distance to the user's current location is relevant. This is only useful
+ Distance to a search center is relevant for the user. Closer places
+ are more highly weighted. This hint is only useful
if a circular bounding area is used in the query.
- \value RatingHint
- The rating of the place is relevant to the user.
- \value AlphabetHint
- Alphabetic ordering of places is relevant to the user.
+ \value LexicalPlaceNameHint
+ Alphabetic ordering of places according to name is relevant to the user.
*/
/*!
Default constructor. Constructs an new request object.
*/
QPlaceSearchRequest::QPlaceSearchRequest()
- : QPlaceRequest(new QPlaceSearchRequestPrivate)
+ : d_ptr(new QPlaceSearchRequestPrivate())
{
}
-Q_IMPLEMENT_COPY_CTOR(QPlaceSearchRequest, QPlaceRequest)
+/*!
+ Constructs a copy of \a other.
+*/
+QPlaceSearchRequest::QPlaceSearchRequest(const QPlaceSearchRequest &other)
+ : d_ptr(other.d_ptr)
+{
+}
/*!
- Destructor.
+ Destroys the request object.
*/
QPlaceSearchRequest::~QPlaceSearchRequest()
{
}
-Q_IMPLEMENT_D_FUNC(QPlaceSearchRequest)
+/*!
+ Assigns \a other to this search request and returns a reference
+ to this search request.
+*/
+QPlaceSearchRequest &QPlaceSearchRequest::operator= (const QPlaceSearchRequest & other)
+{
+ Q_D(QPlaceSearchRequest);
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns true if \a other is equal to this search request,
+ otherwise returns false.
+*/
+bool QPlaceSearchRequest::operator== (const QPlaceSearchRequest &other) const
+{
+ Q_D(const QPlaceSearchRequest);
+ return *d == *other.d_func();
+}
+
+/*!
+ Returns true if \a other is not equal to this search request,
+ otherwise returns false.
+*/
+bool QPlaceSearchRequest::operator!= (const QPlaceSearchRequest &other) const
+{
+ Q_D(const QPlaceSearchRequest);
+ return !(*d == *other.d_func());
+}
/*!
Returns the search term.
@@ -202,6 +282,8 @@ QList<QPlaceCategory> QPlaceSearchRequest::categories() const
/*!
Sets the search request to search by a single \a category
+
+ \sa setCategories()
*/
void QPlaceSearchRequest::setCategory(const QPlaceCategory &category)
{
@@ -217,6 +299,8 @@ void QPlaceSearchRequest::setCategory(const QPlaceCategory &category)
It is possible that some backends may not support multiple categories. In this case,
the first category is used and the rest are ignored.
+
+ \sa setCategory()
*/
void QPlaceSearchRequest::setCategories(const QList<QPlaceCategory> &categories)
{
@@ -277,12 +361,12 @@ QtLocation::VisibilityScope QPlaceSearchRequest::visibilityScope() const
}
/*!
- Sets the \a scope used when searching for places.
+ Sets the visibiliy \a scope used when searching for places.
*/
-void QPlaceSearchRequest::setVisibilityScope(QtLocation::VisibilityScope visibilityScope)
+void QPlaceSearchRequest::setVisibilityScope(QtLocation::VisibilityScope scope)
{
Q_D(QPlaceSearchRequest);
- d->visibilityScope = visibilityScope;
+ d->visibilityScope = scope;
}
/*!
@@ -306,4 +390,63 @@ void QPlaceSearchRequest::setRelevanceHint(QPlaceSearchRequest::RelevanceHint hi
d->relevanceHint = hint;
}
+/*!
+ Returns the maximum number of search results to retrieve.
+
+ A negative value for limit means that it is undefined. It is left up to the backend
+ provider to choose an appropriate number of results to return.
+*/
+int QPlaceSearchRequest::limit() const
+{
+ Q_D(const QPlaceSearchRequest);
+ return d->limit;
+}
+
+/*!
+ Set the maximum number of search results to retrieve to \a limit.
+*/
+void QPlaceSearchRequest::setLimit(int limit)
+{
+ Q_D(QPlaceSearchRequest);
+ d->limit = limit;
+}
+
+/*!
+ Returns the index of the first item that is to be retrieved.
+*/
+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()
+{
+ Q_D(QPlaceSearchRequest);
+ d->clear();
+}
+
+inline QPlaceSearchRequestPrivate* QPlaceSearchRequest::d_func()
+{
+ return static_cast<QPlaceSearchRequestPrivate *>(d_ptr.data());
+}
+
+inline const QPlaceSearchRequestPrivate* QPlaceSearchRequest::d_func() const
+{
+ return static_cast<const QPlaceSearchRequestPrivate *>(d_ptr.constData());
+}
+
QT_END_NAMESPACE
diff --git a/src/location/places/qplacesearchrequest.h b/src/location/places/qplacesearchrequest.h
index de5bf189..91f606be 100644
--- a/src/location/places/qplacesearchrequest.h
+++ b/src/location/places/qplacesearchrequest.h
@@ -43,7 +43,6 @@
#define QPLACESEARCHREQUEST_H
#include <QtCore/QSharedDataPointer>
-#include <QtLocation/QPlaceRequest>
#include <QtLocation/placemacro.h>
#include <QtLocation/QPlaceCategory>
#include <QtLocation/qtlocation.h>
@@ -57,7 +56,7 @@ QT_BEGIN_NAMESPACE
class QGeoBoundingArea;
class QPlaceSearchRequestPrivate;
-class Q_LOCATION_EXPORT QPlaceSearchRequest : public QPlaceRequest
+class Q_LOCATION_EXPORT QPlaceSearchRequest
{
public:
enum RelevanceHint {
@@ -67,7 +66,14 @@ public:
};
QPlaceSearchRequest();
- Q_DECLARE_COPY_CTOR(QPlaceSearchRequest, QPlaceRequest)
+ QPlaceSearchRequest(const QPlaceSearchRequest &other);
+
+
+ QPlaceSearchRequest& operator=(const QPlaceSearchRequest &other);
+
+ bool operator==(const QPlaceSearchRequest &other) const;
+ bool operator!=(const QPlaceSearchRequest &other) const;
+
~QPlaceSearchRequest();
QString searchTerm() const;
@@ -89,8 +95,17 @@ public:
RelevanceHint relevanceHint() const;
void setRelevanceHint(RelevanceHint hint);
+ int offset() const;
+ void setOffset(int offset);
+ int limit() const;
+ void setLimit(int limit);
+
+ void clear();
+
private:
- Q_DECLARE_D_FUNC(QPlaceSearchRequest)
+ QSharedDataPointer<QPlaceSearchRequestPrivate> d_ptr;
+ inline QPlaceSearchRequestPrivate *d_func();
+ inline const QPlaceSearchRequestPrivate *d_func() const;
};
QT_END_NAMESPACE