Browse Source

Added QObject parents

develop
Robin Thoni 6 years ago
parent
commit
736b8ce88f

+ 1
- 1
src/modules/dns-client/includes/dns-client/QDnsClient.h View File

@@ -63,7 +63,7 @@ namespace QDns
63 63
                 quint16 port;
64 64
             };
65 65
 
66
-            explicit QDnsClient(const QHostAddress& host, quint16 port = 53);
66
+            explicit QDnsClient(const QHostAddress& host, quint16 port = 53, QObject* parent = nullptr);
67 67
 
68 68
             const QHostAddress &getHost() const;
69 69
 

+ 1
- 1
src/modules/dns-client/includes/dns-client/QDnsTcpClient.h View File

@@ -16,7 +16,7 @@ namespace QDns
16 16
         {
17 17
             Q_OBJECT
18 18
         public:
19
-            explicit QDnsTcpClient(const QHostAddress &host, quint16 port = 53);
19
+            explicit QDnsTcpClient(const QHostAddress &host, quint16 port = 53, QObject* parent = nullptr);
20 20
 
21 21
         public slots:
22 22
             void connectToHost() override;

+ 1
- 1
src/modules/dns-client/includes/dns-client/QDnsUdpClient.h View File

@@ -16,7 +16,7 @@ namespace QDns
16 16
         {
17 17
             Q_OBJECT
18 18
         public:
19
-            explicit QDnsUdpClient(const QHostAddress& host, quint16 port = 53);
19
+            explicit QDnsUdpClient(const QHostAddress& host, quint16 port = 53, QObject* parent = nullptr);
20 20
 
21 21
         public slots:
22 22
             void connectToHost() override;

+ 3
- 2
src/modules/dns-client/src/QDnsClient.cpp View File

@@ -9,8 +9,9 @@ namespace QDns
9 9
 {
10 10
     namespace Client
11 11
     {
12
-        QDnsClient::QDnsClient(const QHostAddress &host, quint16 port)
13
-            : m_host(host)
12
+        QDnsClient::QDnsClient(const QHostAddress &host, quint16 port, QObject* parent)
13
+            : QObject(parent)
14
+            , m_host(host)
14 15
             , m_port(port)
15 16
             , m_queryTimeout(5000)
16 17
             , m_state(ClientState::Disconnected)

+ 2
- 2
src/modules/dns-client/src/QDnsTcpClient.cpp View File

@@ -8,8 +8,8 @@ namespace QDns
8 8
 {
9 9
     namespace Client
10 10
     {
11
-        QDnsTcpClient::QDnsTcpClient(const QHostAddress &host, quint16 port)
12
-            : QDnsClient(host, port)
11
+        QDnsTcpClient::QDnsTcpClient(const QHostAddress &host, quint16 port, QObject* parent)
12
+            : QDnsClient(host, port, parent)
13 13
             , m_socket(new QTcpSocket(this))
14 14
             , m_size(0)
15 15
         {

+ 2
- 2
src/modules/dns-client/src/QDnsUdpClient.cpp View File

@@ -8,8 +8,8 @@ namespace QDns
8 8
 {
9 9
     namespace Client
10 10
     {
11
-        QDnsUdpClient::QDnsUdpClient(const QHostAddress &host, quint16 port)
12
-            : QDnsClient(host, port)
11
+        QDnsUdpClient::QDnsUdpClient(const QHostAddress &host, quint16 port, QObject* parent)
12
+            : QDnsClient(host, port, parent)
13 13
             , m_socket(new QUdpSocket(this))
14 14
         {
15 15
             connect(m_socket, &QUdpSocket::readyRead, this, &QDnsUdpClient::onReadyRead);

+ 2
- 0
src/modules/dns-server/includes/dns-server/QDnsServer.h View File

@@ -31,6 +31,8 @@ namespace QDns
31 31
                 std::function<void(SendAnswerParams)> sendAnswer;
32 32
             };
33 33
 
34
+            explicit QDnsServer(QObject* parent = nullptr);
35
+
34 36
         signals:
35 37
             void onRequest(OnRequestParams params); // TODO add onError
36 38
 

+ 1
- 1
src/modules/dns-server/includes/dns-server/QDnsTcpServer.h View File

@@ -18,7 +18,7 @@ namespace QDns
18 18
         {
19 19
             Q_OBJECT
20 20
         public:
21
-            QDnsTcpServer();
21
+            explicit QDnsTcpServer(QObject* parent = nullptr);
22 22
 
23 23
         public slots:
24 24
             bool start(const QHostAddress& host, quint16 port) override;

+ 1
- 1
src/modules/dns-server/includes/dns-server/QDnsUdpServer.h View File

@@ -18,7 +18,7 @@ namespace QDns
18 18
         {
19 19
             Q_OBJECT
20 20
         public:
21
-            QDnsUdpServer();
21
+            explicit QDnsUdpServer(QObject* parent = nullptr);
22 22
 
23 23
         public slots:
24 24
             bool start(const QHostAddress& host, quint16 port) override;

+ 4
- 0
src/modules/dns-server/src/QDnsServer.cpp View File

@@ -8,5 +8,9 @@ namespace QDns
8 8
 {
9 9
     namespace Server
10 10
     {
11
+        QDnsServer::QDnsServer(QObject* parent)
12
+            : QObject(parent)
13
+        {
14
+        }
11 15
     }
12 16
 }

+ 3
- 2
src/modules/dns-server/src/QDnsTcpServer.cpp View File

@@ -10,8 +10,9 @@ namespace QDns
10 10
 {
11 11
     namespace Server
12 12
     {
13
-        QDnsTcpServer::QDnsTcpServer()
14
-            : m_socket(new QTcpServer(this))
13
+        QDnsTcpServer::QDnsTcpServer(QObject* parent)
14
+            : QDnsServer(parent)
15
+            , m_socket(new QTcpServer(this))
15 16
         {
16 17
             connect(m_socket, &QTcpServer::newConnection, this, &QDnsTcpServer::onNewConnection);
17 18
         }

+ 3
- 2
src/modules/dns-server/src/QDnsUdpServer.cpp View File

@@ -8,8 +8,9 @@ namespace QDns
8 8
 {
9 9
     namespace Server
10 10
     {
11
-        QDnsUdpServer::QDnsUdpServer()
12
-            : m_socket(new QUdpSocket(this))
11
+        QDnsUdpServer::QDnsUdpServer(QObject* parent)
12
+            : QDnsServer(parent)
13
+            , m_socket(new QUdpSocket(this))
13 14
         {
14 15
             connect(m_socket, &QUdpSocket::readyRead, this, &QDnsUdpServer::onSocketReadyRead);
15 16
         }

Loading…
Cancel
Save