author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (side-by-side diff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/editconnection.cpp | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/editconnection.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 146 |
1 files changed, 100 insertions, 46 deletions
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index 77826d1..3f8a53f 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp @@ -1,3 +1,4 @@ +#include <opie2/odebug.h> #include <qlistview.h> #include <qwidgetstack.h> #include <qframe.h> @@ -31,6 +32,13 @@ public: MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) : QCheckListItem( parent, S, T ) { } + MyQCheckListItem( QListView *parent, const QString & S ) : + QCheckListItem( parent, S, QCheckListItem::Controller ) { } + MyQCheckListItem( QCheckListItem *parent, const QString & S ) : + QCheckListItem( parent, S, QCheckListItem::Controller ) { } + MyQCheckListItem( QListViewItem *parent, const QString & S ) : + QCheckListItem( parent, S, QCheckListItem::Controller ) { } + virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); @@ -116,26 +124,53 @@ NodeCollection * EditConnection::getTmpCollection( void ) { // update content QListViewItem * it = Nodes_LV->firstChild(); ANetNode * NN; - // start iter + + // 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 ) { - // child is controller -> has sub radio - // check if one radio is selected + // 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 - if( SelectedNodes == 0 || - NNI == 0 || + break; + } + it = it->nextSibling(); + } + + if( ! it ) { + owarn << "Radio not selected" << oendl; + 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() ) { // new item not in previous collection - ANetNodeInstance * NNI = (*Mapping)[it]->createInstance(); + ANetNodeInstance * NNI = NN->createInstance(); NNI->initialize(); // this node type not in collection TmpCollection.append( NNI ); @@ -148,16 +183,11 @@ NodeCollection * EditConnection::getTmpCollection( void ) { TmpCollection.append( NNI ); NNI = SelectedNodes->next(); } + + // go deeper to next level + // this level is can be a new controller + // or an item it = it->firstChild(); - // do not bother to check other items - break; - } - it = it->nextSibling(); - } - } else { - // check children - it = it->firstChild(); - } } TmpIsValid = 1; @@ -187,12 +217,11 @@ void EditConnection::setConnection( NodeCollection * NC ) { TmpIsValid = 0; while ( it ) { - // listitem corresponds to netnode NN = (*Mapping)[it]; if( NN == 0 ) { - // child is controller -> has sub radio - QString Ctr = it->text(0); - // check if one radio is selected + // this item is a controller -> + // has radio items as children -> + // find selected one it = it->firstChild(); Found = 0; while( it ) { @@ -209,6 +238,7 @@ void EditConnection::setConnection( NodeCollection * NC ) { } it = it->nextSibling(); } + if( ! Found ) { // this means that this level is NOT present in collection // probably INCOMPATIBEL collection OR Missing plugin @@ -216,11 +246,31 @@ void EditConnection::setConnection( NodeCollection * NC ) { 0, tr( "Error presentig Connection" ), tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). - arg(Ctr) ); + arg(NNI->nodeClass()->name()) ); return; } + + // it now contains selected radio + NN = (*Mapping)[it]; } else { - // automatic item -> check children + // 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>" ). + arg(NNI->nodeClass()->name()) ); + } else { + QMessageBox::warning( + 0, + tr( "Error presentig Connection" ), + tr( "<p>Missing connection\"<i>%1</i>\"</p>" ). + arg(it->text(0)) ); + } + return; + } it = it->firstChild(); } } @@ -269,7 +319,7 @@ void EditConnection::buildFullTree( void ) { NSResources->netNode2Description( "fullsetup" ) ); Nodes_LV->setSelected( TheTop, TRUE ); - // find all Nodes that care toplevel nodes -> ie provide + // find all Nodes that are toplevel nodes -> ie provide // TCP/IP Connection for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); Iter.current(); @@ -284,7 +334,9 @@ void EditConnection::buildFullTree( void ) { MyQCheckListItem * it = new MyQCheckListItem( TheTop, NN->name(), QCheckListItem::RadioButton ); - it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); + it->setPixmap( 0, + NSResources->getPixmap( NN->pixmapName() ) + ); // remember that this node maps to this listitem Mapping->insert( it, NN ); buildSubTree( it, NN ); @@ -299,7 +351,7 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { // this node has alternatives -> needs radio buttons it = new MyQCheckListItem( it, - NSResources->netNode2Name(NNL[0]->provides()), + NSResources->netNode2Name(NN->needs()[0]), QCheckListItem::Controller ); it->setSelectable( FALSE ); } @@ -387,10 +439,11 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) { if( ! NN ) { // intermediate node - NN = (*Mapping)[ it->firstChild() ]; + NN = (*Mapping)[ it->parent() ]; if( NN ) { // figure out type of this node -> produce mesage - Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); + Description_LBL->setText( NSResources->netNode2Description( + NN->needs()[0]) ); } else { Description_LBL->setText( "" ); } @@ -539,39 +592,40 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) { // do we have a complete configuration (all needs are provided for ?) bool EditConnection::haveCompleteConfig( QListViewItem * it ) { - if( it == 0 || ((QCheckListItem *)it)->isOn() ) { - // check children - it = (it) ? it->firstChild() : Nodes_LV->firstChild() ; + + // check if all below this level is selected + it = ( it ) ?it : Nodes_LV->firstChild(); + ANetNode *NN; + bool Found; + while ( it ) { - if( ((QCheckListItem *)it)->type() == - QCheckListItem::Controller ) { - // child is controller -> has sub radio - // check if one radio is selected + NN = (*Mapping)[it]; + if( NN == 0 ) { + // this item is a controller -> + // has radio items as children -> + // find selected one it = it->firstChild(); + Found = 0; while( it ) { if( ((QCheckListItem *)it)->isOn() ) { - // this radio is selected -> go deeper + Found = 1; + // go deeper it = it->firstChild(); - if( ! it ) { - // was deepest level - return 1; - } - // do not bother to check other items break; } it = it->nextSibling(); } - if( ! it ) { - // no radio selected - return 0; + + if( ! Found ) { + return 0; // no not complete -> a radio should have been chkd } + + // it now contains selected radio + NN = (*Mapping)[it]; } else { - // check children + // automatic selection it = it->firstChild(); } } - // deepest level -> all is still OK return 1; - } // was not ON - return 0; } |