Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplacecontactdetail.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
7QT_USE_NAMESPACE
8
9QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QPlaceContactDetailPrivate)
10
11bool QPlaceContactDetailPrivate::operator== (const QPlaceContactDetailPrivate &other) const
12{
13 return label == other.label
14 && value == other.value;
15}
16
17/*!
18\class QPlaceContactDetail
19\brief The QPlaceContactDetail class represents a contact detail such as a phone number or website url.
20\inmodule QtLocation
21
22\ingroup QtLocation-places
23\ingroup QtLocation-places-data
24
25The detail consists of a label and value. The label is a localized string that can be presented
26to the end user that describes that detail value which is the actual phone number, email address and so on.
27
28\section2 Contact Types
29
30The QPlaceContactDetail class defines some constant strings which characterize standard \e {contact types}.
31\list
32 \li QPlaceContactDetail::Phone
33 \li QPlaceContactDetail::Email
34 \li QPlaceContactDetail::Website
35 \li QPlaceContactDetail::Fax
36\endlist
37
38These types are used to access and modify contact details in QPlace via:
39\list
40 \li QPlace::contactDetails()
41 \li QPlace::setContactDetails()
42 \li QPlace::appendContactDetail()
43 \li QPlace::contactTypes()
44\endlist
45
46The \e {contact type} is intended to be a string type so that providers are able to introduce new contact
47types if necessary.
48*/
49
50/*!
51 \qmlvaluetype contactDetail
52 \inqmlmodule QtLocation
53 \ingroup qml-QtLocation5-places
54 \ingroup qml-QtLocation5-places-data
55 \since QtLocation 5.5
56
57 \brief The contactDetail type holds a contact detail such as a phone number or a website
58 address.
59
60 The contactDetail provides a single detail on how one could contact a \l Place. The
61 contactDetail consists of a \l {contactDetail::}{label}, which is a localized string
62 describing the contact method, and a \l {contactDetail::}{value} representing the actual
63 contact detail.
64
65 \section1 Examples
66
67 The following example demonstrates how to assign a single phone number to a place in JavaScript:
68 \snippet declarative/places.qml ContactDetails write single
69
70 The following demonstrates how to assign multiple phone numbers to a place in JavaScript:
71 \snippet declarative/places.qml ContactDetails write multiple
72
73 Note, due to limitations of the QQmlPropertyMap, it is not possible
74 to declaratively specify the contact details in QML, it can only be accomplished
75 via JavaScript.
76*/
77
78/*!
79 \variable QPlaceContactDetail::Phone
80 The constant to specify phone contact details
81*/
82const QString QPlaceContactDetail::Phone(QLatin1String("phone"));
83
84/*!
85 \variable QPlaceContactDetail::Email
86 The constant to specify email contact details.
87*/
88const QString QPlaceContactDetail::Email(QLatin1String("email"));
89
90/*!
91 \variable QPlaceContactDetail::Website
92 The constant used to specify website contact details.
93*/
94const QString QPlaceContactDetail::Website(QLatin1String("website"));
95
96/*!
97 \variable QPlaceContactDetail::Fax
98 The constant used to specify fax contact details.
99*/
100const QString QPlaceContactDetail::Fax(QLatin1String("fax"));
101
102/*!
103 Constructs a contact detail.
104*/
105QPlaceContactDetail::QPlaceContactDetail()
106 : d_ptr(new QPlaceContactDetailPrivate)
107{
108}
109
110/*!
111 Destroys the contact detail.
112*/
113QPlaceContactDetail::~QPlaceContactDetail() = default;
114
115/*!
116 Creates a copy of \a other.
117*/
118QPlaceContactDetail::QPlaceContactDetail(const QPlaceContactDetail &other) noexcept = default;
119
120/*!
121 Assigns \a other to this contact detail and returns a reference to this
122 contact detail.
123*/
124QPlaceContactDetail &QPlaceContactDetail::operator=(const QPlaceContactDetail &other) noexcept
125{
126 if (this == &other)
127 return *this;
128
129 d_ptr = other.d_ptr;
130 return *this;
131}
132
133/*!
134 \fn bool QPlaceContactDetail::operator==(const QPlaceContactDetail &lhs, const QPlaceContactDetail &rhs) noexcept
135
136 Returns true if the contact detail \a lhs is equal to \a rhs,
137 otherwise returns false.
138*/
139bool QPlaceContactDetail::isEqual(const QPlaceContactDetail &other) const noexcept
140{
141 if (d_ptr == other.d_ptr)
142 return true;
143 return ( *(d_ptr.constData()) == *(other.d_ptr.constData()));
144}
145
146/*!
147 \fn bool QPlaceContactDetail::operator!=(const QPlaceContactDetail &lhs, const QPlaceContactDetail &rhs) noexcept
148
149 Returns true if the contact detail \a lhs is not equal to \a rhs,
150 otherwise returns false.
151*/
152
153/*!
154 \qmlproperty string QtLocation::contactDetail::label
155
156 This property holds a label describing the contact detail.
157
158 The label can potentially be localized. The language is dependent on the entity that sets it,
159 typically this is the \l {Plugin}. The \l {Plugin::locales} property defines
160 what language is used.
161*/
162
163/*!
164 \property QPlaceContactDetail::label
165 \brief a label describing the contact detail.
166
167 The label can potentially be localized. The language is dependent on the entity that sets it,
168 typically this is the manager from which the places are sourced.
169 The QPlaceManager::locales() field defines what language is used.
170*/
171QString QPlaceContactDetail::label() const
172{
173 return d_ptr->label;
174}
175
176void QPlaceContactDetail::setLabel(const QString &label)
177{
178 d_ptr->label = label;
179}
180
181/*!
182 \qmlproperty string QtLocation::contactDetail::value
183
184 This property holds the value of the contact detail which may be a phone number, an email
185 address, a website url and so on.
186*/
187
188/*!
189 \property QPlaceContactDetail::value
190 \brief the value of the contact detail.
191*/
192QString QPlaceContactDetail::value() const
193{
194 return d_ptr->value;
195}
196
197void QPlaceContactDetail::setValue(const QString &value)
198{
199 d_ptr->value = value;
200}
201
202/*!
203 Clears the contact detail.
204*/
205void QPlaceContactDetail::clear()
206{
207 d_ptr->label.clear();
208 d_ptr->value.clear();
209}
210
211#include "moc_qplacecontactdetail.cpp"