summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Voelker <jannis.voelker@basyskom.com>2024-02-27 15:42:02 +0100
committerJannis Voelker <jannis.voelker@basyskom.com>2024-02-29 12:46:18 +0100
commit8cefbe796e9d9b8f10c5f15e455cdd3e80dc8148 (patch)
tree0e16cc5a3f4812f43c1061ad236514b162fee857
parent65dab43d525ee9a40cfe598847a4d64c49112d94 (diff)
Rename QOpcUaGenericStructHandler::initializeFinished to initializedChanged()
Pick-to: 6.7 Change-Id: I05e5e143eb74b7cd51dcbd6498af5a194ca296c0 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r--examples/opcua/opcuaviewer/mainwindow.cpp2
-rw-r--r--src/opcua/client/qopcuagenericstructhandler.cpp26
-rw-r--r--src/opcua/client/qopcuagenericstructhandler.h4
-rw-r--r--src/opcua/client/qopcuagenericstructhandler_p.h4
-rw-r--r--src/opcua/client/qopcuagenericstructhandlerprivate.cpp13
-rw-r--r--tests/auto/qopcuaclient/tst_client.cpp6
6 files changed, 40 insertions, 15 deletions
diff --git a/examples/opcua/opcuaviewer/mainwindow.cpp b/examples/opcua/opcuaviewer/mainwindow.cpp
index 587f5e9..187c2ad 100644
--- a/examples/opcua/opcuaviewer/mainwindow.cpp
+++ b/examples/opcua/opcuaviewer/mainwindow.cpp
@@ -300,7 +300,7 @@ void MainWindow::namespacesArrayUpdated(const QStringList &namespaceArray)
disconnect(mOpcUaClient, &QOpcUaClient::namespaceArrayUpdated, this, &MainWindow::namespacesArrayUpdated);
mGenericStructHandler.reset(new QOpcUaGenericStructHandler(mOpcUaClient));
- connect(mGenericStructHandler.get(), &QOpcUaGenericStructHandler::initializeFinished, this, &MainWindow::handleGenericStructHandlerInitFinished);
+ connect(mGenericStructHandler.get(), &QOpcUaGenericStructHandler::initializedChanged, this, &MainWindow::handleGenericStructHandlerInitFinished);
mGenericStructHandler->initialize();
}
diff --git a/src/opcua/client/qopcuagenericstructhandler.cpp b/src/opcua/client/qopcuagenericstructhandler.cpp
index 3cf0af8..bba8cc3 100644
--- a/src/opcua/client/qopcuagenericstructhandler.cpp
+++ b/src/opcua/client/qopcuagenericstructhandler.cpp
@@ -42,8 +42,8 @@ QT_BEGIN_NAMESPACE
QOpcUaGenericStructHandler handler(opcuaClient);
handler.initialize();
- QObject::connect(&handler, &QOpcUaGenericStructHandler::initializeFinished, [opcuaClient, &handler](bool success) {
- if (!success)
+ QObject::connect(&handler, &QOpcUaGenericStructHandler::initializedChanged, [opcuaClient, &handler](bool initialized) {
+ if (!initialized)
return;
auto node = opcuaClient->node("ns=4;i=3003"); // A custom struct test node in the open62541-testserver
@@ -72,8 +72,8 @@ QT_BEGIN_NAMESPACE
QOpcUaGenericStructHandler handler(opcuaClient);
handler.initialize();
- QObject::connect(&handler, &QOpcUaGenericStructHandler::initializeFinished, [opcuaClient, &handler](bool success) {
- if (!success)
+ QObject::connect(&handler, &QOpcUaGenericStructHandler::initializedChanged, [opcuaClient, &handler](bool initialized) {
+ if (!initialized)
return;
QOpcUaGenericStructValue value = handler.createGenericStructValueForTypeId("ns=4;i=3006");
@@ -106,10 +106,10 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QOpcUaGenericStructHandler::initializeFinished(bool success)
+ \fn QOpcUaGenericStructHandler::initializedChanged(bool initialized)
- This signal is emitted when the initialization has finished.
- \a success indicates if the initialization was successful.
+ This signal is emitted when the initialization process has finished.
+ \a initialized indicates if the initialization was successful.
*/
/*!
@@ -123,7 +123,7 @@ QOpcUaGenericStructHandler::QOpcUaGenericStructHandler(QOpcUaClient *client, QOb
/*!
Starts the data type hierarchy traversal.
- Success or failure is reported in the \l initializeFinished signal.
+ Success or failure is reported in the \l initializedChanged signal.
Returns \c false if the operation can't be started.
*/
@@ -248,6 +248,16 @@ bool QOpcUaGenericStructHandler::addCustomEnumDefinition(const QOpcUaEnumDefinit
}
/*!
+ \since 6.7
+
+ Returns \c true if the generic struct handler is initialized.
+*/
+bool QOpcUaGenericStructHandler::initialized() const
+{
+ return d_func()->initialized();
+}
+
+/*!
Returns the data type kind for the type node id \a id.
*/
QOpcUaGenericStructHandler::DataTypeKind QOpcUaGenericStructHandler::dataTypeKindForTypeId(const QString &id) const
diff --git a/src/opcua/client/qopcuagenericstructhandler.h b/src/opcua/client/qopcuagenericstructhandler.h
index de8b47b..06f2c96 100644
--- a/src/opcua/client/qopcuagenericstructhandler.h
+++ b/src/opcua/client/qopcuagenericstructhandler.h
@@ -44,6 +44,8 @@ public:
bool addCustomEnumDefinition(const QOpcUaEnumDefinition &definition, const QString &typeId,
const QString &name, bool isAbstract = false);
+ bool initialized() const;
+
enum class DataTypeKind {
Unknown = 0,
Struct = 1,
@@ -57,7 +59,7 @@ public:
QString typeIdForBinaryEncodingId(const QString &id) const;
Q_SIGNALS:
- void initializeFinished(bool success);
+ void initializedChanged(bool initialized);
};
QT_END_NAMESPACE
diff --git a/src/opcua/client/qopcuagenericstructhandler_p.h b/src/opcua/client/qopcuagenericstructhandler_p.h
index 450076c..d33146b 100644
--- a/src/opcua/client/qopcuagenericstructhandler_p.h
+++ b/src/opcua/client/qopcuagenericstructhandler_p.h
@@ -71,6 +71,8 @@ protected:
bool addCustomStructureDefinition(const QOpcUaStructureDefinition &definition, const QString &typeId, const QString &name, bool isAbstract);
bool addCustomEnumDefinition(const QOpcUaEnumDefinition &definition, const QString &typeId, const QString &name, bool isAbstract);
+ bool initialized() const;
+
template <typename T, QOpcUa::Types OVERLAY = QOpcUa::Types::Undefined>
QVariant decodeArrayOrScalar(QOpcUaBinaryDataEncoding &decoder, qint32 valueRank, bool &success) const
{
@@ -168,6 +170,8 @@ private:
QHash<QString, QString> m_knownSubtypes;
const int m_maxNestingLevel = 500;
+
+ bool m_initialized = false;
};
QT_END_NAMESPACE
diff --git a/src/opcua/client/qopcuagenericstructhandlerprivate.cpp b/src/opcua/client/qopcuagenericstructhandlerprivate.cpp
index 9bd92ba..bdab900 100644
--- a/src/opcua/client/qopcuagenericstructhandlerprivate.cpp
+++ b/src/opcua/client/qopcuagenericstructhandlerprivate.cpp
@@ -21,6 +21,8 @@ bool QOpcUaGenericStructHandlerPrivate::initialize()
if (!m_client)
return false;
+ m_initialized = false;
+
m_baseDataType.reset(new QOpcUaInternalDataTypeNode(m_client));
QObjectPrivate::connect(m_baseDataType.get(), &QOpcUaInternalDataTypeNode::initializeFinished,
@@ -730,8 +732,10 @@ void QOpcUaGenericStructHandlerPrivate::handleFinished(bool success)
Q_Q(QOpcUaGenericStructHandler);
- if (m_finishedCount == 1 || m_hasError)
- emit q->initializeFinished(!m_hasError);
+ if (m_finishedCount == 1 || m_hasError) {
+ m_initialized = !m_hasError;
+ emit q->initializedChanged(m_initialized);
+ }
}
bool QOpcUaGenericStructHandlerPrivate::addCustomStructureDefinition(const QOpcUaStructureDefinition &definition,
@@ -794,6 +798,11 @@ bool QOpcUaGenericStructHandlerPrivate::addCustomEnumDefinition(const QOpcUaEnum
return true;
}
+bool QOpcUaGenericStructHandlerPrivate::initialized() const
+{
+ return m_initialized;
+}
+
void QOpcUaGenericStructHandlerPrivate::handleInitializeFinished(bool success)
{
if (!success) {
diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp
index 1cb04bb..aa612ac 100644
--- a/tests/auto/qopcuaclient/tst_client.cpp
+++ b/tests/auto/qopcuaclient/tst_client.cpp
@@ -5972,7 +5972,7 @@ void Tst_QOpcUaClient::decodeGenericStruct()
QOpcUaGenericStructHandler decoder(opcuaClient);
- QSignalSpy spy(&decoder, &QOpcUaGenericStructHandler::initializeFinished);
+ QSignalSpy spy(&decoder, &QOpcUaGenericStructHandler::initializedChanged);
auto success = decoder.initialize();
QCOMPARE(success, true);
@@ -6166,7 +6166,7 @@ void Tst_QOpcUaClient::encodeGenericStruct()
QOpcUaGenericStructHandler handler(opcuaClient);
- QSignalSpy spy(&handler, &QOpcUaGenericStructHandler::initializeFinished);
+ QSignalSpy spy(&handler, &QOpcUaGenericStructHandler::initializedChanged);
auto success = handler.initialize();
QCOMPARE(success, true);
@@ -6341,7 +6341,7 @@ void Tst_QOpcUaClient::encodeCustomGenericStruct()
QOpcUaGenericStructHandler handler(opcuaClient);
- QSignalSpy spy(&handler, &QOpcUaGenericStructHandler::initializeFinished);
+ QSignalSpy spy(&handler, &QOpcUaGenericStructHandler::initializedChanged);
auto success = handler.initialize();
QCOMPARE(success, true);