summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/editconnection.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/editconnection.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp146
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 +1,2 @@
+#include <opie2/odebug.h>
#include <qlistview.h>
@@ -33,2 +34,9 @@ public:
+ 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,
@@ -118,3 +126,10 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
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 =
@@ -124,2 +139,4 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
+ // the listview always starts with the toplevel
+ // hierarchy. This is always a controller item
while ( it ) {
@@ -127,4 +144,5 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
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();
@@ -133,7 +151,24 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
// 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();
@@ -150,12 +185,7 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
}
+
+ // 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();
- }
}
@@ -189,8 +219,7 @@ void EditConnection::setConnection( NodeCollection * NC ) {
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();
@@ -211,2 +240,3 @@ void EditConnection::setConnection( NodeCollection * NC ) {
}
+
if( ! Found ) {
@@ -218,7 +248,27 @@ void EditConnection::setConnection( NodeCollection * NC ) {
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();
@@ -271,3 +321,3 @@ void EditConnection::buildFullTree( void ) {
- // find all Nodes that care toplevel nodes -> ie provide
+ // find all Nodes that are toplevel nodes -> ie provide
// TCP/IP Connection
@@ -286,3 +336,5 @@ void EditConnection::buildFullTree( void ) {
QCheckListItem::RadioButton );
- it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) );
+ it->setPixmap( 0,
+ NSResources->getPixmap( NN->pixmapName() )
+ );
// remember that this node maps to this listitem
@@ -301,3 +353,3 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) {
it,
- NSResources->netNode2Name(NNL[0]->provides()),
+ NSResources->netNode2Name(NN->needs()[0]),
QCheckListItem::Controller );
@@ -389,6 +441,7 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) {
// 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 {
@@ -541,20 +594,21 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) {
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;
@@ -563,8 +617,11 @@ bool EditConnection::haveCompleteConfig( QListViewItem * it ) {
}
- 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();
@@ -572,6 +629,3 @@ bool EditConnection::haveCompleteConfig( QListViewItem * it ) {
}
- // deepest level -> all is still OK
return 1;
- } // was not ON
- return 0;
}