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
qdeclarativepluginparameter.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 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
6QT_BEGIN_NAMESPACE
7
8/*!
9 \qmltype PluginParameter
10 \inqmlmodule QtPositioning
11 \ingroup qml-QtPositioning5-common
12 \since QtPositioning 5.14
13
14 \brief The PluginParameter type describes a parameter for a
15 \omit
16 plugin, either geoservice \l Plugin, or
17 \endomit
18 position plugin.
19
20 The PluginParameter object is used to provide a parameter of some kind
21 to a plugin. Typically, these parameters contain details like an application
22 token for access to a service, or a proxy server to use for network access,
23 or the serial port to which a serial GPS receiver is connected.
24
25 To set such a parameter, declare a PluginParameter inside an element that
26 accepts plugin parameters as configuration objects, such as a
27 \omit
28 \l Plugin object, or a
29 \endomit
30 \l PositionSource object, and set values for its \l{name} and \l{value}
31 properties. A list of valid parameter names for each plugin is available
32 from the
33 \omit
34 \l {Qt Location#Plugin References and Parameters}{plugin reference pages}
35 for geoservice plugins, and
36 \endomit
37 \l {Qt Positioning plugins#Default plugins}{default plugins page} for
38 position plugins.
39
40 \section2 Example Usage
41
42 The following example shows the instantiation of the
43 \l {Qt Positioning NMEA plugin}{NMEA} plugin with the \e nmea.source
44 parameter that specifies the data source.
45
46 \code
47 PositionSource {
48 name: "nmea"
49 PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }
50 }
51 \endcode
52*/
53
54/*!
55 \qmlproperty string PluginParameter::name
56
57 This property holds the name of the plugin parameter as a single formatted string.
58 This property is a write-once property.
59*/
60
61/*!
62 \qmlproperty QVariant PluginParameter::value
63
64 This property holds the value of the plugin parameter which support different types of values (variant).
65 This property is a write-once property.
66*/
67
68QDeclarativePluginParameter::QDeclarativePluginParameter(QObject *parent)
69 : QObject(parent) {}
70
71QDeclarativePluginParameter::~QDeclarativePluginParameter() {}
72
73void QDeclarativePluginParameter::setName(const QString &name)
74{
75 if (!name_.isEmpty() || name.isEmpty())
76 return;
77
78 name_ = name;
79
80 emit nameChanged(name_);
81 if (value_.isValid())
82 emit initialized();
83}
84
85QString QDeclarativePluginParameter::name() const
86{
87 return name_;
88}
89
90void QDeclarativePluginParameter::setValue(const QVariant &value)
91{
92 if (value_.isValid() || !value.isValid() || value.isNull())
93 return;
94
95 value_ = value;
96
97 emit valueChanged(value_);
98 if (!name_.isEmpty())
99 emit initialized();
100}
101
102QVariant QDeclarativePluginParameter::value() const
103{
104 return value_;
105}
106
107bool QDeclarativePluginParameter::isInitialized() const
108{
109 return !name_.isEmpty() && value_.isValid();
110}
111
112QT_END_NAMESPACE
113
114#include "moc_qdeclarativepluginparameter_p.cpp"