summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/btconfigwidget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/btconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp
index 64046d8..0ac337f 100644
--- a/noncore/apps/opie-console/btconfigwidget.cpp
+++ b/noncore/apps/opie-console/btconfigwidget.cpp
@@ -1,139 +1,139 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlineedit.h> 3#include <qlineedit.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include <qradiobutton.h> 6#include <qradiobutton.h>
7 7
8#include "iolayerbase.h" 8#include "iolayerbase.h"
9#include "btconfigwidget.h" 9#include "btconfigwidget.h"
10 10
11namespace { 11namespace {
12 void setCurrent( const QString& str, QComboBox* bo ) { 12 void setCurrent( const QString& str, QComboBox* bo ) {
13 uint b = bo->count(); 13 uint b = bo->count();
14 for (int i = 0; i < bo->count(); i++ ) { 14 for (int i = 0; i < bo->count(); i++ ) {
15 if ( bo->text(i) == str ) { 15 if ( bo->text(i) == str ) {
16 bo->setCurrentItem( i ); 16 bo->setCurrentItem( i );
17 return; 17 return;
18 } 18 }
19 } 19 }
20 bo->insertItem( str ); 20 bo->insertItem( str );
21 bo->setCurrentItem( b ); 21 bo->setCurrentItem( b );
22 } 22 }
23} 23}
24 24
25BTConfigWidget::BTConfigWidget( const QString& name, 25BTConfigWidget::BTConfigWidget( const QString& name,
26 QWidget* parent, 26 QWidget* parent,
27 const char* na ) 27 const char* na )
28 : ProfileDialogConnectionWidget( name, parent, na ) { 28 : ProfileDialogConnectionWidget( name, parent, na ) {
29 29
30 m_lay = new QVBoxLayout( this ); 30 m_lay = new QVBoxLayout( this );
31 31
32 m_device = new QLabel( tr( "Device" ), this ); 32 m_device = new QLabel( tr( "Device" ), this );
33 QHBox *deviceBox = new QHBox( this ); 33 QHBox *deviceBox = new QHBox( this );
34 m_devRadio = new QRadioButton( deviceBox ); 34 m_devRadio = new QRadioButton( deviceBox );
35 connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) ); 35 connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) );
36 m_deviceCmb = new QComboBox( deviceBox ); 36 m_deviceCmb = new QComboBox( deviceBox );
37 m_deviceCmb->setEditable( TRUE ); 37 m_deviceCmb->setEditable( TRUE );
38 38
39 QLabel *macLabel = new QLabel( this ); 39 QLabel *macLabel = new QLabel( this );
40 macLabel->setText( tr( "Or peer mac address" ) ); 40 macLabel->setText( tr( "Or peer mac address" ) );
41 QHBox *macBox = new QHBox( this ); 41 QHBox *macBox = new QHBox( this );
42 m_macRadio = new QRadioButton( macBox ); 42 m_macRadio = new QRadioButton( macBox );
43 connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) ); 43 connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) );
44 m_mac = new QLineEdit( macBox ); 44 m_mac = new QLineEdit( macBox );
45 45
46 m_base = new IOLayerBase(this, "base"); 46 m_base = new IOLayerBase(this, "base");
47 47
48 m_lay->addWidget( m_device ); 48 m_lay->addWidget( m_device );
49 m_lay->addWidget( deviceBox ); 49 m_lay->addWidget( deviceBox );
50 m_lay->addWidget( macLabel ); 50 m_lay->addWidget( macLabel );
51 m_lay->addWidget( macBox ); 51 m_lay->addWidget( macBox );
52 m_lay->addWidget( m_base ); 52 m_lay->addWidget( m_base );
53 53
54 m_deviceCmb->insertItem( "/dev/ttyU0" ); 54 m_deviceCmb->insertItem( "/dev/ttyU0" );
55 m_deviceCmb->insertItem( "/dev/ttyU1" ); 55 m_deviceCmb->insertItem( "/dev/ttyU1" );
56} 56}
57 57
58BTConfigWidget::~BTConfigWidget() { 58BTConfigWidget::~BTConfigWidget() {
59 59
60} 60}
61void BTConfigWidget::load( const Profile& prof ) { 61void BTConfigWidget::load( const Profile& prof ) {
62 int rad_flow = prof.readNumEntry("Flow"); 62 int rad_flow = prof.readNumEntry("Flow");
63 int rad_parity = prof.readNumEntry("Parity"); 63 int rad_parity = prof.readNumEntry("Parity");
64 int speed = prof.readNumEntry("Speed"); 64 int speed = prof.readNumEntry("Speed");
65 QString mac = prof.readEntry("Mac"); 65 QString mac = prof.readEntry("Mac");
66 66
67 if (!mac.isEmpty() ) { 67 if (!mac.isEmpty() ) {
68 m_mac->setText( mac ); 68 m_mac->setText( mac );
69 } else { 69 } else {
70 m_devRadio->setChecked( true ); 70 m_devRadio->setChecked( true );
71 } 71 }
72 72
73 if (rad_flow == 1) { 73 if (rad_flow == 1) {
74 m_base->setFlow( IOLayerBase::Hardware ); 74 m_base->setFlow( IOLayerBase::Hardware );
75 } else if (rad_flow == 2) { 75 } else if (rad_flow == 2) {
76 m_base->setFlow( IOLayerBase::Software ); 76 m_base->setFlow( IOLayerBase::Software );
77 } else if (rad_flow == 0) { 77 } else if (rad_flow == 0) {
78 m_base->setFlow( IOLayerBase::None ); 78 m_base->setFlow( IOLayerBase::None );
79 } 79 }
80 80
81 if (rad_parity == 1) { 81 if (rad_parity == 1) {
82 m_base->setParity( IOLayerBase::Even ); 82 m_base->setParity( IOLayerBase::Even );
83 } else if ( rad_parity == 2 ) { 83 } else if ( rad_parity == 2 ) {
84 m_base->setParity( IOLayerBase::Odd ); 84 m_base->setParity( IOLayerBase::Odd );
85 } else { 85 } else {
86 m_base->setParity( IOLayerBase::NonePar ); 86 m_base->setParity( IOLayerBase::NonePar );
87 } 87 }
88 88
89 switch( speed ) { 89 switch( speed ) {
90 case 115200: 90 case 115200:
91 m_base->setSpeed(IOLayerBase::Baud_115200 ); 91 m_base->setSpeed(IOLayerBase::Baud_115200 );
92 break; 92 break;
93 case 57600: 93 case 57600:
94 m_base->setSpeed( IOLayerBase::Baud_57600 ); 94 m_base->setSpeed( IOLayerBase::Baud_57600 );
95 break; 95 break;
96 case 38400: 96 case 38400:
97 m_base->setSpeed(IOLayerBase::Baud_38400 ); 97 m_base->setSpeed(IOLayerBase::Baud_38400 );
98 break; 98 break;
99 case 19200: 99 case 19200:
100 m_base->setSpeed( IOLayerBase::Baud_19200 ); 100 m_base->setSpeed( IOLayerBase::Baud_19200 );
101 break; 101 break;
102 case 9600: 102 case 9600:
103 default: 103 default:
104 m_base->setSpeed(IOLayerBase::Baud_9600 ); 104 m_base->setSpeed(IOLayerBase::Baud_9600 );
105 break; 105 break;
106 } 106 }
107 107
108 if ( prof.readEntry("Device").isEmpty() ) return; 108 if ( prof.readEntry("Device").isEmpty() ) return;
109 setCurrent( prof.readEntry("Device"), m_deviceCmb ); 109 setCurrent( prof.readEntry("Device"), m_deviceCmb );
110 110
111} 111}
112/* 112/*
113 * save speed, 113 * save speed,
114 * flow, 114 * flow,
115 * parity 115 * parity
116 */ 116 */
117void BTConfigWidget::save( Profile& prof ) { 117void BTConfigWidget::save( Profile& prof ) {
118 int flow, parity, speed; 118 int flow, parity, speed;
119 flow = parity = speed = 0; 119 flow = parity = speed = 0;
120 prof.writeEntry("Device", m_deviceCmb->currentText() ); 120 prof.writeEntry("Device", m_deviceCmb->currentText() );
121 121
122 122
123 switch( m_base->flow() ) { 123 switch( m_base->flow() ) {
124 case IOLayerBase::None: 124 case IOLayerBase::None:
125 flow = 0; 125 flow = 0;
126 break; 126 break;
127 case IOLayerBase::Software: 127 case IOLayerBase::Software:
128 flow = 2; 128 flow = 2;
129 break; 129 break;
130 case IOLayerBase::Hardware: 130 case IOLayerBase::Hardware:
131 flow = 1; 131 flow = 1;
132 break; 132 break;
133 } 133 }
134 134
135 switch( m_base->parity() ) { 135 switch( m_base->parity() ) {
136 case IOLayerBase::Odd: 136 case IOLayerBase::Odd:
137 parity = 2; 137 parity = 2;
138 break; 138 break;
139 case IOLayerBase::Even: 139 case IOLayerBase::Even: