-rw-r--r-- | noncore/apps/opie-console/io_layer.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.h | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 67 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 13 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.h | 66 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileconfig.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileconfig.h | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 62 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.h | 30 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.cpp | 28 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.h | 28 |
19 files changed, 472 insertions, 33 deletions
diff --git a/noncore/apps/opie-console/io_layer.cpp b/noncore/apps/opie-console/io_layer.cpp index ca1deb8..563a252 100644 --- a/noncore/apps/opie-console/io_layer.cpp +++ b/noncore/apps/opie-console/io_layer.cpp | |||
@@ -1,14 +1,14 @@ | |||
1 | #include "io_layer.h" | 1 | #include "io_layer.h" |
2 | 2 | ||
3 | IOLayer::IOLayer() | 3 | IOLayer::IOLayer() |
4 | : QObject() | 4 | : QObject() |
5 | { | 5 | { |
6 | } | 6 | } |
7 | 7 | ||
8 | IOLayer::IOLayer(const Config &) | 8 | IOLayer::IOLayer(const Profile &) |
9 | : QObject() | 9 | : QObject() |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | IOLayer::~IOLayer() { | 13 | IOLayer::~IOLayer() { |
14 | } | 14 | } |
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index 537c851..2f1ceef 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h | |||
@@ -1,59 +1,60 @@ | |||
1 | #ifndef OPIE_IO_LAYER_H | 1 | #ifndef OPIE_IO_LAYER_H |
2 | #define OPIE_IO_LAYER_H | 2 | #define OPIE_IO_LAYER_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | 6 | ||
7 | #include "profile.h" | ||
8 | |||
7 | /** | 9 | /** |
8 | * This is the base class for IO Layers | 10 | * This is the base class for IO Layers |
9 | * It will used to sent and recv data( QByteArray ) | 11 | * It will used to sent and recv data( QByteArray ) |
10 | * it | 12 | * it |
11 | */ | 13 | */ |
12 | class Config; | ||
13 | class IOLayer : public QObject { | 14 | class IOLayer : public QObject { |
14 | Q_OBJECT | 15 | Q_OBJECT |
15 | public: | 16 | public: |
16 | enum Error { | 17 | enum Error { |
17 | NoError = -1, | 18 | NoError = -1, |
18 | Refuse = 0, | 19 | Refuse = 0, |
19 | CouldNotOpen =1, | 20 | CouldNotOpen =1, |
20 | ClosedUnexpected =2, | 21 | ClosedUnexpected =2, |
21 | ClosedError =3, | 22 | ClosedError =3, |
22 | Terminate = 4 | 23 | Terminate = 4 |
23 | /* add more errors here */ | 24 | /* add more errors here */ |
24 | }; | 25 | }; |
25 | /** | 26 | /** |
26 | * a small c'tor | 27 | * a small c'tor |
27 | */ | 28 | */ |
28 | IOLayer(); | 29 | IOLayer(); |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * create an IOLayer instance from a config file | 32 | * create an IOLayer instance from a config file |
32 | * the currently set group stores the profile/session | 33 | * the currently set group stores the profile/session |
33 | * information | 34 | * information |
34 | */ | 35 | */ |
35 | IOLayer( const Config& ); | 36 | IOLayer( const Profile& ); |
36 | 37 | ||
37 | /** | 38 | /** |
38 | * destructor | 39 | * destructor |
39 | */ | 40 | */ |
40 | virtual ~IOLayer(); | 41 | virtual ~IOLayer(); |
41 | 42 | ||
42 | /** | 43 | /** |
43 | * a small internal identifier | 44 | * a small internal identifier |
44 | */ | 45 | */ |
45 | virtual QString identifier() const = 0; | 46 | virtual QString identifier() const = 0; |
46 | 47 | ||
47 | /** | 48 | /** |
48 | * a short name | 49 | * a short name |
49 | */ | 50 | */ |
50 | virtual QString name() const = 0; | 51 | virtual QString name() const = 0; |
51 | signals: | 52 | signals: |
52 | /** | 53 | /** |
53 | * received input as QCString | 54 | * received input as QCString |
54 | */ | 55 | */ |
55 | virtual void received( const QByteArray& ) = 0; | 56 | virtual void received( const QByteArray& ) = 0; |
56 | 57 | ||
57 | /** | 58 | /** |
58 | * an error occured | 59 | * an error occured |
59 | * int for the error number | 60 | * int for the error number |
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index c9155d1..b495f39 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -1,151 +1,152 @@ | |||
1 | #include <fcntl.h> | 1 | #include <fcntl.h> |
2 | #include <termios.h> | 2 | #include <termios.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | 6 | ||
7 | IOSerial::IOSerial(const Config &config) : IOLayer(config) { | 7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { |
8 | m_fd = 0; | 8 | m_fd = 0; |
9 | reload(config); | 9 | reload(config); |
10 | } | 10 | } |
11 | 11 | ||
12 | 12 | ||
13 | IOSerial::~IOSerial() { | 13 | IOSerial::~IOSerial() { |
14 | if (m_fd) { | 14 | if (m_fd) { |
15 | close(); | 15 | close(); |
16 | } | 16 | } |
17 | } | 17 | } |
18 | 18 | ||
19 | void IOSerial::send(const QByteArray &data) { | 19 | void IOSerial::send(const QByteArray &data) { |
20 | if (m_fd) { | 20 | if (m_fd) { |
21 | write(m_fd, data.data(), data.size()); | 21 | write(m_fd, data.data(), data.size()); |
22 | } else { | 22 | } else { |
23 | emit error(Refuse, tr("Not connected")); | 23 | emit error(Refuse, tr("Not connected")); |
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 | ||
27 | void IOSerial::close() { | 27 | void IOSerial::close() { |
28 | if (m_fd) { | 28 | if (m_fd) { |
29 | delete m_read; | 29 | delete m_read; |
30 | delete m_error; | 30 | delete m_error; |
31 | ::close(m_fd); | 31 | ::close(m_fd); |
32 | m_fd = 0; | 32 | m_fd = 0; |
33 | } else { | 33 | } else { |
34 | emit error(Refuse, tr("Not connected")); | 34 | emit error(Refuse, tr("Not connected")); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | 37 | ||
38 | bool IOSerial::open() { | 38 | bool IOSerial::open() { |
39 | if (!m_fd) { | 39 | if (!m_fd) { |
40 | struct termios tty; | 40 | struct termios tty; |
41 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); | 41 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); |
42 | if (m_fd < 0) { | 42 | if (m_fd < 0) { |
43 | emit error(CouldNotOpen, strerror(errno)); | 43 | emit error(CouldNotOpen, strerror(errno)); |
44 | return FALSE; | 44 | return FALSE; |
45 | } | 45 | } |
46 | tcgetattr(m_fd, &tty); | 46 | tcgetattr(m_fd, &tty); |
47 | 47 | ||
48 | /* Baud rate */ | 48 | /* Baud rate */ |
49 | int speed = getBaud(m_baud); | 49 | int speed = baud(m_baud); |
50 | if (speed == -1) { | 50 | if (speed == -1) { |
51 | emit error(Refuse, tr("Invalid baud rate")); | 51 | emit error(Refuse, tr("Invalid baud rate")); |
52 | } | 52 | } |
53 | cfsetospeed(&tty, speed); | 53 | cfsetospeed(&tty, speed); |
54 | cfsetispeed(&tty, speed); | 54 | cfsetispeed(&tty, speed); |
55 | 55 | ||
56 | /* Take care of Space / Mark parity */ | 56 | /* Take care of Space / Mark parity */ |
57 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { | 57 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { |
58 | m_dbits = 8; | 58 | m_dbits = 8; |
59 | } | 59 | } |
60 | 60 | ||
61 | /* Data bits */ | 61 | /* Data bits */ |
62 | switch (m_dbits) { | 62 | switch (m_dbits) { |
63 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; | 63 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; |
64 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; | 64 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; |
65 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; | 65 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; |
66 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; | 66 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; |
67 | default: break; | ||
67 | } | 68 | } |
68 | 69 | ||
69 | /* Raw, no echo mode */ | 70 | /* Raw, no echo mode */ |
70 | tty.c_iflag = IGNBRK; | 71 | tty.c_iflag = IGNBRK; |
71 | tty.c_lflag = 0; | 72 | tty.c_lflag = 0; |
72 | tty.c_oflag = 0; | 73 | tty.c_oflag = 0; |
73 | tty.c_cflag |= CLOCAL | CREAD; | 74 | tty.c_cflag |= CLOCAL | CREAD; |
74 | 75 | ||
75 | /* Stop bits */ | 76 | /* Stop bits */ |
76 | if (m_sbits == 2) { | 77 | if (m_sbits == 2) { |
77 | tty.c_cflag |= CSTOPB; | 78 | tty.c_cflag |= CSTOPB; |
78 | } else { | 79 | } else { |
79 | tty.c_cflag &= ~CSTOPB; | 80 | tty.c_cflag &= ~CSTOPB; |
80 | } | 81 | } |
81 | 82 | ||
82 | tty.c_cc[VMIN] = 1; | 83 | tty.c_cc[VMIN] = 1; |
83 | tty.c_cc[VTIME] = 5; | 84 | tty.c_cc[VTIME] = 5; |
84 | 85 | ||
85 | /* Flow control */ | 86 | /* Flow control */ |
86 | if (m_flow & FlowSW) | 87 | if (m_flow & FlowSW) |
87 | tty.c_iflag |= IXON | IXOFF; | 88 | tty.c_iflag |= IXON | IXOFF; |
88 | else | 89 | else |
89 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); | 90 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); |
90 | 91 | ||
91 | if (m_flow & FlowHW) | 92 | if (m_flow & FlowHW) |
92 | tty.c_cflag |= CRTSCTS; | 93 | tty.c_cflag |= CRTSCTS; |
93 | else | 94 | else |
94 | tty.c_cflag &= ~CRTSCTS; | 95 | tty.c_cflag &= ~CRTSCTS; |
95 | 96 | ||
96 | /* Parity */ | 97 | /* Parity */ |
97 | tty.c_cflag &= ~(PARENB | PARODD); | 98 | tty.c_cflag &= ~(PARENB | PARODD); |
98 | if (m_parity & ParityEven) | 99 | if (m_parity & ParityEven) |
99 | tty.c_cflag |= PARENB; | 100 | tty.c_cflag |= PARENB; |
100 | else if (m_parity & ParityOdd) | 101 | else if (m_parity & ParityOdd) |
101 | tty.c_cflag |= (PARENB | PARODD); | 102 | tty.c_cflag |= (PARENB | PARODD); |
102 | 103 | ||
103 | /* Set the changes */ | 104 | /* Set the changes */ |
104 | tcsetattr(m_fd, TCSANOW, &tty); | 105 | tcsetattr(m_fd, TCSANOW, &tty); |
105 | 106 | ||
106 | /* Notifications on read & errors */ | 107 | /* Notifications on read & errors */ |
107 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); | 108 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); |
108 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); | 109 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); |
109 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 110 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
110 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 111 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
111 | return TRUE; | 112 | return TRUE; |
112 | } else { | 113 | } else { |
113 | emit error(Refuse, tr("Device is already connected")); | 114 | emit error(Refuse, tr("Device is already connected")); |
114 | return FALSE; | 115 | return FALSE; |
115 | } | 116 | } |
116 | } | 117 | } |
117 | 118 | ||
118 | void IOSerial::reload(const Config &config) { | 119 | void IOSerial::reload(const Profile &config) { |
119 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); | 120 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); |
120 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); | 121 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); |
121 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); | 122 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); |
122 | m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); | 123 | m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); |
123 | m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); | 124 | m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); |
124 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); | 125 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); |
125 | } | 126 | } |
126 | 127 | ||
127 | int IOSerial::getBaud(int baud) const { | 128 | int IOSerial::baud(int baud) const { |
128 | switch (baud) { | 129 | switch (baud) { |
129 | case 300: return B300; break; | 130 | case 300: return B300; break; |
130 | case 600: return B600; break; | 131 | case 600: return B600; break; |
131 | case 1200: return B1200; break; | 132 | case 1200: return B1200; break; |
132 | case 2400: return B2400; break; | 133 | case 2400: return B2400; break; |
133 | case 4800: return B4800; break; | 134 | case 4800: return B4800; break; |
134 | case 9600: return B9600; break; | 135 | case 9600: return B9600; break; |
135 | case 19200: return B19200; break; | 136 | case 19200: return B19200; break; |
136 | case 38400: return B38400; break; | 137 | case 38400: return B38400; break; |
137 | case 57600: return B57600; break; | 138 | case 57600: return B57600; break; |
138 | case 115200: return B115200; break; | 139 | case 115200: return B115200; break; |
139 | } | 140 | } |
140 | return -1; | 141 | return -1; |
141 | } | 142 | } |
142 | 143 | ||
143 | void IOSerial::errorOccured() { | 144 | void IOSerial::errorOccured() { |
144 | emit error(ClosedUnexpected, strerror(errno)); | 145 | emit error(ClosedUnexpected, strerror(errno)); |
145 | close(); | 146 | close(); |
146 | } | 147 | } |
147 | 148 | ||
148 | void IOSerial::dataArrived() { | 149 | void IOSerial::dataArrived() { |
149 | QByteArray array; | 150 | QByteArray array; |
150 | char buf[4096]; | 151 | char buf[4096]; |
151 | 152 | ||
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h index 1d34411..521dac6 100644 --- a/noncore/apps/opie-console/io_serial.h +++ b/noncore/apps/opie-console/io_serial.h | |||
@@ -8,56 +8,56 @@ | |||
8 | #define SERIAL_DEFAULT_DEVICE "/dev/ttyS0" | 8 | #define SERIAL_DEFAULT_DEVICE "/dev/ttyS0" |
9 | #define SERIAL_DEFAULT_BAUD 9600 | 9 | #define SERIAL_DEFAULT_BAUD 9600 |
10 | #define SERIAL_DEFAULT_PARITY 0 | 10 | #define SERIAL_DEFAULT_PARITY 0 |
11 | #define SERIAL_DEFAULT_DBITS 8 | 11 | #define SERIAL_DEFAULT_DBITS 8 |
12 | #define SERIAL_DEFAULT_SBITS 1 | 12 | #define SERIAL_DEFAULT_SBITS 1 |
13 | #define SERIAL_DEFAULT_FLOW 0 | 13 | #define SERIAL_DEFAULT_FLOW 0 |
14 | 14 | ||
15 | /* IOSerial implements a RS232 IO Layer */ | 15 | /* IOSerial implements a RS232 IO Layer */ |
16 | 16 | ||
17 | class IOSerial : public IOLayer { | 17 | class IOSerial : public IOLayer { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | enum Parity { | 20 | enum Parity { |
21 | ParityNone = 0, | 21 | ParityNone = 0, |
22 | ParityEven, | 22 | ParityEven, |
23 | ParityOdd, | 23 | ParityOdd, |
24 | ParitySpace, | 24 | ParitySpace, |
25 | ParityMark | 25 | ParityMark |
26 | }; | 26 | }; |
27 | 27 | ||
28 | enum Flow { | 28 | enum Flow { |
29 | FlowHW = 0x01, | 29 | FlowHW = 0x01, |
30 | FlowSW = 0x02 | 30 | FlowSW = 0x02 |
31 | }; | 31 | }; |
32 | 32 | ||
33 | IOSerial(const Config &); | 33 | IOSerial(const Profile &); |
34 | ~IOSerial(); | 34 | ~IOSerial(); |
35 | 35 | ||
36 | QString identifier() const; | 36 | QString identifier() const; |
37 | QString name() const; | 37 | QString name() const; |
38 | signals: | 38 | signals: |
39 | void received(const QByteArray &); | 39 | void received(const QByteArray &); |
40 | void error(int, const QString &); | 40 | void error(int, const QString &); |
41 | public slots: | 41 | public slots: |
42 | void send(const QByteArray &); | 42 | void send(const QByteArray &); |
43 | bool open(); | 43 | bool open(); |
44 | void close(); | 44 | void close(); |
45 | void reload(const Config &); | 45 | void reload(const Profile &); |
46 | protected: | 46 | protected: |
47 | int getBaud(int baud) const; | 47 | int baud(int baud) const; |
48 | protected slots: | 48 | protected slots: |
49 | void dataArrived(); | 49 | void dataArrived(); |
50 | void errorOccured(); | 50 | void errorOccured(); |
51 | protected: | 51 | protected: |
52 | QSocketNotifier *m_read; | 52 | QSocketNotifier *m_read; |
53 | QSocketNotifier *m_error; | 53 | QSocketNotifier *m_error; |
54 | QString m_device; | 54 | QString m_device; |
55 | int m_baud; | 55 | int m_baud; |
56 | int m_parity; | 56 | int m_parity; |
57 | int m_dbits; | 57 | int m_dbits; |
58 | int m_sbits; | 58 | int m_sbits; |
59 | int m_flow; | 59 | int m_flow; |
60 | int m_fd; | 60 | int m_fd; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | #endif /* OPIE_IO_SERIAL */ | 63 | #endif /* OPIE_IO_SERIAL */ |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index e9b5eda..1ae4a20 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,62 +1,123 @@ | |||
1 | 1 | ||
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | 7 | ||
8 | #include "metafactory.h" | 8 | #include "metafactory.h" |
9 | #include "mainwindow.h" | 9 | #include "mainwindow.h" |
10 | 10 | ||
11 | MainWindow::MainWindow() { | 11 | MainWindow::MainWindow() { |
12 | m_factory = new MetaFactory(); | 12 | m_factory = new MetaFactory(); |
13 | m_sessions.setAutoDelete( TRUE ); | 13 | m_sessions.setAutoDelete( TRUE ); |
14 | m_curSession = -1; | 14 | m_curSession = 0; |
15 | 15 | ||
16 | initUI(); | 16 | initUI(); |
17 | } | 17 | } |
18 | void MainWindow::initUI() { | 18 | void MainWindow::initUI() { |
19 | setToolBarsMovable( FALSE ); | 19 | setToolBarsMovable( FALSE ); |
20 | 20 | ||
21 | m_tool = new QToolBar( this ); | 21 | m_tool = new QToolBar( this ); |
22 | m_tool->setHorizontalStretchable( TRUE ); | 22 | m_tool->setHorizontalStretchable( TRUE ); |
23 | 23 | ||
24 | m_bar = new QMenuBar( m_tool ); | 24 | m_bar = new QMenuBar( m_tool ); |
25 | m_console = new QPopupMenu( this ); | 25 | m_console = new QPopupMenu( this ); |
26 | m_sessionsPop= new QPopupMenu( this ); | ||
27 | m_settings = new QPopupMenu( this ); | ||
26 | 28 | ||
27 | /* | 29 | /* |
28 | * new Action for new sessions | 30 | * new Action for new sessions |
29 | */ | 31 | */ |
30 | QAction* a = new QAction(); | 32 | QAction* a = new QAction(); |
31 | a->setText( tr("New Connection") ); | 33 | a->setText( tr("New Connection") ); |
32 | a->addTo( m_console ); | 34 | a->addTo( m_console ); |
33 | connect(a, SIGNAL(activated() ), | 35 | connect(a, SIGNAL(activated() ), |
34 | this, SLOT(slotNew() ) ); | 36 | this, SLOT(slotNew() ) ); |
35 | 37 | ||
36 | a = new QAction(); | ||
37 | a->setText( tr("New from Session") ); | ||
38 | 38 | ||
39 | |||
40 | /* | ||
41 | * connect action | ||
42 | */ | ||
39 | m_connect = new QAction(); | 43 | m_connect = new QAction(); |
40 | m_connect->setText( tr("Connect") ); | 44 | m_connect->setText( tr("Connect") ); |
41 | m_connect->addTo( m_console ); | 45 | m_connect->addTo( m_console ); |
42 | connect(m_connect, SIGNAL(activated() ), | 46 | connect(m_connect, SIGNAL(activated() ), |
43 | this, SLOT(slotConnect() ) ); | 47 | this, SLOT(slotConnect() ) ); |
44 | 48 | ||
49 | |||
50 | /* | ||
51 | * disconnect action | ||
52 | */ | ||
53 | m_disconnect = new QAction(); | ||
54 | m_disconnect->setText( tr("Disconnect") ); | ||
55 | m_disconnect->addTo( m_console ); | ||
56 | connect(m_disconnect, SIGNAL(activated() ), | ||
57 | this, SLOT(slotDisconnect() ) ); | ||
58 | |||
59 | /* | ||
60 | * terminate action | ||
61 | */ | ||
62 | m_terminate = new QAction(); | ||
63 | m_terminate->setText( tr("Terminate") ); | ||
64 | m_terminate->addTo( m_console ); | ||
65 | connect(m_disconnect, SIGNAL(activated() ), | ||
66 | this, SLOT(slotTerminate() ) ); | ||
67 | |||
68 | /* | ||
69 | * the settings action | ||
70 | */ | ||
71 | m_setProfiles = new QAction(); | ||
72 | m_setProfiles->setText( tr("Configure Profiles") ); | ||
73 | m_setProfiles->addTo( m_settings ); | ||
74 | connect( m_setProfiles, SIGNAL(activated() ), | ||
75 | this, SLOT(slotConfigure() ) ); | ||
76 | |||
77 | /* insert the submenu */ | ||
78 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | ||
79 | -1, 0); | ||
80 | |||
81 | /* insert the connection menu */ | ||
45 | m_bar->insertItem( tr("Connection"), m_console ); | 82 | m_bar->insertItem( tr("Connection"), m_console ); |
46 | 83 | ||
84 | /* the settings menu */ | ||
85 | m_bar->insertItem( tr("Settings"), m_settings ); | ||
86 | |||
47 | } | 87 | } |
48 | MainWindow::~MainWindow() { | 88 | MainWindow::~MainWindow() { |
49 | delete m_factory; | 89 | delete m_factory; |
50 | } | 90 | } |
51 | 91 | ||
52 | MetaFactory* MainWindow::factory() { | 92 | MetaFactory* MainWindow::factory() { |
53 | return m_factory; | 93 | return m_factory; |
54 | } | 94 | } |
55 | 95 | ||
56 | Session* MainWindow::currentSession() { | 96 | Session* MainWindow::currentSession() { |
57 | return m_curSession; | 97 | return m_curSession; |
58 | } | 98 | } |
59 | 99 | ||
60 | QList<Session> MainWindow::sessions() { | 100 | QList<Session> MainWindow::sessions() { |
61 | return m_sessions; | 101 | return m_sessions; |
62 | } | 102 | } |
103 | void MainWindow::slotNew() { | ||
104 | qWarning("New Connection"); | ||
105 | } | ||
106 | void MainWindow::slotConnect() { | ||
107 | if ( currentSession() ) | ||
108 | currentSession()->layer()->open(); | ||
109 | } | ||
110 | void MainWindow::slotDisconnect() { | ||
111 | if ( currentSession() ) | ||
112 | currentSession()->layer()->close(); | ||
113 | } | ||
114 | void MainWindow::slotTerminate() { | ||
115 | if ( currentSession() ) | ||
116 | currentSession()->layer()->close(); | ||
117 | delete m_curSession; | ||
118 | m_curSession = 0l; | ||
119 | /* FIXME move to the next session */ | ||
120 | } | ||
121 | void MainWindow::slotConfigure() { | ||
122 | qWarning("configure"); | ||
123 | } | ||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index db3a653..b6a8419 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -17,58 +17,63 @@ class QAction; | |||
17 | class MetaFactory; | 17 | class MetaFactory; |
18 | 18 | ||
19 | class MainWindow : public QMainWindow { | 19 | class MainWindow : public QMainWindow { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | public: | 21 | public: |
22 | MainWindow( ); | 22 | MainWindow( ); |
23 | ~MainWindow(); | 23 | ~MainWindow(); |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * our factory to generate IOLayer and so on | 26 | * our factory to generate IOLayer and so on |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | MetaFactory* factory(); | 29 | MetaFactory* factory(); |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * A session contains a QWidget*, | 32 | * A session contains a QWidget*, |
33 | * an IOLayer* and some infos for us | 33 | * an IOLayer* and some infos for us |
34 | */ | 34 | */ |
35 | Session* currentSession(); | 35 | Session* currentSession(); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * the session list | 38 | * the session list |
39 | */ | 39 | */ |
40 | QList<Session> sessions(); | 40 | QList<Session> sessions(); |
41 | protected slots: | 41 | |
42 | private slots: | ||
42 | void slotNew(); | 43 | void slotNew(); |
43 | void slotConnect(); | 44 | void slotConnect(); |
45 | void slotDisconnect(); | ||
46 | void slotTerminate(); | ||
47 | void slotConfigure(); | ||
48 | |||
44 | private: | 49 | private: |
45 | void initUI(); | 50 | void initUI(); |
46 | /** | 51 | /** |
47 | * the current session | 52 | * the current session |
48 | */ | 53 | */ |
49 | Session* m_curSession; | 54 | Session* m_curSession; |
50 | 55 | ||
51 | /** | 56 | /** |
52 | * the session list | 57 | * the session list |
53 | */ | 58 | */ |
54 | QList<Session> m_sessions; | 59 | QList<Session> m_sessions; |
55 | 60 | ||
56 | /** | 61 | /** |
57 | * the metafactory | 62 | * the metafactory |
58 | */ | 63 | */ |
59 | MetaFactory* m_factory; | 64 | MetaFactory* m_factory; |
60 | 65 | ||
61 | QToolBar* m_tool; | 66 | QToolBar* m_tool; |
62 | QMenuBar* m_bar; | 67 | QMenuBar* m_bar; |
63 | QPopupMenu* m_console; | 68 | QPopupMenu* m_console; |
64 | QPopupMenu* m_settings; | 69 | QPopupMenu* m_settings; |
65 | QPopupMenu* m_newsession; | 70 | QPopupMenu* m_sessionsPop; |
66 | QAction* m_connect; | 71 | QAction* m_connect; |
67 | QAction* m_disconnect; | 72 | QAction* m_disconnect; |
68 | QAction* m_terminate; | 73 | QAction* m_terminate; |
69 | QAction* m_set; | 74 | QAction* m_setProfiles; |
70 | 75 | ||
71 | }; | 76 | }; |
72 | 77 | ||
73 | 78 | ||
74 | #endif | 79 | #endif |
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index bef6ec7..754f34c 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp | |||
@@ -1,44 +1,58 @@ | |||
1 | 1 | #include <qpe/config.h> | |
2 | #include "metafactory.h" | 2 | #include "metafactory.h" |
3 | 3 | ||
4 | MetaFactory::MetaFactory() { | 4 | MetaFactory::MetaFactory() { |
5 | } | 5 | } |
6 | MetaFactory::~MetaFactory() { | 6 | MetaFactory::~MetaFactory() { |
7 | 7 | ||
8 | } | 8 | } |
9 | void MetaFactory::addConfigWidgetFactory( const QString& str, | 9 | void MetaFactory::addConfigWidgetFactory( const QString& str, |
10 | configWidget wid) { | 10 | configWidget wid) { |
11 | m_confFact.insert( str, wid ); | 11 | m_confFact.insert( str, wid ); |
12 | } | 12 | } |
13 | void MetaFactory::addIOLayerFactory( const QString& str, | 13 | void MetaFactory::addIOLayerFactory( const QString& str, |
14 | iolayer lay) { | 14 | iolayer lay) { |
15 | m_layerFact.insert( str, lay ); | 15 | m_layerFact.insert( str, lay ); |
16 | } | 16 | } |
17 | void MetaFactory::addFileTransferLayer( const QString& str, | 17 | void MetaFactory::addFileTransferLayer( const QString& str, |
18 | filelayer lay) { | 18 | filelayer lay) { |
19 | m_fileFact.insert( str, lay ); | 19 | m_fileFact.insert( str, lay ); |
20 | } | 20 | } |
21 | QStringList MetaFactory::ioLayers()const { | 21 | QStringList MetaFactory::ioLayers()const { |
22 | QStringList list; | 22 | QStringList list; |
23 | QMap<QString, iolayer>::ConstIterator it; | 23 | QMap<QString, iolayer>::ConstIterator it; |
24 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { | 24 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { |
25 | list << it.key(); | 25 | list << it.key(); |
26 | } | 26 | } |
27 | return list; | 27 | return list; |
28 | } | 28 | } |
29 | QStringList MetaFactory::configWidgets()const { | 29 | QStringList MetaFactory::configWidgets()const { |
30 | QStringList list; | 30 | QStringList list; |
31 | QMap<QString, configWidget>::ConstIterator it; | 31 | QMap<QString, configWidget>::ConstIterator it; |
32 | for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { | 32 | for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { |
33 | list << it.key(); | 33 | list << it.key(); |
34 | } | 34 | } |
35 | return list; | 35 | return list; |
36 | } | 36 | } |
37 | QStringList MetaFactory::fileTransferLayers()const { | 37 | QStringList MetaFactory::fileTransferLayers()const { |
38 | QStringList list; | 38 | QStringList list; |
39 | QMap<QString, filelayer>::ConstIterator it; | 39 | QMap<QString, filelayer>::ConstIterator it; |
40 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { | 40 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { |
41 | list << it.key(); | 41 | list << it.key(); |
42 | } | 42 | } |
43 | return list; | 43 | return list; |
44 | } | 44 | } |
45 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { | ||
46 | IOLayer* lay = 0l; | ||
47 | |||
48 | QMap<QString, iolayer>::Iterator it; | ||
49 | it = m_layerFact.find( str ); | ||
50 | if ( it != m_layerFact.end() ) { | ||
51 | lay = (*(it.data()))(prof); | ||
52 | /* | ||
53 | iolayer laye = it.data(); | ||
54 | lay = (*laye )(conf);*/ | ||
55 | } | ||
56 | |||
57 | return lay; | ||
58 | } | ||
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index aae9391..bdd2ad2 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h | |||
@@ -1,43 +1,45 @@ | |||
1 | #ifndef OPIE_META_FACTORY_H | 1 | #ifndef OPIE_META_FACTORY_H |
2 | #define OPIE_META_FACTORY_H | 2 | #define OPIE_META_FACTORY_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets | 5 | * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets |
6 | * and to instantiate these implementations on demand | 6 | * and to instantiate these implementations on demand |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <qwidget.h> | 9 | #include <qwidget.h> |
10 | #include <qmap.h> | 10 | #include <qmap.h> |
11 | 11 | ||
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | 13 | ||
14 | #include "io_layer.h" | 14 | #include "io_layer.h" |
15 | #include "file_layer.h" | 15 | #include "file_layer.h" |
16 | 16 | #include "profile.h" | |
17 | 17 | ||
18 | class MetaFactory { | 18 | class MetaFactory { |
19 | public: | 19 | public: |
20 | typedef QWidget* (*configWidget)(QWidget* parent); | 20 | typedef QWidget* (*configWidget)(QWidget* parent); |
21 | typedef IOLayer* (*iolayer)(const Config& ); | 21 | typedef IOLayer* (*iolayer)(const Profile& ); |
22 | typedef FileTransferLayer* (*filelayer)(IOLayer*); | 22 | typedef FileTransferLayer* (*filelayer)(IOLayer*); |
23 | 23 | ||
24 | MetaFactory(); | 24 | MetaFactory(); |
25 | ~MetaFactory(); | 25 | ~MetaFactory(); |
26 | 26 | ||
27 | void addConfigWidgetFactory( const QString&, | 27 | void addConfigWidgetFactory( const QString&, |
28 | configWidget ); | 28 | configWidget ); |
29 | void addIOLayerFactory(const QString&, | 29 | void addIOLayerFactory(const QString&, |
30 | iolayer ); | 30 | iolayer ); |
31 | void addFileTransferLayer( const QString&, | 31 | void addFileTransferLayer( const QString&, |
32 | filelayer ); | 32 | filelayer ); |
33 | QStringList ioLayers()const; | 33 | QStringList ioLayers()const; |
34 | QStringList configWidgets()const; | 34 | QStringList configWidgets()const; |
35 | QStringList fileTransferLayers()const; | 35 | QStringList fileTransferLayers()const; |
36 | IOLayer* newIOLayer( const QString&,const Profile& ); | ||
37 | |||
36 | private: | 38 | private: |
37 | QMap<QString, configWidget> m_confFact; | 39 | QMap<QString, configWidget> m_confFact; |
38 | QMap<QString, iolayer> m_layerFact; | 40 | QMap<QString, iolayer> m_layerFact; |
39 | QMap<QString, filelayer> m_fileFact; | 41 | QMap<QString, filelayer> m_fileFact; |
40 | }; | 42 | }; |
41 | 43 | ||
42 | 44 | ||
43 | #endif | 45 | #endif |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 4a1180f..e045a48 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,19 +1,28 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = io_layer.h io_serial.h \ | 4 | HEADERS = io_layer.h io_serial.h \ |
5 | file_layer.h \ | 5 | file_layer.h \ |
6 | metafactory.h \ | 6 | metafactory.h \ |
7 | session.h \ | 7 | session.h \ |
8 | mainwindow.h | 8 | mainwindow.h \ |
9 | profile.h \ | ||
10 | profileconfig.h \ | ||
11 | profilemanager.h \ | ||
12 | configwidget.h \ | ||
13 | tabwidget.h | ||
9 | SOURCES = io_layer.cpp io_serial.cpp \ | 14 | SOURCES = io_layer.cpp io_serial.cpp \ |
10 | file_layer.cpp main.cpp \ | 15 | file_layer.cpp main.cpp \ |
11 | metafactory.cpp \ | 16 | metafactory.cpp \ |
12 | session.cpp \ | 17 | session.cpp \ |
13 | mainwindow.cpp | 18 | mainwindow.cpp \ |
19 | profile.cpp \ | ||
20 | profileconfig.cpp \ | ||
21 | profilemanager.cpp \ | ||
22 | tabwidget.cpp | ||
14 | INTERFACES = | 23 | INTERFACES = |
15 | INCLUDEPATH += $(OPIEDIR)/include | 24 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += $(OPIEDIR)/include | 25 | DEPENDPATH += $(OPIEDIR)/include |
17 | LIBS += -lqpe -lopie | 26 | LIBS += -lqpe -lopie |
18 | TARGET = opie-console | 27 | TARGET = opie-console |
19 | 28 | ||
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp new file mode 100644 index 0000000..b730218 --- a/dev/null +++ b/noncore/apps/opie-console/profile.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | #include "profile.h" | ||
2 | |||
3 | Profile::Profile() { | ||
4 | |||
5 | } | ||
6 | Profile::Profile( const QString& name, | ||
7 | const QString& iolayerName, | ||
8 | int background, | ||
9 | int foreground, | ||
10 | int terminal ) | ||
11 | : m_name( name ), m_ioLayer( iolayerName ), m_back( background ), | ||
12 | m_fore( foreground ), m_terminal( terminal ) | ||
13 | { | ||
14 | } | ||
15 | Profile::Profile( const Profile& prof ) | ||
16 | { | ||
17 | (*this) = prof; | ||
18 | } | ||
19 | Profile &Profile::operator=( const Profile& prof ) { | ||
20 | m_name = prof.m_name; | ||
21 | m_ioLayer = prof.m_ioLayer; | ||
22 | m_back = prof.m_back; | ||
23 | m_fore = prof.m_fore; | ||
24 | m_terminal = prof.m_terminal; | ||
25 | |||
26 | return *this; | ||
27 | } | ||
28 | Profile::~Profile() { | ||
29 | } | ||
30 | QString Profile::name()const { | ||
31 | return m_name; | ||
32 | } | ||
33 | QString Profile::ioLayerName()const { | ||
34 | return m_ioLayer; | ||
35 | } | ||
36 | int Profile::foreground()const { | ||
37 | return m_fore; | ||
38 | } | ||
39 | int Profile::background()const { | ||
40 | return m_back; | ||
41 | } | ||
42 | int Profile::terminal()const { | ||
43 | return m_terminal; | ||
44 | } | ||
45 | void Profile::setName( const QString& str ) { | ||
46 | m_name = str; | ||
47 | } | ||
48 | void Profile::setIOLayer( const QString& name ) { | ||
49 | m_ioLayer = name; | ||
50 | } | ||
51 | void Profile::setBackground( int back ) { | ||
52 | m_back = back; | ||
53 | } | ||
54 | void Profile::setForeground( int fore ) { | ||
55 | m_fore = fore; | ||
56 | } | ||
57 | void Profile::setTerminal( int term ) { | ||
58 | m_terminal = term; | ||
59 | } | ||
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h new file mode 100644 index 0000000..8adc0bd --- a/dev/null +++ b/noncore/apps/opie-console/profile.h | |||
@@ -0,0 +1,66 @@ | |||
1 | #ifndef OPIE_PROFILE_H | ||
2 | #define OPIE_PROFILE_H | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qstring.h> | ||
6 | #include <qstringlist.h> | ||
7 | #include <qvaluelist.h> | ||
8 | /** | ||
9 | * A session will be generated from a saved | ||
10 | * profile. A profile contains the iolayername | ||
11 | * a name. | ||
12 | * We can generate a Session from a Profile | ||
13 | * No configuration is contained here.... | ||
14 | */ | ||
15 | class Profile { | ||
16 | public: | ||
17 | typedef QValueList<Profile> ValueList; | ||
18 | enum Color { Black = 0, | ||
19 | White, | ||
20 | Gray }; | ||
21 | enum Terminal {VT102 = 0 }; | ||
22 | enum Font { Micro = 0, Small, Medium }; | ||
23 | Profile(); | ||
24 | Profile( const QString& name, | ||
25 | const QString& iolayerName, | ||
26 | int background, | ||
27 | int foreground, | ||
28 | int terminal); | ||
29 | Profile( const Profile& ); | ||
30 | Profile &operator=( const Profile& ); | ||
31 | |||
32 | ~Profile(); | ||
33 | QString name()const; | ||
34 | QString ioLayerName()const; | ||
35 | int foreground()const; | ||
36 | int background()const; | ||
37 | int terminal()const; | ||
38 | |||
39 | /* | ||
40 | * config stuff | ||
41 | */ | ||
42 | QMap<QString, QString> conf(); | ||
43 | void clearConf(); | ||
44 | void writeEntry( const QString& key, const QString& value ); | ||
45 | void writeEntry( const QString& key, int num ); | ||
46 | void writeEntry( const QString& key, bool b ); | ||
47 | void writeEntry( const QString& key, const QStringList&, const QChar& ); | ||
48 | QString readEntry( const QString& key, const QString& deflt = QString::null)const; | ||
49 | int readNumEntry( const QString& key, int = -1 )const; | ||
50 | bool readBoolEntry( const QString& key, bool = FALSE )const; | ||
51 | |||
52 | void setName( const QString& ); | ||
53 | void setIOLayer( const QString& ); | ||
54 | void setBackground( int back ); | ||
55 | void setForeground( int fore ); | ||
56 | void setTerminal( int term ); | ||
57 | private: | ||
58 | QMap<QString, QString> m_conf; | ||
59 | QString m_name; | ||
60 | QString m_ioLayer; | ||
61 | int m_back; | ||
62 | int m_fore; | ||
63 | int m_terminal; | ||
64 | }; | ||
65 | |||
66 | #endif | ||
diff --git a/noncore/apps/opie-console/profileconfig.cpp b/noncore/apps/opie-console/profileconfig.cpp new file mode 100644 index 0000000..8b16920 --- a/dev/null +++ b/noncore/apps/opie-console/profileconfig.cpp | |||
@@ -0,0 +1,35 @@ | |||
1 | |||
2 | #include "profileconfig.h" | ||
3 | |||
4 | ProfileConfig::ProfileConfig( const QString& prof ) | ||
5 | : Config( prof ) | ||
6 | { | ||
7 | } | ||
8 | ProfileConfig::~ProfileConfig() { | ||
9 | |||
10 | } | ||
11 | QStringList ProfileConfig::groups()const { | ||
12 | QStringList list; | ||
13 | QMap<QString, ConfigGroup>::ConstIterator it; | ||
14 | it= Config::groups.begin(); | ||
15 | |||
16 | for (; it != Config::groups.end(); ++it ) | ||
17 | list << it.key(); | ||
18 | |||
19 | |||
20 | return list; | ||
21 | |||
22 | } | ||
23 | void ProfileConfig::clearAll() { | ||
24 | QMap<QString, ConfigGroup>::ConstIterator it; | ||
25 | it = Config::groups.begin(); | ||
26 | |||
27 | for ( ; it != Config::groups.end(); ++it ) | ||
28 | clearGroup( it.key() ); | ||
29 | } | ||
30 | void ProfileConfig::clearGroup( const QString& str ) { | ||
31 | QString cur =git.key(); | ||
32 | setGroup( str ); | ||
33 | Config::clearGroup(); | ||
34 | setGroup( cur ); | ||
35 | } | ||
diff --git a/noncore/apps/opie-console/profileconfig.h b/noncore/apps/opie-console/profileconfig.h new file mode 100644 index 0000000..e2e149c --- a/dev/null +++ b/noncore/apps/opie-console/profileconfig.h | |||
@@ -0,0 +1,17 @@ | |||
1 | |||
2 | #ifndef OPIE_PROFILE_CONFIG_H | ||
3 | #define OPIE_PROFILE_CONFIG_H | ||
4 | |||
5 | #include <qpe/config.h> | ||
6 | #include <qstringlist.h> | ||
7 | |||
8 | class ProfileConfig : public Config { | ||
9 | public: | ||
10 | ProfileConfig( const QString& prof ); | ||
11 | ~ProfileConfig(); | ||
12 | QStringList groups()const; | ||
13 | void clearGroup( const QString& ); | ||
14 | void clearAll(); | ||
15 | |||
16 | }; | ||
17 | #endif | ||
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp new file mode 100644 index 0000000..db36686 --- a/dev/null +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -0,0 +1,62 @@ | |||
1 | |||
2 | #include <qpe/config.h> | ||
3 | |||
4 | #include "metafactory.h" | ||
5 | #include "profileconfig.h" | ||
6 | #include "profilemanager.h" | ||
7 | |||
8 | ProfileManager::ProfileManager( MetaFactory* fact ) | ||
9 | : m_fact( fact ) | ||
10 | { | ||
11 | |||
12 | } | ||
13 | ProfileManager::~ProfileManager() { | ||
14 | |||
15 | } | ||
16 | void ProfileManager::load() { | ||
17 | m_list.clear(); | ||
18 | ProfileConfig conf("opie-console-profiles"); | ||
19 | QStringList groups = conf.groups(); | ||
20 | QStringList::Iterator it; | ||
21 | |||
22 | /* | ||
23 | * for each profile | ||
24 | */ | ||
25 | /* | ||
26 | * QAsciiDict Parsing FIXME | ||
27 | */ | ||
28 | for ( it = groups.begin(); it != groups.end(); ++it ) { | ||
29 | conf.setGroup( (*it) ); | ||
30 | Profile prof; | ||
31 | prof.setName( conf.readEntry("name") ); | ||
32 | prof.setIOLayer( conf.readEntry("iolayer") ); | ||
33 | prof.setBackground( conf.readNumEntry("back") ); | ||
34 | prof.setForeground( conf.readNumEntry("fore") ); | ||
35 | prof.setTerminal( conf.readNumEntry("terminal") ); | ||
36 | |||
37 | m_list.append( prof ); | ||
38 | } | ||
39 | |||
40 | } | ||
41 | Profile::ValueList ProfileManager::all()const { | ||
42 | return m_list; | ||
43 | } | ||
44 | Session* ProfileManager::fromProfile( const Profile& prof) { | ||
45 | Session* session = new Session(); | ||
46 | session->setName( prof.name() ); | ||
47 | session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), | ||
48 | prof) ); | ||
49 | /* | ||
50 | * FIXME | ||
51 | * load emulation | ||
52 | * load widget | ||
53 | * set colors + fonts | ||
54 | */ | ||
55 | return session; | ||
56 | } | ||
57 | void ProfileManager::save( ) { | ||
58 | m_list.clear(); | ||
59 | ProfileConfig conf("opie-console-profiles"); | ||
60 | Session* se= 0l; | ||
61 | // FIXME save | ||
62 | } | ||
diff --git a/noncore/apps/opie-console/profilemanager.h b/noncore/apps/opie-console/profilemanager.h new file mode 100644 index 0000000..d4d0fd0 --- a/dev/null +++ b/noncore/apps/opie-console/profilemanager.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef OPIE_PROFILE_MANAGER_H | ||
2 | #define OPIE_PROFILE_MANAGER_H | ||
3 | |||
4 | #include <qlist.h> | ||
5 | |||
6 | #include "session.h" | ||
7 | #include "profile.h" | ||
8 | |||
9 | class MetaFactory; | ||
10 | class ConfigWidget; | ||
11 | class ProfileManager { | ||
12 | public: | ||
13 | ProfileManager(MetaFactory*); | ||
14 | ~ProfileManager(); | ||
15 | |||
16 | void load(); | ||
17 | Profile::ValueList all()const; | ||
18 | void clear(); | ||
19 | /** | ||
20 | * also replaces the item | ||
21 | */ | ||
22 | void add( const Profile& prof ); | ||
23 | void remove( const Profile& prof ); | ||
24 | Session* fromProfile( const Profile& ); | ||
25 | void save(); | ||
26 | private: | ||
27 | MetaFactory* m_fact; | ||
28 | Profile::ValueList m_list; | ||
29 | }; | ||
30 | #endif | ||
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index 4198fdc..d32b340 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -1,26 +1,38 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "io_layer.h" | 3 | #include "io_layer.h" |
4 | #include "file_layer.h" | 4 | #include "file_layer.h" |
5 | #include "session.h" | 5 | #include "session.h" |
6 | 6 | ||
7 | Session::Session( QWidget* widget, IOLayer* lay) | 7 | Session::Session() { |
8 | : m_widget( widget ), m_layer( lay ) | 8 | m_widget = 0l; |
9 | m_layer = 0l; | ||
10 | } | ||
11 | Session::Session( const QString& na, QWidget* widget, IOLayer* lay) | ||
12 | : m_name( na ), m_widget( widget ), m_layer( lay ) | ||
9 | { | 13 | { |
10 | } | 14 | } |
11 | Session::~Session() { | 15 | Session::~Session() { |
12 | delete m_layer; | 16 | delete m_layer; |
13 | delete m_widget; | 17 | delete m_widget; |
14 | } | 18 | } |
19 | QString Session::name()const { | ||
20 | return m_name; | ||
21 | } | ||
15 | QWidget* Session::widget() { | 22 | QWidget* Session::widget() { |
16 | return m_widget; | 23 | return m_widget; |
17 | } | 24 | } |
18 | IOLayer* Session::layer() { | 25 | IOLayer* Session::layer() { |
19 | return m_layer; | 26 | return m_layer; |
20 | } | 27 | } |
28 | void Session::setName( const QString& na){ | ||
29 | m_name = na; | ||
30 | } | ||
21 | void Session::setWidget( QWidget* wid ) { | 31 | void Session::setWidget( QWidget* wid ) { |
32 | delete m_widget; | ||
22 | m_widget = wid; | 33 | m_widget = wid; |
23 | } | 34 | } |
24 | void Session::setIOLayer( IOLayer* lay ) { | 35 | void Session::setIOLayer( IOLayer* lay ) { |
36 | delete m_layer; | ||
25 | m_layer = lay; | 37 | m_layer = lay; |
26 | } | 38 | } |
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index 3978e1b..44b5fc8 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h | |||
@@ -1,39 +1,48 @@ | |||
1 | #ifndef OPIE_SESSION_H | 1 | #ifndef OPIE_SESSION_H |
2 | #define OPIE_SESSION_H | 2 | #define OPIE_SESSION_H |
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | 5 | ||
6 | class IOLayer; | 6 | class IOLayer; |
7 | /** | 7 | /** |
8 | * This is a Session. A session contains | 8 | * This is a Session. A session contains |
9 | * a QWidget pointer and a IOLayer | 9 | * a QWidget pointer and a IOLayer |
10 | * Imagine a session like a collection of what | 10 | * Imagine a session like a collection of what |
11 | * is needed to show your widget in a tab ;) | 11 | * is needed to show your widget in a tab ;) |
12 | */ | 12 | */ |
13 | class Session { | 13 | class Session { |
14 | public: | 14 | public: |
15 | /** | 15 | /** |
16 | * c'tor with widget and layer | 16 | * c'tor with widget and layer |
17 | * ownership get's transfered | 17 | * ownership get's transfered |
18 | */ | 18 | */ |
19 | Session( QWidget* widget, IOLayer* ); | 19 | Session(); |
20 | Session( const QString&, QWidget* widget, IOLayer* ); | ||
20 | ~Session(); | 21 | ~Session(); |
21 | 22 | ||
22 | /** | 23 | /** |
24 | * return the name of the session | ||
25 | */ | ||
26 | QString name()const; | ||
27 | |||
28 | /** | ||
23 | * return the widget | 29 | * return the widget |
24 | */ | 30 | */ |
25 | QWidget* widget(); | 31 | QWidget* widget(); |
26 | 32 | ||
27 | /** | 33 | /** |
28 | * return the layer | 34 | * return the layer |
29 | */ | 35 | */ |
30 | IOLayer* layer(); | 36 | IOLayer* layer(); |
31 | void setWidget( QWidget* widget ); | 37 | void setWidget( QWidget* widget ); |
32 | void setIOLayer( IOLayer* ); | 38 | void setIOLayer( IOLayer* ); |
39 | void setName( const QString& ); | ||
33 | 40 | ||
34 | private: | 41 | private: |
42 | QString m_name; | ||
35 | QWidget* m_widget; | 43 | QWidget* m_widget; |
36 | IOLayer* m_layer; | 44 | IOLayer* m_layer; |
45 | |||
37 | }; | 46 | }; |
38 | 47 | ||
39 | #endif | 48 | #endif |
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp new file mode 100644 index 0000000..6091aa2 --- a/dev/null +++ b/noncore/apps/opie-console/tabwidget.cpp | |||
@@ -0,0 +1,28 @@ | |||
1 | |||
2 | #include "tabwidget.h" | ||
3 | |||
4 | TabWidget::TabWidget( QWidget* parent, const char* name ) | ||
5 | : QTabWidget( parent, name ) | ||
6 | { | ||
7 | connect(this, SIGNAL(currentChanged(QWidget*) ), | ||
8 | this, SLOT(slotCurChanged(QWidget*) ) ); | ||
9 | } | ||
10 | TabWidget::~TabWidget() { | ||
11 | } | ||
12 | void TabWidget::add( Session* ses ) { | ||
13 | if ( !ses->widget() ) return; | ||
14 | addTab( ses->widget(), ses->name() ); | ||
15 | m_map.insert( ses->widget(), ses ); | ||
16 | } | ||
17 | void TabWidget::remove( Session* ses ) { | ||
18 | m_map.remove( ses->widget() ); | ||
19 | removePage( ses->widget() ); | ||
20 | } | ||
21 | void TabWidget::slotCurChanged( QWidget* wid ) { | ||
22 | QMap<QWidget*, Session*>::Iterator it; | ||
23 | it = m_map.find(wid ); | ||
24 | if (it == m_map.end() ) | ||
25 | return; | ||
26 | |||
27 | emit activated( it.data() ); | ||
28 | } | ||
diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h new file mode 100644 index 0000000..d5d4be3 --- a/dev/null +++ b/noncore/apps/opie-console/tabwidget.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef OPIE_TAB_WIDGET_H | ||
2 | #define OPIE_TAB_WIDGET_H | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qtabwidget.h> | ||
6 | |||
7 | #include "session.h" | ||
8 | /** | ||
9 | * This is our central tab widget | ||
10 | * we can add sessions here | ||
11 | */ | ||
12 | class TabWidget : QTabWidget{ | ||
13 | Q_OBJECT | ||
14 | public: | ||
15 | TabWidget(QWidget *parent, const char* name ); | ||
16 | ~TabWidget(); | ||
17 | void add( Session* ); | ||
18 | void remove( Session* ); | ||
19 | |||
20 | signals: | ||
21 | void activated(Session* ses ); | ||
22 | private slots: | ||
23 | void slotCurChanged( QWidget* wid ); | ||
24 | private: | ||
25 | QMap<QWidget*, Session*> m_map; | ||
26 | }; | ||
27 | |||
28 | #endif | ||