summaryrefslogtreecommitdiff
path: root/src/location/places
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-10-11 17:31:43 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-12 09:42:00 +0200
commit51bc2527eb58d9dbf4127e23acdd07fa042272b0 (patch)
tree9a5f63f4f9f199b283a4160e888bbf33d05b17d9 /src/location/places
parenta7b9ec3979d86c38d875451015e2169230972b98 (diff)
downloadqtlocation-51bc2527eb58d9dbf4127e23acdd07fa042272b0.tar.gz
Add a user class
Change-Id: I28993ed7d7cd1ba08c850a558c2bcd2f6fb2bf63 Reviewed-on: http://codereview.qt-project.org/6482 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/location/places')
-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
10 files changed, 334 insertions, 40 deletions
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