author | zecke <zecke> | 2002-09-28 18:29:02 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-28 18:29:02 (UTC) |
commit | bc88219d0a9cf935d90c88fe75e238e86c675937 (patch) (unidiff) | |
tree | 0121d1d3d881cf69948f3faf420a71d894dd6832 /noncore | |
parent | 18d575d0ee47a0700091de81bc3e8c54be4eae18 (diff) | |
download | opie-bc88219d0a9cf935d90c88fe75e238e86c675937.zip opie-bc88219d0a9cf935d90c88fe75e238e86c675937.tar.gz opie-bc88219d0a9cf935d90c88fe75e238e86c675937.tar.bz2 |
io_layer take Profile instead of Config
Profile added including some Config like stuff
io_serial getBaud -> baud
a default for gcc3 later
tabdwidget will be our central widget
profileconfig I needed groups() and clearAll
that's pretty much it
-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 | |||
@@ -5,7 +5,7 @@ IOLayer::IOLayer() | |||
5 | { | 5 | { |
6 | } | 6 | } |
7 | 7 | ||
8 | IOLayer::IOLayer(const Config &) | 8 | IOLayer::IOLayer(const Profile &) |
9 | : QObject() | 9 | : QObject() |
10 | { | 10 | { |
11 | } | 11 | } |
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 | |||
@@ -4,12 +4,13 @@ | |||
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: |
@@ -32,7 +33,7 @@ public: | |||
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 |
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 | |||
@@ -4,7 +4,7 @@ | |||
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 | } |
@@ -46,7 +46,7 @@ bool IOSerial::open() { | |||
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 | } |
@@ -57,15 +57,16 @@ bool IOSerial::open() { | |||
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; |
@@ -78,7 +79,7 @@ bool IOSerial::open() { | |||
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 | ||
@@ -87,19 +88,19 @@ bool IOSerial::open() { | |||
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 | ||
@@ -115,7 +116,7 @@ bool IOSerial::open() { | |||
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); |
@@ -124,7 +125,7 @@ void IOSerial::reload(const Config &config) { | |||
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; |
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 | |||
@@ -29,10 +29,10 @@ public: | |||
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: |
@@ -42,9 +42,9 @@ 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(); |
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 | |||
@@ -11,7 +11,7 @@ | |||
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 | } |
@@ -23,6 +23,8 @@ void MainWindow::initUI() { | |||
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 |
@@ -33,17 +35,55 @@ void MainWindow::initUI() { | |||
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; |
@@ -60,3 +100,24 @@ Session* MainWindow::currentSession() { | |||
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 | |||
@@ -38,9 +38,14 @@ public: | |||
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 | /** |
@@ -62,11 +67,11 @@ private: | |||
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 | ||
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,4 +1,4 @@ | |||
1 | 1 | #include <qpe/config.h> | |
2 | #include "metafactory.h" | 2 | #include "metafactory.h" |
3 | 3 | ||
4 | MetaFactory::MetaFactory() { | 4 | MetaFactory::MetaFactory() { |
@@ -42,3 +42,17 @@ QStringList MetaFactory::fileTransferLayers()const { | |||
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 | |||
@@ -13,14 +13,14 @@ | |||
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 | ||
@@ -33,6 +33,8 @@ public: | |||
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; |
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 | |||
@@ -5,12 +5,21 @@ 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 |
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 | |||
@@ -4,23 +4,35 @@ | |||
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 | |||
@@ -16,10 +16,16 @@ public: | |||
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(); |
@@ -30,10 +36,13 @@ public: | |||
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 | ||