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