summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/metafactory.cpp11
-rw-r--r--noncore/apps/opie-console/metafactory.h1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp52
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h2
4 files changed, 52 insertions, 14 deletions
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 04f1cbe..ea7f739 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -35,31 +35,42 @@ QStringList MetaFactory::configWidgets()const {
35 list << it.key(); 35 list << it.key();
36 } 36 }
37 return list; 37 return list;
38} 38}
39QStringList MetaFactory::fileTransferLayers()const { 39QStringList MetaFactory::fileTransferLayers()const {
40 QStringList list; 40 QStringList list;
41 QMap<QString, filelayer>::ConstIterator it; 41 QMap<QString, filelayer>::ConstIterator it;
42 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 42 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
43 list << it.key(); 43 list << it.key();
44 } 44 }
45 return list; 45 return list;
46} 46}
47
47IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 48IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
48 IOLayer* lay = 0l; 49 IOLayer* lay = 0l;
49 50
50 QMap<QString, iolayer>::Iterator it; 51 QMap<QString, iolayer>::Iterator it;
51 it = m_layerFact.find( str ); 52 it = m_layerFact.find( str );
52 if ( it != m_layerFact.end() ) { 53 if ( it != m_layerFact.end() ) {
53 lay = (*(it.data()))(prof); 54 lay = (*(it.data()))(prof);
54 /* 55 /*
55 iolayer laye = it.data(); 56 iolayer laye = it.data();
56 lay = (*laye )(conf);*/ 57 lay = (*laye )(conf);*/
57 } 58 }
58 59
59 return lay; 60 return lay;
60} 61}
61 62
63QWidget *MetaFactory::newConfigWidget ( const QString& str, QWidget* parent) {
64 QWidget *w = NULL;
65 configWidget c;
66
67 c = m_confFact[str];
68 if(c) w = c(parent);
69
70 return w;
71}
72
62QString MetaFactory::name( const QString& str ) { 73QString MetaFactory::name( const QString& str ) {
63 return m_namemap[str]; 74 return m_namemap[str];
64} 75}
65 76
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 7fa53c6..2245231 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -26,24 +26,25 @@ public:
26 26
27 void addConfigWidgetFactory( const QString&, 27 void addConfigWidgetFactory( const QString&,
28 const QString&, 28 const QString&,
29 configWidget ); 29 configWidget );
30 void addIOLayerFactory(const QString&, 30 void addIOLayerFactory(const QString&,
31 iolayer ); 31 iolayer );
32 void addFileTransferLayer( const QString&, 32 void addFileTransferLayer( const QString&,
33 filelayer ); 33 filelayer );
34 QStringList ioLayers()const; 34 QStringList ioLayers()const;
35 QStringList configWidgets()const; 35 QStringList configWidgets()const;
36 QStringList fileTransferLayers()const; 36 QStringList fileTransferLayers()const;
37 IOLayer* newIOLayer( const QString&,const Profile& ); 37 IOLayer* newIOLayer( const QString&,const Profile& );
38 QWidget *newConfigWidget ( const QString&, QWidget* );
38 39
39 QString name( const QString& ); 40 QString name( const QString& );
40 41
41private: 42private:
42 QMap<QString, configWidget> m_confFact; 43 QMap<QString, configWidget> m_confFact;
43 QMap<QString, iolayer> m_layerFact; 44 QMap<QString, iolayer> m_layerFact;
44 QMap<QString, filelayer> m_fileFact; 45 QMap<QString, filelayer> m_fileFact;
45 QMap<QString, QString> m_namemap; 46 QMap<QString, QString> m_namemap;
46}; 47};
47 48
48 49
49#endif 50#endif
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 859abdd..374844e 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -10,48 +10,68 @@
10#include "qmessagebox.h" 10#include "qmessagebox.h"
11#include "qbuttongroup.h" 11#include "qbuttongroup.h"
12#include "qstringlist.h" 12#include "qstringlist.h"
13 13
14#include "metafactory.h" 14#include "metafactory.h"
15 15
16static QWidget *factory_serial(QWidget *parent) 16static QWidget *factory_serial(QWidget *parent)
17{ 17{
18 QFrame *device_frame = new QFrame(parent); 18 QFrame *device_frame = new QFrame(parent);
19 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); 19 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
20 20
21 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); 21 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
22 QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame);
23 frame_number->hide();
24 22
25 QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame); 23 QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame);
26 QLineEdit *frame_number_line = new QLineEdit(device_frame);
27 frame_number_line->hide();
28 24
29 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); 25 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
30 vbox_frame->add(frame_device); 26 vbox_frame->add(frame_device);
31 vbox_frame->add(frame_device_line); 27 vbox_frame->add(frame_device_line);
32 vbox_frame->add(frame_number);
33 vbox_frame->add(frame_number_line);
34 28
35 return device_frame; 29 return device_frame;
36} 30}
37 31
38static QWidget *factory_irda(QWidget *parent) 32static QWidget *factory_irda(QWidget *parent)
39{ 33{
40 return NULL; 34 QFrame *device_frame = new QFrame(parent);
35 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
36
37 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
38
39 QLineEdit *frame_device_line = new QLineEdit("/dev/ircomm0", device_frame);
40
41 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
42 vbox_frame->add(frame_device);
43 vbox_frame->add(frame_device_line);
44
45 return device_frame;
41} 46}
42 47
43static QWidget *factory_modem(QWidget *parent) 48static QWidget *factory_modem(QWidget *parent)
44{ 49{
45 return NULL; 50 QFrame *device_frame = new QFrame(parent);
51 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
52
53 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
54 QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame);
55
56 QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame);
57 QLineEdit *frame_number_line = new QLineEdit(device_frame);
58
59 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
60 vbox_frame->add(frame_device);
61 vbox_frame->add(frame_device_line);
62 vbox_frame->add(frame_number);
63 vbox_frame->add(frame_number_line);
64
65 return device_frame;
46} 66}
47 67
48ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 68ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
49 const Profile& prof ) 69 const Profile& prof )
50 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 70 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
51{ 71{
52// initUI(); 72// initUI();
53 /* now set the widgets */ 73 /* now set the widgets */
54 74
55} 75}
56 76
57ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 77ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
@@ -77,25 +97,29 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
77 97
78 // connection tab, fixed part 98 // connection tab, fixed part
79 99
80 QLabel *device = new QLabel(QObject::tr("Device"), tabconn); 100 QLabel *device = new QLabel(QObject::tr("Device"), tabconn);
81 101
82 device_box = new QComboBox(tabconn); 102 device_box = new QComboBox(tabconn);
83 103
84 QStringList w = m_fact->configWidgets(); 104 QStringList w = m_fact->configWidgets();
85 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 105 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
86 device_box->insertItem(m_fact->name((*it))); 106 device_box->insertItem(m_fact->name((*it)));
87 107
88 // connection tab, factory part 108 // connection tab, factory part
89 QFrame *device_frame = static_cast<QFrame*>(factory_serial(tabconn)); 109 plugin_base = new QWidget(tabconn);
110 plugin_layout = new QHBoxLayout(plugin_base, 0);
111
112 plugin_plugin = m_fact->newConfigWidget("serial", plugin_base);
113 plugin_layout->add(plugin_plugin);
90 114
91 // connection tab, general part 115 // connection tab, general part
92 116
93 speed_box = new QComboBox(tabconn); 117 speed_box = new QComboBox(tabconn);
94 speed_box->insertItem("115200 baud"); 118 speed_box->insertItem("115200 baud");
95 speed_box->insertItem("57600 baud"); 119 speed_box->insertItem("57600 baud");
96 speed_box->insertItem("38400 baud"); 120 speed_box->insertItem("38400 baud");
97 speed_box->insertItem("19200 baud"); 121 speed_box->insertItem("19200 baud");
98 speed_box->insertItem("9600 baud"); 122 speed_box->insertItem("9600 baud");
99 123
100 QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); 124 QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn);
101 QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); 125 QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn);
@@ -151,25 +175,25 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
151 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm); 175 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm);
152 176
153 // layouting 177 // layouting
154 178
155 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 179 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
156 vbox3->add(name); 180 vbox3->add(name);
157 vbox3->add(name_line); 181 vbox3->add(name_line);
158 vbox3->addStretch(1); 182 vbox3->addStretch(1);
159 183
160 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); 184 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
161 vbox->add(device); 185 vbox->add(device);
162 vbox->add(device_box); 186 vbox->add(device_box);
163 vbox->add(device_frame); 187 vbox->add(plugin_base);
164 vbox->add(speed); 188 vbox->add(speed);
165 vbox->add(speed_box); 189 vbox->add(speed_box);
166 vbox->add(flow); 190 vbox->add(flow);
167 QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); 191 QHBoxLayout *hbox = new QHBoxLayout(vbox, 2);
168 hbox->add(flow_hw); 192 hbox->add(flow_hw);
169 hbox->add(flow_sw); 193 hbox->add(flow_sw);
170 //vbox->add(group_flow); 194 //vbox->add(group_flow);
171 vbox->add(parity); 195 vbox->add(parity);
172 QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); 196 QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2);
173 hbox2->add(parity_odd); 197 hbox2->add(parity_odd);
174 hbox2->add(parity_even); 198 hbox2->add(parity_even);
175 //vbox->add(group_parity); 199 //vbox->add(group_parity);
@@ -205,30 +229,30 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
205 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk())); 229 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk()));
206 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); 230 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
207 231
208 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); 232 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
209} 233}
210 234
211ProfileEditorDialog::~ProfileEditorDialog() { 235ProfileEditorDialog::~ProfileEditorDialog() {
212 236
213} 237}
214 238
215void ProfileEditorDialog::slotDevice(int id) 239void ProfileEditorDialog::slotDevice(int id)
216{ 240{
217 MetaFactory::configWidget c; 241 delete plugin_plugin;
218 242
219 //c = m_fact->; 243 plugin_plugin = m_fact->newConfigWidget(prof_type(), plugin_base);
220 c = factory_serial; 244 plugin_layout->add(plugin_plugin);
221 245
222 QFrame *device_frame = static_cast<QFrame*>(c(NULL)); 246 plugin_plugin->show();
223} 247}
224 248
225void ProfileEditorDialog::slotOk() 249void ProfileEditorDialog::slotOk()
226{ 250{
227 if(prof_name().isEmpty()) 251 if(prof_name().isEmpty())
228 { 252 {
229 QMessageBox::information(this, 253 QMessageBox::information(this,
230 QObject::tr("Invalid profile"), 254 QObject::tr("Invalid profile"),
231 QObject::tr("Please enter a profile name.")); 255 QObject::tr("Please enter a profile name."));
232 return; 256 return;
233 } 257 }
234 258
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index dfe4490..00f3c99 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -43,15 +43,17 @@ public slots:
43private: 43private:
44 //void initUI(); 44 //void initUI();
45 MetaFactory* m_fact; 45 MetaFactory* m_fact;
46 EditBase* m_base; 46 EditBase* m_base;
47 QTabWidget* m_tab; 47 QTabWidget* m_tab;
48 QHBoxLayout* m_lay; 48 QHBoxLayout* m_lay;
49 Profile m_prof; 49 Profile m_prof;
50 50
51 //QLabel *frame_number; 51 //QLabel *frame_number;
52 QLineEdit *name_line; 52 QLineEdit *name_line;
53 //QLineEdit *frame_device_line, *frame_number_line; 53 //QLineEdit *frame_device_line, *frame_number_line;
54 QComboBox *terminal_box, *speed_box, *device_box; 54 QComboBox *terminal_box, *speed_box, *device_box;
55 QWidget *plugin_base, *plugin_plugin;
56 QHBoxLayout *plugin_layout;
55}; 57};
56 58
57#endif 59#endif