author | zecke <zecke> | 2002-10-08 23:13:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-08 23:13:17 (UTC) |
commit | 8c353ec8b86ee8f82cc25172fb69dd5fee65e848 (patch) (side-by-side diff) | |
tree | a4549bcba962689edb9c40efcb23114cae5fcda2 /noncore/apps/opie-console/serialconfigwidget.cpp | |
parent | ca0c224318a50c6618691fb30f39aa1d9b0b8a4f (diff) | |
download | opie-8c353ec8b86ee8f82cc25172fb69dd5fee65e848.zip opie-8c353ec8b86ee8f82cc25172fb69dd5fee65e848.tar.gz opie-8c353ec8b86ee8f82cc25172fb69dd5fee65e848.tar.bz2 |
default I dunno
IOLayerBase the return values for speed()/parity()/flow() added
MainWindow debug code :(
opie-console.pro addition of serialconfigwidget.*
ProfileManager fix removing of Profiles quite rude way of doing it
Configure stuff is done and roughly tested
The migration is done!
TO WAZLAF: you might want to adjust Parity stuff for your needs!
Diffstat (limited to 'noncore/apps/opie-console/serialconfigwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp new file mode 100644 index 0000000..a427302 --- a/dev/null +++ b/noncore/apps/opie-console/serialconfigwidget.cpp @@ -0,0 +1,135 @@ +#include <qlabel.h> +#include <qlayout.h> +#include <qcombobox.h> + +#include "iolayerbase.h" +#include "serialconfigwidget.h" + +namespace { + void setCurrent( const QString& str, QComboBox* bo ) { + uint b = bo->count(); + for (uint i = 0; i < bo->count(); i++ ) { + if ( bo->text(i) == str ) { + bo->setCurrentItem( i ); + return; + } + } + bo->insertItem( str ); + bo->setCurrentItem( b ); + } + + +} + +SerialConfigWidget::SerialConfigWidget( const QString& name, + QWidget* parent, + const char* na ) + : ProfileDialogConnectionWidget( name, parent, na ) { + + m_lay = new QVBoxLayout(this ); + m_device = new QLabel(tr("Device"), this ); + m_deviceCmb = new QComboBox(this ); + m_deviceCmb->setEditable( TRUE ); + + m_base = new IOLayerBase(this, "base"); + + m_lay->addWidget( m_device ); + m_lay->addWidget( m_deviceCmb ); + m_lay->addWidget( m_base ); + + m_deviceCmb->insertItem( "/dev/ttyS0" ); + m_deviceCmb->insertItem( "/dev/ttyS1" ); + m_deviceCmb->insertItem( "/dev/ttySA0"); + m_deviceCmb->insertItem( "/dev/ttySA1"); + +} +SerialConfigWidget::~SerialConfigWidget() { + +} +void SerialConfigWidget::load( const Profile& prof ) { + int rad_flow = prof.readNumEntry("Flow"); + int rad_parity = prof.readNumEntry("Parity"); + int speed = prof.readNumEntry("Speed"); + + if (rad_flow == 0) + m_base->setFlow( IOLayerBase::Hardware ); + else + m_base->setFlow( IOLayerBase::Software ); + + if (rad_parity == 1) + m_base->setParity( IOLayerBase::Even ); + else + m_base->setParity( IOLayerBase::Odd ); + + switch( speed ) { + case 115200: + m_base->setSpeed(IOLayerBase::Baud_115200 ); + break; + case 57600: + m_base->setSpeed( IOLayerBase::Baud_57600 ); + break; + case 38400: + m_base->setSpeed(IOLayerBase::Baud_38400 ); + break; + case 19200: + m_base->setSpeed( IOLayerBase::Baud_19200 ); + break; + case 9600: + default: + m_base->setSpeed(IOLayerBase::Baud_9600 ); + break; + } + + if ( prof.readEntry("Device").isEmpty() ) return; + setCurrent( prof.readEntry("Device"), m_deviceCmb ); + +} +/* + * save speed, + * flow, + * parity + */ +void SerialConfigWidget::save( Profile& prof ) { + int flow, parity, speed; + prof.writeEntry("Device", m_deviceCmb->currentText() ); + + switch( m_base->flow() ) { + case IOLayerBase::Software: + flow = 1; + break; + case IOLayerBase::Hardware: + flow = 0; + break; + } + + switch( m_base->parity() ) { + case IOLayerBase::Odd: + parity = 2; + break; + case IOLayerBase::Even: + parity = 1; + break; + } + + switch( m_base->speed() ) { + case IOLayerBase::Baud_115200: + speed = 115200; + break; + case IOLayerBase::Baud_57600: + speed = 57600; + break; + case IOLayerBase::Baud_38400: + speed = 38400; + break; + case IOLayerBase::Baud_19200: + speed = 19200; + break; + case IOLayerBase::Baud_9600: + speed = 9600; + break; + } + + prof.writeEntry("Flow", flow); + prof.writeEntry("Parity", parity); + prof.writeEntry("Speed", speed); +} |