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/profileeditorplugins.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/profileeditorplugins.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp new file mode 100644 index 0000000..54eee3f --- a/dev/null +++ b/noncore/apps/opie-console/profileeditorplugins.cpp @@ -0,0 +1,164 @@ + +#include "profileeditorplugins.h" +#include "profile.h" + +#include "qframe.h" +#include "qlabel.h" +#include "qlineedit.h" +#include "qlayout.h" + +ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p) +{ + m_parent = parent; + m_profile = p; + m_widget = NULL; +} + +ProfileEditorPlugin::~ProfileEditorPlugin() +{ + if(m_widget) delete m_widget; +} + +class ProfileEditorPluginSerial : public ProfileEditorPlugin +{ + public: + + ProfileEditorPluginSerial(QWidget *parent, Profile p) + : ProfileEditorPlugin(parent, p) + { + } + + ~ProfileEditorPluginSerial() + { + } + + QWidget *widget() + { + if(!m_widget) + { + QFrame *device_frame = new QFrame(m_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); + + m_widget = device_frame; + } + + return m_widget; + } + + void save() + { + } +}; + +class ProfileEditorPluginIrda : public ProfileEditorPlugin +{ + public: + + ProfileEditorPluginIrda(QWidget *parent, Profile p) + : ProfileEditorPlugin(parent, p) + { + } + + ~ProfileEditorPluginIrda() + { + } + + QWidget *widget() + { + if(!m_widget) + { + QFrame *device_frame = new QFrame(m_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); + + m_widget = device_frame; + } + + return m_widget; + } + + void save() + { + } +}; + +class ProfileEditorPluginModem : public ProfileEditorPlugin +{ + public: + + ProfileEditorPluginModem(QWidget *parent, Profile p) + : ProfileEditorPlugin(parent, p) + { + } + + ~ProfileEditorPluginModem() + { + } + + QWidget *widget() + { + if(!m_widget) + { + QFrame *device_frame = new QFrame(m_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); + + device_line = new QLineEdit("/dev/ttyS0", device_frame); + number_line = new QLineEdit(device_frame); + + QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); + vbox_frame->add(frame_device); + vbox_frame->add(device_line); + vbox_frame->add(frame_number); + vbox_frame->add(number_line); + + m_widget = device_frame; + } + + return m_widget; + } + + void save() + { + // special settings + Profile p = m_profile; + p.writeEntry("Device", device_line->text()); + p.writeEntry("Number", number_line->text()); + } + + private: + QLineEdit *device_line, *number_line; +}; + +ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p) +{ + return new ProfileEditorPluginSerial(parent, p); +} + +ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p) +{ + return new ProfileEditorPluginIrda(parent, p); +} + +ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p) +{ + return new ProfileEditorPluginModem(parent, p); +} + |