author | mickeyl <mickeyl> | 2005-06-13 20:46:02 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-06-13 20:46:02 (UTC) |
commit | 9e210f138184f9cc93e28dd894243fc7bfea1b0f (patch) (unidiff) | |
tree | bff01f476d0b2370d7bfb8b6275677d6ee4d6580 /noncore | |
parent | 8e7defdc3c1129f9e0935761ead46d9428306f7f (diff) | |
download | opie-9e210f138184f9cc93e28dd894243fc7bfea1b0f.zip opie-9e210f138184f9cc93e28dd894243fc7bfea1b0f.tar.gz opie-9e210f138184f9cc93e28dd894243fc7bfea1b0f.tar.bz2 |
parse possible bindings out of /etc/pcmcia/* and list them in combobox
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 42 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 159 |
2 files changed, 166 insertions, 35 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index e7c97c1..e161d18 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -37,13 +37,15 @@ using namespace Opie::Core; | |||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | ||
40 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qtextstream.h> | ||
41 | 43 | ||
42 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | 44 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) |
43 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | 45 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) |
44 | { | 46 | { |
45 | //setCaption( tr( "Configure %1" ).arg( cardname ) ); | 47 | //setCaption( tr( "Configure %1" ).arg( cardname ) ); |
46 | textCardName->setText( cardname ); | 48 | txtCardName->setText( cardname ); |
47 | 49 | ||
48 | OConfig cfg( "PCMCIA" ); | 50 | OConfig cfg( "PCMCIA" ); |
49 | cfg.setGroup( "Global" ); | 51 | cfg.setGroup( "Global" ); |
@@ -70,15 +72,45 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | |||
70 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); | 72 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); |
71 | } | 73 | } |
72 | 74 | ||
73 | // parse possible device and class names out of /etc/pcmcia/*.conf | 75 | // parse possible bind entries out of /etc/pcmcia/*.conf |
74 | QStringList deviceNames; | 76 | typedef QMap<QString,QString> StringMap; |
75 | QStringList classNames; | 77 | StringMap bindEntries; |
76 | 78 | ||
77 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 79 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
78 | 80 | ||
79 | for ( int i = 0; i < pcmciaconfdir.count(); ++i ) | 81 | for ( int i = 0; i < pcmciaconfdir.count(); ++i ) |
80 | odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl; | 82 | { |
83 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | ||
84 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | ||
85 | QFile conffile( conffilename ); | ||
86 | if ( conffile.open( IO_ReadOnly ) ) | ||
87 | { | ||
88 | QTextStream ts( &conffile ); | ||
89 | while ( !ts.atEnd() ) | ||
90 | { | ||
91 | QString word; | ||
92 | ts >> word; | ||
93 | if ( word == "bind" ) | ||
94 | { | ||
95 | word = ts.readLine(); | ||
96 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | ||
97 | continue; | ||
98 | } | ||
99 | ts.readLine(); | ||
100 | } | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; | ||
105 | continue; | ||
106 | } | ||
107 | } | ||
81 | 108 | ||
109 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) | ||
110 | { | ||
111 | odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; | ||
112 | cbBindTo->insertItem( it.key() ); | ||
113 | } | ||
82 | } | 114 | } |
83 | 115 | ||
84 | ConfigDialog::~ConfigDialog() | 116 | ConfigDialog::~ConfigDialog() |
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui index a9682c5..a0760d6 100644 --- a/noncore/applets/pcmcia/configdialogbase.ui +++ b/noncore/applets/pcmcia/configdialogbase.ui | |||
@@ -11,8 +11,8 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>234</width> | 14 | <width>232</width> |
15 | <height>130</height> | 15 | <height>206</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
@@ -28,11 +28,11 @@ | |||
28 | <grid> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>7</number> | 31 | <number>5</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>4</number> | 35 | <number>2</number> |
36 | </property> | 36 | </property> |
37 | <widget row="2" column="2" > | 37 | <widget row="2" column="2" > |
38 | <class>QLabel</class> | 38 | <class>QLabel</class> |
@@ -93,16 +93,9 @@ | |||
93 | <name>name</name> | 93 | <name>name</name> |
94 | <cstring>cbBindTo</cstring> | 94 | <cstring>cbBindTo</cstring> |
95 | </property> | 95 | </property> |
96 | </widget> | ||
97 | <widget row="1" column="0" rowspan="1" colspan="3" > | ||
98 | <class>Line</class> | ||
99 | <property stdset="1"> | ||
100 | <name>name</name> | ||
101 | <cstring>Line1</cstring> | ||
102 | </property> | ||
103 | <property stdset="1"> | 96 | <property stdset="1"> |
104 | <name>orientation</name> | 97 | <name>editable</name> |
105 | <enum>Horizontal</enum> | 98 | <bool>true</bool> |
106 | </property> | 99 | </property> |
107 | </widget> | 100 | </widget> |
108 | <widget row="3" column="0" > | 101 | <widget row="3" column="0" > |
@@ -116,35 +109,141 @@ | |||
116 | <string>Bind to:</string> | 109 | <string>Bind to:</string> |
117 | </property> | 110 | </property> |
118 | </widget> | 111 | </widget> |
119 | <widget row="4" column="0" > | 112 | <widget row="0" column="0" rowspan="1" colspan="3" > |
120 | <class>QLabel</class> | 113 | <class>QGroupBox</class> |
121 | <property stdset="1"> | 114 | <property stdset="1"> |
122 | <name>name</name> | 115 | <name>name</name> |
123 | <cstring>textClassName</cstring> | 116 | <cstring>GroupBox1</cstring> |
124 | </property> | 117 | </property> |
125 | <property stdset="1"> | 118 | <property stdset="1"> |
126 | <name>text</name> | 119 | <name>title</name> |
127 | <string>Classname:</string> | 120 | <string>Details</string> |
121 | </property> | ||
122 | <property> | ||
123 | <name>layoutMargin</name> | ||
128 | </property> | 124 | </property> |
125 | <property> | ||
126 | <name>layoutSpacing</name> | ||
127 | </property> | ||
128 | <grid> | ||
129 | <property stdset="1"> | ||
130 | <name>margin</name> | ||
131 | <number>6</number> | ||
132 | </property> | ||
133 | <property stdset="1"> | ||
134 | <name>spacing</name> | ||
135 | <number>4</number> | ||
136 | </property> | ||
137 | <widget row="0" column="0" > | ||
138 | <class>QLabel</class> | ||
139 | <property stdset="1"> | ||
140 | <name>name</name> | ||
141 | <cstring>labelCardName</cstring> | ||
142 | </property> | ||
143 | <property stdset="1"> | ||
144 | <name>text</name> | ||
145 | <string>CardName:</string> | ||
146 | </property> | ||
147 | </widget> | ||
148 | <widget row="2" column="0" > | ||
149 | <class>QLabel</class> | ||
150 | <property stdset="1"> | ||
151 | <name>name</name> | ||
152 | <cstring>labelFunction</cstring> | ||
153 | </property> | ||
154 | <property stdset="1"> | ||
155 | <name>text</name> | ||
156 | <string>Function:</string> | ||
157 | </property> | ||
158 | </widget> | ||
159 | <widget row="1" column="0" > | ||
160 | <class>QLabel</class> | ||
161 | <property stdset="1"> | ||
162 | <name>name</name> | ||
163 | <cstring>labelManufacturer</cstring> | ||
164 | </property> | ||
165 | <property stdset="1"> | ||
166 | <name>text</name> | ||
167 | <string>Manufacturer:</string> | ||
168 | </property> | ||
169 | </widget> | ||
170 | <widget row="1" column="1" > | ||
171 | <class>QLabel</class> | ||
172 | <property stdset="1"> | ||
173 | <name>name</name> | ||
174 | <cstring>txtManfid</cstring> | ||
175 | </property> | ||
176 | <property stdset="1"> | ||
177 | <name>sizePolicy</name> | ||
178 | <sizepolicy> | ||
179 | <hsizetype>7</hsizetype> | ||
180 | <vsizetype>1</vsizetype> | ||
181 | </sizepolicy> | ||
182 | </property> | ||
183 | <property stdset="1"> | ||
184 | <name>text</name> | ||
185 | <string>TextLabel6</string> | ||
186 | </property> | ||
187 | </widget> | ||
188 | <widget row="2" column="1" > | ||
189 | <class>QLabel</class> | ||
190 | <property stdset="1"> | ||
191 | <name>name</name> | ||
192 | <cstring>txtFunction</cstring> | ||
193 | </property> | ||
194 | <property stdset="1"> | ||
195 | <name>sizePolicy</name> | ||
196 | <sizepolicy> | ||
197 | <hsizetype>7</hsizetype> | ||
198 | <vsizetype>1</vsizetype> | ||
199 | </sizepolicy> | ||
200 | </property> | ||
201 | <property stdset="1"> | ||
202 | <name>text</name> | ||
203 | <string>TextLabel7</string> | ||
204 | </property> | ||
205 | </widget> | ||
206 | <widget row="0" column="1" > | ||
207 | <class>QLabel</class> | ||
208 | <property stdset="1"> | ||
209 | <name>name</name> | ||
210 | <cstring>txtCardName</cstring> | ||
211 | </property> | ||
212 | <property stdset="1"> | ||
213 | <name>sizePolicy</name> | ||
214 | <sizepolicy> | ||
215 | <hsizetype>7</hsizetype> | ||
216 | <vsizetype>1</vsizetype> | ||
217 | </sizepolicy> | ||
218 | </property> | ||
219 | <property stdset="1"> | ||
220 | <name>text</name> | ||
221 | <string>TextLabel3</string> | ||
222 | </property> | ||
223 | </widget> | ||
224 | </grid> | ||
129 | </widget> | 225 | </widget> |
130 | <widget row="4" column="1" rowspan="1" colspan="2" > | 226 | <spacer row="1" column="1" > |
131 | <class>QComboBox</class> | 227 | <property> |
132 | <property stdset="1"> | ||
133 | <name>name</name> | 228 | <name>name</name> |
134 | <cstring>cbClassName</cstring> | 229 | <cstring>Spacer1</cstring> |
135 | </property> | 230 | </property> |
136 | </widget> | ||
137 | <widget row="0" column="0" rowspan="1" colspan="3" > | ||
138 | <class>QLabel</class> | ||
139 | <property stdset="1"> | 231 | <property stdset="1"> |
140 | <name>name</name> | 232 | <name>orientation</name> |
141 | <cstring>textCardName</cstring> | 233 | <enum>Vertical</enum> |
142 | </property> | 234 | </property> |
143 | <property stdset="1"> | 235 | <property stdset="1"> |
144 | <name>text</name> | 236 | <name>sizeType</name> |
145 | <string>CardName</string> | 237 | <enum>Expanding</enum> |
146 | </property> | 238 | </property> |
147 | </widget> | 239 | <property> |
240 | <name>sizeHint</name> | ||
241 | <size> | ||
242 | <width>20</width> | ||
243 | <height>20</height> | ||
244 | </size> | ||
245 | </property> | ||
246 | </spacer> | ||
148 | </grid> | 247 | </grid> |
149 | </widget> | 248 | </widget> |
150 | </UI> | 249 | </UI> |