summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imports/location/declarativeplaces/declarativeplaces.pri2
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp21
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h5
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceuser.cpp120
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceuser_p.h84
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/location/places/places.pri5
-rw-r--r--src/location/places/qplacecontent.cpp38
-rw-r--r--src/location/places/qplacecontent.h7
-rw-r--r--src/location/places/qplacecontent_p.h6
-rw-r--r--src/location/places/qplaceeditorial.cpp10
-rw-r--r--src/location/places/qplaceimage.cpp3
-rw-r--r--src/location/places/qplacereview.cpp3
-rw-r--r--src/location/places/qplaceuser.cpp153
-rw-r--r--src/location/places/qplaceuser.h83
-rw-r--r--src/location/places/qplaceuser_p.h66
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp10
-rw-r--r--tests/auto/qplacereview/tst_qplacereview.cpp33
18 files changed, 586 insertions, 65 deletions
diff --git a/src/imports/location/declarativeplaces/declarativeplaces.pri b/src/imports/location/declarativeplaces/declarativeplaces.pri
index fa6dcd3a..0b6a749c 100644
--- a/src/imports/location/declarativeplaces/declarativeplaces.pri
+++ b/src/imports/location/declarativeplaces/declarativeplaces.pri
@@ -14,6 +14,7 @@ SOURCES += \
declarativeplaces/qdeclarativeplace.cpp \
declarativeplaces/qdeclarativeplaceattribute.cpp \
declarativeplaces/qdeclarativeplaceicon.cpp \
+ declarativeplaces/qdeclarativeplaceuser.cpp \
declarativeplaces/qdeclarativerating.cpp \
declarativeplaces/qdeclarativesupplier.cpp \
declarativeplaces/qdeclarativesearchmodelbase.cpp
@@ -33,6 +34,7 @@ HEADERS += \
declarativeplaces/qdeclarativeplace_p.h \
declarativeplaces/qdeclarativeplaceattribute_p.h \
declarativeplaces/qdeclarativeplaceicon_p.h \
+ declarativeplaces/qdeclarativeplaceuser_p.h \
declarativeplaces/qdeclarativerating_p.h \
declarativeplaces/qdeclarativesupplier_p.h \
declarativeplaces/qdeclarativesearchmodelbase.h
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
index f12cc93b..0f9209e3 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
@@ -42,6 +42,7 @@
#include "qdeclarativeplacecontentmodel.h"
#include "qdeclarativeplace_p.h"
#include "qdeclarativegeoserviceprovider_p.h"
+#include "qdeclarativeplaceuser_p.h"
#include <QtDeclarative/QDeclarativeInfo>
#include <QtLocation/QGeoServiceProvider>
@@ -58,8 +59,7 @@ QDeclarativePlaceContentModel::QDeclarativePlaceContentModel(QPlaceContent::Type
QHash<int, QByteArray> roles = roleNames();
roles.insert(SupplierRole, "supplier");
roles.insert(SourceUrlRole, "sourceUrl");
- roles.insert(UserIdRole, "userId");
- roles.insert(UserNameRole, "username");
+ roles.insert(PlaceUserRole, "user");
setRoleNames(roles);
}
@@ -145,6 +145,9 @@ void QDeclarativePlaceContentModel::clear()
void QDeclarativePlaceContentModel::clearData()
{
+ qDeleteAll(m_users);
+ m_users.clear();
+
qDeleteAll(m_suppliers);
m_suppliers.clear();
@@ -178,10 +181,8 @@ QVariant QDeclarativePlaceContentModel::data(const QModelIndex &index, int role)
return QVariant::fromValue(static_cast<QObject *>(m_suppliers.value(content.supplier().supplierId())));
case SourceUrlRole:
return content.sourceUrl();
- case UserIdRole:
- return content.userId();
- case UserNameRole:
- return content.userName();
+ case PlaceUserRole:
+ return QVariant::fromValue(static_cast<QObject *>(m_users.value(content.user().userId())));
default:
return QVariant();
}
@@ -300,6 +301,10 @@ void QDeclarativePlaceContentModel::fetchFinished()
m_suppliers.insert(content.supplier().supplierId(),
new QDeclarativeSupplier(content.supplier(), this));
}
+ if (!m_users.contains(content.user().userId())) {
+ m_users.insert(content.user().userId(),
+ new QDeclarativePlaceUser(content.user(), this));
+ }
}
endInsertRows();
startIndex = -1;
@@ -323,6 +328,10 @@ void QDeclarativePlaceContentModel::fetchFinished()
m_suppliers.insert(content.supplier().supplierId(),
new QDeclarativeSupplier(content.supplier(), this));
}
+ if (!m_users.contains(content.user().userId())) {
+ m_users.insert(content.user().userId(),
+ new QDeclarativePlaceUser(content.user(), this));
+ }
}
emit dataChanged(index(startIndex),index(currentIndex));
startIndex = -1;
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
index 5d3bc6f8..6e6335ad 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
@@ -53,6 +53,7 @@ class QDeclarativePlace;
class QDeclarativeGeoServiceProvider;
class QGeoServiceProvider;
class QDeclarativeSupplier;
+class QDeclarativePlaceUser;
class QDeclarativePlaceContentModel : public QAbstractListModel, public QDeclarativeParserStatus
{
@@ -85,8 +86,7 @@ public:
enum Roles {
SupplierRole = Qt::UserRole,
SourceUrlRole,
- UserIdRole,
- UserNameRole,
+ PlaceUserRole,
UserRole //indicator for next conten type specific role
};
@@ -108,6 +108,7 @@ private slots:
protected:
QPlaceContent::Collection m_content;
QMap<QString, QDeclarativeSupplier *> m_suppliers;
+ QMap<QString, QDeclarativePlaceUser *>m_users;
private:
QDeclarativePlace *m_place;
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceuser.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceuser.cpp
new file mode 100644
index 00000000..617164f8
--- /dev/null
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceuser.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** 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 "qdeclarativeplaceuser_p.h"
+
+QT_USE_NAMESPACE
+
+/*!
+ \qmlclass User
+
+ \brief The User element identifies a particular user.
+ \inherits QObject
+
+ \ingroup qml-places
+*/
+
+QDeclarativePlaceUser::QDeclarativePlaceUser(QObject* parent)
+ : QObject(parent) {}
+
+QDeclarativePlaceUser::QDeclarativePlaceUser(const QPlaceUser &user,
+ QObject *parent)
+ : QObject(parent),
+ m_user(user) {}
+
+QDeclarativePlaceUser::~QDeclarativePlaceUser() {}
+
+void QDeclarativePlaceUser::setUser(const QPlaceUser &user)
+{
+ QPlaceUser previousUser = m_user;
+ m_user = user;
+
+ if (m_user.userId() != previousUser.userId())
+ emit userIdChanged();
+
+ if (m_user.name() != previousUser.name())
+ emit nameChanged();
+}
+
+QPlaceUser QDeclarativePlaceUser::user() const
+{
+ return m_user;
+}
+
+/*!
+ \qmlproperty string User::userId
+
+ This property holds the id of the user.
+*/
+
+void QDeclarativePlaceUser::setUserId(const QString &id)
+{
+ if (m_user.userId() == id)
+ return;
+
+ m_user.setUserId(id);
+ emit userIdChanged();
+}
+
+QString QDeclarativePlaceUser::userId() const
+{
+ return m_user.userId();
+}
+
+/*!
+ \qmlproperty string User::name
+
+ This property holds the name of a user.
+*/
+void QDeclarativePlaceUser::setName(const QString &name)
+{
+ if (m_user.name() == name)
+ return;
+
+ m_user.setName(name);
+ emit nameChanged();
+}
+
+QString QDeclarativePlaceUser::name() const
+{
+ return m_user.name();
+}
+
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceuser_p.h b/src/imports/location/declarativeplaces/qdeclarativeplaceuser_p.h
new file mode 100644
index 00000000..6cdcaf5a
--- /dev/null
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceuser_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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 QDECLARATIVEPLACEUSER_P_H
+#define QDECLARATIVEPLACEUSER_P_H
+
+#include <QtCore/QObject>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtLocation/QPlaceUser>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativePlaceUser : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString userId READ userId WRITE setUserId NOTIFY userIdChanged())
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged())
+
+public:
+ explicit QDeclarativePlaceUser(QObject *parent = 0);
+ explicit QDeclarativePlaceUser(const QPlaceUser &src, QObject *parent = 0);
+ ~QDeclarativePlaceUser();
+
+ QPlaceUser user() const;
+ void setUser(const QPlaceUser &src);
+
+ QString userId() const;
+ void setUserId(const QString &id);
+
+ QString name() const;
+ void setName(const QString &name);
+
+signals:
+ void userIdChanged();
+ void nameChanged();
+
+private:
+ QPlaceUser m_user;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativePlaceUser));
+
+#endif
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index abf659af..bfc0e571 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -71,6 +71,7 @@
#include "qdeclarativeplaceicon_p.h"
#include "qdeclarativerating_p.h"
#include "qdeclarativesupplier_p.h"
+#include "qdeclarativeplaceuser_p.h"
#include "qdeclarativerecommendationmodel_p.h"
#include "qdeclarativesupportedcategoriesmodel_p.h"
@@ -134,6 +135,7 @@ public:
qmlRegisterType<QDeclarativeRating>(uri, 5, 0, "Rating");
qmlRegisterType<QDeclarativeReviewModel>(uri, 5, 0, "ReviewModel");
qmlRegisterType<QDeclarativeSupplier>(uri, 5, 0, "Supplier");
+ qmlRegisterType<QDeclarativePlaceUser>(uri, 5, 0, "User");
qmlRegisterType<QDeclarativeRecommendationModel>(uri, 5, 0, "RecommendationModel");
qmlRegisterType<QDeclarativeSupportedCategoriesModel>(uri, 5, 0, "CategoriesModel");
diff --git a/src/location/places/places.pri b/src/location/places/places.pri
index 6e0a4896..b0fb97fc 100644
--- a/src/location/places/places.pri
+++ b/src/location/places/places.pri
@@ -14,6 +14,7 @@ PUBLIC_HEADERS += \
places/qplacerating.h \
places/qplacereview.h \
places/qplacesupplier.h \
+ places/qplaceuser.h \
#result
places/qplacesearchresult.h \
#request classes
@@ -44,7 +45,8 @@ PRIVATE_HEADERS += \
places/qplacereply_p.h \
places/qplacemanagerengine_p.h \
places/qplacerequest_p.h \
- places/qplacecontentrequest_p.h
+ places/qplacecontentrequest_p.h \
+ places/qplaceuser_p.h
SOURCES += \
#data classes
@@ -53,6 +55,7 @@ SOURCES += \
places/qplacecontent.cpp \
places/qplacecontentreply.cpp \
places/qplaceeditorial.cpp \
+ places/qplaceuser.cpp \
#result
places/qplaceicon.cpp \
places/qplaceimage.cpp \
diff --git a/src/location/places/qplacecontent.cpp b/src/location/places/qplacecontent.cpp
index db4c5618..d47bee94 100644
--- a/src/location/places/qplacecontent.cpp
+++ b/src/location/places/qplacecontent.cpp
@@ -63,6 +63,13 @@ inline const QPlaceContentPrivate *QPlaceContent::d_func() const
return static_cast<const QPlaceContentPrivate *>(d_ptr.constData());
}
+bool QPlaceContentPrivate::compare(const QPlaceContentPrivate *other) const
+{
+ return supplier == other->supplier
+ && sourceUrl == other->sourceUrl
+ && user == other->user;
+}
+
/* Constructs an empty content object */
QPlaceContent::QPlaceContent()
:d_ptr(0)
@@ -166,42 +173,23 @@ void QPlaceContent::setSourceUrl(const QUrl &url)
}
/*!
- Returns user id of the user who contributed this content.
-*/
-QString QPlaceContent::userId() const
-{
- Q_D(const QPlaceContent);
- return d->userId;
-}
-
-/*!
- Sets user id to \a id.
-*/
-void QPlaceContent::setUserId(const QString &id)
-{
- Q_D(QPlaceContent);
- d->userId = id;
-}
-
-/*!
- Returns user name of the user who contributed this content.
+ Returns the user who contributed this content.
*/
-QString QPlaceContent::userName() const
+QPlaceUser QPlaceContent::user() const
{
Q_D(const QPlaceContent);
- return d->userName;
+ return d->user;
}
/*!
- Sets user name to \a name.
+ Sets the user who contributed this content.
*/
-void QPlaceContent::setUserName(const QString &name)
+void QPlaceContent::setUser(const QPlaceUser &user)
{
Q_D(QPlaceContent);
- d->userName = name;
+ d->user = user;
}
-
/*!
\internal
Constructs a new content object from the given pointer \a d.
diff --git a/src/location/places/qplacecontent.h b/src/location/places/qplacecontent.h
index 567d4467..7b933d56 100644
--- a/src/location/places/qplacecontent.h
+++ b/src/location/places/qplacecontent.h
@@ -59,6 +59,7 @@ QT_MODULE(Location)
#define Q_DECLARE_CONTENT_COPY_CTOR(Class) \
Class(const QPlaceContent &other);
+class QPlaceUser;
class QPlaceSupplier;
class QPlaceContentPrivate;
class Q_LOCATION_EXPORT QPlaceContent
@@ -90,10 +91,8 @@ public:
QUrl sourceUrl() const;
void setSourceUrl(const QUrl &url);
- QString userId() const;
- void setUserId(const QString &id);
- QString userName() const;
- void setUserName(const QString &name);
+ QPlaceUser user() const;
+ void setUser(const QPlaceUser &user);
protected:
explicit QPlaceContent(QPlaceContentPrivate *d);
diff --git a/src/location/places/qplacecontent_p.h b/src/location/places/qplacecontent_p.h
index 15ae2968..0f0b38ca 100644
--- a/src/location/places/qplacecontent_p.h
+++ b/src/location/places/qplacecontent_p.h
@@ -55,6 +55,7 @@
#include "qplacecontent.h"
#include "qplacesupplier.h"
+#include "qplaceuser.h"
#include <QtCore/QSharedData>
#include <QtCore/QString>
@@ -87,7 +88,7 @@ public:
QPlaceContentPrivate(){}
virtual ~QPlaceContentPrivate(){}
- virtual bool compare(const QPlaceContentPrivate *other) const =0;
+ virtual bool compare(const QPlaceContentPrivate *other) const;
virtual QPlaceContentPrivate* clone() const = 0;
virtual QPlaceContent::Type type() const = 0;
@@ -96,8 +97,7 @@ public:
QPlaceSupplier supplier;
QUrl sourceUrl;
- QString userId;
- QString userName;
+ QPlaceUser user;
};
#if defined(Q_CC_MWERKS)
diff --git a/src/location/places/qplaceeditorial.cpp b/src/location/places/qplaceeditorial.cpp
index e2394f54..9bb400b5 100644
--- a/src/location/places/qplaceeditorial.cpp
+++ b/src/location/places/qplaceeditorial.cpp
@@ -62,11 +62,11 @@ QPlaceEditorialPrivate::~QPlaceEditorialPrivate()
bool QPlaceEditorialPrivate::compare(const QPlaceContentPrivate *other) const
{
const QPlaceEditorialPrivate *od = static_cast<const QPlaceEditorialPrivate *>(other);
- return content == od->content &&
- contentTitle == od->contentTitle &&
- supplier == od->supplier &&
- sourceUrl == od->sourceUrl &&
- language == od->language;
+ return QPlaceContentPrivate::compare(other)
+ && content == od->content
+ && contentTitle == od->contentTitle
+ && sourceUrl == od->sourceUrl
+ && language == od->language;
}
/*!
diff --git a/src/location/places/qplaceimage.cpp b/src/location/places/qplaceimage.cpp
index 101d6a23..167208d8 100644
--- a/src/location/places/qplaceimage.cpp
+++ b/src/location/places/qplaceimage.cpp
@@ -63,7 +63,8 @@ QPlaceImagePrivate::~QPlaceImagePrivate()
bool QPlaceImagePrivate::compare(const QPlaceContentPrivate *other) const
{
const QPlaceImagePrivate *od = static_cast<const QPlaceImagePrivate *>(other);
- return url == od->url && id == od->id && mimeType == od->mimeType;
+ return QPlaceContentPrivate::compare(other)
+ && url == od->url && id == od->id && mimeType == od->mimeType;
}
/*!
diff --git a/src/location/places/qplacereview.cpp b/src/location/places/qplacereview.cpp
index e9529396..c5a4be4f 100644
--- a/src/location/places/qplacereview.cpp
+++ b/src/location/places/qplacereview.cpp
@@ -67,7 +67,8 @@ QPlaceReviewPrivate::~QPlaceReviewPrivate()
bool QPlaceReviewPrivate::compare(const QPlaceContentPrivate *other) const
{
const QPlaceReviewPrivate *od = static_cast<const QPlaceReviewPrivate *>(other);
- return dateTime == od->dateTime &&
+ return QPlaceContentPrivate::compare(other) &&
+ dateTime == od->dateTime &&
content == od->content &&
language == od->language &&
rating == od->rating &&
diff --git a/src/location/places/qplaceuser.cpp b/src/location/places/qplaceuser.cpp
new file mode 100644
index 00000000..9f7e6d83
--- /dev/null
+++ b/src/location/places/qplaceuser.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** 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 "qplaceuser.h"
+#include "qplaceuser_p.h"
+
+QT_USE_NAMESPACE
+
+QPlaceUserPrivate::QPlaceUserPrivate()
+ : QSharedData()
+{
+}
+
+QPlaceUserPrivate::QPlaceUserPrivate(const QPlaceUserPrivate &other)
+ : QSharedData(), userId(other.userId), name(other.name)
+{
+}
+
+QPlaceUserPrivate::~QPlaceUserPrivate()
+{
+}
+
+bool QPlaceUserPrivate::operator==(const QPlaceUserPrivate &other) const
+{
+ return userId == other.userId && name == other.name;
+}
+
+/*!
+ \class QPlaceUser
+
+ \inmodule QPlaces
+
+ \brief The QPlaceUser class represents a user.
+
+ Each QPlaceRating represents a rating object with a count and value.
+
+ QPlaceRating is an in memory representation of a rating object.
+*/
+
+
+/*!
+ Constructs a new user.
+*/
+QPlaceUser::QPlaceUser()
+ : d(new QPlaceUserPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other
+*/
+QPlaceUser::QPlaceUser(const QPlaceUser &other)
+ :d(other.d)
+{
+}
+
+/*!
+ Destructor.
+*/
+QPlaceUser::~QPlaceUser()
+{
+}
+
+/*!
+ Assigns \a other to this user and returns a reference to this user.
+*/
+QPlaceUser &QPlaceUser::operator=(const QPlaceUser &other)
+{
+ d = other.d;
+ return *this;
+}
+
+
+/*!
+ Returns true if this user is equal to \a other.
+ Otherwise returns false.
+*/
+bool QPlaceUser::operator==(const QPlaceUser &other) const
+{
+ return (*d) == *(other.d);
+}
+
+/*!
+ Returns the user id.
+*/
+QString QPlaceUser::userId() const
+{
+ return d->userId;
+}
+
+/*!
+ Sets the \a userId.
+*/
+void QPlaceUser::setUserId(const QString &userId)
+{
+ d->userId = userId;
+}
+
+/*!
+ Returns the user's name.
+*/
+QString QPlaceUser::name() const
+{
+ return d->name;
+}
+
+/*!
+ Sets the user's \a name.
+*/
+
+void QPlaceUser::setName(const QString &name)
+{
+ d->name = name;
+}
+
diff --git a/src/location/places/qplaceuser.h b/src/location/places/qplaceuser.h
new file mode 100644
index 00000000..d554cfd2
--- /dev/null
+++ b/src/location/places/qplaceuser.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** 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 QPLACEUSER_H
+#define QPLACEUSER_H
+
+#include <QSharedDataPointer>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Location)
+
+class QPlaceUserPrivate;
+
+class Q_LOCATION_EXPORT QPlaceUser
+{
+public:
+ QPlaceUser();
+ QPlaceUser(const QPlaceUser &other);
+ ~QPlaceUser();
+
+ QPlaceUser &operator=(const QPlaceUser &other);
+
+ bool operator==(const QPlaceUser &other) const;
+ bool operator!=(const QPlaceUser &other) const {
+ return !(other == *this);
+ }
+
+ QString userId() const;
+ void setUserId(const QString &);
+
+ QString name() const;
+ void setName(const QString &name);
+
+private:
+ QSharedDataPointer<QPlaceUserPrivate> d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/location/places/qplaceuser_p.h b/src/location/places/qplaceuser_p.h
new file mode 100644
index 00000000..50fca88a
--- /dev/null
+++ b/src/location/places/qplaceuser_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** 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 QPLACEUSER_P_H
+#define QPLACEUSER_P_H
+
+#include <QSharedData>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceUserPrivate : public QSharedData
+{
+public:
+ QPlaceUserPrivate();
+ QPlaceUserPrivate(const QPlaceUserPrivate &other);
+
+ ~QPlaceUserPrivate();
+
+ bool operator==(const QPlaceUserPrivate &other) const;
+
+ QString userId;
+ QString name;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
index a0bf281f..0c0c8431 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
@@ -55,6 +55,7 @@
#include <QtScript/QScriptValueIterator>
#include <QtLocation/QPlaceIcon>
#include <QtLocation/QPlaceManager>
+#include <QtLocation/QPlaceUser>
#include <qplacereview.h>
#include <qplacesupplier.h>
@@ -128,13 +129,16 @@ QPlaceReview QPlaceJSonReviewParser::buildReview(const QScriptValue &review, QPl
}
value = review.property(review_username_element);
if (value.isValid() && !value.toString().isEmpty()) {
- newReview.setUserName(value.toString());
+ QPlaceUser user = newReview.user();
+ user.setName(value.toString());
+ newReview.setUser(user);
}
value = review.property(review_userid_element);
if (value.isValid() && !value.toString().isEmpty()) {
- newReview.setUserId(value.toString());
+ QPlaceUser user = newReview.user();
+ user.setUserId(value.toString());
+ newReview.setUser(user);
}
-
QString name, id, icon;
value = review.property(review_vendorname_element);
if (value.isValid() && !value.toString().isEmpty()) {
diff --git a/tests/auto/qplacereview/tst_qplacereview.cpp b/tests/auto/qplacereview/tst_qplacereview.cpp
index 4f82a1d6..a94406c4 100644
--- a/tests/auto/qplacereview/tst_qplacereview.cpp
+++ b/tests/auto/qplacereview/tst_qplacereview.cpp
@@ -44,6 +44,7 @@
#include <QtLocation/QPlaceReview>
#include <QtLocation/QPlaceSupplier>
+#include <QtLocation/QPlaceUser>
QT_USE_NAMESPACE
@@ -63,8 +64,7 @@ private Q_SLOTS:
void ratingTest();
void reviewIdTest();
void titleTest();
- void userIdTest();
- void userNameTest();
+ void userTest();
void sourceUrlTest();
void operatorsTest();
};
@@ -155,20 +155,25 @@ void tst_QPlaceReview::titleTest()
testObj.setTitle("testText");
QVERIFY2(testObj.title() == "testText", "Wrong value returned");
}
-void tst_QPlaceReview::userIdTest()
-{
- QPlaceReview testObj;
- QVERIFY2(testObj.userId() == QString(), "Wrong default value");
- testObj.setUserId("testText");
- QVERIFY2(testObj.userId() == "testText", "Wrong value returned");
-}
-void tst_QPlaceReview::userNameTest()
+
+void tst_QPlaceReview::userTest()
{
- QPlaceReview testObj;
- QVERIFY2(testObj.userName() == QString(), "Wrong default value");
- testObj.setUserName("testText");
- QVERIFY2(testObj.userName() == "testText", "Wrong value returned");
+ QPlaceReview review;
+ QVERIFY(review.user().userId().isEmpty());
+ QVERIFY(review.user().name().isEmpty());
+ QPlaceUser user;
+ user.setUserId(QLatin1String("11111"));
+ user.setName(QLatin1String("Bob"));
+
+ review.setUser(user);
+ QCOMPARE(review.user().userId(), QLatin1String("11111"));
+ QCOMPARE(review.user().name(), QLatin1String("Bob"));
+
+ review.setUser(QPlaceUser());
+ QVERIFY(review.user().userId().isEmpty());
+ QVERIFY(review.user().name().isEmpty());
}
+
void tst_QPlaceReview::sourceUrlTest()
{
QPlaceReview testObj;