author | harlekin <harlekin> | 2002-10-25 18:48:25 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-25 18:48:25 (UTC) |
commit | 4151cc12a6c37cbec4bb6883204703eec2fb8648 (patch) (side-by-side diff) | |
tree | f7e81dc7de747628225ae4627c7cf3028183441a /noncore | |
parent | e8c4383915db7ed6f47899945404247b1fd5c3c4 (diff) | |
download | opie-4151cc12a6c37cbec4bb6883204703eec2fb8648.zip opie-4151cc12a6c37cbec4bb6883204703eec2fb8648.tar.gz opie-4151cc12a6c37cbec4bb6883204703eec2fb8648.tar.bz2 |
added data bits and stop bits
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.cpp | 102 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.h | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/modemconfigwidget.cpp | 62 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 53 |
4 files changed, 204 insertions, 24 deletions
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp index 47f9e76..ba7c86e 100644 --- a/noncore/apps/opie-console/iolayerbase.cpp +++ b/noncore/apps/opie-console/iolayerbase.cpp @@ -6,2 +6,3 @@ #include <qradiobutton.h> +#include <qhbox.h> @@ -30,2 +31,15 @@ namespace { + enum DataIds { + id_data_5, + id_data_6, + id_data_7, + id_data_8 + }; + + enum StopIds { + id_stop_1, + id_stop_1_5, + id_stop_2 + }; + } @@ -39,3 +53,3 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name ) - m_groupFlow = new QButtonGroup(tr("Flow control"),this ); + m_groupFlow = new QHButtonGroup(tr("Flow control"),this ); m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow ); @@ -44,3 +58,3 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name ) - m_groupParity = new QButtonGroup(tr("Parity"), this ); + m_groupParity = new QHButtonGroup(tr("Parity"), this ); m_parityNone = new QRadioButton(tr("None"), m_groupParity ); @@ -49,2 +63,14 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name ) + m_groupData = new QHButtonGroup(tr("Data Bits"), this); + m_data5 = new QRadioButton(tr("5"), m_groupData ); + m_data6 = new QRadioButton(tr("6"), m_groupData ); + m_data7 = new QRadioButton(tr("7"), m_groupData ); + m_data8 = new QRadioButton(tr("8"), m_groupData ); + + m_groupStop = new QHButtonGroup(tr("Stop Bits"), this ); + m_stop1 = new QRadioButton(tr("1"), m_groupStop ); + m_stop15 = new QRadioButton(tr("1.5"), m_groupStop ); + m_stop2 = new QRadioButton(tr("2"), m_groupStop ); + + m_lroot = new QVBoxLayout( this ); @@ -52,18 +78,6 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name ) m_lroot->add(m_speedBox ); - m_lroot->setStretchFactor(m_speedLabel, 1); - m_lroot->setStretchFactor(m_speedBox, 1 ); - - m_hbox = new QHBoxLayout(m_groupFlow, 2 ); - m_hbox->add(m_flowHw ); - m_hbox->add(m_flowSw ); - m_hbox->add(m_flowNone ); m_lroot->add(m_groupFlow ); - m_lroot->setStretchFactor(m_groupFlow, 2 ); - - m_hboxPar = new QHBoxLayout( m_groupParity, 2 ); - m_hboxPar->add(m_parityOdd ); - m_hboxPar->add(m_parityEven ); - m_hboxPar->add(m_parityNone ); m_lroot->add(m_groupParity ); - m_lroot->setStretchFactor(m_groupParity, 2 ); + m_lroot->add( m_groupData ); + m_lroot->add( m_groupStop ); m_lroot->addStretch(2); @@ -130,2 +144,37 @@ void IOLayerBase::setSpeed( Speed sp ) { } + +void IOLayerBase::setData( Data data ) { + switch( data ) { + case Data_Five: + m_data5->setChecked( true ); + break; + case Data_Six: + m_data6->setChecked( true ); + break; + case Data_Seven: + m_data7->setChecked( true ); + break; + default: + m_data8->setChecked( true ); + break; + } +} + + +void IOLayerBase::setStop( Stop stop ) { + switch( stop ) { + case Stop_Two: + m_stop2->setChecked( true ); + break; + case Stop_OnePointFive: + m_stop15->setChecked( true ); + break; + default: + m_stop1->setChecked( true ); + break; + } +} + + + IOLayerBase::Flow IOLayerBase::flow()const { @@ -169 +218,22 @@ IOLayerBase::Speed IOLayerBase::speed()const{ } +IOLayerBase::Data IOLayerBase::data()const { + if ( m_data5->isChecked() ) { + return Data_Five; + } else if ( m_data6->isChecked() ) { + return Data_Six; + } else if ( m_data7->isChecked() ) { + return Data_Seven; + } else { + return Data_Eight; + } +} +IOLayerBase::Stop IOLayerBase::stop()const { + if ( m_stop2->isChecked() ) { + return Stop_Two; + } else if ( m_stop15->isChecked() ) { + return Stop_OnePointFive; + } else { + return Stop_One; + } +} + diff --git a/noncore/apps/opie-console/iolayerbase.h b/noncore/apps/opie-console/iolayerbase.h index 74de46a..e1b96df 100644 --- a/noncore/apps/opie-console/iolayerbase.h +++ b/noncore/apps/opie-console/iolayerbase.h @@ -24,2 +24,5 @@ public: Baud_9600 }; + enum Data { Data_Five =5, Data_Six =6, Data_Seven=7, Data_Eight=8 }; + enum Stop { Stop_One =1, Stop_OnePointFive=15, Stop_Two=2 }; + IOLayerBase( QWidget* base, const char* name = 0l); @@ -30,2 +33,4 @@ public: void setSpeed( Speed speed ); + void setData( Data data ); + void setStop( Stop stop ); @@ -34,2 +39,4 @@ public: Speed speed()const; + Data data()const; + Stop stop()const; private: @@ -38,3 +45,3 @@ private: QComboBox* m_speedBox; - QButtonGroup* m_groupFlow; + QButtonGroup* m_groupFlow, *m_groupData, *m_groupStop ; QRadioButton *m_flowHw, *m_flowSw, *m_flowNone; @@ -43,2 +50,4 @@ private: QRadioButton *m_parityOdd, *m_parityEven, *m_parityNone; + QRadioButton *m_data5, *m_data6, *m_data7, *m_data8; + QRadioButton *m_stop1, *m_stop15, *m_stop2; QHBoxLayout* m_hbox; diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index ec83b9f..ce44dab 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp @@ -36,4 +36,5 @@ ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, telLabel->setText( tr( "Enter telefon number here:" ) ); - m_telNumber = new QLineEdit( this ); + // m_telNumber = new QLineEdit( this ); QHBox *buttonBox = new QHBox( this ); + m_telNumber = new QLineEdit( buttonBox ); QPushButton *atButton = new QPushButton( buttonBox ); @@ -48,3 +49,2 @@ ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, - m_base = new IOLayerBase( this, "base" ); @@ -54,5 +54,5 @@ ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, m_lay->addWidget( telLabel ); - m_lay->addWidget( m_telNumber ); m_lay->addWidget( buttonBox ); m_lay->addWidget( m_base ); + m_lay->addStretch( 0 ); @@ -73,2 +73,4 @@ void ModemConfigWidget::load( const Profile& prof ) { int speed = prof.readNumEntry( "Speed" ); + int dbits = prof.readNumEntry("DataBits"); + int sbits = prof.readNumEntry("StopBits"); QString number = prof.readEntry( "Number" ); @@ -115,2 +117,23 @@ void ModemConfigWidget::load( const Profile& prof ) { + + if ( dbits == 5) { + m_base->setData( IOLayerBase::Data_Five ); + } else if (rad_flow == 6) { + m_base->setData( IOLayerBase::Data_Six ); + } else if (rad_flow == 7) { + m_base->setData( IOLayerBase::Data_Seven ); + } else { + m_base->setData( IOLayerBase::Data_Eight ); + } + + if ( sbits == 2) { + m_base->setStop( IOLayerBase::Stop_Two ); + } else if ( sbits == 15 ) { + m_base->setStop( IOLayerBase::Stop_OnePointFive ); + } else { + m_base->setStop( IOLayerBase::Stop_One ); + } + + + if ( prof.readEntry( "Device" ).isEmpty() ) { @@ -129,4 +152,4 @@ void ModemConfigWidget::load( const Profile& prof ) { void ModemConfigWidget::save( Profile& prof ) { - int flow, parity, speed; - flow = parity = speed = 0; + int flow, parity, speed, data, stop; + flow = parity = speed = data = stop = 0; prof.writeEntry( "Device", m_deviceCmb->currentText() ); @@ -176,2 +199,29 @@ void ModemConfigWidget::save( Profile& prof ) { + switch( m_base->data() ) { + case IOLayerBase::Data_Five: + data = 5; + break; + case IOLayerBase::Data_Six: + data = 6; + break; + case IOLayerBase::Data_Seven: + data = 7; + break; + case IOLayerBase::Data_Eight: + data = 8; + break; + } + + switch( m_base->stop() ) { + case IOLayerBase::Stop_One: + stop = 1; + break; + case IOLayerBase::Stop_OnePointFive: + stop = 15; + break; + case IOLayerBase::Stop_Two: + stop = 2; + break; + } + prof.writeEntry( "Flow", flow ); @@ -179,2 +229,4 @@ void ModemConfigWidget::save( Profile& prof ) { prof.writeEntry( "Speed", speed ); + prof.writeEntry("DataBits", data); + prof.writeEntry("StopBits", stop); prof.writeEntry( "Number", m_telNumber->text() ); diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp index 5c6d975..3edf723 100644 --- a/noncore/apps/opie-console/serialconfigwidget.cpp +++ b/noncore/apps/opie-console/serialconfigwidget.cpp @@ -52,2 +52,4 @@ void SerialConfigWidget::load( const Profile& prof ) { int speed = prof.readNumEntry("Speed"); + int dbits = prof.readNumEntry("DataBits"); + int sbits = prof.readNumEntry("StopBits"); @@ -88,2 +90,20 @@ void SerialConfigWidget::load( const Profile& prof ) { + if ( dbits == 5) { + m_base->setData( IOLayerBase::Data_Five ); + } else if (rad_flow == 6) { + m_base->setData( IOLayerBase::Data_Six ); + } else if (rad_flow == 7) { + m_base->setData( IOLayerBase::Data_Seven ); + } else { + m_base->setData( IOLayerBase::Data_Eight ); + } + + if ( sbits == 2) { + m_base->setStop( IOLayerBase::Stop_Two ); + } else if ( sbits == 15 ) { + m_base->setStop( IOLayerBase::Stop_OnePointFive ); + } else { + m_base->setStop( IOLayerBase::Stop_One ); + } + if ( prof.readEntry("Device").isEmpty() ) return; @@ -98,4 +118,4 @@ void SerialConfigWidget::load( const Profile& prof ) { void SerialConfigWidget::save( Profile& prof ) { - int flow, parity, speed ; - flow = parity = speed = 0; + int flow, parity, speed, data, stop; + flow = parity = speed = data = stop = 0; prof.writeEntry("Device", m_deviceCmb->currentText() ); @@ -145,2 +165,29 @@ void SerialConfigWidget::save( Profile& prof ) { + switch( m_base->data() ) { + case IOLayerBase::Data_Five: + data = 5; + break; + case IOLayerBase::Data_Six: + data = 6; + break; + case IOLayerBase::Data_Seven: + data = 7; + break; + case IOLayerBase::Data_Eight: + data = 8; + break; + } + + switch( m_base->stop() ) { + case IOLayerBase::Stop_One: + stop = 1; + break; + case IOLayerBase::Stop_OnePointFive: + stop = 15; + break; + case IOLayerBase::Stop_Two: + stop = 2; + break; + } + prof.writeEntry("Flow", flow); @@ -148,2 +195,4 @@ void SerialConfigWidget::save( Profile& prof ) { prof.writeEntry("Speed", speed); + prof.writeEntry("DataBits", data); + prof.writeEntry("StopBits", stop); } |