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 "qplaceattribute_p.h"
38#include "qplaceattribute.h"
39
40QT_USE_NAMESPACE
41
42template<> QPlaceAttributePrivate *QSharedDataPointer<QPlaceAttributePrivate>::clone()
43{
44 return d->clone();
45}
46
47QPlaceAttributePrivate::QPlaceAttributePrivate(const QPlaceAttributePrivate &other)
48 : QSharedData(other),
49 label(other.label),
50 text(other.text)
51{
52}
53
54bool QPlaceAttributePrivate::operator== (const QPlaceAttributePrivate &other) const
55{
56 return label == other.label
57 && text == other.text;
58}
59
60bool QPlaceAttributePrivate::isEmpty() const
61{
62 return label.isEmpty()
63 && text.isEmpty();
64}
65
66
67/*!
68 \class QPlaceAttribute
69 \inmodule QtLocation
70 \ingroup QtLocation-places
71 \ingroup QtLocation-places-data
72 \since 5.6
73
74 \brief The QPlaceAttribute class represents generic attribute information about a place.
75
76 A QPlaceAttribute instance stores an additional piece of information about a place that is not
77 otherwise exposed through the QPlace class. A QPlaceAttribute encapsulates a
78 localized label which describes the attribute and rich text string representing the attribute's value.
79 Generally, both are intended to be displayed to the end-user as is.
80
81 Some plugins may not support attributes at all, others may only support a
82 certain set, others still may support a dynamically changing set of attributes
83 over time or even allow attributes to be arbitrarily defined by the client
84 application. The attributes could also vary on a place by place basis,
85 for example one place may have opening hours while another does not.
86 Consult the \l {Plugin References and Parameters}{plugin
87 references} for details.
88
89 \section2 Attribute Types
90 The QPlaceAttribute class defines some constant strings which characterize standard \e {attribute types}.
91 \list
92 \li QPlaceAttribute::OpeningHours
93 \li QPlaceAttribute::Payment
94 \li QPlaceAttribute::Provider
95 \endlist
96
97 There is a class of attribute types of the format x_id_<provider> for example x_id_here.
98 This class of attributes is a set of alternative identifiers of the place, from the specified provider's
99 perspective.
100
101 The above types are used to access and modify attributes in QPlace via:
102 \list
103 \li QPlace::extendedAttribute()
104 \li QPlace::setExtendedAttribute()
105 \li QPlace::removeExtendedAttribute()
106 \li QPlace::removeExtendedAttribute()
107 \endlist
108
109 The \e {attribute type} is a string type so that providers are able to introduce
110 new attributes as necessary. Custom attribute types should always be prefixed
111 by a qualifier in order to avoid conflicts.
112
113 \section3 User Readable and Non-User Readable Attributes
114 Some attributes may not be intended to be readable by end users, the label field
115 of such attributes are empty to indicate this fact.
116*/
117
118/*!
119 \variable QPlaceAttribute::OpeningHours
120 Specifies the opening hours.
121*/
122const QString QPlaceAttribute::OpeningHours(QLatin1String("openingHours"));
123
124/*!
125 \variable QPlaceAttribute::Payment
126 The constant to specify an attribute that defines the methods of payment.
127*/
128const QString QPlaceAttribute::Payment(QLatin1String("payment"));
129
130/*!
131 \variable QPlaceAttribute::Provider
132 The constant to specify an attribute that defines which
133 provider the place came from.
134*/
135const QString QPlaceAttribute::Provider(QLatin1String("x_provider"));
136
137/*!
138 Constructs an attribute.
139*/
140QPlaceAttribute::QPlaceAttribute()
141 : d_ptr(new QPlaceAttributePrivate)
142{
143}
144
145/*!
146 Destroys the attribute.
147*/
148QPlaceAttribute::~QPlaceAttribute()
149{
150}
151
152/*!
153 Creates a copy of \a other.
154*/
155QPlaceAttribute::QPlaceAttribute(const QPlaceAttribute &other)
156 :d_ptr(other.d_ptr)
157{
158}
159
160/*!
161 Assigns \a other to this attribute and returns a reference to this
162 attribute.
163*/
164QPlaceAttribute &QPlaceAttribute::operator=(const QPlaceAttribute &other)
165{
166 if (this == &other)
167 return *this;
168
169 d_ptr = other.d_ptr;
170 return *this;
171}
172
173/*!
174 Returns true if \a other is equal to this attribute, otherwise
175 returns false.
176*/
177bool QPlaceAttribute::operator== (const QPlaceAttribute &other) const
178{
179 if (d_ptr == other.d_ptr)
180 return true;
181 return ( *(d_ptr.constData()) == *(other.d_ptr.constData()));
182}
183
184/*!
185 Returns true if \a other is not equal to this attribute,
186 otherwise returns false.
187*/
188bool QPlaceAttribute::operator!= (const QPlaceAttribute &other) const
189{
190 return (!this->operator ==(other));
191}
192
193/*!
194 Returns a localized label describing the attribute.
195*/
196QString QPlaceAttribute::label() const
197{
198 return d_ptr->label;
199}
200
201/*!
202 Sets the \a label of the attribute.
203*/
204void QPlaceAttribute::setLabel(const QString &label)
205{
206 d_ptr->label = label;
207}
208
209/*!
210 Returns a piece of rich text representing the attribute value.
211*/
212QString QPlaceAttribute::text() const
213{
214 return d_ptr->text;
215}
216
217/*!
218 Sets the \a text of the attribute.
219*/
220void QPlaceAttribute::setText(const QString &text)
221{
222 d_ptr->text = text;
223}
224
225/*!
226 Returns a boolean indicating whether the all the fields of the place attribute are empty or not.
227*/
228bool QPlaceAttribute::isEmpty() const
229{
230 return d_ptr->isEmpty();
231}
232

source code of qtlocation/src/location/places/qplaceattribute.cpp