diff options
Diffstat (limited to '')
| -rw-r--r-- | c++-qt/tests/echo/main.cpp | 15 | ||||
| -rw-r--r-- | c++-qt/tests/echo/mainwnd.cpp | 39 | ||||
| -rw-r--r-- | c++-qt/tests/echo/mainwnd.h | 19 |
3 files changed, 47 insertions, 26 deletions
diff --git a/c++-qt/tests/echo/main.cpp b/c++-qt/tests/echo/main.cpp index 43ceae4..4925fc6 100644 --- a/c++-qt/tests/echo/main.cpp +++ b/c++-qt/tests/echo/main.cpp | |||
| @@ -1,14 +1,21 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007-2012 Xagasoft, All rights reserved. | ||
| 3 | * | ||
| 4 | * This file is part of the libgats library and is released under the | ||
| 5 | * terms of the license contained in the file LICENSE. | ||
| 6 | */ | ||
| 7 | |||
| 1 | #include <QApplication> | 8 | #include <QApplication> |
| 2 | 9 | ||
| 3 | #include "mainwnd.h" | 10 | #include "mainwnd.h" |
| 4 | 11 | ||
| 5 | int main( int argc, char *argv[] ) | 12 | int main( int argc, char *argv[] ) |
| 6 | { | 13 | { |
| 7 | QApplication app( argc, argv ); | 14 | QApplication app( argc, argv ); |
| 8 | 15 | ||
| 9 | MainWnd wnd; | 16 | MainWnd wnd; |
| 10 | wnd.show(); | 17 | wnd.show(); |
| 11 | 18 | ||
| 12 | return app.exec(); | 19 | return app.exec(); |
| 13 | } | 20 | } |
| 14 | 21 | ||
diff --git a/c++-qt/tests/echo/mainwnd.cpp b/c++-qt/tests/echo/mainwnd.cpp index 13c93a1..3995720 100644 --- a/c++-qt/tests/echo/mainwnd.cpp +++ b/c++-qt/tests/echo/mainwnd.cpp | |||
| @@ -1,10 +1,17 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007-2012 Xagasoft, All rights reserved. | ||
| 3 | * | ||
| 4 | * This file is part of the libgats library and is released under the | ||
| 5 | * terms of the license contained in the file LICENSE. | ||
| 6 | */ | ||
| 7 | |||
| 1 | #include "mainwnd.h" | 8 | #include "mainwnd.h" |
| 2 | 9 | ||
| 3 | MainWnd::MainWnd() | 10 | MainWnd::MainWnd() |
| 4 | { | 11 | { |
| 5 | pSrv = new QTcpServer( this ); | 12 | pSrv = new QTcpServer( this ); |
| 6 | connect( pSrv, SIGNAL(newConnection()), this, SLOT(newConnection())); | 13 | connect( pSrv, SIGNAL(newConnection()), this, SLOT(newConnection())); |
| 7 | pSrv->listen( QHostAddress::Any, 7317 ); | 14 | pSrv->listen( QHostAddress::Any, 7317 ); |
| 8 | } | 15 | } |
| 9 | 16 | ||
| 10 | MainWnd::~MainWnd() | 17 | MainWnd::~MainWnd() |
| @@ -13,24 +20,24 @@ MainWnd::~MainWnd() | |||
| 13 | 20 | ||
| 14 | void MainWnd::newConnection() | 21 | void MainWnd::newConnection() |
| 15 | { | 22 | { |
| 16 | while( pSrv->hasPendingConnections() ) | 23 | while( pSrv->hasPendingConnections() ) |
| 17 | { | 24 | { |
| 18 | QTcpSocket *pSock = pSrv->nextPendingConnection(); | 25 | QTcpSocket *pSock = pSrv->nextPendingConnection(); |
| 19 | Gats::GatsStream *pGats = new Gats::GatsStream( *pSock ); | 26 | Gats::GatsStream *pGats = new Gats::GatsStream( *pSock ); |
| 20 | connect( pSock, SIGNAL(readyRead()), pGats, SLOT(readObject()) ); | 27 | connect( pSock, SIGNAL(readyRead()), pGats, SLOT(readObject()) ); |
| 21 | connect( pGats, SIGNAL(objectRead( Gats::Object * )), | 28 | connect( pGats, SIGNAL(objectRead( Gats::Object * )), |
| 22 | this, SLOT(objectRead( Gats::Object * ))); | 29 | this, SLOT(objectRead( Gats::Object * ))); |
| 23 | } | 30 | } |
| 24 | } | 31 | } |
| 25 | 32 | ||
| 26 | void MainWnd::objectRead( Gats::Object *pObj ) | 33 | void MainWnd::objectRead( Gats::Object *pObj ) |
| 27 | { | 34 | { |
| 28 | ((Gats::GatsStream *)sender())->writeObject( pObj ); | 35 | ((Gats::GatsStream *)sender())->writeObject( pObj ); |
| 29 | 36 | ||
| 30 | Gats::Object *pCopy = pObj->clone(); | 37 | Gats::Object *pCopy = pObj->clone(); |
| 31 | delete pObj; | 38 | delete pObj; |
| 32 | 39 | ||
| 33 | ((Gats::GatsStream *)sender())->writeObject( pCopy ); | 40 | ((Gats::GatsStream *)sender())->writeObject( pCopy ); |
| 34 | 41 | ||
| 35 | delete pCopy; | 42 | delete pCopy; |
| 36 | } | 43 | } |
diff --git a/c++-qt/tests/echo/mainwnd.h b/c++-qt/tests/echo/mainwnd.h index 0afbd6a..71c5c8e 100644 --- a/c++-qt/tests/echo/mainwnd.h +++ b/c++-qt/tests/echo/mainwnd.h | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007-2012 Xagasoft, All rights reserved. | ||
| 3 | * | ||
| 4 | * This file is part of the libgats library and is released under the | ||
| 5 | * terms of the license contained in the file LICENSE. | ||
| 6 | */ | ||
| 7 | |||
| 1 | 8 | ||
| 2 | #include <QTcpServer> | 9 | #include <QTcpServer> |
| 3 | #include <QTcpSocket> | 10 | #include <QTcpSocket> |
| @@ -8,16 +15,16 @@ | |||
| 8 | 15 | ||
| 9 | class MainWnd : public QMainWindow | 16 | class MainWnd : public QMainWindow |
| 10 | { | 17 | { |
| 11 | Q_OBJECT; | 18 | Q_OBJECT; |
| 12 | public: | 19 | public: |
| 13 | QTcpServer *pSrv; | 20 | QTcpServer *pSrv; |
| 14 | 21 | ||
| 15 | MainWnd(); | 22 | MainWnd(); |
| 16 | virtual ~MainWnd(); | 23 | virtual ~MainWnd(); |
| 17 | 24 | ||
| 18 | public slots: | 25 | public slots: |
| 19 | void newConnection(); | 26 | void newConnection(); |
| 20 | void objectRead( Gats::Object *pObj ); | 27 | void objectRead( Gats::Object *pObj ); |
| 21 | 28 | ||
| 22 | signals: | 29 | signals: |
| 23 | }; | 30 | }; |
