summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLena Biliaieva <lena.biliaieva@qt.io>2023-12-11 16:24:01 +0100
committerLena Biliaieva <lena.biliaieva@qt.io>2023-12-18 14:14:16 +0100
commit3ed267e722fb232296c5b5bc903ee076bb19035e (patch)
treeedc0584367109a984bc64db652cde3f9d3ef1339 /examples
parenta7b6fb5f4fa7b118353b9a9f2a7cdab59e33c677 (diff)
Review QtOpcUa Viewer Ex: Fix includes
Clean up #includes, use forward class declarations. Fix spacing. Add explicit. Task-number: QTBUG-119786 Pick-to: 6.7 Change-Id: Ibf8828eb038cdbcff178c406f275e2c8ed29a172 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/opcua/opcuaviewer/mainwindow.cpp19
-rw-r--r--examples/opcua/opcuaviewer/mainwindow.h7
-rw-r--r--examples/opcua/opcuaviewer/opcuamodel.cpp6
-rw-r--r--examples/opcua/opcuaviewer/opcuamodel.h13
-rw-r--r--examples/opcua/opcuaviewer/treeitem.cpp31
-rw-r--r--examples/opcua/opcuaviewer/treeitem.h13
6 files changed, 47 insertions, 42 deletions
diff --git a/examples/opcua/opcuaviewer/mainwindow.cpp b/examples/opcua/opcuaviewer/mainwindow.cpp
index ae3d3d7..587f5e9 100644
--- a/examples/opcua/opcuaviewer/mainwindow.cpp
+++ b/examples/opcua/opcuaviewer/mainwindow.cpp
@@ -2,22 +2,21 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
-#include "opcuamodel.h"
-#include "certificatedialog.h"
#include "ui_mainwindow.h"
+#include "certificatedialog.h"
+#include "opcuamodel.h"
+#include "treeitem.h"
-#include <QApplication>
-#include <QDir>
-#include <QMessageBox>
-#include <QStandardPaths>
-#include <QTextCharFormat>
-#include <QTextBlock>
-#include <QOpcUaProvider>
#include <QOpcUaAuthenticationInformation>
#include <QOpcUaErrorState>
+#include <QOpcUaGenericStructHandler>
#include <QOpcUaHistoryReadResponse>
+#include <QOpcUaProvider>
-#include <QOpcUaHistoryReadRawRequest>
+#include <QApplication>
+#include <QDir>
+#include <QMessageBox>
+#include <QStandardPaths>
using namespace Qt::Literals::StringLiterals;
diff --git a/examples/opcua/opcuaviewer/mainwindow.h b/examples/opcua/opcuaviewer/mainwindow.h
index 71b75c9..c3d8929 100644
--- a/examples/opcua/opcuaviewer/mainwindow.h
+++ b/examples/opcua/opcuaviewer/mainwindow.h
@@ -4,12 +4,9 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QItemSelection>
-#include <QMainWindow>
#include <QOpcUaClient>
-#include <QOpcUaGenericStructHandler>
#include <QOpcUaHistoryData>
-#include <QOpcUaProvider>
+#include <QMainWindow>
class OpcUaModel;
@@ -17,6 +14,8 @@ QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
+class QOpcUaGenericStructHandler;
+class QOpcUaProvider;
QT_END_NAMESPACE
class MainWindow : public QMainWindow
diff --git a/examples/opcua/opcuaviewer/opcuamodel.cpp b/examples/opcua/opcuaviewer/opcuamodel.cpp
index 08d7e46..0ae330f 100644
--- a/examples/opcua/opcuaviewer/opcuamodel.cpp
+++ b/examples/opcua/opcuaviewer/opcuamodel.cpp
@@ -3,14 +3,18 @@
#include "opcuamodel.h"
#include "treeitem.h"
+
#include <QOpcUaClient>
-#include <QOpcUaNode>
#include <QIcon>
OpcUaModel::OpcUaModel(QObject *parent) : QAbstractItemModel(parent)
{
}
+OpcUaModel::~OpcUaModel()
+{
+}
+
void OpcUaModel::setOpcUaClient(QOpcUaClient *client)
{
beginResetModel();
diff --git a/examples/opcua/opcuaviewer/opcuamodel.h b/examples/opcua/opcuaviewer/opcuamodel.h
index 134c059..a8af9de 100644
--- a/examples/opcua/opcuaviewer/opcuamodel.h
+++ b/examples/opcua/opcuaviewer/opcuamodel.h
@@ -4,22 +4,23 @@
#ifndef OPCUAMODEL_H
#define OPCUAMODEL_H
-#include "treeitem.h"
-
#include <QAbstractItemModel>
-#include <QOpcUaClient>
-#include <QOpcUaNode>
-#include <QOpcUaGenericStructHandler>
#include <memory>
class TreeItem;
+QT_BEGIN_NAMESPACE
+class QOpcUaClient;
+class QOpcUaGenericStructHandler;
+QT_END_NAMESPACE
+
class OpcUaModel : public QAbstractItemModel
{
Q_OBJECT
public:
- OpcUaModel(QObject *parent = nullptr);
+ explicit OpcUaModel(QObject *parent = nullptr);
+ ~OpcUaModel();
void setOpcUaClient(QOpcUaClient *);
void setGenericStructHandler(QOpcUaGenericStructHandler *handler);
diff --git a/examples/opcua/opcuaviewer/treeitem.cpp b/examples/opcua/opcuaviewer/treeitem.cpp
index 8211990..c8ced61 100644
--- a/examples/opcua/opcuaviewer/treeitem.cpp
+++ b/examples/opcua/opcuaviewer/treeitem.cpp
@@ -3,17 +3,9 @@
#include "treeitem.h"
#include "opcuamodel.h"
-#include <QOpcUaArgument>
-#include <QOpcUaAxisInformation>
-#include <QOpcUaClient>
-#include <QOpcUaComplexNumber>
-#include <QOpcUaDoubleComplexNumber>
-#include <QOpcUaEUInformation>
-#include <QOpcUaExtensionObject>
-#include <QOpcUaLocalizedText>
-#include <QOpcUaQualifiedName>
-#include <QOpcUaRange>
-#include <QOpcUaXValue>
+
+#include <QOpcUaGenericStructHandler>
+
#include <QMetaEnum>
#include <QPixmap>
@@ -21,15 +13,17 @@ using namespace Qt::Literals::StringLiterals;
const int numberOfDisplayColumns = 8; // NodeId, Value, NodeClass, DataType, BrowseName, DisplayName, Description, Historizing
-TreeItem::TreeItem(OpcUaModel *model) : QObject(nullptr)
- , mModel(model)
+TreeItem::TreeItem(OpcUaModel *model)
+ : QObject(nullptr)
+ , mModel(model)
{
}
-TreeItem::TreeItem(QOpcUaNode *node, OpcUaModel *model, TreeItem *parent) : QObject(parent)
- , mOpcNode(node)
- , mModel(model)
- , mParentItem(parent)
+TreeItem::TreeItem(QOpcUaNode *node, OpcUaModel *model, TreeItem *parent)
+ : QObject(parent)
+ , mOpcNode(node)
+ , mModel(model)
+ , mParentItem(parent)
{
connect(mOpcNode.get(), &QOpcUaNode::attributeRead, this, &TreeItem::handleAttributes);
connect(mOpcNode.get(), &QOpcUaNode::attributeUpdated, this, &TreeItem::handleAttributes);
@@ -42,8 +36,9 @@ TreeItem::TreeItem(QOpcUaNode *node, OpcUaModel *model, TreeItem *parent) : QObj
| QOpcUa::NodeAttribute::BrowseName
| QOpcUa::NodeAttribute::DisplayName
| QOpcUa::NodeAttribute::Historizing
- ))
+ )) {
qWarning() << "Reading attributes" << mOpcNode->nodeId() << "failed";
+ }
}
TreeItem::TreeItem(QOpcUaNode *node, OpcUaModel *model, const QOpcUaReferenceDescription &browsingData, TreeItem *parent) : TreeItem(node, model, parent)
diff --git a/examples/opcua/opcuaviewer/treeitem.h b/examples/opcua/opcuaviewer/treeitem.h
index 30ca366..a165d03 100644
--- a/examples/opcua/opcuaviewer/treeitem.h
+++ b/examples/opcua/opcuaviewer/treeitem.h
@@ -4,15 +4,22 @@
#ifndef TREEITEM_H
#define TREEITEM_H
+#include <qopcuatype.h>
+#include <qopcuareferencedescription.h>
+
#include <QObject>
-#include <QOpcUaEUInformation>
-#include <QOpcUaNode>
-#include <QOpcUaRange>
#include <memory>
class OpcUaModel;
+QT_BEGIN_NAMESPACE
+class QOpcUaEUInformation;
+class QOpcUaLocalizedText;
+class QOpcUaNode;
+class QOpcUaRange;
+QT_END_NAMESPACE
+
class TreeItem : public QObject
{
Q_OBJECT