-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 17 | ||||
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index 6ab2dd6..bda9d7e 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp @@ -76,97 +76,100 @@ void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, if ( ! isSelectable() ) _cg.setColor( QColorGroup::Text, Qt::lightGray ); QListViewItem::paintCell( p, _cg, column, width, alignment ); _cg.setColor( QColorGroup::Text, c ); } // // // REAL GUI // // bool EditNetworkSetup::AutoCollapse = 1; EditNetworkSetup::EditNetworkSetup( QWidget* parent ) : EditNetworkSetupGUI( parent, 0, TRUE ), TmpCollection() { Tab_TB->setTabEnabled( Setup_FRM, FALSE ); Setup_FRM->setEnabled( FALSE ); TmpIsValid = 0; SelectedNodes = 0; AutoCollapse_CB->setChecked( AutoCollapse ); Mapping = new QPtrDict<ANetNode>; Mapping->setAutoDelete( FALSE ); Nodes_LV->header()->hide(); // popluate tree with all NetNodes buildFullTree(); } NetworkSetup * EditNetworkSetup::getTmpCollection( void ) { if( TmpIsValid ) // content is stil OK return &(TmpCollection); // reset collection -> delete all NEW NetNodes for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { if( it.current()->isNew() ) { delete it.current(); } } TmpCollection.clear(); - TmpCollection.copyFrom( *SelectedNodes ); + if( SelectedNodes ) { + // initialize like original + TmpCollection.copyFrom( *SelectedNodes ); + } // update content QListViewItem * it = Nodes_LV->firstChild(); ANetNode * NN; // start iter (if there is a collection) /* a node collection is sorted from the toplevel node to the deepest node */ ANetNodeInstance * NNI = (SelectedNodes) ? SelectedNodes->first() : 0 ; TmpCollection.setModified( 0 ); // the listview always starts with the toplevel // hierarchy. This is always a controller item while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { // this item is a controller -> // has radio items as children -> // find selected one it = it->firstChild(); while( it ) { if( ((QCheckListItem *)it)->isOn() ) { // this radio is selected -> go deeper break; } it = it->nextSibling(); } if( ! it ) { TmpIsValid = 0; return 0; } // it now contains selected radio NN = (*Mapping)[it]; } // NN here contains the netnode of the // current item -> this node needs to // be stored in the collection if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { @@ -411,99 +414,105 @@ void EditNetworkSetup::accept( void ) { if( NNI->isModified() ) { TmpCollection.setModified( 1 ); // commit the data } } } QDialog::accept(); } // triggered by CB void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { AutoCollapse = b; } // clicked on node in tree -> update GUI void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { ANetNode * NN; if( it == 0 || it->depth() == 0 ) { Description_LBL->setText( NSResources->netNode2Description( "fullsetup" ) ); // topevel or no selection return; } // store conversion from lvitem to node NN = (*Mapping)[ it ]; if( ! NN ) { // intermediate node NN = (*Mapping)[ it->parent() ]; if( NN ) { // figure out type of this node -> produce mesage Description_LBL->setText( NSResources->netNode2Description( NN->needs()[0]) ); } else { Description_LBL->setText( "" ); } return; } Description_LBL->setText( NN->nodeDescription() ); if( ! it->isSelectable() ) { return; } - if( ! ((QCheckListItem *)it)->isOn() ) { - // clicked on line but NOT on Check or Radio item - return; + ANetNode::NetNodeList & NNL = NN->alternatives(); + + if( NNL.size() != 1 ) { + if( NNL.size() == 0 || + ! ((MyQCheckListItem *)it)->isOn() + ) { + // not clicked on Check or Radio item + return; + } } // item has really changed -> update TmpIsValid = 0; updateGUI( it, NN ); } // cliecked on TAB to go to setup void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { // switched to setup -> update CB and populate ws with // forms for devices if( ! TmpIsValid ) { getTmpCollection(); // clear CB and Ws { QWidget * W; int i = 0; Devices_CB->clear(); while( ( W = Setup_WS->widget( i ) ) ) { Setup_WS->removeWidget( W ); i ++; } } // update CB // and populate WidgetStack { ANetNodeInstance * NNI; QListIterator<ANetNodeInstance> it(TmpCollection); int i = 0; QWidget * W; for ( ; it.current(); ++it ) { NNI = it.current(); Devices_CB->insertItem( NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), NNI->nodeClass()->name() ); // add edit widget W = NNI->edit( Setup_WS ); if( ! W) { W = new QLabel( Setup_WS, tr("No configuration required")); } Setup_WS->addWidget( W , i ); diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index b4622fc..835c7c3 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -676,97 +676,97 @@ QList<NetworkSetup> NetworkSettingsData::collectPossible( if allowed, echo Interface-allowed else Interface-disallowed */ bool NetworkSettingsData::canStart( const QString & Interface ) { // load situation NetworkSetup * NC = 0; QList<NetworkSetup> PossibleNetworkSetups; PossibleNetworkSetups = collectPossible( Interface ); Log( ( "for %s : Possiblilies %d\n", Interface.latin1(), PossibleNetworkSetups.count() )); switch( PossibleNetworkSetups.count() ) { case 0 : // no NetworkSetups break; case 1 : // one NetworkSetup NC = PossibleNetworkSetups.first(); break; default : // need to ask user ? return 1; } if( NC ) { switch( NC->state() ) { case Unchecked : case Unknown : case Unavailable : case Disabled : // this profile does not allow interface to be UP // -> try others break; case Off : // try to UP the device { QString S= NC->setState( Activate ); if( ! S.isEmpty() ) { // could not bring device Online -> try other alters Log(( "disallow %ld for %s : %s\n", NC->number(), Interface.latin1(), S.latin1() )); break; } // interface assigned } // FT case Available : case IsUp : // also called for 'ifdown' // device is ready -> done Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); - printf( "A%ld%s\n", NC->number(), Interface.latin1() ); + printf( "A%d%s\n", NC->number(), Interface.latin1() ); return 0; } } // if we come here no alternatives are possible Log(( "disallow %s\n", Interface.latin1())); printf( "D-%s\n", Interface.latin1() ); return 0; } bool NetworkSettingsData::isModified( void ) { if( ForceModified ) return 1; for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); it.current(); ++it ) { if( it.current()->isModified() ) { return 1; } } return 0; } bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { // load situation QList<NetworkSetup> PossibleTriggered; PossibleTriggered = collectTriggered( Interface ); Log( ( "for %s : Possiblilies %d\n", Interface.latin1(), PossibleTriggered.count() )); return ( PossibleTriggered.count() ) ? 1 : 0; } QList<NetworkSetup> NetworkSettingsData::collectTriggered( const QString & Interface ) { // collect NetworkSetups that could be triggered by this interface NetworkSetup * NC; QList<NetworkSetup> PossibleTriggered; // for all NetworkSetups Name2NetworkSetup_t & M = NSResources->networkSetups(); for( QDictIterator<NetworkSetup> it(M); it.current(); |