summaryrefslogtreecommitdiff
path: root/src/location/places
diff options
context:
space:
mode:
authorabcd <amos.choy@nokia.com>2011-10-25 11:58:08 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-26 06:54:48 +0200
commitbef5f51913200af264116a3f772effc717829d23 (patch)
tree301415b8a844fec2db227f35cd67ec153c36e6fc /src/location/places
parentb8098b735b49278de3af80232ecf671d577c911d (diff)
downloadqtlocation-bef5f51913200af264116a3f772effc717829d23.tar.gz
Refactor contacts.
The REST server now supports labels for each contact value, so now it makes sense to incorporte the ContactValue class. ContactValue = user visible label + value(phone number, email etc) We use a map type implementation where the key for the map is the contact type and the value is a list of contact values. The first element of each list becomes the primary value. Eg the primaryPhone() field references the first element in the list of phone numbers. The setters for the primary___() functions has been removed. Url has also been renamed to Website to keep in line with LBSP. Change-Id: I9382a8286c5348bd1eb93d93f25088dfdf321852 Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/location/places')
-rw-r--r--src/location/places/places.pri4
-rw-r--r--src/location/places/qplacecontactdetail.cpp176
-rw-r--r--src/location/places/qplacecontactdetail.h98
-rw-r--r--src/location/places/qplacecontactdetail_p.h77
4 files changed, 354 insertions, 1 deletions
diff --git a/src/location/places/places.pri b/src/location/places/places.pri
index b0fb97fc..34978b6b 100644
--- a/src/location/places/places.pri
+++ b/src/location/places/places.pri
@@ -1,10 +1,10 @@
-#TODO: remove when plugin is refactored out
INCLUDEPATH += places
PUBLIC_HEADERS += \
places/placemacro.h \
#data classes
places/qplaceattribute.h \
+ places/qplacecontactdetail.h \
places/qplacecategory.h \
places/qplacecontent.h \
places/qplacecontentreply.h \
@@ -35,6 +35,7 @@ PRIVATE_HEADERS += \
places/qplaceattribute_p.h \
places/qplacecategory_p.h \
places/qplacecontent_p.h \
+ places/qplacecontactdetail_p.h \
places/qplaceeditorial_p.h \
places/qplaceicon_p.h \
places/qplaceimage_p.h \
@@ -52,6 +53,7 @@ SOURCES += \
#data classes
places/qplaceattribute.cpp \
places/qplacecategory.cpp \
+ places/qplacecontactdetail.cpp \
places/qplacecontent.cpp \
places/qplacecontentreply.cpp \
places/qplaceeditorial.cpp \
diff --git a/src/location/places/qplacecontactdetail.cpp b/src/location/places/qplacecontactdetail.cpp
new file mode 100644
index 00000000..a29529b5
--- /dev/null
+++ b/src/location/places/qplacecontactdetail.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** 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 "qplacecontactdetail_p.h"
+#include "qplacecontactdetail.h"
+
+QT_USE_NAMESPACE
+
+QPlaceContactDetailPrivate::QPlaceContactDetailPrivate(const QPlaceContactDetailPrivate &other)
+ : QSharedData(other),
+ label(other.label),
+ value(other.value)
+{
+}
+
+bool QPlaceContactDetailPrivate::operator== (const QPlaceContactDetailPrivate &other) const
+{
+ return label == other.label
+ && value == other.value;
+}
+
+/*!
+\class QPlaceContactDetail
+\brief The QPlaceContactDetail class represents a contact detail such as a phone number or url.
+\inmodule QtLocation
+
+\ingroup QtLocation-places
+
+*/
+
+/*!
+ \variable QPlaceContactDetail::Phone
+ The constant to specify phone contact details
+*/
+Q_DEFINE_LATIN1_CONSTANT(QPlaceContactDetail::Phone, "Phone");
+
+/*!
+ \variable QPlaceContactDetail::Email
+ The constant to specify email contact contact details.
+*/
+Q_DEFINE_LATIN1_CONSTANT(QPlaceContactDetail::Email, "Email");
+
+/*!
+ \variable QPlaceContactDetail::Website
+ The constant used to specify website contact details.
+*/
+Q_DEFINE_LATIN1_CONSTANT(QPlaceContactDetail::Website, "Website");
+
+/*!
+ \variable QPlaceContactDetail::Fax
+ The constant used to specify fax contact details.
+*/
+Q_DEFINE_LATIN1_CONSTANT(QPlaceContactDetail::Fax, "Fax");
+
+/*!
+ Constructs an contact detail.
+*/
+QPlaceContactDetail::QPlaceContactDetail()
+ : d_ptr(new QPlaceContactDetailPrivate)
+{
+}
+
+/*!
+ Destroys the contact detail.
+*/
+QPlaceContactDetail::~QPlaceContactDetail()
+{
+}
+
+/*!
+ Creates a copy of \a other.
+*/
+QPlaceContactDetail::QPlaceContactDetail(const QPlaceContactDetail &other)
+ :d_ptr(other.d_ptr)
+{
+}
+
+/*!
+ Assigns \a other to this contact detail and returns a reference to this
+ contact detail.
+*/
+QPlaceContactDetail &QPlaceContactDetail::operator=(const QPlaceContactDetail &other)
+{
+ d_ptr = other.d_ptr;
+ return *this;
+}
+
+/*!
+ Returns true if \a other is equal to this contact detail, otherwise
+ returns false.
+*/
+bool QPlaceContactDetail::operator== (const QPlaceContactDetail &other) const
+{
+ if (d_ptr == other.d_ptr)
+ return true;
+ return ( *(d_ptr.constData()) == *(other.d_ptr.constData()));
+}
+
+/*!
+ Returns true if \a other is not equal to this contact detail,
+ otherwise returns false.
+*/
+bool QPlaceContactDetail::operator!= (const QPlaceContactDetail &other) const
+{
+ return (!this->operator ==(other));
+}
+
+/*!
+ Returns a localized label describing the contact detail.
+*/
+QString QPlaceContactDetail::label() const
+{
+ return d_ptr->label;
+}
+
+/*!
+ Sets the \a label of the contact detail.
+*/
+void QPlaceContactDetail::setLabel(const QString &label)
+{
+ d_ptr->label = label;
+}
+
+/*!
+ Returns the value of the contact detail.
+*/
+QString QPlaceContactDetail::value() const
+{
+ return d_ptr->value;
+}
+
+/*!
+ Sets the \a value of the this contact detail.
+*/
+void QPlaceContactDetail::setValue(const QString &value)
+{
+ d_ptr->value = value;
+}
diff --git a/src/location/places/qplacecontactdetail.h b/src/location/places/qplacecontactdetail.h
new file mode 100644
index 00000000..ba65e324
--- /dev/null
+++ b/src/location/places/qplacecontactdetail.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 QPLACECONTACTDETAIL_H
+#define QPLACECONTACTDETAIL_H
+
+#include <QString>
+#include <QVariant>
+#include <QSharedDataPointer>
+#include <QLatin1Constant>
+
+#include <QtLocation/qlocationglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceContactDetailPrivate;
+class Q_LOCATION_EXPORT QPlaceContactDetail
+{
+public:
+#ifdef Q_QDOC
+ static const QLatin1Constant Phone;
+ static const QLatin1Constant Email;
+ static const QLatin1Constant Website;
+ static const QLatin1Constant Fax;
+#else
+ Q_DECLARE_LATIN1_CONSTANT(Phone, "Phone");
+ Q_DECLARE_LATIN1_CONSTANT(Email, "Email");
+ Q_DECLARE_LATIN1_CONSTANT(Website, "Website");
+ Q_DECLARE_LATIN1_CONSTANT(Fax, "Fax");
+#endif
+
+ QPlaceContactDetail();
+ QPlaceContactDetail(const QPlaceContactDetail &other);
+ virtual ~QPlaceContactDetail();
+
+ QPlaceContactDetail &operator=(const QPlaceContactDetail &other);
+
+ bool operator==(const QPlaceContactDetail &other) const;
+ bool operator!=(const QPlaceContactDetail &other) const;
+
+ QString label() const;
+ void setLabel(const QString &label);
+
+ QString value() const;
+ void setValue(const QString &value);
+
+private:
+ QSharedDataPointer<QPlaceContactDetailPrivate> d_ptr;
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QPlaceContactDetail));
+
+#endif
diff --git a/src/location/places/qplacecontactdetail_p.h b/src/location/places/qplacecontactdetail_p.h
new file mode 100644
index 00000000..94c4ed44
--- /dev/null
+++ b/src/location/places/qplacecontactdetail_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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 QPLACECONTACTDETAIL_P_H
+#define QPLACECONTACTDETAIL_P_H
+
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QSharedData>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceContactDetailPrivate : public QSharedData
+{
+public:
+ QPlaceContactDetailPrivate(){}
+ QPlaceContactDetailPrivate(const QPlaceContactDetailPrivate &other);
+ virtual ~QPlaceContactDetailPrivate(){}
+
+ bool operator== (const QPlaceContactDetailPrivate &other) const;
+
+ QString label;
+ QString value;
+};
+
+QT_END_NAMESPACE
+
+#endif