1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtLocation module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL3$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or later as published by the Free
28 ** Software Foundation and appearing in the file LICENSE.GPL included in
29 ** the packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 2.0 requirements will be
31 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
32 **
33 ** $QT_END_LICENSE$
34 **
35 ****************************************************************************/
36 
37 #include "qplacecontactdetail_p.h"
38 #include "qplacecontactdetail.h"
39 
40 QT_USE_NAMESPACE
41 
QPlaceContactDetailPrivate(const QPlaceContactDetailPrivate & other)42 QPlaceContactDetailPrivate::QPlaceContactDetailPrivate(const QPlaceContactDetailPrivate &other)
43     : QSharedData(other),
44       label(other.label),
45       value(other.value)
46 {
47 }
48 
operator ==(const QPlaceContactDetailPrivate & other) const49 bool QPlaceContactDetailPrivate::operator== (const QPlaceContactDetailPrivate &other) const
50 {
51     return label == other.label
52             && value == other.value;
53 }
54 
55 /*!
56 \class QPlaceContactDetail
57 \brief The QPlaceContactDetail class represents a contact detail such as a phone number or website url.
58 \inmodule QtLocation
59 
60 \ingroup QtLocation-places
61 \ingroup QtLocation-places-data
62 
63 The detail consists of a label and value.  The label is a localized string that can be presented
64 to the end user that describes that detail value which is the actual phone number, email address and so on.
65 
66 \section2 Contact Types
67 
68 The QPlaceContactDetail class defines some constant strings which characterize standard \e {contact types}.
69 \list
70     \li QPlaceContactDetail::Phone
71     \li QPlaceContactDetail::Email
72     \li QPlaceContactDetail::Website
73     \li QPlaceContactDetail::Fax
74 \endlist
75 
76 These types are used to access and modify contact details in QPlace via:
77 \list
78     \li QPlace::contactDetails()
79     \li QPlace::setContactDetails()
80     \li QPlace::appendContactDetail()
81     \li QPlace::contactTypes()
82 \endlist
83 
84 The \e {contact type} is intended to be a string type so that providers are able to introduce new contact
85 types if necessary.
86 */
87 
88 /*!
89    \variable QPlaceContactDetail::Phone
90    The constant to specify phone contact details
91 */
92 const QString QPlaceContactDetail::Phone(QLatin1String("phone"));
93 
94 /*!
95    \variable QPlaceContactDetail::Email
96    The constant to specify email contact details.
97 */
98 const QString QPlaceContactDetail::Email(QLatin1String("email"));
99 
100 /*!
101    \variable QPlaceContactDetail::Website
102    The constant used to specify website contact details.
103 */
104 const QString QPlaceContactDetail::Website(QLatin1String("website"));
105 
106 /*!
107    \variable QPlaceContactDetail::Fax
108    The constant used to specify fax contact details.
109 */
110 const QString QPlaceContactDetail::Fax(QLatin1String("fax"));
111 
112 /*!
113     Constructs a contact detail.
114 */
QPlaceContactDetail()115 QPlaceContactDetail::QPlaceContactDetail()
116     : d_ptr(new QPlaceContactDetailPrivate)
117 {
118 }
119 
120 /*!
121     Destroys the contact detail.
122 */
~QPlaceContactDetail()123 QPlaceContactDetail::~QPlaceContactDetail()
124 {
125 }
126 
127 /*!
128     Creates a copy of \a other.
129 */
QPlaceContactDetail(const QPlaceContactDetail & other)130 QPlaceContactDetail::QPlaceContactDetail(const QPlaceContactDetail &other)
131     :d_ptr(other.d_ptr)
132 {
133 }
134 
135 /*!
136     Assigns \a other to this contact detail and returns a reference to this
137     contact detail.
138 */
operator =(const QPlaceContactDetail & other)139 QPlaceContactDetail &QPlaceContactDetail::operator=(const QPlaceContactDetail &other)
140 {
141     if (this == &other)
142         return *this;
143 
144     d_ptr = other.d_ptr;
145     return *this;
146 }
147 
148 /*!
149     Returns true if \a other is equal to this contact detail, otherwise
150     returns false.
151 */
operator ==(const QPlaceContactDetail & other) const152 bool QPlaceContactDetail::operator== (const QPlaceContactDetail &other) const
153 {
154     if (d_ptr == other.d_ptr)
155         return true;
156     return ( *(d_ptr.constData()) == *(other.d_ptr.constData()));
157 }
158 
159 /*!
160     Returns true if \a other is not equal to this contact detail,
161     otherwise returns false.
162 */
operator !=(const QPlaceContactDetail & other) const163 bool QPlaceContactDetail::operator!= (const QPlaceContactDetail &other) const
164 {
165     return (!this->operator ==(other));
166 }
167 
168 /*!
169     Returns a label describing the contact detail.
170 
171     The label can potentially be localized. The language is dependent on the entity that sets it,
172     typically this is the manager from which the places are sourced.
173     The QPlaceManager::locales() field defines what language is used.
174 */
label() const175 QString QPlaceContactDetail::label() const
176 {
177     return d_ptr->label;
178 }
179 
180 /*!
181     Sets the \a label of the contact detail.
182 */
setLabel(const QString & label)183 void QPlaceContactDetail::setLabel(const QString &label)
184 {
185     d_ptr->label = label;
186 }
187 
188 /*!
189     Returns the value of the contact detail.
190 */
value() const191 QString QPlaceContactDetail::value() const
192 {
193     return d_ptr->value;
194 }
195 
196 /*!
197     Sets the \a value of this contact detail.
198 */
setValue(const QString & value)199 void QPlaceContactDetail::setValue(const QString &value)
200 {
201     d_ptr->value = value;
202 }
203 
204 /*!
205     Clears the contact detail.
206 */
clear()207 void QPlaceContactDetail::clear()
208 {
209     d_ptr->label.clear();
210     d_ptr->value.clear();
211 }
212