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
4#ifndef OPCUASERVERDISCOVERY_P_H
5#define OPCUASERVERDISCOVERY_P_H
6
7#include <private/opcuastatus_p.h>
8#include <private/opcuaconnection_p.h>
9
10#include <QtOpcUa/qopcuatype.h>
11#include <QOpcUaApplicationDescription>
12#include <QStandardItemModel>
13#include <QtQml/qqml.h>
14
15//
16// W A R N I N G
17// -------------
18//
19// This file is not part of the Qt API. It exists purely as an
20// implementation detail. This header file may change from version to
21// version without notice, or even be removed.
22//
23// We mean it.
24//
25
26QT_BEGIN_NAMESPACE
27
28class OpcUaServerDiscovery : public QStandardItemModel
29{
30 Q_OBJECT
31 Q_PROPERTY(QString discoveryUrl READ discoveryUrl WRITE setDiscoveryUrl NOTIFY discoveryUrlChanged)
32 Q_PROPERTY(int count READ count NOTIFY countChanged)
33 Q_PROPERTY(OpcUaStatus status READ status NOTIFY statusChanged)
34 Q_PROPERTY(OpcUaConnection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
35
36 QML_NAMED_ELEMENT(ServerDiscovery)
37 QML_ADDED_IN_VERSION(5, 13)
38
39public:
40 OpcUaServerDiscovery(QObject *parent = nullptr);
41 ~OpcUaServerDiscovery();
42
43 const QString &discoveryUrl() const;
44 void setDiscoveryUrl(const QString &discoverUrl);
45 int count() const;
46 Q_INVOKABLE QOpcUaApplicationDescription at(int row) const;
47 const OpcUaStatus &status() const;
48 void setConnection(OpcUaConnection *);
49 OpcUaConnection *connection();
50
51signals:
52 void discoveryUrlChanged();
53 void serversChanged();
54 void countChanged();
55 void statusChanged();
56 void connectionChanged(OpcUaConnection *);
57
58private slots:
59 void connectSignals();
60 void handleServers(const QList<QOpcUaApplicationDescription> &servers, QOpcUa::UaStatusCode statusCode, const QUrl &requestUrl);
61 void startFindServers();
62
63private:
64 void clearData();
65
66 QString m_discoveryUrl;
67 OpcUaConnection *m_connection = nullptr;
68 OpcUaStatus m_status;
69};
70
71
72QT_END_NAMESPACE
73
74#endif // OPCUASERVERDISCOVERY_P_H
75

source code of qtopcua/src/declarative_opcua/opcuaserverdiscovery_p.h