Diffstat (limited to 'noncore/settings/networksettings2/editconnection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index 717d9e9..6ab2dd6 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp | |||
@@ -72,67 +72,69 @@ void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, | |||
72 | int column, int width, int alignment ) | 72 | int column, int width, int alignment ) |
73 | { | 73 | { |
74 | QColorGroup _cg( cg ); | 74 | QColorGroup _cg( cg ); |
75 | QColor c = _cg.text(); | 75 | QColor c = _cg.text(); |
76 | if ( ! isSelectable() ) | 76 | if ( ! isSelectable() ) |
77 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); | 77 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); |
78 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 78 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
79 | _cg.setColor( QColorGroup::Text, c ); | 79 | _cg.setColor( QColorGroup::Text, c ); |
80 | } | 80 | } |
81 | 81 | ||
82 | // | 82 | // |
83 | // | 83 | // |
84 | // REAL GUI | 84 | // REAL GUI |
85 | // | 85 | // |
86 | // | 86 | // |
87 | 87 | ||
88 | bool EditConnection::AutoCollapse = 1; | 88 | bool EditNetworkSetup::AutoCollapse = 1; |
89 | 89 | ||
90 | EditConnection::EditConnection( QWidget* parent ) : | 90 | EditNetworkSetup::EditNetworkSetup( QWidget* parent ) : |
91 | EditConnectionGUI( parent, 0, TRUE ), TmpCollection() { | 91 | EditNetworkSetupGUI( parent, 0, TRUE ), TmpCollection() { |
92 | 92 | ||
93 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); | 93 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); |
94 | Setup_FRM->setEnabled( FALSE ); | 94 | Setup_FRM->setEnabled( FALSE ); |
95 | 95 | ||
96 | TmpIsValid = 0; | 96 | TmpIsValid = 0; |
97 | SelectedNodes = 0; | 97 | SelectedNodes = 0; |
98 | 98 | ||
99 | AutoCollapse_CB->setChecked( AutoCollapse ); | 99 | AutoCollapse_CB->setChecked( AutoCollapse ); |
100 | 100 | ||
101 | Mapping = new QPtrDict<ANetNode>; | 101 | Mapping = new QPtrDict<ANetNode>; |
102 | Mapping->setAutoDelete( FALSE ); | 102 | Mapping->setAutoDelete( FALSE ); |
103 | Nodes_LV->header()->hide(); | 103 | Nodes_LV->header()->hide(); |
104 | // popluate tree with all NetNodes | 104 | // popluate tree with all NetNodes |
105 | buildFullTree(); | 105 | buildFullTree(); |
106 | } | 106 | } |
107 | 107 | ||
108 | NodeCollection * EditConnection::getTmpCollection( void ) { | 108 | NetworkSetup * EditNetworkSetup::getTmpCollection( void ) { |
109 | 109 | ||
110 | if( TmpIsValid ) | 110 | if( TmpIsValid ) |
111 | // content is stil OK | 111 | // content is stil OK |
112 | return &(TmpCollection); | 112 | return &(TmpCollection); |
113 | 113 | ||
114 | // reset collection -> delete all NEW NetNodes | 114 | // reset collection -> delete all NEW NetNodes |
115 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 115 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
116 | it.current(); | 116 | it.current(); |
117 | ++it ) { | 117 | ++it ) { |
118 | if( it.current()->isNew() ) { | 118 | if( it.current()->isNew() ) { |
119 | delete it.current(); | 119 | delete it.current(); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | |||
122 | TmpCollection.clear(); | 123 | TmpCollection.clear(); |
124 | TmpCollection.copyFrom( *SelectedNodes ); | ||
123 | 125 | ||
124 | // update content | 126 | // update content |
125 | QListViewItem * it = Nodes_LV->firstChild(); | 127 | QListViewItem * it = Nodes_LV->firstChild(); |
126 | ANetNode * NN; | 128 | ANetNode * NN; |
127 | 129 | ||
128 | // start iter (if there is a collection) | 130 | // start iter (if there is a collection) |
129 | /* | 131 | /* |
130 | 132 | ||
131 | a node collection is sorted from the toplevel | 133 | a node collection is sorted from the toplevel |
132 | node to the deepest node | 134 | node to the deepest node |
133 | 135 | ||
134 | */ | 136 | */ |
135 | ANetNodeInstance * NNI = | 137 | ANetNodeInstance * NNI = |
136 | (SelectedNodes) ? SelectedNodes->first() : 0 ; | 138 | (SelectedNodes) ? SelectedNodes->first() : 0 ; |
137 | 139 | ||
138 | TmpCollection.setModified( 0 ); | 140 | TmpCollection.setModified( 0 ); |
@@ -180,34 +182,34 @@ NodeCollection * EditConnection::getTmpCollection( void ) { | |||
180 | } else { | 182 | } else { |
181 | // already in list -> copy pointer | 183 | // already in list -> copy pointer |
182 | TmpCollection.append( NNI ); | 184 | TmpCollection.append( NNI ); |
183 | NNI = SelectedNodes->next(); | 185 | NNI = SelectedNodes->next(); |
184 | } | 186 | } |
185 | 187 | ||
186 | // go deeper to next level | 188 | // go deeper to next level |
187 | // this level is can be a new controller | 189 | // this level is can be a new controller |
188 | // or an item | 190 | // or an item |
189 | it = it->firstChild(); | 191 | it = it->firstChild(); |
190 | } | 192 | } |
191 | 193 | ||
192 | TmpIsValid = 1; | 194 | TmpIsValid = 1; |
193 | return &(TmpCollection); | 195 | return &(TmpCollection); |
194 | } | 196 | } |
195 | 197 | ||
196 | // pass a connection NodeCollection to be edited | 198 | // pass a NetworkSetup NetworkSetup to be edited |
197 | void EditConnection::setConnection( NodeCollection * NC ) { | 199 | void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) { |
198 | ANetNodeInstance * NNI; | 200 | ANetNodeInstance * NNI; |
199 | ANetNode * NN; | 201 | ANetNode * NN; |
200 | 202 | ||
201 | SelectedNodes = NC; | 203 | SelectedNodes = NC; |
202 | Name_LE->setText( NC->name() ); | 204 | Name_LE->setText( NC->name() ); |
203 | NNI = NC->first(); | 205 | NNI = NC->first(); |
204 | 206 | ||
205 | // show configure tabl | 207 | // show configure tabl |
206 | Tab_TB->setCurrentPage( 1 ); | 208 | Tab_TB->setCurrentPage( 1 ); |
207 | 209 | ||
208 | // valid colledction | 210 | // valid colledction |
209 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); | 211 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); |
210 | Setup_FRM->setEnabled( FALSE ); | 212 | Setup_FRM->setEnabled( FALSE ); |
211 | 213 | ||
212 | // select items in collection | 214 | // select items in collection |
213 | QListViewItem * it = Nodes_LV->firstChild(); | 215 | QListViewItem * it = Nodes_LV->firstChild(); |
@@ -230,132 +232,132 @@ void EditConnection::setConnection( NodeCollection * NC ) { | |||
230 | updateGUI( it, NNI->nodeClass() ); | 232 | updateGUI( it, NNI->nodeClass() ); |
231 | // check its children | 233 | // check its children |
232 | Found = 1; | 234 | Found = 1; |
233 | it = it->firstChild(); | 235 | it = it->firstChild(); |
234 | NNI = SelectedNodes->next(); | 236 | NNI = SelectedNodes->next(); |
235 | // do not bother to check other items | 237 | // do not bother to check other items |
236 | break; | 238 | break; |
237 | } | 239 | } |
238 | it = it->nextSibling(); | 240 | it = it->nextSibling(); |
239 | } | 241 | } |
240 | 242 | ||
241 | if( ! Found ) { | 243 | if( ! Found ) { |
242 | // this means that this level is NOT present in collection | 244 | // this means that this level is NOT present in collection |
243 | // probably INCOMPATIBEL collection OR Missing plugin | 245 | // probably INCOMPATIBEL collection OR Missing plugin |
244 | QMessageBox::warning( | 246 | QMessageBox::warning( |
245 | 0, | 247 | 0, |
246 | tr( "Error presentig Connection" ), | 248 | tr( "Error presentig NetworkSetup" ), |
247 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). | 249 | tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). |
248 | arg(NNI->nodeClass()->name()) ); | 250 | arg(NNI->nodeClass()->name()) ); |
249 | return; | 251 | return; |
250 | } | 252 | } |
251 | 253 | ||
252 | // it now contains selected radio | 254 | // it now contains selected radio |
253 | NN = (*Mapping)[it]; | 255 | NN = (*Mapping)[it]; |
254 | } else { | 256 | } else { |
255 | // automatic selection | 257 | // automatic selection |
256 | if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { | 258 | if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { |
257 | // should exist and be the same | 259 | // should exist and be the same |
258 | if( NNI ) { | 260 | if( NNI ) { |
259 | QMessageBox::warning( | 261 | QMessageBox::warning( |
260 | 0, | 262 | 0, |
261 | tr( "Error presentig Connection" ), | 263 | tr( "Error presentig NetworkSetup" ), |
262 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). | 264 | tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). |
263 | arg(NNI->nodeClass()->name()) ); | 265 | arg(NNI->nodeClass()->name()) ); |
264 | } else { | 266 | } else { |
265 | QMessageBox::warning( | 267 | QMessageBox::warning( |
266 | 0, | 268 | 0, |
267 | tr( "Error presentig Connection" ), | 269 | tr( "Error presentig NetworkSetup" ), |
268 | tr( "<p>Missing connection\"<i>%1</i>\"</p>" ). | 270 | tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). |
269 | arg(it->text(0)) ); | 271 | arg(it->text(0)) ); |
270 | } | 272 | } |
271 | return; | 273 | return; |
272 | } | 274 | } |
273 | it = it->firstChild(); | 275 | it = it->firstChild(); |
274 | } | 276 | } |
275 | } | 277 | } |
276 | } | 278 | } |
277 | 279 | ||
278 | // get result of editing (either new OR updated collection | 280 | // get result of editing (either new OR updated collection |
279 | NodeCollection * EditConnection::connection( void ) { | 281 | NetworkSetup * EditNetworkSetup::networkSetup( void ) { |
280 | 282 | ||
281 | if( SelectedNodes == 0 ) { | 283 | if( SelectedNodes == 0 ) { |
282 | // new collection | 284 | // new collection |
283 | SelectedNodes = new NodeCollection; | 285 | SelectedNodes = new NetworkSetup; |
284 | } | 286 | } |
285 | 287 | ||
286 | // clean out old entries | 288 | // clean out old entries |
287 | SelectedNodes->clear(); | 289 | SelectedNodes->clear(); |
288 | 290 | ||
289 | // transfer | 291 | // transfer |
290 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 292 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
291 | it.current(); | 293 | it.current(); |
292 | ++it ) { | 294 | ++it ) { |
293 | SelectedNodes->append( it.current() ); | 295 | SelectedNodes->append( it.current() ); |
294 | } | 296 | } |
295 | 297 | ||
296 | if( TmpCollection.isModified() ) | 298 | if( TmpCollection.isModified() ) |
297 | SelectedNodes->setModified( 1 ); | 299 | SelectedNodes->setModified( 1 ); |
298 | 300 | ||
299 | if( SelectedNodes->name() != Name_LE->text() ) { | 301 | if( SelectedNodes->name() != Name_LE->text() ) { |
300 | SelectedNodes->setName( Name_LE->text() ); | 302 | SelectedNodes->setName( Name_LE->text() ); |
301 | SelectedNodes->setModified( 1 ); | 303 | SelectedNodes->setModified( 1 ); |
302 | } | 304 | } |
303 | 305 | ||
304 | return SelectedNodes; | 306 | return SelectedNodes; |
305 | } | 307 | } |
306 | 308 | ||
307 | // Build device tree -> start | 309 | // Build device tree -> start |
308 | void EditConnection::buildFullTree( void ) { | 310 | void EditNetworkSetup::buildFullTree( void ) { |
309 | ANetNode * NN; | 311 | ANetNode * NN; |
310 | 312 | ||
311 | // toplevel item | 313 | // toplevel item |
312 | MyQCheckListItem * TheTop = new MyQCheckListItem( | 314 | MyQCheckListItem * TheTop = new MyQCheckListItem( |
313 | Nodes_LV, | 315 | Nodes_LV, |
314 | NSResources->netNode2Name("fullsetup"), | 316 | NSResources->netNode2Name("fullsetup"), |
315 | QCheckListItem::Controller ); | 317 | QCheckListItem::Controller ); |
316 | TheTop->setOpen( TRUE ); | 318 | TheTop->setOpen( TRUE ); |
317 | Description_LBL->setText( | 319 | Description_LBL->setText( |
318 | NSResources->netNode2Description( "fullsetup" ) ); | 320 | NSResources->netNode2Description( "fullsetup" ) ); |
319 | Nodes_LV->setSelected( TheTop, TRUE ); | 321 | Nodes_LV->setSelected( TheTop, TRUE ); |
320 | 322 | ||
321 | // find all Nodes that are toplevel nodes -> ie provide | 323 | // find all Nodes that are toplevel nodes -> ie provide |
322 | // TCP/IP Connection | 324 | // TCP/IP NetworkSetup |
323 | for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); | 325 | for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); |
324 | Iter.current(); | 326 | Iter.current(); |
325 | ++Iter ) { | 327 | ++Iter ) { |
326 | NN = Iter.current(); | 328 | NN = Iter.current(); |
327 | 329 | ||
328 | if( ! NN->isToplevel() ) { | 330 | if( ! NN->isToplevel() ) { |
329 | continue; | 331 | continue; |
330 | } | 332 | } |
331 | 333 | ||
332 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, | 334 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, |
333 | NN->name(), | 335 | NN->name(), |
334 | QCheckListItem::RadioButton ); | 336 | QCheckListItem::RadioButton ); |
335 | it->setPixmap( 0, | 337 | it->setPixmap( 0, |
336 | NSResources->getPixmap( NN->pixmapName() ) | 338 | NSResources->getPixmap( NN->pixmapName() ) |
337 | ); | 339 | ); |
338 | // remember that this node maps to this listitem | 340 | // remember that this node maps to this listitem |
339 | Mapping->insert( it, NN ); | 341 | Mapping->insert( it, NN ); |
340 | buildSubTree( it, NN ); | 342 | buildSubTree( it, NN ); |
341 | } | 343 | } |
342 | } | 344 | } |
343 | 345 | ||
344 | // Build device tree -> help function | 346 | // Build device tree -> help function |
345 | void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { | 347 | void EditNetworkSetup::buildSubTree( QListViewItem * it, ANetNode *NN ) { |
346 | ANetNode::NetNodeList & NNL = NN->alternatives(); | 348 | ANetNode::NetNodeList & NNL = NN->alternatives(); |
347 | 349 | ||
348 | if( NNL.size() > 1 ) { | 350 | if( NNL.size() > 1 ) { |
349 | // this node has alternatives -> needs radio buttons | 351 | // this node has alternatives -> needs radio buttons |
350 | it = new MyQCheckListItem( | 352 | it = new MyQCheckListItem( |
351 | it, | 353 | it, |
352 | NSResources->netNode2Name(NN->needs()[0]), | 354 | NSResources->netNode2Name(NN->needs()[0]), |
353 | QCheckListItem::Controller ); | 355 | QCheckListItem::Controller ); |
354 | it->setSelectable( FALSE ); | 356 | it->setSelectable( FALSE ); |
355 | } | 357 | } |
356 | 358 | ||
357 | for ( unsigned int i=0; i < NNL.size(); i++ ) { | 359 | for ( unsigned int i=0; i < NNL.size(); i++ ) { |
358 | QListViewItem * CI; | 360 | QListViewItem * CI; |
359 | if( NNL.size() > 1 ) { | 361 | if( NNL.size() > 1 ) { |
360 | // generate radio buttons | 362 | // generate radio buttons |
361 | CI = new MyQCheckListItem( | 363 | CI = new MyQCheckListItem( |
@@ -365,37 +367,37 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { | |||
365 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); | 367 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); |
366 | Mapping->insert( CI, NNL[i] ); | 368 | Mapping->insert( CI, NNL[i] ); |
367 | CI->setSelectable( FALSE ); | 369 | CI->setSelectable( FALSE ); |
368 | } else { | 370 | } else { |
369 | // Single item | 371 | // Single item |
370 | CI = new MyQListViewItem( it, NNL[i]->name() ); | 372 | CI = new MyQListViewItem( it, NNL[i]->name() ); |
371 | // remember that this node maps to this listitem | 373 | // remember that this node maps to this listitem |
372 | Mapping->insert( CI, NNL[i] ); | 374 | Mapping->insert( CI, NNL[i] ); |
373 | CI->setSelectable( FALSE ); | 375 | CI->setSelectable( FALSE ); |
374 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); | 376 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); |
375 | } | 377 | } |
376 | buildSubTree( CI, NNL[i] ); | 378 | buildSubTree( CI, NNL[i] ); |
377 | } | 379 | } |
378 | } | 380 | } |
379 | 381 | ||
380 | // Clicked ok OK button | 382 | // Clicked ok OK button |
381 | void EditConnection::accept( void ) { | 383 | void EditNetworkSetup::accept( void ) { |
382 | if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) { | 384 | if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) { |
383 | QMessageBox::warning( | 385 | QMessageBox::warning( |
384 | 0, | 386 | 0, |
385 | tr( "Closing Connection Setup" ), | 387 | tr( "Closing NetworkSetup Setup" ), |
386 | tr( "Definition not complete or no name" ) ); | 388 | tr( "Definition not complete or no name" ) ); |
387 | return; | 389 | return; |
388 | } | 390 | } |
389 | 391 | ||
390 | // check if all devices have acceptable input | 392 | // check if all devices have acceptable input |
391 | getTmpCollection(); | 393 | getTmpCollection(); |
392 | { ANetNodeInstance * NNI; | 394 | { ANetNodeInstance * NNI; |
393 | QString S; | 395 | QString S; |
394 | 396 | ||
395 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 397 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
396 | it.current(); | 398 | it.current(); |
397 | ++it ) { | 399 | ++it ) { |
398 | NNI = it.current(); | 400 | NNI = it.current(); |
399 | // widget must show its own problems | 401 | // widget must show its own problems |
400 | S = NNI->acceptable(); | 402 | S = NNI->acceptable(); |
401 | if( ! S.isEmpty() ) { | 403 | if( ! S.isEmpty() ) { |
@@ -405,38 +407,38 @@ void EditConnection::accept( void ) { | |||
405 | S ); | 407 | S ); |
406 | return; | 408 | return; |
407 | } | 409 | } |
408 | NNI->commit(); | 410 | NNI->commit(); |
409 | 411 | ||
410 | if( NNI->isModified() ) { | 412 | if( NNI->isModified() ) { |
411 | TmpCollection.setModified( 1 ); | 413 | TmpCollection.setModified( 1 ); |
412 | // commit the data | 414 | // commit the data |
413 | } | 415 | } |
414 | } | 416 | } |
415 | } | 417 | } |
416 | 418 | ||
417 | QDialog::accept(); | 419 | QDialog::accept(); |
418 | } | 420 | } |
419 | 421 | ||
420 | // triggered by CB | 422 | // triggered by CB |
421 | void EditConnection::SLOT_AutoCollapse( bool b ) { | 423 | void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { |
422 | AutoCollapse = b; | 424 | AutoCollapse = b; |
423 | } | 425 | } |
424 | 426 | ||
425 | // clicked on node in tree -> update GUI | 427 | // clicked on node in tree -> update GUI |
426 | void EditConnection::SLOT_SelectNode( QListViewItem * it ) { | 428 | void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { |
427 | ANetNode * NN; | 429 | ANetNode * NN; |
428 | if( it == 0 || it->depth() == 0 ) { | 430 | if( it == 0 || it->depth() == 0 ) { |
429 | Description_LBL->setText( | 431 | Description_LBL->setText( |
430 | NSResources->netNode2Description( "fullsetup" ) ); | 432 | NSResources->netNode2Description( "fullsetup" ) ); |
431 | // topevel or no selection | 433 | // topevel or no selection |
432 | return; | 434 | return; |
433 | } | 435 | } |
434 | 436 | ||
435 | // store conversion from lvitem to node | 437 | // store conversion from lvitem to node |
436 | NN = (*Mapping)[ it ]; | 438 | NN = (*Mapping)[ it ]; |
437 | 439 | ||
438 | if( ! NN ) { | 440 | if( ! NN ) { |
439 | // intermediate node | 441 | // intermediate node |
440 | NN = (*Mapping)[ it->parent() ]; | 442 | NN = (*Mapping)[ it->parent() ]; |
441 | if( NN ) { | 443 | if( NN ) { |
442 | // figure out type of this node -> produce mesage | 444 | // figure out type of this node -> produce mesage |
@@ -452,33 +454,33 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) { | |||
452 | 454 | ||
453 | if( ! it->isSelectable() ) { | 455 | if( ! it->isSelectable() ) { |
454 | return; | 456 | return; |
455 | } | 457 | } |
456 | 458 | ||
457 | if( ! ((QCheckListItem *)it)->isOn() ) { | 459 | if( ! ((QCheckListItem *)it)->isOn() ) { |
458 | // clicked on line but NOT on Check or Radio item | 460 | // clicked on line but NOT on Check or Radio item |
459 | return; | 461 | return; |
460 | } | 462 | } |
461 | 463 | ||
462 | // item has really changed -> update | 464 | // item has really changed -> update |
463 | TmpIsValid = 0; | 465 | TmpIsValid = 0; |
464 | updateGUI( it, NN ); | 466 | updateGUI( it, NN ); |
465 | } | 467 | } |
466 | 468 | ||
467 | // cliecked on TAB to go to setup | 469 | // cliecked on TAB to go to setup |
468 | void EditConnection::SLOT_AlterTab( const QString & S ) { | 470 | void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { |
469 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { | 471 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { |
470 | // switched to setup -> update CB and populate ws with | 472 | // switched to setup -> update CB and populate ws with |
471 | // forms for devices | 473 | // forms for devices |
472 | 474 | ||
473 | if( ! TmpIsValid ) { | 475 | if( ! TmpIsValid ) { |
474 | getTmpCollection(); | 476 | getTmpCollection(); |
475 | 477 | ||
476 | // clear CB and Ws | 478 | // clear CB and Ws |
477 | { QWidget * W; | 479 | { QWidget * W; |
478 | int i = 0; | 480 | int i = 0; |
479 | 481 | ||
480 | Devices_CB->clear(); | 482 | Devices_CB->clear(); |
481 | while( ( W = Setup_WS->widget( i ) ) ) { | 483 | while( ( W = Setup_WS->widget( i ) ) ) { |
482 | Setup_WS->removeWidget( W ); | 484 | Setup_WS->removeWidget( W ); |
483 | i ++; | 485 | i ++; |
484 | } | 486 | } |
@@ -501,71 +503,71 @@ void EditConnection::SLOT_AlterTab( const QString & S ) { | |||
501 | // add edit widget | 503 | // add edit widget |
502 | W = NNI->edit( Setup_WS ); | 504 | W = NNI->edit( Setup_WS ); |
503 | if( ! W) { | 505 | if( ! W) { |
504 | W = new QLabel( Setup_WS, | 506 | W = new QLabel( Setup_WS, |
505 | tr("No configuration required")); | 507 | tr("No configuration required")); |
506 | } | 508 | } |
507 | Setup_WS->addWidget( W , i ); | 509 | Setup_WS->addWidget( W , i ); |
508 | i ++; | 510 | i ++; |
509 | } | 511 | } |
510 | } | 512 | } |
511 | Setup_WS->raiseWidget( 0 ); | 513 | Setup_WS->raiseWidget( 0 ); |
512 | } // still valid | 514 | } // still valid |
513 | } | 515 | } |
514 | } | 516 | } |
515 | 517 | ||
516 | // update visual feedback of selection state | 518 | // update visual feedback of selection state |
517 | void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { | 519 | void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { |
518 | 520 | ||
519 | bool HCC = haveCompleteConfig( it ); | 521 | bool HCC = haveCompleteConfig( it ); |
520 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); | 522 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); |
521 | Setup_FRM->setEnabled( HCC ); | 523 | Setup_FRM->setEnabled( HCC ); |
522 | 524 | ||
523 | // disable children of all siblings at same level | 525 | // disable children of all siblings at same level |
524 | QListViewItem * Sbl = it->parent()->firstChild(); | 526 | QListViewItem * Sbl = it->parent()->firstChild(); |
525 | while( Sbl ) { | 527 | while( Sbl ) { |
526 | if ( Sbl != it ) { | 528 | if ( Sbl != it ) { |
527 | disableTree( Sbl->firstChild(), FALSE ); | 529 | disableTree( Sbl->firstChild(), FALSE ); |
528 | Sbl->setSelectable( TRUE ); | 530 | Sbl->setSelectable( TRUE ); |
529 | if( AutoCollapse ) | 531 | if( AutoCollapse ) |
530 | Sbl->setOpen( FALSE ); | 532 | Sbl->setOpen( FALSE ); |
531 | } | 533 | } |
532 | Sbl = Sbl->nextSibling(); | 534 | Sbl = Sbl->nextSibling(); |
533 | } | 535 | } |
534 | 536 | ||
535 | // enable selected path (as deep as it goes | 537 | // enable selected path (as deep as it goes |
536 | it->setOpen( TRUE ); | 538 | it->setOpen( TRUE ); |
537 | enablePath( it->firstChild(), | 539 | enablePath( it->firstChild(), |
538 | (it->depth()==1) ? | 540 | (it->depth()==1) ? |
539 | 1 : // toplevel always alternatives | 541 | 1 : // toplevel always alternatives |
540 | (NN->alternatives().size() > 1) ); | 542 | (NN->alternatives().size() > 1) ); |
541 | } | 543 | } |
542 | 544 | ||
543 | void EditConnection::disableTree( QListViewItem * it, bool Mode ) { | 545 | void EditNetworkSetup::disableTree( QListViewItem * it, bool Mode ) { |
544 | while( it ) { | 546 | while( it ) { |
545 | // disable sbl's chidren | 547 | // disable sbl's chidren |
546 | it->setSelectable( Mode ); | 548 | it->setSelectable( Mode ); |
547 | if( AutoCollapse ) | 549 | if( AutoCollapse ) |
548 | it->setOpen( Mode ); | 550 | it->setOpen( Mode ); |
549 | disableTree( it->firstChild(), Mode ); | 551 | disableTree( it->firstChild(), Mode ); |
550 | it = it->nextSibling(); | 552 | it = it->nextSibling(); |
551 | } | 553 | } |
552 | } | 554 | } |
553 | 555 | ||
554 | // pah : ParentHasAlternatives | 556 | // pah : ParentHasAlternatives |
555 | void EditConnection::enablePath( QListViewItem * it, bool pha ) { | 557 | void EditNetworkSetup::enablePath( QListViewItem * it, bool pha ) { |
556 | while( it ) { | 558 | while( it ) { |
557 | ANetNode * NN; | 559 | ANetNode * NN; |
558 | NN = (*Mapping)[it]; | 560 | NN = (*Mapping)[it]; |
559 | if( NN ) { | 561 | if( NN ) { |
560 | if( pha ) { | 562 | if( pha ) { |
561 | bool doOn = ((QCheckListItem *)it)->isOn(); | 563 | bool doOn = ((QCheckListItem *)it)->isOn(); |
562 | // we are a checklistitem for sure | 564 | // we are a checklistitem for sure |
563 | it->setSelectable( TRUE ); | 565 | it->setSelectable( TRUE ); |
564 | if( AutoCollapse && ! doOn ) | 566 | if( AutoCollapse && ! doOn ) |
565 | it->setOpen( doOn ); | 567 | it->setOpen( doOn ); |
566 | if( doOn ) { | 568 | if( doOn ) { |
567 | // selected alternative | 569 | // selected alternative |
568 | enablePath( it->firstChild(), | 570 | enablePath( it->firstChild(), |
569 | NN->alternatives().size() > 1); | 571 | NN->alternatives().size() > 1); |
570 | } else { | 572 | } else { |
571 | // non-selected alternative | 573 | // non-selected alternative |
@@ -576,33 +578,33 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) { | |||
576 | it->setSelectable( TRUE ); | 578 | it->setSelectable( TRUE ); |
577 | it->setOpen( TRUE ); | 579 | it->setOpen( TRUE ); |
578 | enablePath( it->firstChild(), | 580 | enablePath( it->firstChild(), |
579 | NN->alternatives().size() > 1); | 581 | NN->alternatives().size() > 1); |
580 | } | 582 | } |
581 | } else { | 583 | } else { |
582 | // controller node | 584 | // controller node |
583 | it->setSelectable( TRUE ); | 585 | it->setSelectable( TRUE ); |
584 | it->setOpen( TRUE ); | 586 | it->setOpen( TRUE ); |
585 | enablePath( it->firstChild(), pha ); | 587 | enablePath( it->firstChild(), pha ); |
586 | } | 588 | } |
587 | it = it->nextSibling(); | 589 | it = it->nextSibling(); |
588 | } | 590 | } |
589 | } | 591 | } |
590 | 592 | ||
591 | // do we have a complete configuration (all needs are provided for ?) | 593 | // do we have a complete configuration (all needs are provided for ?) |
592 | bool EditConnection::haveCompleteConfig( QListViewItem * it ) { | 594 | bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) { |
593 | 595 | ||
594 | // check if all below this level is selected | 596 | // check if all below this level is selected |
595 | it = ( it ) ?it : Nodes_LV->firstChild(); | 597 | it = ( it ) ?it : Nodes_LV->firstChild(); |
596 | ANetNode *NN; | 598 | ANetNode *NN; |
597 | bool Found; | 599 | bool Found; |
598 | 600 | ||
599 | while ( it ) { | 601 | while ( it ) { |
600 | NN = (*Mapping)[it]; | 602 | NN = (*Mapping)[it]; |
601 | if( NN == 0 ) { | 603 | if( NN == 0 ) { |
602 | // this item is a controller -> | 604 | // this item is a controller -> |
603 | // has radio items as children -> | 605 | // has radio items as children -> |
604 | // find selected one | 606 | // find selected one |
605 | it = it->firstChild(); | 607 | it = it->firstChild(); |
606 | Found = 0; | 608 | Found = 0; |
607 | while( it ) { | 609 | while( it ) { |
608 | if( ((QCheckListItem *)it)->isOn() ) { | 610 | if( ((QCheckListItem *)it)->isOn() ) { |