summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/common.h2
-rw-r--r--noncore/apps/opie-console/configdialog.cpp10
-rw-r--r--noncore/apps/opie-console/configdialog.h5
-rw-r--r--noncore/apps/opie-console/default.cpp65
-rw-r--r--noncore/apps/opie-console/default.h30
-rw-r--r--noncore/apps/opie-console/io_layer.h2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp4
-rw-r--r--noncore/apps/opie-console/metafactory.cpp76
-rw-r--r--noncore/apps/opie-console/metafactory.h60
-rw-r--r--noncore/apps/opie-console/opie-console.pro16
-rw-r--r--noncore/apps/opie-console/profile.cpp21
-rw-r--r--noncore/apps/opie-console/profile.h11
-rw-r--r--noncore/apps/opie-console/profiledialogwidget.cpp32
-rw-r--r--noncore/apps/opie-console/profiledialogwidget.h50
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp239
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h25
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.h142
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp6
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp2
-rw-r--r--noncore/apps/opie-console/sz_transfer.h12
20 files changed, 544 insertions, 266 deletions
diff --git a/noncore/apps/opie-console/common.h b/noncore/apps/opie-console/common.h
index ac0e2cf..979c2bd 100644
--- a/noncore/apps/opie-console/common.h
+++ b/noncore/apps/opie-console/common.h
@@ -28,3 +28,3 @@
28#ifndef BOOL 28#ifndef BOOL
29typedef int BOOL; 29typedef bool BOOL;
30#endif 30#endif
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index ee1ffb4..50512b6 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -31,4 +31,5 @@ Profile ConfigListItem::profile()const {
31 31
32ConfigDialog::ConfigDialog( const Profile::ValueList& lis, QWidget* parent ) 32ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa,
33 : ConfigureBase( parent, 0, TRUE ) 33 QWidget* parent )
34 : ConfigureBase( parent, 0, TRUE ), m_fact( fa )
34{ 35{
@@ -73,3 +74,3 @@ void ConfigDialog::slotEdit() {
73 74
74 ProfileEditorDialog dlg(new MetaFactory(), p); 75 ProfileEditorDialog dlg(m_fact, p);
75 76
@@ -92,3 +93,4 @@ void ConfigDialog::slotEdit() {
92void ConfigDialog::slotAdd() { 93void ConfigDialog::slotAdd() {
93 ProfileEditorDialog dlg(new MetaFactory()); 94 qWarning("slotAdd");
95 ProfileEditorDialog dlg(m_fact);
94 96
diff --git a/noncore/apps/opie-console/configdialog.h b/noncore/apps/opie-console/configdialog.h
index a0c40d0..b81a004 100644
--- a/noncore/apps/opie-console/configdialog.h
+++ b/noncore/apps/opie-console/configdialog.h
@@ -8,2 +8,3 @@
8 8
9class MetaFactory;
9class ConfigDialog : public ConfigureBase { 10class ConfigDialog : public ConfigureBase {
@@ -11,3 +12,3 @@ class ConfigDialog : public ConfigureBase {
11public: 12public:
12 ConfigDialog( const Profile::ValueList&, QWidget* parent = 0l); 13 ConfigDialog( const Profile::ValueList&, MetaFactory*, QWidget* parent = 0l);
13 ~ConfigDialog(); 14 ~ConfigDialog();
@@ -19,2 +20,4 @@ protected slots:
19 void slotAdd(); 20 void slotAdd();
21private:
22 MetaFactory* m_fact;
20 23
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
new file mode 100644
index 0000000..78495d2
--- a/dev/null
+++ b/noncore/apps/opie-console/default.cpp
@@ -0,0 +1,65 @@
1#include "io_serial.h"
2#include "sz_transfer.h"
3
4#include "default.h"
5
6extern "C" {
7 // FILE Transfer Stuff
8 FileTransferLayer* newSZTransfer(IOLayer* lay) {
9 return new SzTransfer( SzTransfer::SZ, lay );
10 }
11 FileTransferLayer* newSYTransfer(IOLayer* lay) {
12 return new SzTransfer( SzTransfer::SY, lay );
13 }
14 FileTransferLayer* newSXTransfer(IOLayer* lay) {
15 return new SzTransfer( SzTransfer::SX, lay );
16 }
17
18 // Layer stuff
19 IOLayer* newSerialLayer( const Profile& prof) {
20 return new IOSerial( prof );
21 }
22 IOLayer* newBTLayer( const Profile& ) {
23 return 0l;
24 }
25 IOLayer* newIrDaLayer( const Profile& ) {
26 return 0l;
27 }
28
29 // Connection Widgets
30 ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) {
31 return 0l;
32 }
33 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) {
34 return newSerialWidget(str, wid);
35 }
36 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) {
37 return newSerialWidget(str, wid );
38 }
39
40 // Terminal Widget(s)
41 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ) {
42 return 0l;
43 }
44
45};
46
47Default::Default( MetaFactory* fact ) {
48 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
49 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
50 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
51
52 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
53 fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
54 fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
55
56 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
57 fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
58 fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
59
60 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
61
62}
63Default::~Default() {
64
65}
diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h
new file mode 100644
index 0000000..ed78986
--- a/dev/null
+++ b/noncore/apps/opie-console/default.h
@@ -0,0 +1,30 @@
1#ifndef OPIE_DEFAULT_H
2#define OPIE_DEFAULT_H
3
4#include "metafactory.h"
5
6extern "C" {
7 FileTransferLayer* newSZTransfer(IOLayer*);
8 FileTransferLayer* newSYTransfer(IOLayer*);
9 FileTransferLayer* newSXTransfer(IOLayer*);
10
11 IOLayer* newSerialLayer(const Profile&);
12 IOLayer* newBTLayer(const Profile& );
13 IOLayer* newIrDaLayer(const Profile& );
14
15 ProfileDialogWidget* newSerialWidget(const QString&, QWidget* );
16 ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* );
17 ProfileDialogWidget* newBTWidget (const QString&, QWidget* );
18
19 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* );
20};
21
22class MetaFactory;
23struct Default {
24public:
25 Default(MetaFactory* );
26 ~Default();
27};
28
29
30#endif
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index 2f1ceef..b891b2b 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -83,3 +83,3 @@ public slots:
83 */ 83 */
84 virtual void reload( const Config& ) = 0; 84 virtual void reload( const Profile& ) = 0;
85}; 85};
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 31f1138..647a331 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -8,2 +8,3 @@
8#include "configdialog.h" 8#include "configdialog.h"
9#include "default.h"
9#include "metafactory.h" 10#include "metafactory.h"
@@ -15,2 +16,3 @@ MainWindow::MainWindow() {
15 m_factory = new MetaFactory(); 16 m_factory = new MetaFactory();
17 Default def(m_factory);
16 m_sessions.setAutoDelete( TRUE ); 18 m_sessions.setAutoDelete( TRUE );
@@ -158,3 +160,3 @@ void MainWindow::slotConfigure() {
158 qWarning("configure"); 160 qWarning("configure");
159 ConfigDialog conf( manager()->all() ); 161 ConfigDialog conf( manager()->all(), factory() );
160 conf.showMaximized(); 162 conf.showMaximized();
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index b69d6da..077b418 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -8,14 +8,24 @@ MetaFactory::~MetaFactory() {
8} 8}
9void MetaFactory::addConfigWidgetFactory( const QString& str, 9void MetaFactory::addConnectionWidgetFactory( const QCString& name,
10 const QString& name, 10 const QString& str,
11 configWidget wid) { 11 configWidget wid) {
12 m_namemap.insert ( str, name ); 12 m_strings.insert( str, name );
13 m_confFact.insert( str, wid ); 13 m_conFact.insert( str, wid );
14} 14}
15void MetaFactory::addIOLayerFactory( const QString& str, 15void MetaFactory::addTerminalWidgetFactory( const QCString& name,
16 const QString& str,
17 configWidget wid ) {
18 m_strings.insert( str, name );
19 m_termFact.insert( str, wid );
20}
21void MetaFactory::addIOLayerFactory( const QCString& name,
22 const QString& str,
16 iolayer lay) { 23 iolayer lay) {
24 m_strings.insert( str, name );
17 m_layerFact.insert( str, lay ); 25 m_layerFact.insert( str, lay );
18} 26}
19void MetaFactory::addFileTransferLayer( const QString& str, 27void MetaFactory::addFileTransferLayer( const QCString& name,
28 const QString& str,
20 filelayer lay) { 29 filelayer lay) {
30 m_strings.insert(str, name );
21 m_fileFact.insert( str, lay ); 31 m_fileFact.insert( str, lay );
@@ -30,6 +40,14 @@ QStringList MetaFactory::ioLayers()const {
30} 40}
31QStringList MetaFactory::configWidgets()const { 41QStringList MetaFactory::connectionWidgets()const {
42 QStringList list;
43 QMap<QString, configWidget>::ConstIterator it;
44 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
45 list << it.key();
46 }
47 return list;
48}
49QStringList MetaFactory::terminalWidgets()const {
32 QStringList list; 50 QStringList list;
33 QMap<QString, configWidget>::ConstIterator it; 51 QMap<QString, configWidget>::ConstIterator it;
34 for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { 52 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
35 list << it.key(); 53 list << it.key();
@@ -62,15 +80,35 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
62 80
63ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, Profile *prof) { 81ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
64 ProfileEditorPlugin *p = NULL; 82 ProfileDialogWidget* wid = 0l;
65 configWidget c;
66 83
67 c = m_confFact[str]; 84 QMap<QString, configWidget>::Iterator it;
68 if(c) p = c(parent, prof); 85 it = m_conFact.find( str );
69 86 if ( it != m_conFact.end() ) {
70 return p; 87 wid = (*(it.data() ) )(str,parent);
88 }
89 return wid;
71} 90}
91ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
92 if (str.isEmpty() )
93 return 0l;
94 ProfileDialogWidget* wid = 0l;
95 qWarning("new terminalPlugin %s %l", str.latin1(), parent );
72 96
73QString MetaFactory::name( const QString& str ) { 97 QMap<QString, configWidget>::Iterator it;
74 return m_namemap[str]; 98 it = m_termFact.find( str );
99 if ( it != m_conFact.end() ) {
100 wid = (*(it.data() ) )(str,parent);
101 }
102 return wid;
103}
104QCString MetaFactory::internal( const QString& str )const {
105 return m_strings[str];
106}
107QString MetaFactory::external( const QCString& str )const {
108 QMap<QString, QCString>::ConstIterator it;
109 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
110 if ( it.data() == str )
111 return it.key();
112 }
113 return QString::null;
75} 114}
76
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 216de03..3f7ddce 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -16,3 +16,3 @@
16#include "profile.h" 16#include "profile.h"
17#include "profileeditorplugins.h" 17#include "profiledialogwidget.h"
18 18
@@ -20,3 +20,3 @@ class MetaFactory {
20public: 20public:
21 typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, Profile* prof); 21 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
22 typedef IOLayer* (*iolayer)(const Profile& ); 22 typedef IOLayer* (*iolayer)(const Profile& );
@@ -27,22 +27,56 @@ public:
27 27
28 void addConfigWidgetFactory( const QString&, 28 /**
29 const QString&, 29 * add a ProfileDialogWidget to the factory
30 configWidget ); 30 * name is the name shown to the user
31 void addIOLayerFactory(const QString&, 31 */
32 iolayer ); 32 void addConnectionWidgetFactory( const QCString& internalName,
33 void addFileTransferLayer( const QString&, 33 const QString& uiString,
34 configWidget );
35 void addTerminalWidgetFactory ( const QCString& internalName,
36 const QString& name,
37 configWidget );
38
39 /**
40 * adds an IOLayer factory
41 */
42 void addIOLayerFactory( const QCString&,
43 const QString&,
44 iolayer );
45
46 /**
47 * adds a FileTransfer Layer
48 */
49 void addFileTransferLayer( const QCString& name,
50 const QString&,
34 filelayer ); 51 filelayer );
52
53 /* translated UI Strings */
35 QStringList ioLayers()const; 54 QStringList ioLayers()const;
36 QStringList configWidgets()const; 55 QStringList connectionWidgets()const;
56 QStringList terminalWidgets()const;
37 QStringList fileTransferLayers()const; 57 QStringList fileTransferLayers()const;
38 IOLayer* newIOLayer( const QString&,const Profile& ); 58 IOLayer* newIOLayer( const QString&,const Profile& );
39 ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, Profile* ); 59 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
60 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
61
62 /*
63 * internal takes the maybe translated
64 * public QString and maps it to the internal
65 * not translatable QCString
66 */
67 QCString internal( const QString& )const;
68
69 /*
70 * external takes the internal name
71 * it returns a translated name
72 */
73 QString external( const QCString& )const;
40 74
41 QString name( const QString& );
42 75
43private: 76private:
44 QMap<QString, configWidget> m_confFact; 77 QMap<QString, QCString> m_strings;
78 QMap<QString, configWidget> m_conFact;
79 QMap<QString, configWidget> m_termFact;
45 QMap<QString, iolayer> m_layerFact; 80 QMap<QString, iolayer> m_layerFact;
46 QMap<QString, filelayer> m_fileFact; 81 QMap<QString, filelayer> m_fileFact;
47 QMap<QString, QString> m_namemap;
48}; 82};
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 768e453..984072a 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -15,4 +15,2 @@ HEADERS = io_layer.h io_serial.h \
15 configdialog.h \ 15 configdialog.h \
16 profileeditordialog.h \
17 profileeditorplugins.h \
18 emulation_layer.h \ 16 emulation_layer.h \
@@ -25,3 +23,6 @@ HEADERS = io_layer.h io_serial.h \
25 widget_layer.h \ 23 widget_layer.h \
26 transferdialog.h 24 transferdialog.h \
25 profiledialogwidget.h \
26 profileeditordialog.h \
27 default.h
27 28
@@ -29,3 +30,3 @@ SOURCES = io_layer.cpp io_serial.cpp \
29 file_layer.cpp sz_transfer.cpp \ 30 file_layer.cpp sz_transfer.cpp \
30 main.cpp \ 31 main.cpp \
31 metafactory.cpp \ 32 metafactory.cpp \
@@ -38,4 +39,2 @@ SOURCES = io_layer.cpp io_serial.cpp \
38 configdialog.cpp \ 39 configdialog.cpp \
39 profileeditordialog.cpp \
40 profileeditorplugins.cpp \
41 emulation_layer.cpp \ 40 emulation_layer.cpp \
@@ -47,3 +46,6 @@ SOURCES = io_layer.cpp io_serial.cpp \
47 widget_layer.cpp \ 46 widget_layer.cpp \
48 transferdialog.cpp 47 transferdialog.cpp \
48 profiledialogwidget.cpp \
49 profileeditordialog.cpp \
50 default.cpp
49 51
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp
index c8f5eb0..1a94619 100644
--- a/noncore/apps/opie-console/profile.cpp
+++ b/noncore/apps/opie-console/profile.cpp
@@ -6,3 +6,4 @@ Profile::Profile() {
6Profile::Profile( const QString& name, 6Profile::Profile( const QString& name,
7 const QString& iolayerName, 7 const QCString& iolayerName,
8 const QCString& termName,
8 int background, 9 int background,
@@ -10,6 +11,5 @@ Profile::Profile( const QString& name,
10 int terminal ) 11 int terminal )
11 : m_name( name ), m_ioLayer( iolayerName ), m_back( background ), 12 : m_name( name ), m_ioLayer( iolayerName ), m_term( termName),
12 m_fore( foreground ), m_terminal( terminal ) 13 m_back( background ), m_fore( foreground ), m_terminal( terminal )
13{ 14{}
14}
15Profile::Profile( const Profile& prof ) 15Profile::Profile( const Profile& prof )
@@ -30,2 +30,3 @@ Profile &Profile::operator=( const Profile& prof ) {
30 m_conf = prof.m_conf; 30 m_conf = prof.m_conf;
31 m_term = prof.m_term;
31 32
@@ -41,5 +42,8 @@ QString Profile::name()const {
41} 42}
42QString Profile::ioLayerName()const { 43QCString Profile::ioLayerName()const {
43 return m_ioLayer; 44 return m_ioLayer;
44} 45}
46QCString Profile::terminalName( )const {
47 return m_term;
48}
45int Profile::foreground()const { 49int Profile::foreground()const {
@@ -56,5 +60,8 @@ void Profile::setName( const QString& str ) {
56} 60}
57void Profile::setIOLayer( const QString& name ) { 61void Profile::setIOLayer( const QCString& name ) {
58 m_ioLayer = name; 62 m_ioLayer = name;
59} 63}
64void Profile::setTerminalName( const QCString& str ) {
65 m_term = str;
66}
60void Profile::setBackground( int back ) { 67void Profile::setBackground( int back ) {
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h
index 5652ac5..78fe6ab 100644
--- a/noncore/apps/opie-console/profile.h
+++ b/noncore/apps/opie-console/profile.h
@@ -24,3 +24,4 @@ public:
24 Profile( const QString& name, 24 Profile( const QString& name,
25 const QString& iolayerName, 25 const QCString& iolayerName,
26 const QCString& termName,
26 int background, 27 int background,
@@ -34,3 +35,4 @@ public:
34 QString name()const; 35 QString name()const;
35 QString ioLayerName()const; 36 QCString ioLayerName()const;
37 QCString terminalName()const;
36 int foreground()const; 38 int foreground()const;
@@ -53,3 +55,4 @@ public:
53 void setName( const QString& ); 55 void setName( const QString& );
54 void setIOLayer( const QString& ); 56 void setIOLayer( const QCString& );
57 void setTerminalName( const QCString& );
55 void setBackground( int back ); 58 void setBackground( int back );
@@ -61,3 +64,3 @@ private:
61 QString m_name; 64 QString m_name;
62 QString m_ioLayer; 65 QCString m_ioLayer, m_term;
63 int m_back; 66 int m_back;
diff --git a/noncore/apps/opie-console/profiledialogwidget.cpp b/noncore/apps/opie-console/profiledialogwidget.cpp
new file mode 100644
index 0000000..24d59bf
--- a/dev/null
+++ b/noncore/apps/opie-console/profiledialogwidget.cpp
@@ -0,0 +1,32 @@
1#include "profiledialogwidget.h"
2
3ProfileDialogWidget::ProfileDialogWidget( const QString&, QWidget* parent,
4 const char* name )
5 : QWidget( parent, name ) {
6}
7ProfileDialogWidget::~ProfileDialogWidget() {
8}
9
10ProfileDialogTerminalWidget::ProfileDialogTerminalWidget( const QString& na,
11 QWidget* parent,
12 const char* name )
13 : ProfileDialogWidget( na, parent, name )
14{
15}
16ProfileDialogTerminalWidget::~ProfileDialogTerminalWidget() {
17}
18ProfileDialogWidget::Type ProfileDialogTerminalWidget::type()const {
19 return Terminal;
20}
21
22ProfileDialogConnectionWidget::ProfileDialogConnectionWidget( const QString& na,
23 QWidget* parent,
24 const char* name )
25 : ProfileDialogWidget(na, parent, name )
26{
27}
28ProfileDialogConnectionWidget::~ProfileDialogConnectionWidget() {
29}
30ProfileDialogWidget::Type ProfileDialogConnectionWidget::type()const {
31 return Connection;
32}
diff --git a/noncore/apps/opie-console/profiledialogwidget.h b/noncore/apps/opie-console/profiledialogwidget.h
new file mode 100644
index 0000000..5d279e6
--- a/dev/null
+++ b/noncore/apps/opie-console/profiledialogwidget.h
@@ -0,0 +1,50 @@
1#ifndef OPIE_PROFILE_DIALOG_WIDGET_H
2#define OPIE_PROFILE_DIALOG_WIDGET_H
3
4#include <qwidget.h>
5
6#include "profile.h"
7
8class ProfileDialogWidget : public QWidget {
9 Q_OBJECT
10public:
11 enum Type {
12 Connection,
13 Terminal
14 };
15 ProfileDialogWidget( const QString& name, QWidget* parent, const char* name = 0l);
16 ~ProfileDialogWidget();
17
18 /*
19 * load data from a Profile into
20 * the DialogWidget
21 */
22 virtual void load( const Profile& ) = 0;
23
24 /*
25 * save data into a profile
26 * from the DialogWidget
27 */
28 virtual void save( Profile& ) = 0;
29
30 virtual Type type()const = 0;
31};
32class ProfileDialogTerminalWidget : public ProfileDialogWidget {
33 Q_OBJECT
34public:
35 ProfileDialogTerminalWidget( const QString& name, QWidget* widget,
36 const char* name =0l);
37 ~ProfileDialogTerminalWidget();
38 Type type()const;
39};
40class ProfileDialogConnectionWidget : public ProfileDialogWidget {
41 Q_OBJECT
42public:
43 ProfileDialogConnectionWidget( const QString& name, QWidget* parent,
44 const char* name =0l);
45 ~ProfileDialogConnectionWidget();
46 Type type() const;
47
48};
49
50#endif
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 3843943..061b1c2 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,11 +1,10 @@
1#include <qlayout.h>
2#include <qlineedit.h>
3#include <qlabel.h>
4#include <qmessagebox.h>
5#include <qstringlist.h>
6#include <qcombobox.h>
1 7
2#include <opie/otabwidget.h>
3#include "profileeditordialog.h"
4 8
5#include "qlayout.h" 9#include <opie/otabwidget.h>
6#include "qlineedit.h"
7#include "qlabel.h"
8#include "qmessagebox.h"
9#include "qstringlist.h"
10#include "qcombobox.h"
11 10
@@ -13,2 +12,15 @@
13#include "metafactory.h" 12#include "metafactory.h"
13#include "profileeditordialog.h"
14
15namespace {
16 void setCurrent( const QString& str, QComboBox* bo ) {
17 for (uint i = 0; i < bo->count(); i++ ) {
18 if ( bo->text(i) == str ) {
19 bo->setCurrentItem( i );
20 }
21 }
22 }
23
24
25}
14 26
@@ -29,3 +41,3 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
29 // Default profile 41 // Default profile
30 m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); 42 m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102);
31 43
@@ -44,2 +56,3 @@ void ProfileEditorDialog::initUI()
44{ 56{
57 m_con = m_term = 0l;
45 58
@@ -49,86 +62,67 @@ void ProfileEditorDialog::initUI()
49 62
50 QWidget *tabterm, *tabconn, *tabprof; 63 QWidget *tabprof;
51 64
52 tabprof = new QWidget(this); 65 /* base tabs */
53 tabterm = new QWidget(this); 66 tabprof = new QWidget(this);
54 tabconn = new QWidget(this); 67 m_tabTerm = new QWidget(this);
55 68 m_tabCon = new QWidget(this);
56 // for the time being: fake factory 69
57 70 /* base layout for tabs */
58 m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); 71 m_layCon = new QHBoxLayout( m_tabCon , 2 );
59 m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); 72 m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
60 m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); 73
61 74 // profile tab
62 // profile tab 75
63 76 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
64 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); 77 m_name = new QLineEdit(tabprof);
65 78 QLabel *con = new QLabel(tr("Connection"), tabprof );
66 name_line = new QLineEdit(tabprof); 79 QLabel *term = new QLabel(tr("Terminal"), tabprof );
67 80 m_conCmb = new QComboBox( tabprof );
68 // connection tab, fixed part 81 m_termCmb = new QComboBox( tabprof );
69 82
70 QLabel *device = new QLabel(QObject::tr("Device"), tabconn); 83 // layouting
71 84 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
72 device_box = new QComboBox(tabconn); 85 vbox3->add(name);
73 86 vbox3->add(m_name);
74 QStringList w = m_fact->configWidgets(); 87 vbox3->add(con );
75 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 88 vbox3->add(m_conCmb );
76 device_box->insertItem(m_fact->name((*it))); 89 vbox3->add(term );
77 90 vbox3->add(m_termCmb );
78 // connection tab, factory part 91 vbox3->addStretch(1);
79 plugin_base = new QWidget(tabconn); 92
80 plugin_layout = new QHBoxLayout(plugin_base, 0); 93 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
81 94 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
82 plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof); 95 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
83 plugin_layout->add(plugin_plugin->widget()); 96 tabWidget->setCurrentTab( tabprof );
84 97
85 // connection tab, general part 98
99 // fill the comboboxes
100 QStringList list = m_fact->connectionWidgets();
101 QStringList::Iterator it;
102 for (it =list.begin(); it != list.end(); ++it ) {
103 m_conCmb->insertItem( (*it) );
104 }
105 list = m_fact->terminalWidgets();
106 for (it =list.begin(); it != list.end(); ++it ) {
107 m_termCmb->insertItem( (*it) );
108 }
109
110 // load profile values
111 m_name->setText(m_prof.name());
112 slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
113 slotTermActivated( m_fact->external(m_prof.terminalName() ) );
114 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
115 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
116
117 qWarning("Layer: %s %s", m_prof.ioLayerName().data(),
118 m_fact->external(m_prof.ioLayerName() ).latin1() );
119 qWarning("Term: %s %s", m_prof.terminalName().data(),
120 m_fact->external(m_prof.terminalName() ).latin1() );
121
122 // signal and slots
123 connect(m_conCmb, SIGNAL(activated(const QString& ) ),
124 this, SLOT(slotConActivated(const QString&) ) );
125 connect(m_termCmb, SIGNAL(activated(const QString& ) ),
126 this, SLOT(slotTermActivated(const QString& ) ) );
86 127
87 QWidget *conn_widget = plugin_plugin->connection_widget();
88 conn_widget->reparent(tabconn, 0, QPoint(), true);
89
90 // terminal tab
91
92 QWidget *term_widget = plugin_plugin->terminal_widget();
93 term_widget->reparent(tabterm, 0, QPoint(), true);
94
95 // layouting
96
97 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
98 vbox3->add(name);
99 vbox3->add(name_line);
100 vbox3->addStretch(1);
101
102 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
103 vbox->add(device);
104 vbox->add(device_box);
105 vbox->add(plugin_base);
106 vbox->add(conn_widget);
107 vbox->setStretchFactor(device, 1);
108 vbox->setStretchFactor(device_box, 1);
109 vbox->setStretchFactor(plugin_base, 1);
110 vbox->setStretchFactor(conn_widget, 7);
111
112 QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2);
113 vbox2->add(term_widget);
114
115 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
116 tabWidget->addTab(tabconn, "", QObject::tr("Connection"));
117 tabWidget->addTab(tabterm, "", QObject::tr("Terminal"));
118 tabWidget->setCurrentTab( tabprof );
119
120 // load profile values
121 name_line->setText(m_prof.name());
122 for(int i = 0; i < device_box->count(); i++)
123 {
124 device_box->setCurrentItem(i);
125 if(prof_type() == m_prof.ioLayerName())
126 {
127 slotDevice(i);
128 break;
129 }
130 }
131
132 // signals
133 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
134} 128}
@@ -138,21 +132,5 @@ ProfileEditorDialog::~ProfileEditorDialog() {
138} 132}
139
140void ProfileEditorDialog::slotDevice(int id)
141{
142 delete plugin_plugin;
143
144 plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof);
145 plugin_layout->add(plugin_plugin->widget());
146
147 // Reload profile associated to device, including e.g. conn_device()
148 // m_prof = plugin_plugin->profile()
149 // or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
150
151 //plugin_plugin->show();
152 plugin_plugin->widget()->show();
153}
154
155void ProfileEditorDialog::accept() 133void ProfileEditorDialog::accept()
156{ 134{
157 if(prof_name().isEmpty()) 135 if(profName().isEmpty())
158 { 136 {
@@ -164,7 +142,10 @@ void ProfileEditorDialog::accept()
164 // Save profile and plugin profile 142 // Save profile and plugin profile
165 if(plugin_plugin) plugin_plugin->save(); 143 //if(plugin_plugin) plugin_plugin->save();
166 144
167 // Save general values 145 // Save general values
168 m_prof.setName(prof_name()); 146 m_prof.setName(profName());
169 m_prof.setIOLayer(prof_type()); 147 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
148 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
149 qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(),
150 m_termCmb->currentText().latin1() );
170 151
@@ -174,16 +155,36 @@ void ProfileEditorDialog::accept()
174 155
175QString ProfileEditorDialog::prof_name() 156QString ProfileEditorDialog::profName()const
176{ 157{
177 return name_line->text(); 158 return m_name->text();
178} 159}
179 160
180QString ProfileEditorDialog::prof_type() 161QCString ProfileEditorDialog::profType()const
181{ 162{
182 QStringList w = m_fact->configWidgets(); 163 /*QStringList w = m_fact->configWidgets();
183 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 164 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
184 if(device_box->currentText() == m_fact->name((*it))) return (*it); 165 if(device_box->currentText() == m_fact->name((*it))) return (*it);
185 166 */
186 return QString::null; 167 return QCString();
168}
169/*
170 * we need to switch the widget
171 */
172void ProfileEditorDialog::slotConActivated( const QString& str ) {
173 delete m_con;
174 m_con = m_fact->newConnectionPlugin( str, m_tabCon );
175
176 if (m_con )
177 m_layCon->addWidget( m_con );
178}
179/*
180 * we need to switch the widget
181 */
182void ProfileEditorDialog::slotTermActivated( const QString& str ) {
183 delete m_term;
184 m_term = m_fact->newTerminalPlugin( str, 0l );
185 qWarning("past");
186
187 if (m_term)
188 m_layTerm->addWidget( m_term );
187} 189}
188
189 190
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index 8e830f1..3b67bb3 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -14,3 +14,3 @@ class QComboBox;
14class QLabel; 14class QLabel;
15class ProfileEditorPlugin; 15class ProfileDialogWidget;
16 16
@@ -22,7 +22,6 @@ public:
22 ProfileEditorDialog(MetaFactory* fact ); 22 ProfileEditorDialog(MetaFactory* fact );
23 ~ProfileEditorDialog(); 23 ~ProfileEditorDialog();
24 Profile profile()const; 24 Profile profile()const;
25 25
26 QString prof_name(); 26
27 QString prof_type();
28 27
@@ -30,10 +29,12 @@ public slots:
30 void accept(); 29 void accept();
31 void slotDevice(int id);
32 30
31private slots:
32 void slotConActivated(const QString& );
33 void slotTermActivated( const QString& );
33private: 34private:
34 void initUI(); 35 void initUI();
36 QString profName()const;
37 QCString profType()const;
35 38
36 MetaFactory* m_fact; 39 MetaFactory* m_fact;
37 EditBase* m_base;
38 QTabWidget* m_tab;
39 QHBoxLayout* m_lay; 40 QHBoxLayout* m_lay;
@@ -41,8 +42,8 @@ private:
41 42
42 QLineEdit *name_line; 43 QLineEdit *m_name;
43 QComboBox *device_box; 44 QComboBox *m_conCmb, *m_termCmb;
44 45
45 QWidget *plugin_base; 46 QWidget *m_tabCon, *m_tabTerm;
46 ProfileEditorPlugin *plugin_plugin; 47 ProfileDialogWidget* m_con, *m_term;
47 QHBoxLayout *plugin_layout; 48 QHBoxLayout *m_layCon, *m_layTerm;
48}; 49};
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h
index 591163a..4ca780e 100644
--- a/noncore/apps/opie-console/profileeditorplugins.h
+++ b/noncore/apps/opie-console/profileeditorplugins.h
@@ -5,3 +5,3 @@
5 5
6#include "qobject.h" 6#include <qobject.h>
7 7
@@ -11,72 +11,72 @@ class ProfileEditorPlugin : public QObject
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 public: 13public:
14 ProfileEditorPlugin(QWidget *parent, Profile *p); 14 ProfileEditorPlugin(QWidget *parent);
15 15
16 virtual ~ProfileEditorPlugin(); 16 virtual ~ProfileEditorPlugin();
17 17
18 virtual void save() = 0; 18 virtual void save() = 0;
19 19
20 virtual QWidget *widget() = 0; 20 virtual QWidget *widget() = 0;
21 21
22 QWidget *connection_widget(); 22 QWidget *connection_widget();
23 QWidget *terminal_widget(); 23 QWidget *terminal_widget();
24 24
25 public slots: 25public slots:
26 void slotConnFlow(int id); 26 void slotConnFlow(int id);
27 void slotConnParity(int id); 27 void slotConnParity(int id);
28 void slotConnSpeed(int id); 28 void slotConnSpeed(int id);
29 void slotTermTerm(int id); 29 void slotTermTerm(int id);
30 void slotTermColour(int id); 30 void slotTermColour(int id);
31 void slotTermFont(int id); 31 void slotTermFont(int id);
32 void slotTermEcho(bool on); 32 void slotTermEcho(bool on);
33 void slotTermWrap(bool on); 33 void slotTermWrap(bool on);
34 void slotTermInbound(bool on); 34 void slotTermInbound(bool on);
35 void slotTermOutbound(bool on); 35 void slotTermOutbound(bool on);
36 36
37 protected: 37protected:
38 QWidget *m_parent, *m_widget; 38 QWidget *m_parent, *m_widget;
39 Profile *m_profile; 39 Profile *m_profile;
40 40
41 private: 41private:
42 enum ParityIds 42 enum ParityIds
43 { 43 {
44 id_parity_odd, 44 id_parity_odd,
45 id_parity_even 45 id_parity_even
46 }; 46 };
47 47
48 enum FlowIds 48 enum FlowIds
49 { 49 {
50 id_flow_hw, 50 id_flow_hw,
51 id_flow_sw 51 id_flow_sw
52 }; 52 };
53 53
54 enum SpeedIds 54 enum SpeedIds
55 { 55 {
56 id_baud_115200, 56 id_baud_115200,
57 id_baud_57600, 57 id_baud_57600,
58 id_baud_38400, 58 id_baud_38400,
59 id_baud_19200, 59 id_baud_19200,
60 id_baud_9600 60 id_baud_9600
61 }; 61 };
62 62
63 enum TermIds 63 enum TermIds
64 { 64 {
65 id_term_vt100, 65 id_term_vt100,
66 id_term_vt220, 66 id_term_vt220,
67 id_term_ansi 67 id_term_ansi
68 }; 68 };
69 69
70 enum ColourIds 70 enum ColourIds
71 { 71 {
72 id_term_black, 72 id_term_black,
73 id_term_white 73 id_term_white
74 }; 74 };
75 75
76 enum FontIds 76 enum FontIds
77 { 77 {
78 id_size_small, 78 id_size_small,
79 id_size_medium, 79 id_size_medium,
80 id_size_large 80 id_size_large
81 }; 81 };
82}; 82};
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 72a5117..6ad08b5 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -30,3 +30,4 @@ void ProfileManager::load() {
30 prof.setName( conf.readEntry("name") ); 30 prof.setName( conf.readEntry("name") );
31 prof.setIOLayer( conf.readEntry("iolayer") ); 31 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
32 prof.setTerminalName( conf.readEntry("term").utf8() );
32 prof.setBackground( conf.readNumEntry("back") ); 33 prof.setBackground( conf.readNumEntry("back") );
@@ -67,3 +68,4 @@ void ProfileManager::save( ) {
67 conf.writeEntry( "name", (*it).name() ); 68 conf.writeEntry( "name", (*it).name() );
68 conf.writeEntry( "ioplayer", (*it).ioLayerName() ); 69 conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) );
70 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
69 conf.writeEntry( "back", (*it).background() ); 71 conf.writeEntry( "back", (*it).background() );
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index de321ae..10f3f7a 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -5,3 +5,3 @@
5 5
6SzTransfer::SzTransfer(IOLayer *layer) : FileTransferLayer(layer) 6SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
7{ 7{
diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h
index 778d1d3..825680d 100644
--- a/noncore/apps/opie-console/sz_transfer.h
+++ b/noncore/apps/opie-console/sz_transfer.h
@@ -11,4 +11,9 @@ class SzTransfer : public FileTransferLayer {
11public: 11public:
12 enum Type {
13 SZ=0,
14 SX,
15 SY
16 };
12 17
13 SzTransfer( IOLayer * ); 18 SzTransfer( Type t, IOLayer * );
14 ~SzTransfer(); 19 ~SzTransfer();
@@ -19,4 +24,4 @@ public slots:
19 */ 24 */
20 void sendFile( const QString& file ) = 0; 25 void sendFile( const QString& file ) ;
21 void sendFile( const QFile& ) = 0; 26 void sendFile( const QFile& );
22 27
@@ -29,2 +34,3 @@ private:
29 OProcess *proc; 34 OProcess *proc;
35 Type m_t;
30 36