Diffstat (limited to 'noncore/settings/networksettings2/networksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings.cpp | 101 |
1 files changed, 49 insertions, 52 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index f72fa8e..e1110e2 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | 2 | ||
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | #include <qiconset.h> | 4 | #include <qlistbox.h> |
5 | #include <qgroupbox.h> | 5 | #include <qgroupbox.h> |
6 | #include <qtimer.h> | 6 | #include <qtimer.h> |
7 | #include <qlistbox.h> | 7 | #include <qlistbox.h> |
@@ -35,24 +35,21 @@ NetworkSettings::NetworkSettings( QWidget *parent, | |||
35 | On_TB->setPixmap( NSResources->getPixmap( "off" ) ); | 35 | On_TB->setPixmap( NSResources->getPixmap( "off" ) ); |
36 | 36 | ||
37 | // populate main Listbox | 37 | // populate main Listbox |
38 | Profiles_IV->clear(); | 38 | Profiles_LB->clear(); |
39 | { Name2Connection_t & M = NSResources->connections(); | 39 | { Name2Connection_t & M = NSResources->connections(); |
40 | NodeCollection * NC; | 40 | NodeCollection * NC; |
41 | QIconViewItem * IVI; | ||
42 | |||
43 | // for all connections | 41 | // for all connections |
44 | for( QDictIterator<NodeCollection> it(M); | 42 | for( QDictIterator<NodeCollection> it(M); |
45 | it.current(); | 43 | it.current(); |
46 | ++it ) { | 44 | ++it ) { |
47 | NC = it.current(); | 45 | NC = it.current(); |
48 | IVI = new QIconViewItem( Profiles_IV, | 46 | Profiles_LB->insertItem( NC->devicePixmap(), |
49 | NC->name(), | 47 | NC->name() ); |
50 | NC->devicePixmap() ); | ||
51 | } | 48 | } |
52 | } | 49 | } |
53 | 50 | ||
54 | if( Profiles_IV->count() ) { | 51 | if( Profiles_LB->count() ) { |
55 | Profiles_IV->setSelected( Profiles_IV->firstItem(), TRUE ); | 52 | Profiles_LB->setSelected( 0, TRUE ); |
56 | } | 53 | } |
57 | 54 | ||
58 | // if no profiles -> auto popup editing | 55 | // if no profiles -> auto popup editing |
@@ -91,18 +88,18 @@ NetworkSettings::~NetworkSettings() { | |||
91 | } | 88 | } |
92 | 89 | ||
93 | void NetworkSettings::SLOT_RefreshStates( void ) { | 90 | void NetworkSettings::SLOT_RefreshStates( void ) { |
94 | QIconViewItem * IVI = Profiles_IV->currentItem(); // remeber | 91 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember |
95 | 92 | ||
96 | if( IVI ) { | 93 | if( LBI ) { |
97 | NodeCollection * NC; | 94 | NodeCollection * NC; |
98 | NSResources->system().probeInterfaces(); | 95 | NSResources->system().probeInterfaces(); |
99 | // update current selection only | 96 | // update current selection only |
100 | NC = NSResources->findConnection( IVI->text() ); | 97 | NC = NSResources->findConnection( LBI->text() ); |
101 | if( NC ) { | 98 | if( NC ) { |
102 | State_t OldS = NC->state(); | 99 | State_t OldS = NC->state(); |
103 | State_t NewS = NC->state(1); | 100 | State_t NewS = NC->state(1); |
104 | if( OldS != NewS ) { | 101 | if( OldS != NewS ) { |
105 | updateProfileState( IVI ); | 102 | updateProfileState( LBI ); |
106 | } | 103 | } |
107 | } | 104 | } |
108 | } | 105 | } |
@@ -138,9 +135,9 @@ void NetworkSettings::SLOT_AddNode( void ) { | |||
138 | } | 135 | } |
139 | 136 | ||
140 | void NetworkSettings::SLOT_DeleteNode( void ) { | 137 | void NetworkSettings::SLOT_DeleteNode( void ) { |
141 | QIconViewItem * IVI = Profiles_IV->currentItem(); | 138 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
142 | 139 | ||
143 | if ( ! IVI ) | 140 | if ( ! LBI ) |
144 | return; | 141 | return; |
145 | 142 | ||
146 | if( QMessageBox::warning( | 143 | if( QMessageBox::warning( |
@@ -148,19 +145,19 @@ void NetworkSettings::SLOT_DeleteNode( void ) { | |||
148 | tr( "Removing profile" ), | 145 | tr( "Removing profile" ), |
149 | tr( "Remove selected profile ?" ), | 146 | tr( "Remove selected profile ?" ), |
150 | 1, 0 ) == 1 ) { | 147 | 1, 0 ) == 1 ) { |
151 | NSResources->removeConnection( IVI->text() ); | 148 | NSResources->removeConnection( LBI->text() ); |
152 | delete IVI; | 149 | delete LBI; |
153 | setModified( 1 ); | 150 | setModified( 1 ); |
154 | NSD.forceGeneration(1); | 151 | NSD.forceGeneration(1); |
155 | } | 152 | } |
156 | } | 153 | } |
157 | 154 | ||
158 | void NetworkSettings::SLOT_EditNode( QIconViewItem * IVI ) { | 155 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { |
159 | QString OldName = ""; | 156 | QString OldName = ""; |
160 | EditConnection EC( this ); | 157 | EditConnection EC( this ); |
161 | 158 | ||
162 | if( IVI ) { | 159 | if( LBI ) { |
163 | NodeCollection * NC = NSResources->findConnection( IVI->text() ); | 160 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
164 | if( ! NC ) { | 161 | if( ! NC ) { |
165 | return; | 162 | return; |
166 | } | 163 | } |
@@ -176,29 +173,29 @@ void NetworkSettings::SLOT_EditNode( QIconViewItem * IVI ) { | |||
176 | NodeCollection * NC = EC.connection(); | 173 | NodeCollection * NC = EC.connection(); |
177 | if( NC->isModified() ) { | 174 | if( NC->isModified() ) { |
178 | setModified( 1 ); | 175 | setModified( 1 ); |
179 | if( IVI ) { | 176 | if( LBI ) { |
180 | // new name -> remove item | 177 | // new name -> remove item |
181 | NSResources->removeConnection( OldName ); | 178 | NSResources->removeConnection( OldName ); |
182 | // must add it here since change will trigger event | 179 | // must add it here since change will trigger event |
183 | NSResources->addConnection( NC ); | 180 | NSResources->addConnection( NC ); |
184 | IVI->setText( NC->name() ); | 181 | Profiles_LB->changeItem( NC->devicePixmap(), |
185 | IVI->setPixmap( NC->devicePixmap() ); | 182 | NC->name(), |
183 | Profiles_LB->index( LBI ) | ||
184 | ); | ||
186 | } else { | 185 | } else { |
187 | // new item | 186 | // new item |
187 | int ci = Profiles_LB->count(); | ||
188 | NSResources->addConnection( NC ); | 188 | NSResources->addConnection( NC ); |
189 | NC->setNumber( NC->maxConnectionNumber()+1 ); | 189 | NC->setNumber( NC->maxConnectionNumber()+1 ); |
190 | IVI = new QIconViewItem( Profiles_IV, | 190 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); |
191 | NC->name(), | 191 | Profiles_LB->setSelected( ci, TRUE ); |
192 | NC->devicePixmap() | ||
193 | ); | ||
194 | Profiles_IV->setSelected( IVI, TRUE ); | ||
195 | } | 192 | } |
196 | updateProfileState( IVI ); | 193 | updateProfileState( LBI ); |
197 | } | 194 | } |
198 | } else { | 195 | } else { |
199 | // cancelled : reset connection | 196 | // cancelled : reset connection |
200 | if( IVI ) { | 197 | if( LBI ) { |
201 | NodeCollection * NC = NSResources->findConnection( IVI->text() ); | 198 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
202 | NC->reassign(); | 199 | NC->reassign(); |
203 | } | 200 | } |
204 | } | 201 | } |
@@ -206,11 +203,11 @@ void NetworkSettings::SLOT_EditNode( QIconViewItem * IVI ) { | |||
206 | UpdateTimer->start( 5000 ); | 203 | UpdateTimer->start( 5000 ); |
207 | } | 204 | } |
208 | 205 | ||
209 | void NetworkSettings::SLOT_ShowNode( QIconViewItem * IVI ) { | 206 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { |
210 | if( IVI == 0 ) | 207 | if( LBI == 0 ) |
211 | return; | 208 | return; |
212 | 209 | ||
213 | NodeCollection * NC = NSResources->findConnection( IVI->text() ); | 210 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
214 | 211 | ||
215 | // is button possible | 212 | // is button possible |
216 | bool EnabledPossible, OnPossible, ConnectPossible; | 213 | bool EnabledPossible, OnPossible, ConnectPossible; |
@@ -261,20 +258,20 @@ void NetworkSettings::SLOT_ShowNode( QIconViewItem * IVI ) { | |||
261 | Description_LBL->setText( NC->description() ); | 258 | Description_LBL->setText( NC->description() ); |
262 | } | 259 | } |
263 | 260 | ||
264 | CurProfile_GB->setTitle( IVI->text() ); | 261 | CurProfile_GB->setTitle( LBI->text() ); |
265 | State_LBL->setText( NC->stateName() ); | 262 | State_LBL->setText( NC->stateName() ); |
266 | } | 263 | } |
267 | 264 | ||
268 | void NetworkSettings::SLOT_CheckState( void ) { | 265 | void NetworkSettings::SLOT_CheckState( void ) { |
269 | QIconViewItem * IVI = Profiles_IV->currentItem(); | 266 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
270 | if ( ! IVI ) | 267 | if ( ! LBI ) |
271 | return; | 268 | return; |
272 | updateProfileState( IVI ); | 269 | updateProfileState( LBI ); |
273 | } | 270 | } |
274 | 271 | ||
275 | void NetworkSettings::updateProfileState( QIconViewItem * IVI ) { | 272 | void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { |
276 | if( IVI == Profiles_IV->currentItem() ) { | 273 | if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { |
277 | SLOT_ShowNode( IVI ); | 274 | SLOT_ShowNode( LBI ); |
278 | } | 275 | } |
279 | } | 276 | } |
280 | 277 | ||
@@ -291,13 +288,13 @@ void NetworkSettings::SLOT_GenerateConfig( void ) { | |||
291 | } | 288 | } |
292 | 289 | ||
293 | void NetworkSettings::SLOT_Enable( void ) { | 290 | void NetworkSettings::SLOT_Enable( void ) { |
294 | QIconViewItem * IVI = Profiles_IV->currentItem(); | 291 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
295 | QString Msg; | 292 | QString Msg; |
296 | if ( ! IVI ) | 293 | if ( ! LBI ) |
297 | return; | 294 | return; |
298 | 295 | ||
299 | NodeCollection * NC = | 296 | NodeCollection * NC = |
300 | NSResources->findConnection( IVI->text() ); | 297 | NSResources->findConnection( LBI->text() ); |
301 | 298 | ||
302 | bool rv; | 299 | bool rv; |
303 | switch( NC->state() ) { | 300 | switch( NC->state() ) { |
@@ -318,17 +315,17 @@ void NetworkSettings::SLOT_Enable( void ) { | |||
318 | Msg ); | 315 | Msg ); |
319 | return; | 316 | return; |
320 | } | 317 | } |
321 | updateProfileState( IVI ); | 318 | updateProfileState( LBI ); |
322 | } | 319 | } |
323 | 320 | ||
324 | void NetworkSettings::SLOT_On( void ) { | 321 | void NetworkSettings::SLOT_On( void ) { |
325 | QIconViewItem * IVI = Profiles_IV->currentItem(); | 322 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
326 | 323 | ||
327 | if ( ! IVI ) | 324 | if ( ! LBI ) |
328 | return; | 325 | return; |
329 | 326 | ||
330 | NodeCollection * NC = | 327 | NodeCollection * NC = |
331 | NSResources->findConnection( IVI->text() ); | 328 | NSResources->findConnection( LBI->text() ); |
332 | 329 | ||
333 | bool rv; | 330 | bool rv; |
334 | switch( NC->state() ) { | 331 | switch( NC->state() ) { |
@@ -357,17 +354,17 @@ void NetworkSettings::SLOT_On( void ) { | |||
357 | tr( "Cannot enable profile" ) ); | 354 | tr( "Cannot enable profile" ) ); |
358 | return; | 355 | return; |
359 | } | 356 | } |
360 | updateProfileState( IVI ); | 357 | updateProfileState( LBI ); |
361 | } | 358 | } |
362 | 359 | ||
363 | void NetworkSettings::SLOT_Connect( void ) { | 360 | void NetworkSettings::SLOT_Connect( void ) { |
364 | QIconViewItem * IVI = Profiles_IV->currentItem(); | 361 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
365 | 362 | ||
366 | if ( ! IVI ) | 363 | if ( ! LBI ) |
367 | return; | 364 | return; |
368 | 365 | ||
369 | NodeCollection * NC = | 366 | NodeCollection * NC = |
370 | NSResources->findConnection( IVI->text() ); | 367 | NSResources->findConnection( LBI->text() ); |
371 | 368 | ||
372 | bool rv; | 369 | bool rv; |
373 | switch( NC->state() ) { | 370 | switch( NC->state() ) { |