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