1// Copyright (C) 2015 basysKom GmbH, opensource@basyskom.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qopcualocalizedtext.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QOpcUaLocalizedText
10 \inmodule QtOpcUa
11 \brief The OPC UA LocalizedText type.
12
13 This is the Qt OPC UA representation for the OPC UA LocalizedText type defined in OPC UA 1.05 part 3, 8.5.
14 A LocalizedText value contains a text string with associated locale information in a second string (e. g. "en" or "en-US").
15 The format of the locale information string is <language>[-<country/region>]. Language is usually given as ISO 639 two letter code,
16 country/region as ISO 3166 two letter code. Custom codes are also allowed (see OPC UA 1.05 part 3, 8.4).
17 It can be used to provide multiple text strings in different languages for a value using an array of LocalizedText elements.
18*/
19
20/*!
21 \qmltype LocalizedText
22 \inqmlmodule QtOpcUa
23 \brief Contains a text with associated locale.
24 \since QtOpcUa 5.12
25 \deprecated [6.9]
26
27 The two members of this type contain the actual text and the locale of the text.
28*/
29
30/*!
31 \property QOpcUaLocalizedText::text
32
33 Textual content.
34*/
35
36/*!
37 \qmlproperty string LocalizedText::text
38
39 Textual content.
40*/
41
42/*!
43 \property QOpcUaLocalizedText::locale
44
45 Locale of the contained text.
46 This has to be in a modified ISO standard notation, for example \c en-US.
47 See OPC UA specification 1.05 part 3, 8.4 for details.
48*/
49
50/*!
51 \qmlproperty string LocalizedText::locale
52
53 Locale of the contained text.
54 This has to be in a modified ISO standard notation, for example \c en-US.
55 See OPC UA specification 1.05 part 3, 8.4 for details.
56*/
57
58class QOpcUaLocalizedTextData : public QSharedData
59{
60public:
61 QString locale;
62 QString text;
63};
64
65/*!
66 Default constructs a localized text with no parameters set.
67*/
68QOpcUaLocalizedText::QOpcUaLocalizedText()
69 : data(new QOpcUaLocalizedTextData)
70{
71}
72
73/*!
74 Constructs a localized text from \a rhs.
75*/
76QOpcUaLocalizedText::QOpcUaLocalizedText(const QOpcUaLocalizedText &rhs)
77 : data(rhs.data)
78{
79}
80
81/*!
82 Constructs a localized text with the locale \a locale and the text \a text.
83*/
84QOpcUaLocalizedText::QOpcUaLocalizedText(const QString &locale, const QString &text)
85 : data(new QOpcUaLocalizedTextData)
86{
87 data->locale = locale;
88 data->text = text;
89}
90
91/*!
92 Sets the values from \a rhs in this localized text.
93*/
94QOpcUaLocalizedText &QOpcUaLocalizedText::operator=(const QOpcUaLocalizedText &rhs)
95{
96 if (this != &rhs)
97 data.operator=(o: rhs.data);
98 return *this;
99}
100
101/*!
102 Returns \c true if this localized text has the same value as \a rhs.
103*/
104bool QOpcUaLocalizedText::operator==(const QOpcUaLocalizedText &rhs) const
105{
106 return data->locale == rhs.locale() &&
107 data->text == rhs.text();
108}
109
110/*!
111 Converts this localized text to \l QVariant.
112*/
113QOpcUaLocalizedText::operator QVariant() const
114{
115 return QVariant::fromValue(value: *this);
116}
117
118QOpcUaLocalizedText::~QOpcUaLocalizedText()
119{
120}
121
122/*!
123 Returns the text.
124*/
125QString QOpcUaLocalizedText::text() const
126{
127 return data->text;
128}
129
130/*!
131 Sets the text to \a text.
132*/
133void QOpcUaLocalizedText::setText(const QString &text)
134{
135 data->text = text;
136}
137
138/*!
139 Returns the locale.
140*/
141QString QOpcUaLocalizedText::locale() const
142{
143 return data->locale;
144}
145
146/*!
147 Sets the locale to \a locale.
148*/
149void QOpcUaLocalizedText::setLocale(const QString &locale)
150{
151 data->locale = locale;
152}
153
154#ifndef QT_NO_DEBUG_STREAM
155
156/*!
157 \fn QDebug QOpcUaLocalizedText::operator<<(QDebug debug, const QOpcUaLocalizedText &text)
158 \since 6.3
159
160 Writes the localized \a text to the \a debug output.
161
162 \sa QDebug
163*/
164QDebug operator<<(QDebug debug, const QOpcUaLocalizedText &lt)
165{
166 QDebugStateSaver saver(debug);
167 debug.nospace().quote() << "QOpcUaLocalizedText(" << lt.locale() << ", " << lt.text() << ")";
168 return debug;
169}
170
171#endif
172
173QT_END_NAMESPACE
174

source code of qtopcua/src/opcua/client/qopcualocalizedtext.cpp