summaryrefslogtreecommitdiff
path: root/noncore
authorwazlaf <wazlaf>2002-10-20 14:53:08 (UTC)
committer wazlaf <wazlaf>2002-10-20 14:53:08 (UTC)
commit18ba3be9ca69c42476e310649e3068d2d5f8a03b (patch) (unidiff)
treed6a68e8f1a319ef8320d714356beebcf440a630f /noncore
parent9f442f5af601d1e15bb4d0509ed012e61609260d (diff)
downloadopie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.zip
opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.tar.gz
opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.tar.bz2
scripting fixed (moved from emulation_layer to emulation_handler). Scripts now use QByteArray instead of QString
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp34
-rw-r--r--noncore/apps/opie-console/emulation_handler.h19
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp36
-rw-r--r--noncore/apps/opie-console/emulation_layer.h18
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp16
-rw-r--r--noncore/apps/opie-console/script.cpp15
-rw-r--r--noncore/apps/opie-console/script.h6
7 files changed, 68 insertions, 76 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 8846959..df8e573 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -8,3 +8,3 @@
8#include "emulation_handler.h" 8#include "emulation_handler.h"
9 9#include "script.h"
10 10
@@ -15,2 +15,3 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c
15 m_teWid->setMinimumSize(150, 70 ); 15 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0;
16 parent->resize( m_teWid->calcSize(80, 24 ) ); 17 parent->resize( m_teWid->calcSize(80, 24 ) );
@@ -30,2 +31,4 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c
30EmulationHandler::~EmulationHandler() { 31EmulationHandler::~EmulationHandler() {
32 if (isRecording())
33 clearScript();
31 delete m_teEmu; 34 delete m_teEmu;
@@ -33,2 +36,3 @@ EmulationHandler::~EmulationHandler() {
33} 36}
37
34void EmulationHandler::load( const Profile& prof) { 38void EmulationHandler::load( const Profile& prof) {
@@ -47,2 +51,4 @@ void EmulationHandler::recvEmulation(const char* src, int len ) {
47 51
52 if (isRecording())
53 m_script->append(ar);
48 emit send(ar); 54 emit send(ar);
@@ -147 +153,27 @@ QPushButton* EmulationHandler::cornerButton() {
147} 153}
154
155
156Script *EmulationHandler::script() {
157 return m_script;
158}
159
160bool EmulationHandler::isRecording() {
161 return (m_script != 0);
162}
163
164void EmulationHandler::startRecording() {
165 if (!isRecording())
166 m_script = new Script();
167}
168
169void EmulationHandler::clearScript() {
170 if (isRecording()) {
171 delete m_script;
172 m_script = 0;
173 }
174}
175
176void EmulationHandler::runScript(const Script *script) {
177 emit send(script->script());
178}
179
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h
index 9ceafc6..7ca2cf3 100644
--- a/noncore/apps/opie-console/emulation_handler.h
+++ b/noncore/apps/opie-console/emulation_handler.h
@@ -31,2 +31,3 @@ class TEmulation;
31class QFont; 31class QFont;
32class Script;
32class EmulationHandler : public QObject { 33class EmulationHandler : public QObject {
@@ -50,2 +51,18 @@ public:
50 QPushButton* cornerButton(); 51 QPushButton* cornerButton();
52
53 /* Scripts */
54 /* Create a new script and record all typed characters */
55 void startRecording();
56
57 /* Return whether we are currently recording a script */
58 bool isRecording();
59
60 /* Return the current script (or NULL) */
61 Script *script();
62
63 /* Stop recording and remove the current script from memory */
64 void clearScript();
65
66 /* Run a script by forwarding its keys to the EmulationLayer */
67 void runScript(const Script *);
51 68
@@ -69,3 +86,3 @@ private:
69 TEmulation* m_teEmu; 86 TEmulation* m_teEmu;
70 87 Script * m_script;
71}; 88};
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 265c11f..6a2679e 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -109,3 +109,2 @@ EmulationLayer::EmulationLayer( WidgetLayer* gui )
109 connected = FALSE; 109 connected = FALSE;
110 m_script = 0;
111 110
@@ -135,4 +134,2 @@ EmulationLayer::~EmulationLayer()
135 delete screen[1]; 134 delete screen[1];
136 if (isRecording())
137 clearScript();
138 bulk_timer.stop(); 135 bulk_timer.stop();
@@ -234,5 +231,2 @@ void EmulationLayer::onKeyPress( QKeyEvent* ev )
234 231
235 /* Are we currently recording a script? If so, store the typed character */
236 if (isRecording())
237 m_script->appendString(ev->text());
238 emit sndBlock( (QByteArray) c ); 232 emit sndBlock( (QByteArray) c );
@@ -263,31 +257,2 @@ void EmulationLayer::onRcvBlock(const QByteArray &s )
263 257
264// Scripts ----------------------------------------------------------------- --
265
266
267Script *EmulationLayer::script() {
268 return m_script;
269}
270
271bool EmulationLayer::isRecording() {
272 return (m_script != 0);
273}
274
275void EmulationLayer::startRecording() {
276 if (!isRecording())
277 m_script = new Script();
278}
279
280void EmulationLayer::clearScript() {
281 if (isRecording()) {
282
283 }
284}
285
286void EmulationLayer::runScript(const Script *script) {
287 QByteArray a = QByteArray();
288 QString str = script->script();
289 a.setRawData(str.ascii(), str.length());
290 emit sndBlock(a);
291}
292
293// Selection --------------------------------------------------------------- -- 258// Selection --------------------------------------------------------------- --
@@ -408 +373,2 @@ void EmulationLayer::setColumns(int columns)
408} 373}
374
diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h
index 928ad04..73e5bf6 100644
--- a/noncore/apps/opie-console/emulation_layer.h
+++ b/noncore/apps/opie-console/emulation_layer.h
@@ -34,3 +34,2 @@
34#include "keytrans.h" 34#include "keytrans.h"
35#include "script.h"
36 35
@@ -107,18 +106,2 @@ public:
107 106
108 /* Scripts */
109
110 /* Create a new script and record all typed characters */
111 void startRecording();
112
113 /* Return whether we are currently recording a script */
114 bool isRecording();
115
116 /* Return the current script (or NULL) */
117 Script *script();
118
119 /* Stop recording and remove the current script from memory */
120 void clearScript();
121
122 /* Run a script by forwarding its keys to the EmulationLayer */
123 void runScript(const Script *);
124protected: 107protected:
@@ -158,3 +141,2 @@ private:
158 int bulk_incnt; // bulk counter 141 int bulk_incnt; // bulk counter
159 Script *m_script;
160 142
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index a7541f0..49f9653 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -288,6 +288,5 @@ void MainWindow::slotNew() {
288void MainWindow::slotRecordScript() { 288void MainWindow::slotRecordScript() {
289/* if (currentSession()) { 289 if (currentSession()) {
290 currentSession()->emulationLayer()->startRecording(); 290 currentSession()->emulationHandler()->startRecording();
291 } 291 }
292 */
293} 292}
@@ -295,3 +294,3 @@ void MainWindow::slotRecordScript() {
295void MainWindow::slotSaveScript() { 294void MainWindow::slotSaveScript() {
296/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 295 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
297 MimeTypes types; 296 MimeTypes types;
@@ -302,7 +301,6 @@ void MainWindow::slotSaveScript() {
302 if (!filename.isEmpty()) { 301 if (!filename.isEmpty()) {
303 currentSession()->emulationLayer()->script()->saveTo(filename); 302 currentSession()->emulationHandler()->script()->saveTo(filename);
304 currentSession()->emulationLayer()->clearScript(); 303 currentSession()->emulationHandler()->clearScript();
305 } 304 }
306 } 305 }
307 */
308} 306}
@@ -310,3 +308,2 @@ void MainWindow::slotSaveScript() {
310void MainWindow::slotRunScript() { 308void MainWindow::slotRunScript() {
311/*
312 if (currentSession()) { 309 if (currentSession()) {
@@ -319,6 +316,5 @@ void MainWindow::slotRunScript() {
319 Script script(DocLnk(filename).file()); 316 Script script(DocLnk(filename).file());
320 currentSession()->emulationLayer()->runScript(&script); 317 currentSession()->emulationHandler()->runScript(&script);
321 } 318 }
322 } 319 }
323 */
324} 320}
diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp
index a09fab6..9cb1cd3 100644
--- a/noncore/apps/opie-console/script.cpp
+++ b/noncore/apps/opie-console/script.cpp
@@ -9,6 +9,3 @@ Script::Script(const QString fileName) {
9 QFile file(fileName); 9 QFile file(fileName);
10 QTextStream stream(&file); 10 m_script = file.readAll();
11 while (!stream.atEnd()) {
12 appendString(stream.readLine());
13 }
14} 11}
@@ -18,3 +15,3 @@ void Script::saveTo(const QString fileName) const {
18 file.open(IO_WriteOnly); 15 file.open(IO_WriteOnly);
19 file.writeBlock(m_script.ascii(), m_script.length()); 16 file.writeBlock(m_script);
20 file.close(); 17 file.close();
@@ -23,7 +20,9 @@ void Script::saveTo(const QString fileName) const {
23 20
24void Script::appendString(const QString string) { 21void Script::append(const QByteArray &data) {
25 m_script += string; 22 int size = m_script.size();
23 m_script.resize(size + data.size());
24 memcpy(m_script.data() + size, data.data(), data.size());
26} 25}
27 26
28QString Script::script() const { 27QByteArray Script::script() const {
29 return m_script; 28 return m_script;
diff --git a/noncore/apps/opie-console/script.h b/noncore/apps/opie-console/script.h
index dc2351b..b3eac7f 100644
--- a/noncore/apps/opie-console/script.h
+++ b/noncore/apps/opie-console/script.h
@@ -17,3 +17,3 @@ public:
17 /* Append a line to the script */ 17 /* Append a line to the script */
18 void appendString(const QString string); 18 void append(const QByteArray &data);
19 19
@@ -23,5 +23,5 @@ public:
23 /* Return the script's content */ 23 /* Return the script's content */
24 QString script() const; 24 QByteArray script() const;
25protected: 25protected:
26 QString m_script; 26 QByteArray m_script;
27}; 27};