summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-08-22 20:24:43 +1000
committerabcd <qt_abcd1@ovi.com>2011-08-24 09:30:54 +0200
commit631783858474a28a219bcdd704efad5ef72d0f34 (patch)
tree210ddfd11f1d78b113dd8c3ecac72ab6df6a86a5
parente6dbdfbbad070c5ca7a4e14bdd917ee2c7b52f71 (diff)
downloadqtlocation-631783858474a28a219bcdd704efad5ef72d0f34.tar.gz
Use content mechanism to retrieve reviews
This means we no longer need the qplacereviewreply or the paginationlist. We also create a QPlaceContentRequest class to specialize in requesting content. It follows the same pattern that QPlaceContent does where the private classes use inheritance to mirror the public classes so that we only have a single d pointer instance per class(as opposed to a dpointer for QPlaceRequest and a dpointer for QPlaceContentRequest). QPlaceSeachRequest has been modified like this as well. Also in the nokia plugin we rename the qplaceimagereplyimpl class to the qplacecontentreplyimpl class. We use this to get the reviews as well as images and we no longer need the qplacereviewreplyimpl class. Change-Id: I0aa1254a4df3d136bf81f9faf0f6ec06a0773100 Reviewed-on: http://codereview.qt.nokia.com/3305 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: abcd <qt_abcd1@ovi.com>
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp15
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp76
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h2
-rw-r--r--src/location/places/placemacro.h30
-rw-r--r--src/location/places/places.pri14
-rw-r--r--src/location/places/qplacecontentrequest.cpp128
-rw-r--r--src/location/places/qplacecontentrequest.h (renamed from src/location/places/qplacereviewreply.h)42
-rw-r--r--src/location/places/qplacecontentrequest_p.h (renamed from src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.h)51
-rw-r--r--src/location/places/qplaceimage_p.h2
-rw-r--r--src/location/places/qplacemanager.cpp14
-rw-r--r--src/location/places/qplacemanager.h6
-rw-r--r--src/location/places/qplacemanagerengine.h4
-rw-r--r--src/location/places/qplacepaginationlist.h126
-rw-r--r--src/location/places/qplacerequest.cpp75
-rw-r--r--src/location/places/qplacerequest.h22
-rw-r--r--src/location/places/qplacerequest_p.h81
-rw-r--r--src/location/places/qplacereview.cpp80
-rw-r--r--src/location/places/qplacereview.h14
-rw-r--r--src/location/places/qplacereview_p.h9
-rw-r--r--src/location/places/qplacereviewreply.cpp141
-rw-r--r--src/location/places/qplacesearchrequest.cpp86
-rw-r--r--src/location/places/qplacesearchrequest.h12
-rw-r--r--src/location/qgeoplace.cpp45
-rw-r--r--src/location/qgeoplace.h3
-rw-r--r--src/location/qgeoplace_p.h2
-rw-r--r--src/plugins/geoservices/nokia/places/places.pri6
-rw-r--r--src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp (renamed from src/plugins/geoservices/nokia/places/qplaceimagereplyimpl.cpp)46
-rw-r--r--src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h (renamed from src/plugins/geoservices/nokia/places/qplaceimagereplyimpl.h)11
-rw-r--r--src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.cpp127
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp83
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h6
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/geotestplugin/qplacemanagerengine_test.h11
-rw-r--r--tests/auto/qgeoplace/tst_qgeoplace.cpp78
-rw-r--r--tests/auto/qplacecontentrequest/qplacecontentrequest.pro6
-rw-r--r--tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp76
-rw-r--r--tests/auto/qplacerequest/tst_qplacerequest.cpp1
-rw-r--r--tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp22
38 files changed, 762 insertions, 792 deletions
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp
index e673e2f7..ee58b4c4 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp
@@ -156,21 +156,22 @@ void QDeclarativePlaceImageModel::fetchMore(const QModelIndex &parent)
return;
}
- QPlaceRequest query;
+ QPlaceContentRequest request;
+ request.setContentType(QPlaceContent::ImageType);
if (m_imageCount == -1) {
- query.setOffset(0);
- query.setLimit(m_batchSize);
+ request.setOffset(0);
+ request.setLimit(m_batchSize);
} else {
QPair<int, int> missing = findMissingKey(m_images);
- query.setOffset(missing.first);
+ request.setOffset(missing.first);
if (missing.second == -1)
- query.setLimit(m_batchSize);
+ request.setLimit(m_batchSize);
else
- query.setLimit(qMin(m_batchSize, missing.second - missing.first + 1));
+ request.setLimit(qMin(m_batchSize, missing.second - missing.first + 1));
}
- m_reply = placeManager->getContent(QPlaceContent::ImageType, m_place->place(), query);
+ m_reply = placeManager->getContent(m_place->place(), request);
connect(m_reply, SIGNAL(finished()), this, SLOT(fetchFinished()), Qt::QueuedConnection);
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp
index 8fbd9410..5bbee737 100644
--- a/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp
@@ -155,21 +155,22 @@ void QDeclarativeReviewModel::fetchMore(const QModelIndex &parent)
return;
}
- QPlaceRequest query;
+ QPlaceContentRequest request;
+ request.setContentType(QPlaceContent::ReviewType);
if (m_reviewCount == -1) {
- query.setOffset(0);
- query.setLimit(m_batchSize);
+ request.setOffset(0);
+ request.setLimit(m_batchSize);
} else {
QPair<int, int> missing = findMissingKey(m_reviews);
- query.setOffset(missing.first);
+ request.setOffset(missing.first);
if (missing.second == -1)
- query.setLimit(m_batchSize);
+ request.setLimit(m_batchSize);
else
- query.setLimit(qMin(m_batchSize, missing.second - missing.first + 1));
+ request.setLimit(qMin(m_batchSize, missing.second - missing.first + 1));
}
- m_reply = placeManager->getReviews(m_place->place(), query);
+ m_reply = placeManager->getContent(m_place->place(), request);
connect(m_reply, SIGNAL(finished()), this, SLOT(fetchFinished()), Qt::QueuedConnection);
}
@@ -196,7 +197,7 @@ void QDeclarativeReviewModel::componentComplete()
void QDeclarativeReviewModel::fetchFinished()
{
- QPlaceReviewReply *reply = m_reply;
+ QPlaceContentReply *reply = m_reply;
m_reply = 0;
if (m_reviewCount != reply->totalCount()) {
@@ -204,15 +205,60 @@ void QDeclarativeReviewModel::fetchFinished()
emit totalCountChanged();
}
- if (reply->reviews().items() > 0) {
- int startIndex = reply->reviews().start();
+ if (!reply->content().isEmpty()) {
+ QPlaceContent::Collection reviews = reply->content();
+
+ //find out which indexes are new and which ones have changed.
+ QMapIterator<int, QPlaceContent> reviewsIter(reviews);
+ QList<int> changedIndexes;
+ QList<int> newIndexes;
+ while (reviewsIter.hasNext()) {
+ reviewsIter.next();
+ if (!m_reviews.contains(reviewsIter.key())) {
+ newIndexes.append(reviewsIter.key());
+ } else if (reviewsIter.value() != m_reviews.value(reviewsIter.key())->review()) {
+ changedIndexes.append(reviewsIter.key());
+ } else {
+ //review item at given index has not changed, do nothing
+ }
+ }
- QList<QPlaceReview> reviews = reply->reviews().data();
+ //insert new indexes in blocks where within each
+ //block, the indexes are consecutive.
+ QListIterator<int> newIndexesIter(newIndexes);
+ int startIndex = -1;
+ while (newIndexesIter.hasNext()) {
+ int currentIndex = newIndexesIter.next();
+ if (startIndex == -1)
+ startIndex = currentIndex;
+
+ if (!newIndexesIter.hasNext() || (newIndexesIter.hasNext() && (newIndexesIter.peekNext() > (currentIndex + 1)))) {
+ beginInsertRows(QModelIndex(),startIndex,currentIndex);
+ for (int i = startIndex; i <= currentIndex; ++i)
+ m_reviews.insert(i, new QDeclarativeReview(reviews.value(i), this));
+ endInsertRows();
+ startIndex = -1;
+ }
+ }
- beginInsertRows(QModelIndex(), startIndex, startIndex + reviews.length() - 1);
- for (int i = 0; i < reviews.length(); ++i)
- m_reviews.insert(startIndex + i, new QDeclarativeReview(reviews.at(i), this));
- endInsertRows();
+ //modify changed indexes in blocks where within each
+ //block, the indexes are consecutive.
+ startIndex = -1;
+ QListIterator<int> changedIndexesIter(changedIndexes);
+ while (changedIndexesIter.hasNext()) {
+ int currentIndex = changedIndexesIter.next();
+ if (startIndex == -1)
+ startIndex = currentIndex;
+
+ if (!changedIndexesIter.hasNext() || (changedIndexesIter.hasNext() && changedIndexesIter.peekNext() > (currentIndex +1))) {
+ for (int i = startIndex; i <= currentIndex; ++i) {
+ m_reviews.remove(i);
+ m_reviews.insert(i, new QDeclarativeReview(reviews.value(i), this));
+ }
+ emit dataChanged(index(startIndex),index(currentIndex));
+ startIndex = -1;
+ }
+ }
}
reply->deleteLater();
diff --git a/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h
index a66be326..aa8245e6 100644
--- a/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h
@@ -61,7 +61,7 @@ private:
int m_batchSize;
int m_reviewCount;
QMap<int, QDeclarativeReview *> m_reviews;
- QPlaceReviewReply *m_reply;
+ QPlaceContentReply *m_reply;
bool m_complete;
};
diff --git a/src/location/places/placemacro.h b/src/location/places/placemacro.h
new file mode 100644
index 00000000..0e9d99a4
--- /dev/null
+++ b/src/location/places/placemacro.h
@@ -0,0 +1,30 @@
+#ifndef PLACE_MACRO_H
+#define PLACE_MACRO_H
+
+#define Q_DECLARE_D_FUNC(Class) \
+ inline Class##Private* d_func(); \
+ inline const Class##Private* d_func() const;\
+ friend class Class##Private;
+
+#define Q_DECLARE_COPY_CTOR(Class, BaseClass) \
+ Class(const BaseClass &other);
+
+#define Q_IMPLEMENT_D_FUNC(Class) \
+ Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
+ const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); }
+
+#define Q_IMPLEMENT_COPY_CTOR(Class, BaseClass) \
+ Class::Class(const BaseClass& other) : BaseClass() { Class##Private::copyIfPossible(d_ptr, other); }
+
+#define Q_DEFINE_PRIVATE_HELPER(Class, BaseClass, ClassType, basename) \
+ BaseClass##Private* clone() const { return new Class##Private(*this); } \
+ virtual BaseClass::Type type() const {return ClassType;} \
+ static void copyIfPossible(QSharedDataPointer<BaseClass##Private>& d_ptr, const BaseClass &other) \
+ { \
+ if (other.basename##Type() == ClassType) \
+ d_ptr = extract_d(other); \
+ else \
+ d_ptr = new Class##Private; \
+ }
+
+#endif
diff --git a/src/location/places/places.pri b/src/location/places/places.pri
index b8756ec3..2dc67434 100644
--- a/src/location/places/places.pri
+++ b/src/location/places/places.pri
@@ -2,6 +2,7 @@
INCLUDEPATH += places
PUBLIC_HEADERS += \
+ places/placemacro.h \
#data classes
places/qplaceattribute.h \
places/qplacecategory.h \
@@ -9,20 +10,19 @@ PUBLIC_HEADERS += \
places/qplacecontentreply.h \
places/qplacedescription.h \
places/qplaceimage.h \
- places/qplacepaginationlist.h \
places/qplaceperiod.h \
places/qplacerating.h \
places/qplacereview.h \
places/qplacesupplier.h \
#result
places/qplacesearchresult.h \
-#query classes
+#request classes
+ places/qplacecontentrequest.h \
places/qplacerequest.h \
places/qplacesearchrequest.h \
#reply classes
places/qplacereply.h \
places/qplacedetailsreply.h \
- places/qplacereviewreply.h \
places/qplacesavereply.h \
places/qplacesearchreply.h \
places/qplacetextpredictionreply.h \
@@ -44,7 +44,9 @@ PRIVATE_HEADERS += \
places/qplacesearchresult_p.h \
places/qplacereply_p.h \
places/qplacemanager_p.h \
- places/qplacemanagerengine_p.h
+ places/qplacemanagerengine_p.h \
+ places/qplacerequest_p.h \
+ places/qplacecontentrequest_p.h
SOURCES += \
#data classes
@@ -62,13 +64,13 @@ SOURCES += \
places/qplacesupplier.cpp \
#result
places/qplacesearchresult.cpp \
-#query classes
+#request classes
+ places/qplacecontentrequest.cpp \
places/qplacerequest.cpp \
places/qplacesearchrequest.cpp \
#reply classes
places/qplacereply.cpp \
places/qplacedetailsreply.cpp \
- places/qplacereviewreply.cpp \
places/qplacesearchreply.cpp \
places/qplacetextpredictionreply.cpp \
#manager and engine
diff --git a/src/location/places/qplacecontentrequest.cpp b/src/location/places/qplacecontentrequest.cpp
new file mode 100644
index 00000000..f51287dd
--- /dev/null
+++ b/src/location/places/qplacecontentrequest.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** 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 "qplacecontentrequest_p.h"
+#include "qplacecontentrequest.h"
+#include "qgeocoordinate.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlaceContentRequestPrivate::QPlaceContentRequestPrivate()
+ : QPlaceRequestPrivate(), contentType(QPlaceContent::InvalidType)
+{
+}
+
+QPlaceContentRequestPrivate::~QPlaceContentRequestPrivate()
+{
+}
+
+QPlaceContentRequestPrivate::QPlaceContentRequestPrivate(const QPlaceContentRequestPrivate &other)
+ : QPlaceRequestPrivate(other)
+{
+ this->contentType = other.contentType;
+}
+
+bool QPlaceContentRequestPrivate::compare(const QPlaceRequestPrivate *other) const
+{
+ const QPlaceContentRequestPrivate *od = static_cast<const QPlaceContentRequestPrivate *>(other);
+ return (QPlaceRequestPrivate::compare(other)
+ && this->contentType ==od->contentType);
+}
+
+void QPlaceContentRequestPrivate::clear()
+{
+ QPlaceRequestPrivate::clear();
+ this->contentType = QPlaceContent::InvalidType;
+}
+
+/*!
+ \class QPlaceContentRequest
+
+ \inmodule Location
+
+ \brief The QPlaceContentRequest class represents the query parameters
+ of a content request.
+
+ \ingroup places-main
+
+ The QPlaceContentRequest class represents a query parameters object, it currently
+ specifies the type of content to be retrived.
+*/
+
+/*!
+ Default constructor. Constructs an new request object.
+*/
+QPlaceContentRequest::QPlaceContentRequest()
+ : QPlaceRequest(new QPlaceContentRequestPrivate)
+{
+}
+
+Q_IMPLEMENT_COPY_CTOR(QPlaceContentRequest, QPlaceRequest)
+
+/*!
+ Destructor.
+*/
+QPlaceContentRequest::~QPlaceContentRequest()
+{
+}
+
+Q_IMPLEMENT_D_FUNC(QPlaceContentRequest)
+
+
+/*!
+ Returns the type of content to be requested, eg reviews or images
+*/
+QPlaceContent::Type QPlaceContentRequest::contentType() const
+{
+ Q_D(const QPlaceContentRequest);
+ return d->contentType;
+}
+
+/*!
+ Sets the \a type of content to be requested.
+*/
+void QPlaceContentRequest::setContentType(QPlaceContent::Type type)
+{
+ Q_D(QPlaceContentRequest);
+ d->contentType = type;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/places/qplacereviewreply.h b/src/location/places/qplacecontentrequest.h
index 714885c3..ec4dd7a9 100644
--- a/src/location/places/qplacereviewreply.h
+++ b/src/location/places/qplacecontentrequest.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** 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 Qt Mobility Components.
+** This file is part of the QtLocation module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,40 +39,34 @@
**
****************************************************************************/
-#ifndef QPLACEREVIEWREPLY_H
-#define QPLACEREVIEWREPLY_H
+#ifndef QPLACECONTENTREQUEST_H
+#define QPLACECONTENTREQUEST_H
-#include "qplacereply.h"
-#include "qplacereview.h"
-#include "qplacepaginationlist.h"
+#include <QSharedDataPointer>
-#include <QStringList>
+#include "qplacecontent.h"
+#include "qplacerequest.h"
+#include "placemacro.h"
QT_BEGIN_NAMESPACE
-class QPlaceReviewReplyPrivate;
-class Q_LOCATION_EXPORT QPlaceReviewReply : public QPlaceReply
+class QPlaceContentRequestPrivate;
+
+class Q_LOCATION_EXPORT QPlaceContentRequest : public QPlaceRequest
{
- Q_OBJECT
public:
- QPlaceReviewReply(QObject *parent = 0);
- virtual ~QPlaceReviewReply();
-
- QPlaceReply::Type type() const;
+ QPlaceContentRequest();
+ Q_DECLARE_COPY_CTOR(QPlaceContentRequest, QPlaceRequest)
- QPlacePaginationList<QPlaceReview> reviews() const;
+ virtual ~QPlaceContentRequest();
- int totalCount() const;
+ QPlaceContent::Type contentType() const;
+ void setContentType(QPlaceContent::Type type);
-protected:
- void setOffset(int offset);
- void setReviews(const QList<QPlaceReview> &objects);
- void setTotalCount(int total);
private:
- Q_DISABLE_COPY(QPlaceReviewReply)
- Q_DECLARE_PRIVATE(QPlaceReviewReply)
+ Q_DECLARE_D_FUNC(QPlaceContentRequest)
};
-QT_BEGIN_NAMESPACE
+QT_END_NAMESPACE
#endif
diff --git a/src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.h b/src/location/places/qplacecontentrequest_p.h
index fd374074..896dee8c 100644
--- a/src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.h
+++ b/src/location/places/qplacecontentrequest_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** 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 Qt Mobility Components.
+** This file is part of the QtLocation module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -37,50 +37,31 @@
**
** $QT_END_LICENSE$
**
-** This file is part of the Ovi services plugin for the Maps and
-** Navigation API. The use of these services, whether by use of the
-** plugin or by other means, is governed by the terms and conditions
-** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
-** this package, located in the directory containing the Ovi services
-** plugin source code.
-**
****************************************************************************/
-#ifndef QPLACEREVIEWREPLYIMPL_H
-#define QPLACEREVIEWREPLYIMPL_H
-
-#include <QObject>
-#include <QHash>
+#ifndef QPLACECONTENTREQUEST_P_H
+#define QPLACECONTENTREQUEST_P_H
-#include <qplacereviewreply.h>
-#include "qplacerestreply.h"
-#include "qplacejsonreviewparser.h"
+#include "placemacro.h"
+#include "qplacecontent_p.h"
+#include "qplacerequest_p.h"
QT_BEGIN_NAMESPACE
-class QPlaceReviewReplyImpl : public QPlaceReviewReply
+class QPlaceContentRequestPrivate : public QPlaceRequestPrivate
{
- Q_OBJECT
public:
- explicit QPlaceReviewReplyImpl(QPlaceRestReply *reply, QObject *parent = 0);
- ~QPlaceReviewReplyImpl();
- void abort();
- void setStartNumber(int number);
-
-Q_SIGNALS:
- void processingFinished(QPlaceReply *reply);
- void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage);
+ QPlaceContentRequestPrivate();
+ QPlaceContentRequestPrivate(const QPlaceContentRequestPrivate &other);
+ ~QPlaceContentRequestPrivate();
-private slots:
- void restError(QPlaceRestReply::Error error);
- void resultReady(const QPlaceJSonParser::Error &error,
- const QString &errorMessage);
+ bool compare(const QPlaceRequestPrivate *other) const;
+ Q_DEFINE_PRIVATE_HELPER(QPlaceContentRequest, QPlaceRequest, QPlaceRequest::ContentType, request)
+ void clear();
-private:
- QPlaceRestReply *restReply;
- QPlaceJSonReviewParser *parser;
+ QPlaceContent::Type contentType;
};
QT_END_NAMESPACE
-#endif // QPLACEREVIEWREPLYIMPL_H
+#endif
diff --git a/src/location/places/qplaceimage_p.h b/src/location/places/qplaceimage_p.h
index efa70a5e..d0470ef9 100644
--- a/src/location/places/qplaceimage_p.h
+++ b/src/location/places/qplaceimage_p.h
@@ -60,7 +60,7 @@ public:
bool compare(const QPlaceContentPrivate *other) const;
- Q_DEFINE_CONTENT_PRIVATE_HELPER(QPlaceImage, QPlaceContent::ImageType);
+ Q_DEFINE_CONTENT_PRIVATE_HELPER(QPlaceImage, QPlaceContent::ImageType)
QUrl url;
QUrl thumbnailUrl;
diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp
index a08c0960..8303d4f1 100644
--- a/src/location/places/qplacemanager.cpp
+++ b/src/location/places/qplacemanager.cpp
@@ -136,12 +136,12 @@ QPlaceDetailsReply *QPlaceManager::getPlaceDetails(const QString &placeId) const
}
/*!
- Retrieves content of type \a contentType from a given \a place according to thes parameters specified in
+ Retrieves content from a given \a place according to thes parameters specified in
\a request.
*/
-QPlaceContentReply *QPlaceManager::getContent(QPlaceContent::Type contentType, const QGeoPlace &place, const QPlaceRequest &request) const
+QPlaceContentReply *QPlaceManager::getContent(const QGeoPlace &place, const QPlaceContentRequest &request) const
{
- return d->engine->getContent(contentType, place, request);
+ return d->engine->getContent(place, request);
}
/*!
@@ -153,14 +153,6 @@ QPlaceReply* QPlaceManager::postRating(const QString &placeId, qreal rating)
}
/*!
- Returns reviews for a given \a place according to the parameters specified in \a request.
-*/
-QPlaceReviewReply *QPlaceManager::getReviews(const QGeoPlace &place, const QPlaceRequest &request) const
-{
- return d->engine->getReviews(place, request);
-}
-
-/*!
Searches for places according to a given \a request.
*/
QPlaceSearchReply *QPlaceManager::searchForPlaces(const QPlaceSearchRequest &request) const
diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h
index 483f6dab..d4a57f55 100644
--- a/src/location/places/qplacemanager.h
+++ b/src/location/places/qplacemanager.h
@@ -44,11 +44,11 @@
#include "qmobilityglobal.h"
#include "qplacecontentreply.h"
+#include "qplacecontentrequest.h"
#include "qplacerequest.h"
#include "qplacesavereply.h"
#include "qplacereply.h"
#include "qplacedetailsreply.h"
-#include "qplacereviewreply.h"
#include "qplacetextpredictionreply.h"
#include <QLocale>
@@ -110,9 +110,7 @@ public:
QPlaceDetailsReply *getPlaceDetails(const QString &placeId) const;
QPlaceReply *postRating(const QString &placeId, qreal value);
- QPlaceReviewReply *getReviews(const QGeoPlace &place, const QPlaceRequest &query) const;
-
- QPlaceContentReply *getContent(QPlaceContent::Type type, const QGeoPlace &place, const QPlaceRequest &query) const;
+ QPlaceContentReply *getContent(const QGeoPlace &place, const QPlaceContentRequest &request) const;
QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &query) const;
diff --git a/src/location/places/qplacemanagerengine.h b/src/location/places/qplacemanagerengine.h
index c49ec472..7e21ad8f 100644
--- a/src/location/places/qplacemanagerengine.h
+++ b/src/location/places/qplacemanagerengine.h
@@ -61,12 +61,10 @@ public:
virtual QPlaceDetailsReply *getPlaceDetails(const QString &placeId) = 0;
- virtual QPlaceContentReply *getContent(QPlaceContent::Type, const QGeoPlace &place, const QPlaceRequest &request) = 0;
+ virtual QPlaceContentReply *getContent(const QGeoPlace &place, const QPlaceContentRequest &request) = 0;
virtual QPlaceReply *postRating(const QString &placeId, qreal value) = 0;
- virtual QPlaceReviewReply *getReviews(const QGeoPlace &place, const QPlaceRequest &request) = 0;
-
virtual QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &request) = 0;
virtual QPlaceSearchReply *recommendations(const QGeoPlace &place, const QPlaceSearchRequest &request) = 0;
diff --git a/src/location/places/qplacepaginationlist.h b/src/location/places/qplacepaginationlist.h
deleted file mode 100644
index 107dd349..00000000
--- a/src/location/places/qplacepaginationlist.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $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 QPLACEPAGINATIONLIST_H
-#define QPLACEPAGINATIONLIST_H
-
-#include <QSharedDataPointer>
-#include <QList>
-#include "qmobilityglobal.h"
-#include "qplacesupplier.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QPlacePaginationList
-
- \inmodule QPlaces
-
- \brief The QPlacePaginationList class represents a list object.
-
- Each QPlacePaginationList represents a pagination-enabled list. It contais list
- of items on current page and ifnormations about indexes of those items.
-
-*/
-template <typename T>
-class Q_LOCATION_EXPORT QPlacePaginationList
-{
-public:
- QPlacePaginationList() : startIndx(0) {};
- QPlacePaginationList(const QPlacePaginationList<T> &other) {
- this->startIndx = other.startIndx;
- this->dataList = other.dataList;
- }
-
- ~QPlacePaginationList() {};
-
- QPlacePaginationList<T> &operator=(const QPlacePaginationList<T> &other) {
- this->startIndx = other.startIndx;
- this->dataList = other.dataList;
- return *this;
- }
-
- bool operator==(const QPlacePaginationList<T> &other) const {
- return (
- this->startIndx == other.startIndx
- && this->dataList == other.dataList
- );
- }
- bool operator!=(const QPlacePaginationList<T> &other) const {
- return !(other == *this);
- }
-
- /*!
- Returns items count on current page.
- */
- int items() { return dataList.count(); }
- /*!
- Returns index of first item on current page.
- */
- int start() { return startIndx; }
- /*!
- Returns index of last item on current page.
- */
- int stop() { return startIndx + dataList.count() - 1; }
- /*!
- Returns items list on current page.
- */
- QList<T> data() { return dataList; }
- /*!
- Sets index of first item on current page.
- */
- void setStart(const int &start) { startIndx = start; }
- /*!
- Sets list of items on current page.
- */
- void setData(const QList<T> &data) { dataList = data; }
- /*!
- Append item to the list.
- */
- void addItem(const T &item) { dataList.append(item); }
-private:
- int startIndx;
- QList<T> dataList;
-};
-
-QT_END_NAMESPACE
-
-#endif // QPLACEPAGINATIONLIST_H
diff --git a/src/location/places/qplacerequest.cpp b/src/location/places/qplacerequest.cpp
index bc7f10cf..b2eb74d8 100644
--- a/src/location/places/qplacerequest.cpp
+++ b/src/location/places/qplacerequest.cpp
@@ -40,26 +40,16 @@
****************************************************************************/
#include "qplacerequest.h"
+#include "qplacerequest_p.h"
QT_BEGIN_NAMESPACE
-class QPlaceRequestPrivate : public QSharedData
+#if !defined(Q_CC_MWERKS)
+template<> QT_PREPEND_NAMESPACE(QPlaceRequestPrivate) *QSharedDataPointer<QT_PREPEND_NAMESPACE(QPlaceRequestPrivate)>::clone()
{
-public:
- QPlaceRequestPrivate();
- QPlaceRequestPrivate(const QPlaceRequestPrivate &other);
-
- ~QPlaceRequestPrivate();
-
- bool operator==(const QPlaceRequestPrivate &other) const;
-
- int offset;
- int limit;
-};
-
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
+ return d->clone();
+}
+#endif
QPlaceRequestPrivate::QPlaceRequestPrivate()
: QSharedData(),
@@ -79,12 +69,18 @@ QPlaceRequestPrivate::~QPlaceRequestPrivate()
{
}
-bool QPlaceRequestPrivate::operator==(const QPlaceRequestPrivate &other) const
+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()
{
- return (
- this->offset == other.offset
- && this->limit == other.limit
- );
+ this->offset =0;
+ this->limit = -1;
}
/*!
@@ -102,7 +98,7 @@ bool QPlaceRequestPrivate::operator==(const QPlaceRequestPrivate &other) const
Default constructor. Constructs an new query object.
*/
QPlaceRequest::QPlaceRequest()
- : d(new QPlaceRequestPrivate)
+ : d_ptr(new QPlaceRequestPrivate)
{
}
@@ -110,7 +106,7 @@ QPlaceRequest::QPlaceRequest()
Constructs a copy of \a other
*/
QPlaceRequest::QPlaceRequest(const QPlaceRequest &other)
- :d(other.d)
+ :d_ptr(other.d_ptr)
{
}
@@ -122,13 +118,24 @@ QPlaceRequest::~QPlaceRequest()
}
QPlaceRequest &QPlaceRequest::operator =(const QPlaceRequest &other) {
- d = other.d;
+ d_ptr = other.d_ptr;
return *this;
}
bool QPlaceRequest::operator==(const QPlaceRequest &other) const
{
- return (*(d.constData()) == *(other.d.constData()));
+ if (!d_ptr)
+ return !other.d_ptr;
+
+ if (requestType() != other.requestType())
+ return false;
+
+ return d_ptr->compare(other.d_ptr);
+}
+
+QPlaceRequest::Type QPlaceRequest::requestType() const
+{
+ return d_ptr->type();
}
/*!
@@ -140,7 +147,7 @@ bool QPlaceRequest::operator==(const QPlaceRequest &other) const
*/
int QPlaceRequest::offset() const
{
- return d->offset;
+ return d_ptr->offset;
}
/*!
@@ -148,7 +155,7 @@ int QPlaceRequest::offset() const
*/
void QPlaceRequest::setOffset(int offset)
{
- d->offset = offset;
+ d_ptr->offset = offset;
}
/*!
@@ -158,7 +165,7 @@ void QPlaceRequest::setOffset(int offset)
*/
int QPlaceRequest::limit() const
{
- return d->limit;
+ return d_ptr->limit;
}
/*!
@@ -172,7 +179,7 @@ int QPlaceRequest::limit() const
*/
void QPlaceRequest::setLimit(int limit)
{
- d->limit = limit;
+ d_ptr->limit = limit;
}
/*!
@@ -180,6 +187,12 @@ void QPlaceRequest::setLimit(int limit)
*/
void QPlaceRequest::clear()
{
- d->offset = 0;
- d->limit = -1;
+ 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
index d520b052..93ca3fc8 100644
--- a/src/location/places/qplacerequest.h
+++ b/src/location/places/qplacerequest.h
@@ -42,8 +42,8 @@
#ifndef QPLACEQUERY_H
#define QPLACEQUERY_H
+#include <QMetaType>
#include <QSharedDataPointer>
-#include "qmobilityglobal.h"
QT_BEGIN_NAMESPACE
@@ -52,10 +52,16 @@ class QPlaceRequestPrivate;
class Q_LOCATION_EXPORT QPlaceRequest
{
public:
+ enum Type {
+ DefaultType,
+ ContentType,
+ SearchType
+ };
+
QPlaceRequest();
QPlaceRequest(const QPlaceRequest &other);
- virtual ~QPlaceRequest();
+ ~QPlaceRequest();
QPlaceRequest &operator=(const QPlaceRequest &other);
@@ -69,12 +75,18 @@ public:
int limit() const;
void setLimit(int limit);
- virtual void clear();
+ QPlaceRequest::Type requestType() const;
+
+ void clear();
-private:
- QSharedDataPointer<QPlaceRequestPrivate> d;
+protected:
+ explicit QPlaceRequest(QPlaceRequestPrivate *d);
+ QSharedDataPointer<QPlaceRequestPrivate> d_ptr;
+ friend class QPlaceRequestPrivate;
};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QPlaceRequest))
+
#endif
diff --git a/src/location/places/qplacerequest_p.h b/src/location/places/qplacerequest_p.h
new file mode 100644
index 00000000..dfb5b335
--- /dev/null
+++ b/src/location/places/qplacerequest_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** 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 tOhe 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();
+ QPlaceRequestPrivate(const QPlaceRequestPrivate &other);
+ virtual ~QPlaceRequestPrivate();
+
+ virtual bool compare(const QPlaceRequestPrivate *other) const;
+ virtual QPlaceRequestPrivate *clone() const;
+ virtual QPlaceRequest::Type type() const { return QPlaceRequest::ContentType; }
+ 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;
+};
+
+#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/qplacereview.cpp b/src/location/places/qplacereview.cpp
index fb372d21..1623e9ed 100644
--- a/src/location/places/qplacereview.cpp
+++ b/src/location/places/qplacereview.cpp
@@ -45,7 +45,7 @@
QT_USE_NAMESPACE
QPlaceReviewPrivate::QPlaceReviewPrivate()
- : QSharedData(),
+ : QPlaceContentPrivate(),
helpfulVotings(0),
unhelpfulVotings(0),
rating(0)
@@ -53,7 +53,7 @@ QPlaceReviewPrivate::QPlaceReviewPrivate()
}
QPlaceReviewPrivate::QPlaceReviewPrivate(const QPlaceReviewPrivate &other)
- : QSharedData()
+ : QPlaceContentPrivate(other)
{
this->date = other.date;
this->description = other.description;
@@ -74,22 +74,23 @@ QPlaceReviewPrivate::~QPlaceReviewPrivate()
{
}
-bool QPlaceReviewPrivate::operator==(const QPlaceReviewPrivate &other) const
+bool QPlaceReviewPrivate::compare(const QPlaceContentPrivate *other) const
{
+ const QPlaceReviewPrivate *od = static_cast<const QPlaceReviewPrivate *>(other);
return (
- this->date == other.date
- && this->description == other.description
- && this->language == other.language
- && this->helpfulVotings == other.helpfulVotings
- && this->mediaIds == other.mediaIds
- && this->unhelpfulVotings == other.unhelpfulVotings
- && this->rating == other.rating
- && this->reviewId == other.reviewId
- && this->supplier == other.supplier
- && this->title == other.title
- && this->userId == other.userId
- && this->userName == other.userName
- && this->originatorUrl == other.originatorUrl
+ this->date == od->date
+ && this->description == od->description
+ && this->language == od->language
+ && this->helpfulVotings == od->helpfulVotings
+ && this->mediaIds == od->mediaIds
+ && this->unhelpfulVotings == od->unhelpfulVotings
+ && this->rating == od->rating
+ && this->reviewId == od->reviewId
+ && this->supplier == od->supplier
+ && this->title == od->title
+ && this->userId == od->userId
+ && this->userName == od->userName
+ && this->originatorUrl == od->originatorUrl
);
}
@@ -116,17 +117,12 @@ bool QPlaceReviewPrivate::operator==(const QPlaceReviewPrivate &other) const
Constructs an new review object.
*/
QPlaceReview::QPlaceReview()
- : d(new QPlaceReviewPrivate)
+ : QPlaceContent(new QPlaceReviewPrivate)
{
}
-/*!
- Constructs a copy of \a other
-*/
-QPlaceReview::QPlaceReview(const QPlaceReview &other)
- :d(other.d)
-{
-}
+Q_IMPLEMENT_CONTENT_COPY_CTOR(QPlaceReview)
+
/*!
Destructor.
@@ -135,21 +131,14 @@ QPlaceReview::~QPlaceReview()
{
}
-QPlaceReview &QPlaceReview::operator =(const QPlaceReview &other) {
- d = other.d;
- return *this;
-}
-
-bool QPlaceReview::operator==(const QPlaceReview &other) const
-{
- return (*(d.constData()) == *(other.d.constData()));
-}
+Q_IMPLEMENT_CONTENT_D_FUNC(QPlaceReview)
/*!
Returns review date.
*/
QString QPlaceReview::date() const
{
+ Q_D(const QPlaceReview);
return d->date;
}
@@ -158,6 +147,7 @@ QString QPlaceReview::date() const
*/
void QPlaceReview::setDate(const QString &data)
{
+ Q_D(QPlaceReview);
d->date = data;
}
@@ -166,6 +156,7 @@ void QPlaceReview::setDate(const QString &data)
*/
QString QPlaceReview::description() const
{
+ Q_D(const QPlaceReview);
return d->description;
}
@@ -174,6 +165,7 @@ QString QPlaceReview::description() const
*/
void QPlaceReview::setDescription(const QString &data)
{
+ Q_D(QPlaceReview);
d->description = data;
}
@@ -182,6 +174,7 @@ void QPlaceReview::setDescription(const QString &data)
*/
QString QPlaceReview::language() const
{
+ Q_D(const QPlaceReview);
return d->language;
}
@@ -190,6 +183,7 @@ QString QPlaceReview::language() const
*/
void QPlaceReview::setLanguage(const QString &data)
{
+ Q_D(QPlaceReview);
d->language = data;
}
@@ -198,6 +192,7 @@ void QPlaceReview::setLanguage(const QString &data)
*/
int QPlaceReview::helpfulVotings() const
{
+ Q_D(const QPlaceReview);
return d->helpfulVotings;
}
@@ -206,6 +201,7 @@ int QPlaceReview::helpfulVotings() const
*/
void QPlaceReview::setHelpfulVotings(const int &votes)
{
+ Q_D(QPlaceReview);
d->helpfulVotings = votes;
}
@@ -214,6 +210,7 @@ void QPlaceReview::setHelpfulVotings(const int &votes)
*/
QStringList QPlaceReview::mediaIds() const
{
+ Q_D(const QPlaceReview);
return d->mediaIds;
}
@@ -222,6 +219,7 @@ QStringList QPlaceReview::mediaIds() const
*/
void QPlaceReview::setMediaIds(const QStringList &data)
{
+ Q_D(QPlaceReview);
d->mediaIds = data;
}
@@ -230,6 +228,7 @@ void QPlaceReview::setMediaIds(const QStringList &data)
*/
int QPlaceReview::unhelpfulVotings() const
{
+ Q_D(const QPlaceReview);
return d->unhelpfulVotings;
}
@@ -238,6 +237,7 @@ int QPlaceReview::unhelpfulVotings() const
*/
void QPlaceReview::setUnhelpfulVotings(const int &votes)
{
+ Q_D(QPlaceReview);
d->unhelpfulVotings = votes;
}
@@ -246,6 +246,7 @@ void QPlaceReview::setUnhelpfulVotings(const int &votes)
*/
qreal QPlaceReview::rating() const
{
+ Q_D(const QPlaceReview);
return d->rating;
}
@@ -254,6 +255,7 @@ qreal QPlaceReview::rating() const
*/
void QPlaceReview::setRating(const qreal &data)
{
+ Q_D(QPlaceReview);
d->rating = data;
}
@@ -262,6 +264,7 @@ void QPlaceReview::setRating(const qreal &data)
*/
QString QPlaceReview::reviewId() const
{
+ Q_D(const QPlaceReview);
return d->reviewId;
}
@@ -270,6 +273,7 @@ QString QPlaceReview::reviewId() const
*/
void QPlaceReview::setReviewId(const QString &data)
{
+ Q_D(QPlaceReview);
d->reviewId = data;
}
@@ -278,6 +282,7 @@ void QPlaceReview::setReviewId(const QString &data)
*/
QPlaceSupplier QPlaceReview::supplier() const
{
+ Q_D(const QPlaceReview);
return d->supplier;
}
@@ -286,6 +291,7 @@ QPlaceSupplier QPlaceReview::supplier() const
*/
void QPlaceReview::setSupplier(const QPlaceSupplier &data)
{
+ Q_D(QPlaceReview);
d->supplier = data;
}
@@ -294,6 +300,7 @@ void QPlaceReview::setSupplier(const QPlaceSupplier &data)
*/
QString QPlaceReview::title() const
{
+ Q_D(const QPlaceReview);
return d->title;
}
@@ -302,6 +309,7 @@ QString QPlaceReview::title() const
*/
void QPlaceReview::setTitle(const QString &data)
{
+ Q_D(QPlaceReview);
d->title = data;
}
@@ -310,6 +318,7 @@ void QPlaceReview::setTitle(const QString &data)
*/
QString QPlaceReview::userId() const
{
+ Q_D(const QPlaceReview);
return d->userId;
}
@@ -318,6 +327,7 @@ QString QPlaceReview::userId() const
*/
void QPlaceReview::setUserId(const QString &data)
{
+ Q_D(QPlaceReview);
d->userId = data;
}
@@ -326,6 +336,7 @@ void QPlaceReview::setUserId(const QString &data)
*/
QString QPlaceReview::userName() const
{
+ Q_D(const QPlaceReview);
return d->userName;
}
@@ -334,6 +345,7 @@ QString QPlaceReview::userName() const
*/
void QPlaceReview::setUserName(const QString &data)
{
+ Q_D(QPlaceReview);
d->userName = data;
}
@@ -342,6 +354,7 @@ void QPlaceReview::setUserName(const QString &data)
*/
QString QPlaceReview::originatorUrl() const
{
+ Q_D(const QPlaceReview);
return d->originatorUrl;
}
@@ -350,5 +363,6 @@ QString QPlaceReview::originatorUrl() const
*/
void QPlaceReview::setOriginatorUrl(const QString &url)
{
+ Q_D(QPlaceReview);
d->originatorUrl = url;
}
diff --git a/src/location/places/qplacereview.h b/src/location/places/qplacereview.h
index eea4faf6..ddd42885 100644
--- a/src/location/places/qplacereview.h
+++ b/src/location/places/qplacereview.h
@@ -46,26 +46,20 @@
#include <QStringList>
#include "qmobilityglobal.h"
#include "qplacesupplier.h"
+#include "qplacecontent.h"
QT_BEGIN_NAMESPACE
class QPlaceReviewPrivate;
-class Q_LOCATION_EXPORT QPlaceReview
+class Q_LOCATION_EXPORT QPlaceReview : public QPlaceContent
{
public:
QPlaceReview();
- QPlaceReview(const QPlaceReview &other);
+ Q_DECLARE_CONTENT_COPY_CTOR(QPlaceReview)
virtual ~QPlaceReview();
- QPlaceReview &operator=(const QPlaceReview &other);
-
- bool operator==(const QPlaceReview &other) const;
- bool operator!=(const QPlaceReview &other) const {
- return !(other == *this);
- }
-
QString date() const;
void setDate(const QString &data);
QString description() const;
@@ -94,7 +88,7 @@ public:
void setOriginatorUrl(const QString &data);
private:
- QSharedDataPointer<QPlaceReviewPrivate> d;
+ Q_DECLARE_CONTENT_D_FUNC(QPlaceReview)
};
QT_END_NAMESPACE
diff --git a/src/location/places/qplacereview_p.h b/src/location/places/qplacereview_p.h
index 4eb4e1ab..1222e2e5 100644
--- a/src/location/places/qplacereview_p.h
+++ b/src/location/places/qplacereview_p.h
@@ -45,10 +45,11 @@
#include <QSharedData>
#include "qplacereview.h"
+#include "qplacecontent_p.h"
QT_BEGIN_NAMESPACE
-class QPlaceReviewPrivate : public QSharedData
+class QPlaceReviewPrivate : public QPlaceContentPrivate
{
public:
QPlaceReviewPrivate();
@@ -56,7 +57,9 @@ public:
~QPlaceReviewPrivate();
- bool operator==(const QPlaceReviewPrivate &other) const;
+ bool compare(const QPlaceContentPrivate *other) const;
+
+ Q_DEFINE_CONTENT_PRIVATE_HELPER(QPlaceReview, QPlaceContent::ReviewType);
QString date;
QString description;
@@ -75,4 +78,4 @@ public:
QT_END_NAMESPACE
-#endif // QPLACEREVIEW_P_H
+#endif
diff --git a/src/location/places/qplacereviewreply.cpp b/src/location/places/qplacereviewreply.cpp
deleted file mode 100644
index 590fc7f9..00000000
--- a/src/location/places/qplacereviewreply.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $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 "qplacereviewreply.h"
-#include "qplacereply_p.h"
-
-#include "qgeoplace.h"
-
-QT_BEGIN_NAMESPACE
-class QPlaceReviewReplyPrivate : public QPlaceReplyPrivate
-{
-public:
- QPlaceReviewReplyPrivate()
- : totalCount(0)
- { }
-
- QPlacePaginationList<QPlaceReview> reviews;
- int totalCount;
-};
-
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
-
-/*!
- \class QPlaceReviewReply
-
- \brief The QPlaceReviewReply class manages a review retrieval operation started by an
- instance of QPlaceManager.
-
- \inmodule QtLocation
-
- \ingroup places-main
-*/
-
-/*!
- Constructs a review reply with a given \a parent.
-*/
-QPlaceReviewReply::QPlaceReviewReply(QObject *parent)
- : QPlaceReply(new QPlaceReviewReplyPrivate, parent)
-{
-}
-
-/*!
- Destroys the reply.
-*/
-QPlaceReviewReply::~QPlaceReviewReply()
-{
-}
-
-/*!
- Returns the type of reply.
-*/
-QPlaceReply::Type QPlaceReviewReply::type() const
-{
- return QPlaceReply::ReviewReply;
-}
-
- /*!
- Returns the reviews.
-*/
-QPlacePaginationList<QPlaceReview> QPlaceReviewReply::reviews() const
-{
- Q_D(const QPlaceReviewReply);
- return d->reviews;
-}
-
-/*!
- Sets the \a reviews.
-*/
-void QPlaceReviewReply::setReviews(const QList<QPlaceReview> &reviews)
-{
- Q_D(QPlaceReviewReply);
- d->reviews.setData(reviews);
-}
-
-/*!
- Sets the \a offset number of the first review.
-*/
-void QPlaceReviewReply::setOffset(int offset)
-{
- Q_D(QPlaceReviewReply);
- d->reviews.setStart(offset);
-}
-
-/*!
- Returns the total number of reviews for a place. If the total number of
- reviews cannot be counted a value of -1 is returned.
-*/
-int QPlaceReviewReply::totalCount() const
-{
- Q_D(const QPlaceReviewReply);
- return d->totalCount;
-}
-
-/*!
- Sets the \a total number of reviews for a place.
-*/
-void QPlaceReviewReply::setTotalCount(int total)
-{
- Q_D(QPlaceReviewReply);
- d->totalCount = total;
-}
diff --git a/src/location/places/qplacesearchrequest.cpp b/src/location/places/qplacesearchrequest.cpp
index 733a07f0..c12b6c6c 100644
--- a/src/location/places/qplacesearchrequest.cpp
+++ b/src/location/places/qplacesearchrequest.cpp
@@ -39,20 +39,22 @@
**
****************************************************************************/
+#include "qplacerequest_p.h"
#include "qplacesearchrequest.h"
#include "qgeocoordinate.h"
QT_BEGIN_NAMESPACE
-class QPlaceSearchRequestPrivate : public QSharedData
+class QPlaceSearchRequestPrivate : public QPlaceRequestPrivate
{
public:
QPlaceSearchRequestPrivate();
QPlaceSearchRequestPrivate(const QPlaceSearchRequestPrivate &other);
-
~QPlaceSearchRequestPrivate();
- bool operator==(const QPlaceSearchRequestPrivate &other) const;
+ bool compare(const QPlaceRequestPrivate *other) const;
+ Q_DEFINE_PRIVATE_HELPER(QPlaceSearchRequest, QPlaceRequest, QPlaceRequest::SearchType, request)
+ void clear();
QString searchTerm;
QList<QPlaceCategory> categories;
@@ -61,12 +63,8 @@ public:
QPlaceManager::VisibilityScopes scope;
};
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
-
QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate()
- : QSharedData(),
+ : QPlaceRequestPrivate(),
dymNumber(0),
searchArea(0),
scope(QPlaceManager::NoScope)
@@ -74,7 +72,7 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate()
}
QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate(const QPlaceSearchRequestPrivate &other)
- : QSharedData(),
+ : QPlaceRequestPrivate(other),
dymNumber(0)
{
this->searchTerm = other.searchTerm;
@@ -88,16 +86,16 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate(const QPlaceSearchRequest
QPlaceSearchRequestPrivate::~QPlaceSearchRequestPrivate()
{
delete searchArea;
- searchArea = 0;
}
-bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &other) const
+bool QPlaceSearchRequestPrivate::compare(const QPlaceRequestPrivate *other) const
{
+ const QPlaceSearchRequestPrivate *od = static_cast<const QPlaceSearchRequestPrivate *>(other);
bool searchAreaMatch = false;
- if ((this->searchArea == 0) && (other.searchArea == 0)) {
+ if ((this->searchArea == 0) && (od->searchArea == 0)) {
searchAreaMatch = true;
- } else if (this->searchArea && other.searchArea) {
- if ((*this->searchArea) == (*other.searchArea))
+ } else if (this->searchArea && od->searchArea) {
+ if ((*this->searchArea) == (*od->searchArea))
searchAreaMatch = true;
else
searchAreaMatch = false;
@@ -106,14 +104,27 @@ bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &ot
}
return (
- this->searchTerm == other.searchTerm
- && this->categories == other.categories
- && this->dymNumber == other.dymNumber
+ this->searchTerm == od->searchTerm
+ && this->categories == od->categories
+ && this->dymNumber == od->dymNumber
&& searchAreaMatch
- && this->scope == other.scope
+ && this->scope == od->scope
);
}
+void QPlaceSearchRequestPrivate::clear()
+{
+ QPlaceRequestPrivate::clear();
+ searchTerm.clear();
+ categories.clear();
+ if (searchArea) {
+ delete searchArea;
+ searchArea = 0;
+ }
+ dymNumber = 0;
+ scope = QPlaceManager::NoScope;
+}
+
/*!
\class QPlaceSearchRequest
@@ -145,19 +156,11 @@ bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &ot
Default constructor. Constructs an new request object.
*/
QPlaceSearchRequest::QPlaceSearchRequest()
- : QPlaceRequest(),
- d(new QPlaceSearchRequestPrivate)
+ : QPlaceRequest(new QPlaceSearchRequestPrivate)
{
}
-/*!
- Constructs a copy of \a other
-*/
-QPlaceSearchRequest::QPlaceSearchRequest(const QPlaceSearchRequest &other)
- : QPlaceRequest(other),
- d(other.d)
-{
-}
+Q_IMPLEMENT_COPY_CTOR(QPlaceSearchRequest, QPlaceRequest)
/*!
Destructor.
@@ -166,24 +169,14 @@ QPlaceSearchRequest::~QPlaceSearchRequest()
{
}
-QPlaceSearchRequest &QPlaceSearchRequest::operator =(const QPlaceSearchRequest &other) {
- this->QPlaceRequest::operator =(other);
- d = other.d;
- return *this;
-}
-
-bool QPlaceSearchRequest::operator==(const QPlaceSearchRequest &other) const
-{
- return (this->QPlaceRequest::operator ==(other)
- && (*(d.constData()) == *(other.d.constData())));
-}
-
+Q_IMPLEMENT_D_FUNC(QPlaceSearchRequest)
/*!
Returns the search term.
*/
QString QPlaceSearchRequest::searchTerm() const
{
+ Q_D(const QPlaceSearchRequest);
return d->searchTerm;
}
@@ -192,6 +185,7 @@ QString QPlaceSearchRequest::searchTerm() const
*/
void QPlaceSearchRequest::setSearchTerm(const QString &term)
{
+ Q_D(QPlaceSearchRequest);
d->searchTerm = term;
}
@@ -202,6 +196,7 @@ void QPlaceSearchRequest::setSearchTerm(const QString &term)
*/
QList<QPlaceCategory> QPlaceSearchRequest::categories() const
{
+ Q_D(const QPlaceSearchRequest);
return d->categories;
}
@@ -210,6 +205,7 @@ QList<QPlaceCategory> QPlaceSearchRequest::categories() const
*/
void QPlaceSearchRequest::setCategory(const QPlaceCategory &category)
{
+ Q_D(QPlaceSearchRequest);
d->categories.clear();
if (!category.categoryId().isEmpty())
@@ -221,6 +217,7 @@ void QPlaceSearchRequest::setCategory(const QPlaceCategory &category)
*/
QGeoBoundingArea *QPlaceSearchRequest::searchArea() const
{
+ Q_D(const QPlaceSearchRequest);
return d->searchArea;
}
@@ -231,6 +228,7 @@ QGeoBoundingArea *QPlaceSearchRequest::searchArea() const
*/
void QPlaceSearchRequest::setSearchArea(QGeoBoundingArea *area)
{
+ Q_D(QPlaceSearchRequest);
if (d->searchArea != area)
delete d->searchArea;
@@ -242,6 +240,7 @@ void QPlaceSearchRequest::setSearchArea(QGeoBoundingArea *area)
*/
int QPlaceSearchRequest::didYouMeanSuggestionNumber() const
{
+ Q_D(const QPlaceSearchRequest);
return d->dymNumber;
}
@@ -250,6 +249,7 @@ int QPlaceSearchRequest::didYouMeanSuggestionNumber() const
*/
void QPlaceSearchRequest::setDidYouMeanSuggestionNumber(const int &number)
{
+ Q_D(QPlaceSearchRequest);
d->dymNumber = number;
}
@@ -261,6 +261,7 @@ void QPlaceSearchRequest::setDidYouMeanSuggestionNumber(const int &number)
*/
QPlaceManager::VisibilityScopes QPlaceSearchRequest::visibilityScope() const
{
+ Q_D(const QPlaceSearchRequest);
return d->scope;
}
@@ -269,6 +270,7 @@ QPlaceManager::VisibilityScopes QPlaceSearchRequest::visibilityScope() const
*/
void QPlaceSearchRequest::setVisibilityScope(QPlaceManager::VisibilityScopes scope)
{
+ Q_D(QPlaceSearchRequest);
d->scope = scope;
}
@@ -277,6 +279,8 @@ void QPlaceSearchRequest::setVisibilityScope(QPlaceManager::VisibilityScopes sco
*/
void QPlaceSearchRequest::clear()
{
+ Q_D(QPlaceSearchRequest);
+
QPlaceRequest::clear();
d->searchTerm.clear();
d->categories.clear();
@@ -286,3 +290,5 @@ void QPlaceSearchRequest::clear()
d->dymNumber = 0;
d->scope = QPlaceManager::NoScope;
}
+
+QT_END_NAMESPACE
diff --git a/src/location/places/qplacesearchrequest.h b/src/location/places/qplacesearchrequest.h
index 463da0fd..83edd0b4 100644
--- a/src/location/places/qplacesearchrequest.h
+++ b/src/location/places/qplacesearchrequest.h
@@ -65,17 +65,9 @@ public:
};
QPlaceSearchRequest();
- QPlaceSearchRequest(const QPlaceSearchRequest &other);
-
+ Q_DECLARE_COPY_CTOR(QPlaceSearchRequest, QPlaceRequest)
virtual ~QPlaceSearchRequest();
- QPlaceSearchRequest &operator=(const QPlaceSearchRequest &other);
-
- bool operator==(const QPlaceSearchRequest &other) const;
- bool operator!=(const QPlaceSearchRequest &other) const {
- return !(other == *this);
- }
-
QString searchTerm() const;
void setSearchTerm(const QString &term);
@@ -94,7 +86,7 @@ public:
void clear();
private:
- QSharedDataPointer<QPlaceSearchRequestPrivate> d;
+ Q_DECLARE_D_FUNC(QPlaceSearchRequest)
};
QT_END_NAMESPACE
diff --git a/src/location/qgeoplace.cpp b/src/location/qgeoplace.cpp
index 3ba1bf45..c984912a 100644
--- a/src/location/qgeoplace.cpp
+++ b/src/location/qgeoplace.cpp
@@ -357,42 +357,6 @@ void QGeoPlace::setPlaceId(const QString &placeId)
}
/*!
- Returns reviews.
-*/
-QPlacePaginationList<QPlaceReview> QGeoPlace::reviews() const
-{
- Q_D(const QGeoPlace);
- return d->reviews;
-}
-
-/*!
- Sets reviews.
-*/
-void QGeoPlace::setReviews(const QPlacePaginationList<QPlaceReview> &reviews)
-{
- Q_D(QGeoPlace);
- d->reviews = reviews;
-}
-
-/*!
- Returns review count.
-*/
-int QGeoPlace::reviewCount() const
-{
- Q_D(const QGeoPlace);
- return d->reviewCount;
-}
-
-/*!
- Sets review count.
-*/
-void QGeoPlace::setReviewCount(const int &count)
-{
- Q_D(QGeoPlace);
- d->reviewCount = count;
-}
-
-/*!
Returns list of tags.
*/
QStringList QGeoPlace::tags() const
@@ -533,7 +497,6 @@ void QGeoPlace::insertExtendedAttribute(const QString &key, const QPlaceAttribut
QGeoPlacePrivate::QGeoPlacePrivate()
: QSharedData(),
- reviewCount(0),
detailsFetched(false)
{
}
@@ -551,8 +514,6 @@ QGeoPlacePrivate::QGeoPlacePrivate(const QGeoPlacePrivate &other)
contentCounts(other.contentCounts),
name(other.name),
placeId(other.placeId),
- reviews(other.reviews),
- reviewCount(other.reviewCount),
tags(other.tags),
detailsFetched(other.detailsFetched),
primaryPhone(other.primaryPhone),
@@ -576,8 +537,6 @@ QGeoPlacePrivate& QGeoPlacePrivate::operator= (const QGeoPlacePrivate & other)
feeds = other.feeds;
name = other.name;
placeId = other.placeId;
- reviews = other.reviews;
- reviewCount = other.reviewCount;
tags = other.tags;
primaryPhone = other.primaryPhone;
primaryFax = other.primaryFax;
@@ -602,8 +561,6 @@ bool QGeoPlacePrivate::operator== (const QGeoPlacePrivate &other) const
qDebug() << "contentCounts " << (contentCounts == other.contentCounts);
qDebug() << "name " << (name == other.name);
qDebug() << "placeId" << (placeId == other.placeId);
- qDebug() << "reviews" << (reviews == other.reviews);
- qDebug() << "review count" << (reviewCount == other.reviewCount);
qDebug() << "tags" << (tags == other.tags);
qDebug() << "phone" << (primaryPhone == other.primaryPhone);
qDebug() << "fax" << (primaryFax == other.primaryFax);
@@ -623,8 +580,6 @@ bool QGeoPlacePrivate::operator== (const QGeoPlacePrivate &other) const
&& contentCounts == other.contentCounts
&& name == other.name
&& placeId == other.placeId
- && reviews == other.reviews
- && reviewCount == other.reviewCount
&& tags == other.tags
&& primaryPhone == other.primaryPhone
&& primaryFax == other.primaryFax
diff --git a/src/location/qgeoplace.h b/src/location/qgeoplace.h
index 9c27d25e..b0a849e1 100644
--- a/src/location/qgeoplace.h
+++ b/src/location/qgeoplace.h
@@ -54,7 +54,6 @@
#include "qplacecontent.h"
#include "qplacedescription.h"
#include "qplacerating.h"
-#include "qplacepaginationlist.h"
#include "qplacereview.h"
#include "qplaceattribute.h"
@@ -102,8 +101,6 @@ public:
void setName(const QString &name);
QString placeId() const;
void setPlaceId(const QString &placeId);
- QPlacePaginationList<QPlaceReview> reviews() const;
- void setReviews(const QPlacePaginationList<QPlaceReview> &reviews);
int reviewCount() const;
void setReviewCount(const int &count);
QStringList tags() const;
diff --git a/src/location/qgeoplace_p.h b/src/location/qgeoplace_p.h
index e8b09abe..6b5917df 100644
--- a/src/location/qgeoplace_p.h
+++ b/src/location/qgeoplace_p.h
@@ -86,8 +86,6 @@ public:
QStringList feeds;
QString name;
QString placeId;
- QPlacePaginationList<QPlaceReview> reviews;
- int reviewCount;
QStringList tags;
QMap<QPlaceContent::Type, QPlaceContent::Collection> contentCollections;
diff --git a/src/plugins/geoservices/nokia/places/places.pri b/src/plugins/geoservices/nokia/places/places.pri
index c1112981..664e5041 100644
--- a/src/plugins/geoservices/nokia/places/places.pri
+++ b/src/plugins/geoservices/nokia/places/places.pri
@@ -14,11 +14,10 @@ HEADERS += \
#query classes
#reply classes
places/qplacecategoriesreplyimpl.h \
- places/qplaceimagereplyimpl.h \
+ places/qplacecontentreplyimpl.h \
places/qplacedetailsreplyimpl.h \
places/qplaceratingreplyimpl.h \
places/qplacerecommendationreplyimpl.h \
- places/qplacereviewreplyimpl.h \
places/qplacesearchreplyimpl.h \
places/qplacetextpredictionreplyimpl.h \
#manager and engine
@@ -44,10 +43,9 @@ SOURCES += \
#reply classes
places/qplacecategoriesreplyimpl.cpp \
places/qplacedetailsreplyimpl.cpp \
- places/qplaceimagereplyimpl.cpp \
+ places/qplacecontentreplyimpl.cpp \
places/qplaceratingreplyimpl.cpp \
places/qplacerecommendationreplyimpl.cpp \
- places/qplacereviewreplyimpl.cpp \
places/qplacesearchreplyimpl.cpp \
places/qplacetextpredictionreplyimpl.cpp \
#manager and engine
diff --git a/src/plugins/geoservices/nokia/places/qplaceimagereplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp
index 10ec472d..6f4af882 100644
--- a/src/plugins/geoservices/nokia/places/qplaceimagereplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp
@@ -46,7 +46,7 @@
**
****************************************************************************/
-#include "qplaceimagereplyimpl.h"
+#include "qplacecontentreplyimpl.h"
#if defined(QT_PLACES_LOGGING)
#include <QDebug>
@@ -57,11 +57,14 @@ QT_USE_NAMESPACE
/*!
Constructor.
*/
-QPlaceImageReplyImpl::QPlaceImageReplyImpl(QPlaceRestReply *reply, QObject *parent) :
- QPlaceContentReply(parent),
+QPlaceContentReplyImpl::QPlaceContentReplyImpl(QPlaceContent::Type type, QPlaceRestReply *reply, QObject *parent) :
+ QPlaceContentReply(parent), contentType(type),
restReply(reply)
{
- parser = new QPlaceJSonMediaParser(this);
+ if (contentType == QPlaceContent::ImageType)
+ parser = new QPlaceJSonMediaParser(this);
+ else if (contentType == QPlaceContent::ReviewType)
+ parser = new QPlaceJSonReviewParser(this);
if (restReply) {
restReply->setParent(this);
@@ -77,22 +80,22 @@ QPlaceImageReplyImpl::QPlaceImageReplyImpl(QPlaceRestReply *reply, QObject *pare
/*!
Destructor.
*/
-QPlaceImageReplyImpl::~QPlaceImageReplyImpl()
+QPlaceContentReplyImpl::~QPlaceContentReplyImpl()
{
}
-void QPlaceImageReplyImpl::abort()
+void QPlaceContentReplyImpl::abort()
{
if (restReply)
restReply->cancelProcessing();
}
-void QPlaceImageReplyImpl::setStartNumber(int number)
+void QPlaceContentReplyImpl::setStartNumber(int number)
{
startNumber = number;
}
-void QPlaceImageReplyImpl::restError(QPlaceReply::Error errorId, const QString &errorString)
+void QPlaceContentReplyImpl::restError(QPlaceReply::Error errorId, const QString &errorString)
{
setError(errorId, errorString);
@@ -103,7 +106,7 @@ void QPlaceImageReplyImpl::restError(QPlaceReply::Error errorId, const QString &
emit processingFinished(this);
}
-void QPlaceImageReplyImpl::restError(QPlaceRestReply::Error errorId)
+void QPlaceContentReplyImpl::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
this->setError(CancelError, "RequestCanceled");
@@ -117,16 +120,27 @@ void QPlaceImageReplyImpl::restError(QPlaceRestReply::Error errorId)
emit processingFinished(this);
}
-void QPlaceImageReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
+void QPlaceContentReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
const QString &errorMessage)
{
if (errorId == QPlaceJSonParser::NoError) {
- QList<QPlaceImage> imageOjects = parser->resultMedia();
- QPlaceContent::Collection collection;
- for (int i=0; i < imageOjects.count(); ++i)
- collection.insert(startNumber +i, imageOjects.at(i));
- setContent(collection);
- setTotalCount(parser->allMediaCount());
+ if (contentType == QPlaceContent::ImageType) {
+ QPlaceJSonMediaParser * mediaParser = qobject_cast<QPlaceJSonMediaParser*>(parser);
+ QList<QPlaceImage> imageOjects = mediaParser->resultMedia();
+ QPlaceContent::Collection collection;
+ for (int i=0; i < imageOjects.count(); ++i)
+ collection.insert(startNumber +i, imageOjects.at(i));
+ setContent(collection);
+ setTotalCount(mediaParser->allMediaCount());
+ } else if (contentType == QPlaceContent::ReviewType) {
+ QPlaceJSonReviewParser *reviewParser = qobject_cast<QPlaceJSonReviewParser*>(parser);
+ QList<QPlaceReview> reviewObjects = reviewParser->results();
+ QPlaceContent::Collection collection;
+ for (int i=0; i < reviewObjects.count(); ++i)
+ collection.insert(startNumber + i, reviewObjects.at(i));
+ setContent(collection);
+ setTotalCount(reviewParser->allReviewsCount());
+ }
} else if (errorId == QPlaceJSonParser::ParsingError) {
setError(ParseError, errorMessage);
emit error(this->error(), this->errorString());
diff --git a/src/plugins/geoservices/nokia/places/qplaceimagereplyimpl.h b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h
index 843dc670..f1a879d1 100644
--- a/src/plugins/geoservices/nokia/places/qplaceimagereplyimpl.h
+++ b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h
@@ -55,15 +55,16 @@
#include <qplacecontentreply.h>
#include "qplacerestreply.h"
#include "qplacejsonmediaparser.h"
+#include "qplacejsonreviewparser.h"
QT_BEGIN_NAMESPACE
-class QPlaceImageReplyImpl : public QPlaceContentReply
+class QPlaceContentReplyImpl : public QPlaceContentReply
{
Q_OBJECT
public:
- explicit QPlaceImageReplyImpl(QPlaceRestReply *reply, QObject *parent = 0);
- ~QPlaceImageReplyImpl();
+ QPlaceContentReplyImpl(QPlaceContent::Type type, QPlaceRestReply *reply, QObject *parent = 0);
+ ~QPlaceContentReplyImpl();
void abort();
void setStartNumber(int number);
@@ -79,7 +80,9 @@ public slots:
private:
QPlaceRestReply *restReply;
- QPlaceJSonMediaParser *parser;
+ QPlaceJSonParser *parser;
+ QPlaceContent::Type contentType;
+
int startNumber;
};
diff --git a/src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.cpp
deleted file mode 100644
index ffeade55..00000000
--- a/src/plugins/geoservices/nokia/places/qplacereviewreplyimpl.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $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$
-**
-** This file is part of the Ovi services plugin for the Maps and
-** Navigation API. The use of these services, whether by use of the
-** plugin or by other means, is governed by the terms and conditions
-** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in
-** this package, located in the directory containing the Ovi services
-** plugin source code.
-**
-****************************************************************************/
-
-#include "qplacereviewreplyimpl.h"
-
-#if defined(QT_PLACES_LOGGING)
- #include <QDebug>
-#endif
-
-QT_USE_NAMESPACE
-
-/*!
- Constructor.
-*/
-QPlaceReviewReplyImpl::QPlaceReviewReplyImpl(QPlaceRestReply *reply, QObject *parent) :
- QPlaceReviewReply(parent),
- restReply(reply)
-{
- parser = new QPlaceJSonReviewParser(this);
-
- if (restReply) {
- restReply->setParent(this);
- connect(restReply, SIGNAL(finished(const QString &)),
- parser, SLOT(processData(const QString &)));
- connect(restReply, SIGNAL(error(QPlaceRestReply::Error)),
- this, SLOT(restError(QPlaceRestReply::Error)));
- connect(parser, SIGNAL(finished(QPlaceJSonParser::Error,QString)),
- this, SLOT(resultReady(QPlaceJSonParser::Error,QString)));
- }
-}
-
-/*!
- Destructor.
-*/
-QPlaceReviewReplyImpl::~QPlaceReviewReplyImpl()
-{
-}
-
-void QPlaceReviewReplyImpl::abort()
-{
- if (restReply)
- restReply->cancelProcessing();
-}
-
-void QPlaceReviewReplyImpl::setStartNumber(int number)
-{
- setOffset(number);
-}
-
-void QPlaceReviewReplyImpl::restError(QPlaceRestReply::Error errorId)
-{
- if (errorId == QPlaceRestReply::Canceled) {
- this->setError(CancelError, "RequestCanceled");
- } else if (errorId == QPlaceRestReply::NetworkError) {
- this->setError(CommunicationError, "Network error");
- }
- emit error(this->error(), this->errorString());
- emit processingError(this, this->error(), this->errorString());
- setFinished(true);
- emit finished();
- emit processingFinished(this);
-}
-
-void QPlaceReviewReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
- const QString &errorMessage)
-{
- if (errorId == QPlaceJSonParser::NoError) {
- setReviews(parser->results());
- setTotalCount(parser->allReviewsCount());
- } else if (errorId == QPlaceJSonParser::ParsingError) {
- setError(ParseError, errorMessage);
- emit error(this->error(), this->errorString());
- emit processingError(this, ParseError, errorMessage);
- }
- setFinished(true);
- emit finished();
- emit processingFinished(this);
- parser->deleteLater();
- parser = NULL;
- restReply->deleteLater();
- restReply = NULL;
-}
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
index 5ebe7b0c..cb9598a1 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
@@ -49,10 +49,9 @@
#include "qplacemanagerengine_nokia.h"
#include "places/qplacecategoriesrepository.h"
+#include "places/qplacecontentreplyimpl.h"
#include "places/qplacetextpredictionreplyimpl.h"
#include "places/qplacesearchreplyimpl.h"
-#include "places/qplacereviewreplyimpl.h"
-#include "places/qplaceimagereplyimpl.h"
#include "places/qplacerecommendationreplyimpl.h"
#include "places/qplacedetailsreplyimpl.h"
#include "places/qplaceratingreplyimpl.h"
@@ -108,36 +107,48 @@ QPlaceDetailsReply *QPlaceManagerEngineNokia::getPlaceDetails(const QString &pla
return reply;
}
-QPlaceContentReply *QPlaceManagerEngineNokia::getContent(QPlaceContent::Type type, const QGeoPlace &place, const QPlaceRequest &query)
+QPlaceContentReply *QPlaceManagerEngineNokia::getContent(const QGeoPlace &place, const QPlaceContentRequest &request)
{
- QPlaceImageReplyImpl *reply = 0;
- if (type == QPlaceContent::ImageType) {
- QPlaceImageReplyImpl *reply = NULL;
- QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceImagesRequest(place.placeId(),
- query);
- if (restReply) {
- reply = new QPlaceImageReplyImpl(restReply, this);
- reply->setStartNumber(query.offset());
- connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
- this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
- connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
- this, SLOT(processingFinished(QPlaceReply*)));
+ QPlaceContentReplyImpl *reply;
+ switch (request.contentType()) {
+ case QPlaceContent::ImageType: {
+ QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceImagesRequest(place.placeId(),
+ request);
+ reply = new QPlaceContentReplyImpl(request.contentType(), restReply, this);
+
+ if (!restReply)
+ QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnknownError),
+ Q_ARG(QString, QString("Could not create rest reply for image content request")));
+ break;
+ }
+ case QPlaceContent::ReviewType: {
+ QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceReviewRequest(place.placeId(),
+ request);
+ reply = new QPlaceContentReplyImpl(request.contentType(), restReply, this);
+
+ if (!restReply)
+ QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnknownError),
+ Q_ARG(QString, QString("Could not create rest reply for review content request")));
+ break;
+ }
+ default: {
+ reply = new QPlaceContentReplyImpl(request.contentType(), 0, this);
+ QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
+ Q_ARG(QString, QString("Retrieval of given content type not supported")));
}
- return reply;
- } else {
- reply = new QPlaceImageReplyImpl(0, 0);
- connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
- this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
- connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
- this, SLOT(processingFinished(QPlaceReply*)));
-
- QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
- Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
- Q_ARG(QString, QString("Retrieval of given content type not supported")));
- return reply;
}
-}
+ reply->setStartNumber(request.offset());
+ connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
+ this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
+ connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
+ this, SLOT(processingFinished(QPlaceReply*)));
+
+ return reply;
+}
QPlaceReply *QPlaceManagerEngineNokia::postRating(const QString &placeId, qreal value)
{
QPlaceRatingReplyImpl *reply = NULL;
@@ -155,22 +166,6 @@ QPlaceReply *QPlaceManagerEngineNokia::postRating(const QString &placeId, qreal
return reply;
}
-QPlaceReviewReply *QPlaceManagerEngineNokia::getReviews(const QGeoPlace &place, const QPlaceRequest &query)
-{
- QPlaceReviewReplyImpl *reply = NULL;
- QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceReviewRequest(place.placeId(),
- query);
- if (restReply) {
- reply = new QPlaceReviewReplyImpl(restReply, this);
- reply->setStartNumber(query.offset());
- connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
- this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
- connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
- this, SLOT(processingFinished(QPlaceReply*)));
- }
- return reply;
-}
-
QPlaceSearchReply *QPlaceManagerEngineNokia::searchForPlaces(const QPlaceSearchRequest &query)
{
//TODO: handling of scope
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
index a9038ae8..44c6f30b 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
@@ -49,10 +49,12 @@
#ifndef QPLACEMANAGERENGINE_NOKIA_H
#define QPLACEMANAGERENGINE_NOKIA_H
+#include <qplacecontent.h>
#include <qplacemanagerengine.h>
#include <qgeoserviceprovider.h>
QT_BEGIN_NAMESPACE
+class QPlaceContentReply;
class QPlaceManagerEngineNokia : public QPlaceManagerEngine
{
@@ -66,12 +68,10 @@ public:
QPlaceDetailsReply *getPlaceDetails(const QString &placeId);
- QPlaceContentReply *getContent(QPlaceContent::Type contentType, const QGeoPlace &place, const QPlaceRequest &request);
+ QPlaceContentReply *getContent(const QGeoPlace &place, const QPlaceContentRequest &request);
QPlaceReply *postRating(const QString &placeId, qreal value);
- QPlaceReviewReply *getReviews(const QGeoPlace &place, const QPlaceRequest &query);
-
QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &query);
QPlaceSearchReply *recommendations(const QGeoPlace &place, const QPlaceSearchRequest &query);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 070b92e8..6a02b6bc 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -17,6 +17,7 @@ SUBDIRS += geotestplugin \
qgeocodereply \
qgeocodingmanager \
qplacecategory \
+ qplacecontentrequest \
qplacedescription \
qplacemanager \
qplaceimage \
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h
index 01973fa2..8e971e9a 100644
--- a/tests/auto/geotestplugin/qplacemanagerengine_test.h
+++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h
@@ -77,9 +77,8 @@ public:
return 0;
}
- QPlaceContentReply *getContent(QPlaceContent::Type type, const QGeoPlace &place, const QPlaceRequest &query)
+ QPlaceContentReply *getContent(const QGeoPlace &place, const QPlaceContentRequest &query)
{
- Q_UNUSED(type)
Q_UNUSED(place)
Q_UNUSED(query)
@@ -94,14 +93,6 @@ public:
return 0;
}
- QPlaceReviewReply *getReviews(const QGeoPlace &place, const QPlaceRequest &query)
- {
- Q_UNUSED(place)
- Q_UNUSED(query)
-
- return 0;
- }
-
QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &query)
{
Q_UNUSED(query)
diff --git a/tests/auto/qgeoplace/tst_qgeoplace.cpp b/tests/auto/qgeoplace/tst_qgeoplace.cpp
index 7a5265c1..6a52e76b 100644
--- a/tests/auto/qgeoplace/tst_qgeoplace.cpp
+++ b/tests/auto/qgeoplace/tst_qgeoplace.cpp
@@ -24,12 +24,11 @@ private Q_SLOTS:
void ratingTest();
void suppliersTest();
void feedsTest();
- void contentTest();
+ void imageContentTest();
+ void reviewContentTest();
void contentCountTest();
void nameTest();
void placeIdTest();
- void reviewsTest();
- void reviewCountTest();
void tagsTest();
void primaryPhoneTest();
void primaryFaxTest();
@@ -101,14 +100,6 @@ void tst_QGeoPlace::contentCountTest()
QVERIFY2(testObj.contentCount(QPlaceContent::ImageType) == 0, "Wrong value returned");
}
-void tst_QGeoPlace::reviewCountTest()
-{
- QGeoPlace testObj;
- QVERIFY2(testObj.reviewCount() == 0, "Wrong default value");
- testObj.setReviewCount(10);
- QVERIFY2(testObj.reviewCount() == 10, "Wrong value returned");
-}
-
void tst_QGeoPlace::ratingTest()
{
QGeoPlace testObj;
@@ -153,7 +144,7 @@ void tst_QGeoPlace::detailsFetchedTest()
QVERIFY2(testPlace.detailsFetched() == false, "Wrong value returned");
}
-void tst_QGeoPlace::contentTest()
+void tst_QGeoPlace::imageContentTest()
{
QUrl thumbnailUrl("testId");
@@ -205,23 +196,54 @@ void tst_QGeoPlace::contentTest()
QCOMPARE(QPlaceImage(retrievedCollection.value(5)), dummyImage6);
}
-void tst_QGeoPlace::reviewsTest()
+void tst_QGeoPlace::reviewContentTest()
{
- QGeoPlace testObj;
- QVERIFY2(testObj.reviews().items() == 0, "Wrong default value");
- QPlaceReview sup;
- sup.setDescription("testId");
- QList<QPlaceReview> list;
- list.append(sup);
- sup.setLanguage("testName2");
- list.append(sup);
- QPlacePaginationList<QPlaceReview> reviewsList;
- reviewsList.setData(list);
- testObj.setReviews(reviewsList);
- QVERIFY2(testObj.reviews().items() == 2, "Wrong value returned");
- QVERIFY2(testObj.reviews().data()[1].language() == "testName2", "Wrong value returned");
- QVERIFY2(testObj.reviews().start() == 0, "Wrong value returned");
- QVERIFY2(testObj.reviews().stop() == 1, "Wrong value returned");
+ QGeoPlace place;
+ QVERIFY2(place.content(QPlaceContent::ReviewType).count() ==0,"Wrong default value");
+
+ QPlaceReview dummyReview;
+ dummyReview.setTitle(QLatin1String("Review 1"));
+
+ QPlaceReview dummyReview2;
+ dummyReview2.setTitle(QLatin1String("Review 2"));
+
+ QPlaceReview dummyReview3;
+ dummyReview3.setTitle(QLatin1String("Review 3"));
+
+ QPlaceContent::Collection reviewCollection;
+ reviewCollection.insert(0,dummyReview);
+ reviewCollection.insert(1, dummyReview2);
+ reviewCollection.insert(2, dummyReview3);
+
+ place.setContent(QPlaceContent::ReviewType, reviewCollection);
+ QPlaceContent::Collection retrievedCollection = place.content(QPlaceContent::ReviewType);
+
+ QCOMPARE(retrievedCollection.count(), 3);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(0)), dummyReview);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(1)), dummyReview2);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(2)), dummyReview3);
+
+ //replace the second and insert a sixth review
+ //indexes 4 and 5 are "missing"
+ QPlaceReview dummyReview2New;
+ dummyReview2.setTitle(QLatin1String("Review 2 new"));
+
+ QPlaceReview dummyReview6;
+ dummyReview6.setTitle(QLatin1String("Review 6"));
+
+ reviewCollection.clear();
+ reviewCollection.insert(1, dummyReview2New);
+ reviewCollection.insert(5, dummyReview6);
+ place.addContent(QPlaceContent::ReviewType, reviewCollection);
+
+ retrievedCollection = place.content(QPlaceContent::ReviewType);
+ QCOMPARE(retrievedCollection.count(), 4);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(0)), dummyReview);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(1)), dummyReview2New);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(2)), dummyReview3);
+ QCOMPARE(QPlaceReview(retrievedCollection.value(3)), QPlaceReview());
+ QCOMPARE(QPlaceReview(retrievedCollection.value(4)), QPlaceReview());
+ QCOMPARE(QPlaceReview(retrievedCollection.value(5)), dummyReview6);
}
void tst_QGeoPlace::categoriesTest()
diff --git a/tests/auto/qplacecontentrequest/qplacecontentrequest.pro b/tests/auto/qplacecontentrequest/qplacecontentrequest.pro
new file mode 100644
index 00000000..6e27c4ee
--- /dev/null
+++ b/tests/auto/qplacecontentrequest/qplacecontentrequest.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+CONFIG += testcase
+TARGET = tst_qplacecontentrequest
+SOURCES += tst_qplacecontentrequest.cpp
+
+QT += location testlib
diff --git a/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp b/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp
new file mode 100644
index 00000000..74e00915
--- /dev/null
+++ b/tests/auto/qplacecontentrequest/tst_qplacecontentrequest.cpp
@@ -0,0 +1,76 @@
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+#include <qplacecontentrequest.h>
+
+QT_USE_NAMESPACE
+
+class tst_QPlaceContentRequest : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPlaceContentRequest();
+
+private Q_SLOTS:
+ void contentTest();
+ void clearTest();
+};
+
+tst_QPlaceContentRequest::tst_QPlaceContentRequest()
+{
+}
+
+void tst_QPlaceContentRequest::contentTest()
+{
+ QPlaceContentRequest req;
+ QCOMPARE(req.limit(), -1);
+ QCOMPARE(req.offset(), 0);
+ QCOMPARE(req.contentType(), QPlaceContent::InvalidType);
+
+ //check that we can set the request fields
+ req.setLimit(100);
+ req.setOffset(5);
+ req.setContentType(QPlaceContent::ImageType);
+ QCOMPARE(req.limit(), 100);
+ QCOMPARE(req.offset(), 5);
+ QCOMPARE(req.contentType(), QPlaceContent::ImageType);
+
+ //check that we assignment works correctly
+ QPlaceContentRequest otherReq;
+ otherReq.setLimit(10);
+ otherReq.setOffset(15);
+ otherReq.setContentType(QPlaceContent::ReviewType);
+ req = otherReq;
+ QCOMPARE(req.limit(), 10);
+ QCOMPARE(req.offset(), 15);
+ QCOMPARE(req.contentType(), QPlaceContent::ReviewType);
+
+ //check assigningment to a base class instance and comparison
+ QPlaceRequest plainReq(otherReq);
+ QVERIFY(req == otherReq);
+
+ //check assignment from base class to derived class
+ QPlaceContentRequest contentReq = plainReq;
+ QVERIFY(contentReq == req);
+
+ //check that comparison will fail if one the fields are different
+ contentReq.setLimit(9000);
+ QVERIFY(contentReq != req);
+}
+
+void tst_QPlaceContentRequest::clearTest()
+{
+ QPlaceContentRequest req;
+ req.setContentType(QPlaceContent::ReviewType);
+ req.setLimit(9000);
+ req.setOffset(1);
+ req.clear();
+ QVERIFY(req.contentType() == QPlaceContent::InvalidType);
+ QVERIFY(req.limit() == -1);
+ QVERIFY(req.offset() == 0);
+}
+
+QTEST_APPLESS_MAIN(tst_QPlaceContentRequest);
+
+#include "tst_qplacecontentrequest.moc"
diff --git a/tests/auto/qplacerequest/tst_qplacerequest.cpp b/tests/auto/qplacerequest/tst_qplacerequest.cpp
index 810dd958..2dedcb63 100644
--- a/tests/auto/qplacerequest/tst_qplacerequest.cpp
+++ b/tests/auto/qplacerequest/tst_qplacerequest.cpp
@@ -2,6 +2,7 @@
#include <QtTest/QtTest>
#include <qplacerequest.h>
+#include <qplacecontentrequest.h>
QT_USE_NAMESPACE
diff --git a/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp b/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp
index 8e2e7655..ec00bf77 100644
--- a/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp
+++ b/tests/auto/qplacesearchrequest/tst_qplacesearchrequest.cpp
@@ -24,6 +24,7 @@ private Q_SLOTS:
void didYouMeanSuggestionNumberTest();
void visibilityScopeTest();
void operatorsTest();
+ void clearTest();
};
tst_QPlaceSearchRequest::tst_QPlaceSearchRequest()
@@ -200,6 +201,27 @@ void tst_QPlaceSearchRequest::operatorsTest()
QVERIFY2(testObj != testObj2, "Different scopes identified as matching");
}
+void tst_QPlaceSearchRequest::clearTest()
+{
+ QPlaceSearchRequest req;
+ req.setSearchTerm("pizza");
+ req.setSearchArea(new QGeoBoundingCircle(QGeoCoordinate(1,1), 5000));
+ QPlaceCategory category;
+ category.setName("Fast Food");
+ req.setCategory(category);
+ req.setDidYouMeanSuggestionNumber(5);
+ req.setLimit(100);
+ req.setOffset(5);
+
+ req.clear();
+ QVERIFY(req.searchTerm().isEmpty());
+ QVERIFY(req.searchArea() == 0);
+ QVERIFY(req.categories().isEmpty());
+ QVERIFY(req.didYouMeanSuggestionNumber() == 0);
+ QVERIFY(req.limit() == -1);
+ QVERIFY(req.offset() == 0);
+}
+
QTEST_APPLESS_MAIN(tst_QPlaceSearchRequest);
#include "tst_qplacesearchrequest.moc"