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 @@ -76,59 +76,61 @@ 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 EditConnection::AutoCollapse = 1; +bool EditNetworkSetup::AutoCollapse = 1; -EditConnection::EditConnection( QWidget* parent ) : - EditConnectionGUI( parent, 0, TRUE ), TmpCollection() { +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(); } -NodeCollection * EditConnection::getTmpCollection( void ) { +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 ); // 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 */ @@ -184,26 +186,26 @@ NodeCollection * EditConnection::getTmpCollection( void ) { } // go deeper to next level // this level is can be a new controller // or an item it = it->firstChild(); } TmpIsValid = 1; return &(TmpCollection); } -// pass a connection NodeCollection to be edited -void EditConnection::setConnection( NodeCollection * NC ) { +// pass a NetworkSetup NetworkSetup to be edited +void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) { ANetNodeInstance * NNI; ANetNode * NN; SelectedNodes = NC; Name_LE->setText( NC->name() ); NNI = NC->first(); // show configure tabl Tab_TB->setCurrentPage( 1 ); // valid colledction Tab_TB->setTabEnabled( Setup_FRM, FALSE ); @@ -234,124 +236,124 @@ void EditConnection::setConnection( NodeCollection * NC ) { NNI = SelectedNodes->next(); // do not bother to check other items break; } it = it->nextSibling(); } if( ! Found ) { // this means that this level is NOT present in collection // probably INCOMPATIBEL collection OR Missing plugin QMessageBox::warning( 0, - tr( "Error presentig Connection" ), - tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). + tr( "Error presentig NetworkSetup" ), + tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). arg(NNI->nodeClass()->name()) ); return; } // it now contains selected radio NN = (*Mapping)[it]; } else { // automatic selection if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { // should exist and be the same if( NNI ) { QMessageBox::warning( 0, - tr( "Error presentig Connection" ), - tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). + tr( "Error presentig NetworkSetup" ), + tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). arg(NNI->nodeClass()->name()) ); } else { QMessageBox::warning( 0, - tr( "Error presentig Connection" ), - tr( "<p>Missing connection\"<i>%1</i>\"</p>" ). + tr( "Error presentig NetworkSetup" ), + tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). arg(it->text(0)) ); } return; } it = it->firstChild(); } } } // get result of editing (either new OR updated collection -NodeCollection * EditConnection::connection( void ) { +NetworkSetup * EditNetworkSetup::networkSetup( void ) { if( SelectedNodes == 0 ) { // new collection - SelectedNodes = new NodeCollection; + SelectedNodes = new NetworkSetup; } // clean out old entries SelectedNodes->clear(); // transfer for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { SelectedNodes->append( it.current() ); } if( TmpCollection.isModified() ) SelectedNodes->setModified( 1 ); if( SelectedNodes->name() != Name_LE->text() ) { SelectedNodes->setName( Name_LE->text() ); SelectedNodes->setModified( 1 ); } return SelectedNodes; } // Build device tree -> start -void EditConnection::buildFullTree( void ) { +void EditNetworkSetup::buildFullTree( void ) { ANetNode * NN; // toplevel item MyQCheckListItem * TheTop = new MyQCheckListItem( Nodes_LV, NSResources->netNode2Name("fullsetup"), QCheckListItem::Controller ); TheTop->setOpen( TRUE ); Description_LBL->setText( NSResources->netNode2Description( "fullsetup" ) ); Nodes_LV->setSelected( TheTop, TRUE ); // find all Nodes that are toplevel nodes -> ie provide - // TCP/IP Connection + // TCP/IP NetworkSetup for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); Iter.current(); ++Iter ) { NN = Iter.current(); if( ! NN->isToplevel() ) { continue; } MyQCheckListItem * it = new MyQCheckListItem( TheTop, NN->name(), QCheckListItem::RadioButton ); it->setPixmap( 0, NSResources->getPixmap( NN->pixmapName() ) ); // remember that this node maps to this listitem Mapping->insert( it, NN ); buildSubTree( it, NN ); } } // Build device tree -> help function -void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { +void EditNetworkSetup::buildSubTree( QListViewItem * it, ANetNode *NN ) { ANetNode::NetNodeList & NNL = NN->alternatives(); if( NNL.size() > 1 ) { // this node has alternatives -> needs radio buttons it = new MyQCheckListItem( it, NSResources->netNode2Name(NN->needs()[0]), QCheckListItem::Controller ); it->setSelectable( FALSE ); } for ( unsigned int i=0; i < NNL.size(); i++ ) { @@ -369,29 +371,29 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { // Single item CI = new MyQListViewItem( it, NNL[i]->name() ); // remember that this node maps to this listitem Mapping->insert( CI, NNL[i] ); CI->setSelectable( FALSE ); CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); } buildSubTree( CI, NNL[i] ); } } // Clicked ok OK button -void EditConnection::accept( void ) { +void EditNetworkSetup::accept( void ) { if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) { QMessageBox::warning( 0, - tr( "Closing Connection Setup" ), + tr( "Closing NetworkSetup Setup" ), tr( "Definition not complete or no name" ) ); return; } // check if all devices have acceptable input getTmpCollection(); { ANetNodeInstance * NNI; QString S; for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { @@ -409,30 +411,30 @@ void EditConnection::accept( void ) { if( NNI->isModified() ) { TmpCollection.setModified( 1 ); // commit the data } } } QDialog::accept(); } // triggered by CB -void EditConnection::SLOT_AutoCollapse( bool b ) { +void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { AutoCollapse = b; } // clicked on node in tree -> update GUI -void EditConnection::SLOT_SelectNode( QListViewItem * it ) { +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 ) { @@ -456,25 +458,25 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) { if( ! ((QCheckListItem *)it)->isOn() ) { // clicked on line but NOT on Check or Radio item return; } // item has really changed -> update TmpIsValid = 0; updateGUI( it, NN ); } // cliecked on TAB to go to setup -void EditConnection::SLOT_AlterTab( const QString & S ) { +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(); @@ -505,25 +507,25 @@ void EditConnection::SLOT_AlterTab( const QString & S ) { tr("No configuration required")); } Setup_WS->addWidget( W , i ); i ++; } } Setup_WS->raiseWidget( 0 ); } // still valid } } // update visual feedback of selection state -void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { +void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { bool HCC = haveCompleteConfig( it ); Tab_TB->setTabEnabled( Setup_FRM, HCC ); Setup_FRM->setEnabled( HCC ); // disable children of all siblings at same level QListViewItem * Sbl = it->parent()->firstChild(); while( Sbl ) { if ( Sbl != it ) { disableTree( Sbl->firstChild(), FALSE ); Sbl->setSelectable( TRUE ); if( AutoCollapse ) @@ -531,37 +533,37 @@ void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { } Sbl = Sbl->nextSibling(); } // enable selected path (as deep as it goes it->setOpen( TRUE ); enablePath( it->firstChild(), (it->depth()==1) ? 1 : // toplevel always alternatives (NN->alternatives().size() > 1) ); } -void EditConnection::disableTree( QListViewItem * it, bool Mode ) { +void EditNetworkSetup::disableTree( QListViewItem * it, bool Mode ) { while( it ) { // disable sbl's chidren it->setSelectable( Mode ); if( AutoCollapse ) it->setOpen( Mode ); disableTree( it->firstChild(), Mode ); it = it->nextSibling(); } } // pah : ParentHasAlternatives -void EditConnection::enablePath( QListViewItem * it, bool pha ) { +void EditNetworkSetup::enablePath( QListViewItem * it, bool pha ) { while( it ) { ANetNode * NN; NN = (*Mapping)[it]; if( NN ) { if( pha ) { bool doOn = ((QCheckListItem *)it)->isOn(); // we are a checklistitem for sure it->setSelectable( TRUE ); if( AutoCollapse && ! doOn ) it->setOpen( doOn ); if( doOn ) { // selected alternative @@ -580,25 +582,25 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) { } } else { // controller node it->setSelectable( TRUE ); it->setOpen( TRUE ); enablePath( it->firstChild(), pha ); } it = it->nextSibling(); } } // do we have a complete configuration (all needs are provided for ?) -bool EditConnection::haveCompleteConfig( QListViewItem * it ) { +bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) { // check if all below this level is selected it = ( it ) ?it : Nodes_LV->firstChild(); ANetNode *NN; bool Found; while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { // this item is a controller -> // has radio items as children -> // find selected one |