author | zecke <zecke> | 2002-10-08 23:13:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-08 23:13:17 (UTC) |
commit | 8c353ec8b86ee8f82cc25172fb69dd5fee65e848 (patch) (unidiff) | |
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) (ignore 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 @@ | |||
1 | #include <qlabel.h> | ||
2 | #include <qlayout.h> | ||
3 | #include <qcombobox.h> | ||
4 | |||
5 | #include "iolayerbase.h" | ||
6 | #include "serialconfigwidget.h" | ||
7 | |||
8 | namespace { | ||
9 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
10 | uint b = bo->count(); | ||
11 | for (uint i = 0; i < bo->count(); i++ ) { | ||
12 | if ( bo->text(i) == str ) { | ||
13 | bo->setCurrentItem( i ); | ||
14 | return; | ||
15 | } | ||
16 | } | ||
17 | bo->insertItem( str ); | ||
18 | bo->setCurrentItem( b ); | ||
19 | } | ||
20 | |||
21 | |||
22 | } | ||
23 | |||
24 | SerialConfigWidget::SerialConfigWidget( const QString& name, | ||
25 | QWidget* parent, | ||
26 | const char* na ) | ||
27 | : ProfileDialogConnectionWidget( name, parent, na ) { | ||
28 | |||
29 | m_lay = new QVBoxLayout(this ); | ||
30 | m_device = new QLabel(tr("Device"), this ); | ||
31 | m_deviceCmb = new QComboBox(this ); | ||
32 | m_deviceCmb->setEditable( TRUE ); | ||
33 | |||
34 | m_base = new IOLayerBase(this, "base"); | ||
35 | |||
36 | m_lay->addWidget( m_device ); | ||
37 | m_lay->addWidget( m_deviceCmb ); | ||
38 | m_lay->addWidget( m_base ); | ||
39 | |||
40 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | ||
41 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | ||
42 | m_deviceCmb->insertItem( "/dev/ttySA0"); | ||
43 | m_deviceCmb->insertItem( "/dev/ttySA1"); | ||
44 | |||
45 | } | ||
46 | SerialConfigWidget::~SerialConfigWidget() { | ||
47 | |||
48 | } | ||
49 | void SerialConfigWidget::load( const Profile& prof ) { | ||
50 | int rad_flow = prof.readNumEntry("Flow"); | ||
51 | int rad_parity = prof.readNumEntry("Parity"); | ||
52 | int speed = prof.readNumEntry("Speed"); | ||
53 | |||
54 | if (rad_flow == 0) | ||
55 | m_base->setFlow( IOLayerBase::Hardware ); | ||
56 | else | ||
57 | m_base->setFlow( IOLayerBase::Software ); | ||
58 | |||
59 | if (rad_parity == 1) | ||
60 | m_base->setParity( IOLayerBase::Even ); | ||
61 | else | ||
62 | m_base->setParity( IOLayerBase::Odd ); | ||
63 | |||
64 | switch( speed ) { | ||
65 | case 115200: | ||
66 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | ||
67 | break; | ||
68 | case 57600: | ||
69 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | ||
70 | break; | ||
71 | case 38400: | ||
72 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | ||
73 | break; | ||
74 | case 19200: | ||
75 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | ||
76 | break; | ||
77 | case 9600: | ||
78 | default: | ||
79 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | ||
80 | break; | ||
81 | } | ||
82 | |||
83 | if ( prof.readEntry("Device").isEmpty() ) return; | ||
84 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | ||
85 | |||
86 | } | ||
87 | /* | ||
88 | * save speed, | ||
89 | * flow, | ||
90 | * parity | ||
91 | */ | ||
92 | void SerialConfigWidget::save( Profile& prof ) { | ||
93 | int flow, parity, speed; | ||
94 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | ||
95 | |||
96 | switch( m_base->flow() ) { | ||
97 | case IOLayerBase::Software: | ||
98 | flow = 1; | ||
99 | break; | ||
100 | case IOLayerBase::Hardware: | ||
101 | flow = 0; | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | switch( m_base->parity() ) { | ||
106 | case IOLayerBase::Odd: | ||
107 | parity = 2; | ||
108 | break; | ||
109 | case IOLayerBase::Even: | ||
110 | parity = 1; | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | switch( m_base->speed() ) { | ||
115 | case IOLayerBase::Baud_115200: | ||
116 | speed = 115200; | ||
117 | break; | ||
118 | case IOLayerBase::Baud_57600: | ||
119 | speed = 57600; | ||
120 | break; | ||
121 | case IOLayerBase::Baud_38400: | ||
122 | speed = 38400; | ||
123 | break; | ||
124 | case IOLayerBase::Baud_19200: | ||
125 | speed = 19200; | ||
126 | break; | ||
127 | case IOLayerBase::Baud_9600: | ||
128 | speed = 9600; | ||
129 | break; | ||
130 | } | ||
131 | |||
132 | prof.writeEntry("Flow", flow); | ||
133 | prof.writeEntry("Parity", parity); | ||
134 | prof.writeEntry("Speed", speed); | ||
135 | } | ||