-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 41 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 62 |
2 files changed, 103 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp new file mode 100644 index 0000000..787de67 --- a/dev/null +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -0,0 +1,41 @@ | |||
1 | #include <qwidget.h> | ||
2 | |||
3 | #include "TEWidget.h" | ||
4 | #include "TEmuVt102.h" | ||
5 | |||
6 | #include "emulation_handler.h" | ||
7 | |||
8 | |||
9 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent, const char* name ) | ||
10 | : QObject(0, name ) | ||
11 | { | ||
12 | load(prof ); | ||
13 | m_teWid = new TEWidget( parent, "TerminalMain" ); | ||
14 | parent->resize( m_teWid->calcSize(80, 24 ) ); | ||
15 | m_teEmu = new TEmuVt102(m_teWid ); | ||
16 | |||
17 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), | ||
18 | this, SIGNAL(changeSize(int, int) ) ); | ||
19 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), | ||
20 | this, SLOT(recvEmulation(const char*, int) ) ); | ||
21 | |||
22 | } | ||
23 | EmulationHandler::~EmulationHandler() { | ||
24 | delete m_teEmu; | ||
25 | delete m_teWid; | ||
26 | } | ||
27 | void EmulationHandler::load( const Profile& ) { | ||
28 | |||
29 | } | ||
30 | void EmulationHandler::recv( const QByteArray& ar) { | ||
31 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | ||
32 | } | ||
33 | void EmulationHandler::recvEmulation(const char* src, int len ) { | ||
34 | QByteArray ar(len); | ||
35 | memcpy(ar.data(), src, sizeof(char) * len ); | ||
36 | |||
37 | emit send(ar); | ||
38 | } | ||
39 | QWidget* EmulationHandler::widget() { | ||
40 | return m_teWid; | ||
41 | } | ||
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h new file mode 100644 index 0000000..58b94bc --- a/dev/null +++ b/noncore/apps/opie-console/emulation_handler.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef OPIE_EMULATION_HANDLER_H | ||
2 | #define OPIE_EMULATION_HANDLER_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qcstring.h> | ||
6 | |||
7 | /* | ||
8 | * Badly ibotty lacks the time to finish | ||
9 | * his widget in time.. | ||
10 | * Never the less we've to have an EmulationWidget | ||
11 | * This is why I'm taking the inferior not cleaned | ||
12 | * up TE* KDE STUFF | ||
13 | */ | ||
14 | |||
15 | /** | ||
16 | * This is the layer above the IOLayer* | ||
17 | * This nice QObject here will get stuff from | ||
18 | * got a slot and a signal | ||
19 | * the signal for data | ||
20 | * the slot for receiving | ||
21 | * it'll set up the widget internally | ||
22 | * and manage the communication between | ||
23 | * the pre QByteArray world! | ||
24 | */ | ||
25 | class Profile; | ||
26 | class QWidget; | ||
27 | class TEWidget; | ||
28 | class TEmulation; | ||
29 | class EmulationHandler : public QObject { | ||
30 | Q_OBJECT | ||
31 | public: | ||
32 | /** | ||
33 | * simple c'tor the parent of the TEWdiget | ||
34 | * and a name | ||
35 | * and a Profile | ||
36 | */ | ||
37 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); | ||
38 | |||
39 | /** | ||
40 | * delete all components | ||
41 | */ | ||
42 | ~EmulationHandler(); | ||
43 | |||
44 | void load( const Profile& ); | ||
45 | QWidget* widget(); | ||
46 | signals: | ||
47 | void send( const QByteArray& ); | ||
48 | void changeSize(int rows, int cols ); | ||
49 | |||
50 | public slots: | ||
51 | void recv( const QByteArray& ); | ||
52 | |||
53 | private slots: | ||
54 | void recvEmulation( const char*, int len ); | ||
55 | |||
56 | private: | ||
57 | TEWidget* m_teWid; | ||
58 | TEmulation* m_teEmu; | ||
59 | |||
60 | }; | ||
61 | |||
62 | #endif | ||