author | zecke <zecke> | 2002-10-08 16:37:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-08 16:37:37 (UTC) |
commit | 76fb8a57bf9fbae3a7073c8b0be1216f34adf99c (patch) (side-by-side diff) | |
tree | 3f486d66ce474039b1a0fc4ade770e6e8a7c32b3 /noncore/apps/opie-console/profileeditordialog.cpp | |
parent | faeb94a4000dc539577af465107b5d10903f92d6 (diff) | |
download | opie-76fb8a57bf9fbae3a7073c8b0be1216f34adf99c.zip opie-76fb8a57bf9fbae3a7073c8b0be1216f34adf99c.tar.gz opie-76fb8a57bf9fbae3a7073c8b0be1216f34adf99c.tar.bz2 |
SzModem:
Make it compile remove = 0 from sendFile
Add a Type to Sz
so it could cover SX,SY too
MetaFactory:
take QCString name
QString uiString
so Carsten will be able to translate
and users can switch Language without losing profiles
Default
It's aware of all Default/BuiltIn Plugins and adds them to the factory
Common
typedef bool BOOL TT is not using bool because it wasn't available at that time
they use uint : 1...
maybe we should change UINT_8 to Q_UINT8...
MainWindow:
give the factory to the config widget
use Default
IOLayer
reload should take Profile not Config
ConfigDialog:
make use of Factory and do not do new MetaFactory.. i should
make the c'tor private and add MainWindow as friend
ProfileEditorDialog:
Huge clean ups to the architecture. I still need to convert
the widgets.
Use the factory right
Diffstat (limited to 'noncore/apps/opie-console/profileeditordialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 239 |
1 files changed, 120 insertions, 119 deletions
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,19 +1,31 @@ +#include <qlayout.h> +#include <qlineedit.h> +#include <qlabel.h> +#include <qmessagebox.h> +#include <qstringlist.h> +#include <qcombobox.h> -#include <opie/otabwidget.h> -#include "profileeditordialog.h" -#include "qlayout.h" -#include "qlineedit.h" -#include "qlabel.h" -#include "qmessagebox.h" -#include "qstringlist.h" -#include "qcombobox.h" +#include <opie/otabwidget.h> #include "profileeditorplugins.h" #include "metafactory.h" +#include "profileeditordialog.h" + +namespace { + void setCurrent( const QString& str, QComboBox* bo ) { + for (uint i = 0; i < bo->count(); i++ ) { + if ( bo->text(i) == str ) { + bo->setCurrentItem( i ); + } + } + } + + +} ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, const Profile& prof ) : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) { initUI(); @@ -24,13 +36,13 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) : QDialog(0, 0, TRUE), m_fact( fact ) { // Default profile - m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); + m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); initUI(); // Apply current profile // plugin_plugin->load(profile); } @@ -39,151 +51,140 @@ Profile ProfileEditorDialog::profile() const { return m_prof; } void ProfileEditorDialog::initUI() { + m_con = m_term = 0l; QVBoxLayout *mainLayout = new QVBoxLayout( this ); OTabWidget *tabWidget = new OTabWidget( this ); mainLayout->add(tabWidget); - QWidget *tabterm, *tabconn, *tabprof; - - tabprof = new QWidget(this); - tabterm = new QWidget(this); - tabconn = new QWidget(this); - - // for the time being: fake factory - - m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); - m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); - m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); - - // profile tab - - QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); - - name_line = new QLineEdit(tabprof); - - // connection tab, fixed part - - QLabel *device = new QLabel(QObject::tr("Device"), tabconn); - - device_box = new QComboBox(tabconn); - - QStringList w = m_fact->configWidgets(); - for(QStringList::Iterator it = w.begin(); it != w.end(); it++) - 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->newConfigPlugin("serial", plugin_base, &m_prof); - plugin_layout->add(plugin_plugin->widget()); - - // connection tab, general part + QWidget *tabprof; + + /* base tabs */ + tabprof = new QWidget(this); + m_tabTerm = new QWidget(this); + m_tabCon = new QWidget(this); + + /* base layout for tabs */ + m_layCon = new QHBoxLayout( m_tabCon , 2 ); + m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); + + // profile tab + + QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); + m_name = new QLineEdit(tabprof); + QLabel *con = new QLabel(tr("Connection"), tabprof ); + QLabel *term = new QLabel(tr("Terminal"), tabprof ); + m_conCmb = new QComboBox( tabprof ); + m_termCmb = new QComboBox( tabprof ); + + // layouting + QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); + vbox3->add(name); + vbox3->add(m_name); + vbox3->add(con ); + vbox3->add(m_conCmb ); + vbox3->add(term ); + vbox3->add(m_termCmb ); + vbox3->addStretch(1); + + tabWidget->addTab(tabprof, "", QObject::tr("Profile")); + tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); + tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); + tabWidget->setCurrentTab( tabprof ); + + + // fill the comboboxes + QStringList list = m_fact->connectionWidgets(); + QStringList::Iterator it; + for (it =list.begin(); it != list.end(); ++it ) { + m_conCmb->insertItem( (*it) ); + } + list = m_fact->terminalWidgets(); + for (it =list.begin(); it != list.end(); ++it ) { + m_termCmb->insertItem( (*it) ); + } + + // load profile values + m_name->setText(m_prof.name()); + slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); + slotTermActivated( m_fact->external(m_prof.terminalName() ) ); + setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); + setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); + + qWarning("Layer: %s %s", m_prof.ioLayerName().data(), + m_fact->external(m_prof.ioLayerName() ).latin1() ); + qWarning("Term: %s %s", m_prof.terminalName().data(), + m_fact->external(m_prof.terminalName() ).latin1() ); + + // signal and slots + connect(m_conCmb, SIGNAL(activated(const QString& ) ), + this, SLOT(slotConActivated(const QString&) ) ); + connect(m_termCmb, SIGNAL(activated(const QString& ) ), + this, SLOT(slotTermActivated(const QString& ) ) ); - QWidget *conn_widget = plugin_plugin->connection_widget(); - conn_widget->reparent(tabconn, 0, QPoint(), true); - - // terminal tab - - QWidget *term_widget = plugin_plugin->terminal_widget(); - term_widget->reparent(tabterm, 0, QPoint(), true); - - // layouting - - QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); - vbox3->add(name); - vbox3->add(name_line); - vbox3->addStretch(1); - - QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); - vbox->add(device); - vbox->add(device_box); - vbox->add(plugin_base); - vbox->add(conn_widget); - vbox->setStretchFactor(device, 1); - vbox->setStretchFactor(device_box, 1); - vbox->setStretchFactor(plugin_base, 1); - vbox->setStretchFactor(conn_widget, 7); - - QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); - vbox2->add(term_widget); - - tabWidget->addTab(tabprof, "", QObject::tr("Profile")); - tabWidget->addTab(tabconn, "", QObject::tr("Connection")); - tabWidget->addTab(tabterm, "", QObject::tr("Terminal")); - tabWidget->setCurrentTab( tabprof ); - - // load profile values - name_line->setText(m_prof.name()); - for(int i = 0; i < device_box->count(); i++) - { - device_box->setCurrentItem(i); - if(prof_type() == m_prof.ioLayerName()) - { - slotDevice(i); - break; - } - } - - // signals - connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); } ProfileEditorDialog::~ProfileEditorDialog() { } - -void ProfileEditorDialog::slotDevice(int id) -{ - delete 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(); - plugin_plugin->widget()->show(); -} - void ProfileEditorDialog::accept() { - if(prof_name().isEmpty()) + if(profName().isEmpty()) { QMessageBox::information(this, 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(); // Save general values - m_prof.setName(prof_name()); - m_prof.setIOLayer(prof_type()); + m_prof.setName(profName()); + m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); + m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); + qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(), + m_termCmb->currentText().latin1() ); QDialog::accept(); } -QString ProfileEditorDialog::prof_name() +QString ProfileEditorDialog::profName()const { - return name_line->text(); + return m_name->text(); } -QString ProfileEditorDialog::prof_type() +QCString ProfileEditorDialog::profType()const { - QStringList w = m_fact->configWidgets(); + /*QStringList w = m_fact->configWidgets(); for(QStringList::Iterator it = w.begin(); it != w.end(); it++) if(device_box->currentText() == m_fact->name((*it))) return (*it); - - return QString::null; + */ + return QCString(); +} +/* + * we need to switch the widget + */ +void ProfileEditorDialog::slotConActivated( const QString& str ) { + delete m_con; + m_con = m_fact->newConnectionPlugin( str, m_tabCon ); + + if (m_con ) + m_layCon->addWidget( m_con ); +} +/* + * we need to switch the widget + */ +void ProfileEditorDialog::slotTermActivated( const QString& str ) { + delete m_term; + m_term = m_fact->newTerminalPlugin( str, 0l ); + qWarning("past"); + + if (m_term) + m_layTerm->addWidget( m_term ); } - |