author | josef <josef> | 2002-10-06 18:34:28 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-06 18:34:28 (UTC) |
commit | aa8332baeebf7056d81fc245399477c7feaa1235 (patch) (side-by-side diff) | |
tree | 4b23429bcad955d02df24b40144cf5b7b6ffe0f3 /noncore/apps/opie-console/profileeditordialog.cpp | |
parent | 6da8cac26f1d610d458c91bc2daad018cf9cf887 (diff) | |
download | opie-aa8332baeebf7056d81fc245399477c7feaa1235.zip opie-aa8332baeebf7056d81fc245399477c7feaa1235.tar.gz opie-aa8332baeebf7056d81fc245399477c7feaa1235.tar.bz2 |
- more factorization (is nearly complete now ;)
- move config plugins into separate file (3 classes and virtual superclass)
- first stub for save function
Diffstat (limited to 'noncore/apps/opie-console/profileeditordialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 81 |
1 files changed, 8 insertions, 73 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index aee4051..fbe0f23 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -8,78 +8,15 @@ #include "qcombobox.h" #include "qcheckbox.h" #include "qmessagebox.h" #include "qbuttongroup.h" #include "qstringlist.h" +#include "profileeditorplugins.h" #include "metafactory.h" -static QWidget *factory_serial(QWidget *parent) -{ - QFrame *device_frame = new QFrame(parent); - device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); - - QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame); - - QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); - vbox_frame->add(frame_device); - vbox_frame->add(frame_device_line); - - return device_frame; -} - -static QWidget *factory_irda(QWidget *parent) -{ - QFrame *device_frame = new QFrame(parent); - device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); - - QLineEdit *frame_device_line = new QLineEdit("/dev/ircomm0", device_frame); - - QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); - vbox_frame->add(frame_device); - vbox_frame->add(frame_device_line); - - return device_frame; -} - -static QWidget *factory_modem(QWidget *parent) -{ - QFrame *device_frame = new QFrame(parent); - device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); - QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); - - QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame); - QLineEdit *frame_number_line = new QLineEdit(device_frame); - - QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); - vbox_frame->add(frame_device); - vbox_frame->add(frame_device_line); - vbox_frame->add(frame_number); - vbox_frame->add(frame_number_line); - - return device_frame; -} - -// Something like that must be called upon plugin_plugin->save() -//void save_modem() -//{ -// // special settings -// p.writeEntry("Device", dlg.conn_device()); -// p.writeEntry("Baud", dlg.conn_baud()); -// p.writeEntry("Parity", dlg.conn_parity()); -// p.writeEntry("DataBits", dlg.conn_databits()); -// p.writeEntry("StopBits", dlg.conn_stopbits()); -// p.writeEntry("Flow", dlg.conn_flow()); -//} - ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, const Profile& prof ) : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) { initUI(); @@ -136,14 +73,14 @@ void ProfileEditorDialog::initUI() device_box->insertItem(m_fact->name((*it))); // connection tab, factory part plugin_base = new QWidget(tabconn); plugin_layout = new QHBoxLayout(plugin_base, 0); - plugin_plugin = m_fact->newConfigWidget("serial", plugin_base); - plugin_layout->add(plugin_plugin); + plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, m_prof); + plugin_layout->add(plugin_plugin->widget()); // connection tab, general part speed_box = new QComboBox(tabconn); speed_box->insertItem("115200 baud"); speed_box->insertItem("57600 baud"); @@ -254,14 +191,12 @@ void ProfileEditorDialog::initUI() addTab(tabconn, QObject::tr("Connection")); addTab(tabterm, QObject::tr("Terminal")); setOkButton(QObject::tr("OK")); setCancelButton(QObject::tr("Cancel")); - //connect(this, SIGNAL(applyButtonPressed()), SLOT(slotOk())); - connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk())); connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); } ProfileEditorDialog::~ProfileEditorDialog() { @@ -269,21 +204,21 @@ ProfileEditorDialog::~ProfileEditorDialog() { } void ProfileEditorDialog::slotDevice(int id) { delete plugin_plugin; - plugin_plugin = m_fact->newConfigWidget(prof_type(), plugin_base); - plugin_layout->add(plugin_plugin); + plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof); + plugin_layout->add(plugin_plugin->widget()); // Reload profile associated to device, including e.g. conn_device() // m_prof = plugin_plugin->profile() // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) - plugin_plugin->show(); - // This would be: plugin_plugin->widget()->show(); + //plugin_plugin->show(); + plugin_plugin->widget()->show(); } void ProfileEditorDialog::accept() { if(prof_name().isEmpty()) { @@ -291,13 +226,13 @@ void ProfileEditorDialog::accept() QObject::tr("Invalid profile"), QObject::tr("Please enter a profile name.")); return; } // Save profile and plugin profile - //if(plugin_plugin) plugin_plugin->save(); + if(plugin_plugin) plugin_plugin->save(); QDialog::accept(); } void ProfileEditorDialog::slotCancel() { |