diff options
Diffstat (limited to '')
-rw-r--r-- | c++-libbu++/src/gatscon/clientwidget.cpp | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/c++-libbu++/src/gatscon/clientwidget.cpp b/c++-libbu++/src/gatscon/clientwidget.cpp index 941d9fa..f13e736 100644 --- a/c++-libbu++/src/gatscon/clientwidget.cpp +++ b/c++-libbu++/src/gatscon/clientwidget.cpp | |||
@@ -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 | #include "clientwidget.h" | 8 | #include "clientwidget.h" |
2 | #include "clientthread.h" | 9 | #include "clientthread.h" |
3 | 10 | ||
@@ -14,16 +21,16 @@ | |||
14 | using namespace Bu; | 21 | using namespace Bu; |
15 | 22 | ||
16 | ClientWidget::ClientWidget( QWidget *pParent, const QByteArray &baHost, | 23 | ClientWidget::ClientWidget( QWidget *pParent, const QByteArray &baHost, |
17 | int iPort ) : | 24 | int iPort ) : |
18 | QWidget( pParent ) | 25 | QWidget( pParent ) |
19 | { | 26 | { |
20 | setupUi( this ); | 27 | setupUi( this ); |
21 | 28 | ||
22 | pCli = new ClientThread( this, baHost, iPort ); | 29 | pCli = new ClientThread( this, baHost, iPort ); |
23 | connect( pCli, SIGNAL(recv( Gats::Object *)), | 30 | connect( pCli, SIGNAL(recv( Gats::Object *)), |
24 | this, SLOT(recv(Gats::Object *)), Qt::QueuedConnection ); | 31 | this, SLOT(recv(Gats::Object *)), Qt::QueuedConnection ); |
25 | 32 | ||
26 | pCli->start(); | 33 | pCli->start(); |
27 | } | 34 | } |
28 | 35 | ||
29 | ClientWidget::~ClientWidget() | 36 | ClientWidget::~ClientWidget() |
@@ -32,51 +39,51 @@ ClientWidget::~ClientWidget() | |||
32 | 39 | ||
33 | void ClientWidget::saveTo( const QString &sFile ) | 40 | void ClientWidget::saveTo( const QString &sFile ) |
34 | { | 41 | { |
35 | File fOut( sFile.toAscii().constData(), File::WriteNew ); | 42 | File fOut( sFile.toAscii().constData(), File::WriteNew ); |
36 | Gats::GatsStream gsOut( fOut ); | 43 | Gats::GatsStream gsOut( fOut ); |
37 | QTreeWidgetItem *pRoot = twHistory->invisibleRootItem(); | 44 | QTreeWidgetItem *pRoot = twHistory->invisibleRootItem(); |
38 | for( int j = 0; j < pRoot->childCount(); j++ ) | 45 | for( int j = 0; j < pRoot->childCount(); j++ ) |
39 | { | 46 | { |
40 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); | 47 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); |
41 | gsOut.writeObject( pObj ); | 48 | gsOut.writeObject( pObj ); |
42 | delete pObj; | 49 | delete pObj; |
43 | } | 50 | } |
44 | } | 51 | } |
45 | 52 | ||
46 | void ClientWidget::send() | 53 | void ClientWidget::send() |
47 | { | 54 | { |
48 | try | 55 | try |
49 | { | 56 | { |
50 | Gats::Object *pObj = Gats::Object::strToGats( | 57 | Gats::Object *pObj = Gats::Object::strToGats( |
51 | leGats->text().toAscii().constData() | 58 | leGats->text().toAscii().constData() |
52 | ); | 59 | ); |
53 | sio << "Send: " << *pObj << sio.nl; | 60 | sio << "Send: " << *pObj << sio.nl; |
54 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | 61 | QTreeWidgetItem *pIt = new QTreeWidgetItem( |
55 | twHistory->invisibleRootItem() | 62 | twHistory->invisibleRootItem() |
56 | ); | 63 | ); |
57 | pIt->setText( 0, "send" ); | 64 | pIt->setText( 0, "send" ); |
58 | gatsToTree( pIt, pObj ); | 65 | gatsToTree( pIt, pObj ); |
59 | pCli->send( pObj ); | 66 | pCli->send( pObj ); |
60 | delete pObj; | 67 | delete pObj; |
61 | 68 | ||
62 | leGats->setText(""); | 69 | leGats->setText(""); |
63 | leGats->setFocus(); | 70 | leGats->setFocus(); |
64 | } | 71 | } |
65 | catch( Bu::ExceptionBase &e ) | 72 | catch( Bu::ExceptionBase &e ) |
66 | { | 73 | { |
67 | QMessageBox::critical( this, "Gats Console - Error", e.what() ); | 74 | QMessageBox::critical( this, "Gats Console - Error", e.what() ); |
68 | } | 75 | } |
69 | } | 76 | } |
70 | 77 | ||
71 | void ClientWidget::recv( Gats::Object *pObj ) | 78 | void ClientWidget::recv( Gats::Object *pObj ) |
72 | { | 79 | { |
73 | sio << "Recv: " << *pObj << sio.nl; | 80 | sio << "Recv: " << *pObj << sio.nl; |
74 | 81 | ||
75 | QTreeWidgetItem *pIt = new QTreeWidgetItem( | 82 | QTreeWidgetItem *pIt = new QTreeWidgetItem( |
76 | twHistory->invisibleRootItem() | 83 | twHistory->invisibleRootItem() |
77 | ); | 84 | ); |
78 | pIt->setText( 0, "recv" ); | 85 | pIt->setText( 0, "recv" ); |
79 | gatsToTree( pIt, pObj ); | 86 | gatsToTree( pIt, pObj ); |
80 | delete pObj; | 87 | delete pObj; |
81 | } | 88 | } |
82 | 89 | ||