Diffstat (limited to 'noncore/settings/networksettings2/editconnection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index bda9d7e..a9bef65 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp | |||
@@ -412,152 +412,157 @@ void EditNetworkSetup::accept( void ) { | |||
412 | } | 412 | } |
413 | NNI->commit(); | 413 | NNI->commit(); |
414 | 414 | ||
415 | if( NNI->isModified() ) { | 415 | if( NNI->isModified() ) { |
416 | TmpCollection.setModified( 1 ); | 416 | TmpCollection.setModified( 1 ); |
417 | // commit the data | 417 | // commit the data |
418 | } | 418 | } |
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | QDialog::accept(); | 422 | QDialog::accept(); |
423 | } | 423 | } |
424 | 424 | ||
425 | // triggered by CB | 425 | // triggered by CB |
426 | void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { | 426 | void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { |
427 | AutoCollapse = b; | 427 | AutoCollapse = b; |
428 | } | 428 | } |
429 | 429 | ||
430 | // clicked on node in tree -> update GUI | 430 | // clicked on node in tree -> update GUI |
431 | void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { | 431 | void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { |
432 | ANetNode * NN; | 432 | ANetNode * NN; |
433 | if( it == 0 || it->depth() == 0 ) { | 433 | if( it == 0 || it->depth() == 0 ) { |
434 | Description_LBL->setText( | 434 | Description_LBL->setText( |
435 | NSResources->netNode2Description( "fullsetup" ) ); | 435 | NSResources->netNode2Description( "fullsetup" ) ); |
436 | // topevel or no selection | 436 | // topevel or no selection |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | 439 | ||
440 | // store conversion from lvitem to node | 440 | // store conversion from lvitem to node |
441 | NN = (*Mapping)[ it ]; | 441 | NN = (*Mapping)[ it ]; |
442 | 442 | ||
443 | if( ! NN ) { | 443 | if( ! NN ) { |
444 | // intermediate node | 444 | // intermediate (controller) node |
445 | NN = (*Mapping)[ it->parent() ]; | 445 | NN = (*Mapping)[ it->parent() ]; |
446 | if( NN ) { | 446 | if( NN ) { |
447 | // figure out type of this node -> produce mesage | 447 | // figure out type of this node -> produce message |
448 | Description_LBL->setText( NSResources->netNode2Description( | 448 | Description_LBL->setText( NSResources->netNode2Description( |
449 | NN->needs()[0]) ); | 449 | NN->needs()[0]) ); |
450 | } else { | 450 | } else { |
451 | Description_LBL->setText( "" ); | 451 | Description_LBL->setText( "" ); |
452 | } | 452 | } |
453 | return; | 453 | return; |
454 | } | 454 | } |
455 | 455 | ||
456 | // clicked on regular node | ||
456 | Description_LBL->setText( NN->nodeDescription() ); | 457 | Description_LBL->setText( NN->nodeDescription() ); |
457 | 458 | ||
458 | if( ! it->isSelectable() ) { | 459 | if( ! it->isSelectable() ) { |
459 | return; | 460 | return; |
460 | } | 461 | } |
461 | 462 | ||
462 | ANetNode::NetNodeList & NNL = NN->alternatives(); | 463 | ANetNode::NetNodeList & NNL = NN->alternatives(); |
463 | 464 | ||
464 | if( NNL.size() != 1 ) { | 465 | if( NNL.size() == 0 ) { |
465 | if( NNL.size() == 0 || | 466 | // this item has no alternatives -> end node |
466 | ! ((MyQCheckListItem *)it)->isOn() | 467 | TmpIsValid = 0; |
467 | ) { | 468 | updateGUI( it, NN ); |
468 | // not clicked on Check or Radio item | 469 | return; |
469 | return; | 470 | } |
470 | } | 471 | |
472 | if( ! ((MyQCheckListItem *)it)->isOn() ) { | ||
473 | // not clicked on Check or Radio item | ||
474 | return; | ||
471 | } | 475 | } |
472 | 476 | ||
473 | // item has really changed -> update | 477 | // item has really changed -> update |
474 | TmpIsValid = 0; | 478 | TmpIsValid = 0; |
475 | updateGUI( it, NN ); | 479 | updateGUI( it, NN ); |
476 | } | 480 | } |
477 | 481 | ||
478 | // cliecked on TAB to go to setup | 482 | // cliecked on TAB to go to setup |
479 | void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { | 483 | void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { |
480 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { | 484 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { |
481 | // switched to setup -> update CB and populate ws with | 485 | // switched to setup -> update CB and populate ws with |
482 | // forms for devices | 486 | // forms for devices |
483 | 487 | ||
484 | if( ! TmpIsValid ) { | 488 | if( ! TmpIsValid ) { |
485 | getTmpCollection(); | 489 | getTmpCollection(); |
486 | 490 | ||
487 | // clear CB and Ws | 491 | // clear CB and Ws |
488 | { QWidget * W; | 492 | { QWidget * W; |
489 | int i = 0; | 493 | int i = 0; |
490 | 494 | ||
491 | Devices_CB->clear(); | 495 | Devices_CB->clear(); |
492 | while( ( W = Setup_WS->widget( i ) ) ) { | 496 | while( ( W = Setup_WS->widget( i ) ) ) { |
493 | Setup_WS->removeWidget( W ); | 497 | Setup_WS->removeWidget( W ); |
494 | i ++; | 498 | i ++; |
495 | } | 499 | } |
496 | } | 500 | } |
497 | 501 | ||
498 | // update CB | 502 | // update CB |
499 | // and populate WidgetStack | 503 | // and populate WidgetStack |
500 | { ANetNodeInstance * NNI; | 504 | { ANetNodeInstance * NNI; |
501 | QListIterator<ANetNodeInstance> it(TmpCollection); | 505 | QListIterator<ANetNodeInstance> it(TmpCollection); |
502 | int i = 0; | 506 | int i = 0; |
503 | QWidget * W; | 507 | QWidget * W; |
504 | 508 | ||
505 | for ( ; it.current(); ++it ) { | 509 | for ( ; it.current(); ++it ) { |
506 | NNI = it.current(); | 510 | NNI = it.current(); |
507 | Devices_CB->insertItem( | 511 | Devices_CB->insertItem( |
508 | NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), | 512 | NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), |
509 | NNI->nodeClass()->name() | 513 | NNI->nodeClass()->name() |
510 | ); | 514 | ); |
511 | 515 | ||
512 | // add edit widget | 516 | // add edit widget |
513 | W = NNI->edit( Setup_WS ); | 517 | W = NNI->edit( Setup_WS ); |
514 | if( ! W) { | 518 | if( ! W) { |
515 | W = new QLabel( Setup_WS, | 519 | W = new QLabel( Setup_WS, |
516 | tr("No configuration required")); | 520 | tr("No configuration required")); |
517 | } | 521 | } |
518 | Setup_WS->addWidget( W , i ); | 522 | Setup_WS->addWidget( W , i ); |
519 | i ++; | 523 | i ++; |
520 | } | 524 | } |
521 | } | 525 | } |
522 | Setup_WS->raiseWidget( 0 ); | 526 | Setup_WS->raiseWidget( 0 ); |
523 | } // still valid | 527 | } // still valid |
524 | } | 528 | } |
525 | } | 529 | } |
526 | 530 | ||
527 | // update visual feedback of selection state | 531 | // update visual feedback of selection state |
528 | void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { | 532 | void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { |
529 | 533 | ||
530 | bool HCC = haveCompleteConfig( it ); | 534 | bool HCC = haveCompleteConfig( it ); |
531 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); | 535 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); |
536 | Log(( "COMPLETE CONFIG %d\n", HCC )); | ||
532 | Setup_FRM->setEnabled( HCC ); | 537 | Setup_FRM->setEnabled( HCC ); |
533 | 538 | ||
534 | // disable children of all siblings at same level | 539 | // disable children of all siblings at same level |
535 | QListViewItem * Sbl = it->parent()->firstChild(); | 540 | QListViewItem * Sbl = it->parent()->firstChild(); |
536 | while( Sbl ) { | 541 | while( Sbl ) { |
537 | if ( Sbl != it ) { | 542 | if ( Sbl != it ) { |
538 | disableTree( Sbl->firstChild(), FALSE ); | 543 | disableTree( Sbl->firstChild(), FALSE ); |
539 | Sbl->setSelectable( TRUE ); | 544 | Sbl->setSelectable( TRUE ); |
540 | if( AutoCollapse ) | 545 | if( AutoCollapse ) |
541 | Sbl->setOpen( FALSE ); | 546 | Sbl->setOpen( FALSE ); |
542 | } | 547 | } |
543 | Sbl = Sbl->nextSibling(); | 548 | Sbl = Sbl->nextSibling(); |
544 | } | 549 | } |
545 | 550 | ||
546 | // enable selected path (as deep as it goes | 551 | // enable selected path (as deep as it goes |
547 | it->setOpen( TRUE ); | 552 | it->setOpen( TRUE ); |
548 | enablePath( it->firstChild(), | 553 | enablePath( it->firstChild(), |
549 | (it->depth()==1) ? | 554 | (it->depth()==1) ? |
550 | 1 : // toplevel always alternatives | 555 | 1 : // toplevel always alternatives |
551 | (NN->alternatives().size() > 1) ); | 556 | (NN->alternatives().size() > 1) ); |
552 | } | 557 | } |
553 | 558 | ||
554 | void EditNetworkSetup::disableTree( QListViewItem * it, bool Mode ) { | 559 | void EditNetworkSetup::disableTree( QListViewItem * it, bool Mode ) { |
555 | while( it ) { | 560 | while( it ) { |
556 | // disable sbl's chidren | 561 | // disable sbl's chidren |
557 | it->setSelectable( Mode ); | 562 | it->setSelectable( Mode ); |
558 | if( AutoCollapse ) | 563 | if( AutoCollapse ) |
559 | it->setOpen( Mode ); | 564 | it->setOpen( Mode ); |
560 | disableTree( it->firstChild(), Mode ); | 565 | disableTree( it->firstChild(), Mode ); |
561 | it = it->nextSibling(); | 566 | it = it->nextSibling(); |
562 | } | 567 | } |
563 | } | 568 | } |
@@ -597,44 +602,45 @@ void EditNetworkSetup::enablePath( QListViewItem * it, bool pha ) { | |||
597 | } | 602 | } |
598 | it = it->nextSibling(); | 603 | it = it->nextSibling(); |
599 | } | 604 | } |
600 | } | 605 | } |
601 | 606 | ||
602 | // do we have a complete configuration (all needs are provided for ?) | 607 | // do we have a complete configuration (all needs are provided for ?) |
603 | bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) { | 608 | bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) { |
604 | 609 | ||
605 | // check if all below this level is selected | 610 | // check if all below this level is selected |
606 | it = ( it ) ?it : Nodes_LV->firstChild(); | 611 | it = ( it ) ?it : Nodes_LV->firstChild(); |
607 | ANetNode *NN; | 612 | ANetNode *NN; |
608 | bool Found; | 613 | bool Found; |
609 | 614 | ||
610 | while ( it ) { | 615 | while ( it ) { |
611 | NN = (*Mapping)[it]; | 616 | NN = (*Mapping)[it]; |
612 | if( NN == 0 ) { | 617 | if( NN == 0 ) { |
613 | // this item is a controller -> | 618 | // this item is a controller -> |
614 | // has radio items as children -> | 619 | // has radio items as children -> |
615 | // find selected one | 620 | // find selected one |
616 | it = it->firstChild(); | 621 | it = it->firstChild(); |
617 | Found = 0; | 622 | Found = 0; |
618 | while( it ) { | 623 | while( it ) { |
619 | if( ((QCheckListItem *)it)->isOn() ) { | 624 | if( ((QCheckListItem *)it)->isOn() ) { |
620 | Found = 1; | 625 | Found = 1; |
621 | // go deeper | 626 | // go deeper |
622 | it = it->firstChild(); | 627 | it = it->firstChild(); |
623 | break; | 628 | break; |
624 | } | 629 | } |
625 | it = it->nextSibling(); | 630 | it = it->nextSibling(); |
626 | } | 631 | } |
627 | 632 | ||
628 | if( ! Found ) { | 633 | if( ! Found ) { |
634 | Log(( "Setup not complete\n" )); | ||
629 | return 0; // no not complete -> a radio should have been chkd | 635 | return 0; // no not complete -> a radio should have been chkd |
630 | } | 636 | } |
631 | 637 | ||
632 | // it now contains selected radio | 638 | // it now contains selected radio |
633 | NN = (*Mapping)[it]; | 639 | NN = (*Mapping)[it]; |
634 | } else { | 640 | } else { |
635 | // automatic selection | 641 | // automatic selection |
636 | it = it->firstChild(); | 642 | it = it->firstChild(); |
637 | } | 643 | } |
638 | } | 644 | } |
639 | return 1; | 645 | return 1; |
640 | } | 646 | } |