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