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
qdeclarativecontactdetails.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 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
// Qt-Security score:significant reason:default
4
5
#
include
"qdeclarativecontactdetails_p.h"
6
7
#
include
<
QPlaceContactDetail
>
8
9
QT_BEGIN_NAMESPACE
10
11
/*!
12
\qmltype ContactDetails
13
\nativetype QDeclarativeContactDetails
14
\inqmlmodule QtLocation
15
\ingroup qml-QtLocation5-places
16
\ingroup qml-QtLocation5-places-data
17
\since QtLocation 5.5
18
19
\brief The ContactDetails type holds contact details for a \l Place.
20
21
The ContactDetails type is a map of \l contactDetail objects.
22
To access contact details in the map use the \l keys() method to get the list of keys stored in
23
the map and then use the \c {[]} operator to access the \l contactDetail items.
24
25
The following keys are defined in the API. \l Plugin implementations are free to define
26
additional keys.
27
28
\list
29
\li phone
30
\li fax
31
\li email
32
\li website
33
\endlist
34
35
ContactDetails instances are only ever used in the context of \l {Place}{Places}. It is not possible
36
to create a ContactDetails instance directly or re-assign ContactDetails instances to \l {Place}{Places}.
37
Modification of ContactDetails can only be accomplished via Javascript.
38
39
\section1 Examples
40
41
The following example shows how to access all \l {contactDetail}{contact details}
42
and print them to the console:
43
44
\snippet declarative/maps.qml QtLocation import
45
\codeline
46
\snippet declarative/places.qml ContactDetails read
47
48
The returned list of contact details is an \l {QObjectList-based model}{object list} and so can be used directly as a data model. For example, the
49
following demonstrates how to display a list of contact phone numbers in a list view:
50
51
\snippet declarative/places.qml QtQuick import
52
\snippet declarative/maps.qml QtLocation import
53
\codeline
54
\snippet declarative/places.qml ContactDetails phoneList
55
56
The following example demonstrates how to assign a single phone number to a place in JavaScript:
57
\snippet declarative/places.qml ContactDetails write single
58
59
The following demonstrates how to assign multiple phone numbers to a place in JavaScript:
60
\snippet declarative/places.qml ContactDetails write multiple
61
*/
62
63
/*!
64
\qmlmethod variant ContactDetails::keys()
65
66
Returns an array of contact detail keys currently stored in the map.
67
*/
68
QDeclarativeContactDetails::QDeclarativeContactDetails(QObject *parent)
69
: QQmlPropertyMap(
this
, parent)
70
{
71
}
72
73
QVariant QDeclarativeContactDetails::updateValue(
const
QString &,
const
QVariant &input)
74
{
75
if
(input.metaType() == QMetaType::fromType<QPlaceContactDetail>()) {
76
QVariantList varList;
77
varList.append(input);
78
return
varList;
79
}
80
81
return
input;
82
}
83
84
QT_END_NAMESPACE
qtlocation
src
location
declarativeplaces
qdeclarativecontactdetails.cpp
Generated on
for Qt by
1.16.1