| 1 | // Copyright (C) 2018 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 | |
| 4 | #include <private/opcuaattributevalue_p.h> |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | /*! |
| 9 | \class OpcUaAttributeValue |
| 10 | \inqmlmodule QtOpcUa |
| 11 | \brief Stores an attribute value and provides a changed signal. |
| 12 | \internal |
| 13 | \deprecated [6.9] |
| 14 | |
| 15 | This class is just for internal use in the declarative backend and not exposed to users. |
| 16 | |
| 17 | When setting the value it will emit a changed signal if the value has changed. |
| 18 | |
| 19 | \sa OpcUaAttributeCache |
| 20 | */ |
| 21 | |
| 22 | OpcUaAttributeValue::OpcUaAttributeValue(QObject *parent) |
| 23 | : QObject(parent) |
| 24 | { |
| 25 | |
| 26 | } |
| 27 | |
| 28 | bool OpcUaAttributeValue::operator ==(const OpcUaAttributeValue &rhs) |
| 29 | { |
| 30 | return m_value == rhs.m_value; |
| 31 | } |
| 32 | |
| 33 | void OpcUaAttributeValue::setValue(const QVariant &value) |
| 34 | { |
| 35 | if (value.metaType() != m_value.metaType() || value != m_value) { |
| 36 | m_value = value; |
| 37 | emit changed(value: m_value); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void OpcUaAttributeValue::invalidate() |
| 42 | { |
| 43 | setValue(QVariant()); |
| 44 | } |
| 45 | |
| 46 | const QVariant &OpcUaAttributeValue::value() const |
| 47 | { |
| 48 | return m_value; |
| 49 | } |
| 50 | |
| 51 | OpcUaAttributeValue::operator QVariant() const |
| 52 | { |
| 53 | return value(); |
| 54 | } |
| 55 | |
| 56 | QT_END_NAMESPACE |
| 57 |
