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 +1,2 @@ | |||
1 | #include <opie2/odebug.h> | ||
1 | #include <qlistview.h> | 2 | #include <qlistview.h> |
@@ -33,2 +34,9 @@ public: | |||
33 | 34 | ||
35 | MyQCheckListItem( QListView *parent, const QString & S ) : | ||
36 | QCheckListItem( parent, S, QCheckListItem::Controller ) { } | ||
37 | MyQCheckListItem( QCheckListItem *parent, const QString & S ) : | ||
38 | QCheckListItem( parent, S, QCheckListItem::Controller ) { } | ||
39 | MyQCheckListItem( QListViewItem *parent, const QString & S ) : | ||
40 | QCheckListItem( parent, S, QCheckListItem::Controller ) { } | ||
41 | |||
34 | virtual void paintCell( QPainter *p, const QColorGroup &cg, | 42 | virtual void paintCell( QPainter *p, const QColorGroup &cg, |
@@ -118,3 +126,10 @@ NodeCollection * EditConnection::getTmpCollection( void ) { | |||
118 | ANetNode * NN; | 126 | ANetNode * NN; |
119 | // start iter | 127 | |
128 | // start iter (if there is a collection) | ||
129 | /* | ||
130 | |||
131 | a node collection is sorted from the toplevel | ||
132 | node to the deepest node | ||
133 | |||
134 | */ | ||
120 | ANetNodeInstance * NNI = | 135 | ANetNodeInstance * NNI = |
@@ -124,2 +139,4 @@ NodeCollection * EditConnection::getTmpCollection( void ) { | |||
124 | 139 | ||
140 | // the listview always starts with the toplevel | ||
141 | // hierarchy. This is always a controller item | ||
125 | while ( it ) { | 142 | while ( it ) { |
@@ -127,4 +144,5 @@ NodeCollection * EditConnection::getTmpCollection( void ) { | |||
127 | if( NN == 0 ) { | 144 | if( NN == 0 ) { |
128 | // child is controller -> has sub radio | 145 | // this item is a controller -> |
129 | // check if one radio is selected | 146 | // has radio items as children -> |
147 | // find selected one | ||
130 | it = it->firstChild(); | 148 | it = it->firstChild(); |
@@ -133,7 +151,24 @@ NodeCollection * EditConnection::getTmpCollection( void ) { | |||
133 | // this radio is selected -> go deeper | 151 | // this radio is selected -> go deeper |
134 | if( SelectedNodes == 0 || | 152 | break; |
135 | NNI == 0 || | 153 | } |
154 | it = it->nextSibling(); | ||
155 | } | ||
156 | |||
157 | if( ! it ) { | ||
158 | owarn << "Radio not selected" << oendl; | ||
159 | TmpIsValid = 0; | ||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | // it now contains selected radio | ||
164 | NN = (*Mapping)[it]; | ||
165 | } | ||
166 | |||
167 | // NN here contains the netnode of the | ||
168 | // current item -> this node needs to | ||
169 | // be stored in the collection | ||
170 | if( NNI == 0 || | ||
136 | it->text(0) != NNI->nodeClass()->name() ) { | 171 | it->text(0) != NNI->nodeClass()->name() ) { |
137 | // new item not in previous collection | 172 | // new item not in previous collection |
138 | ANetNodeInstance * NNI = (*Mapping)[it]->createInstance(); | 173 | ANetNodeInstance * NNI = NN->createInstance(); |
139 | NNI->initialize(); | 174 | NNI->initialize(); |
@@ -150,12 +185,7 @@ NodeCollection * EditConnection::getTmpCollection( void ) { | |||
150 | } | 185 | } |
186 | |||
187 | // go deeper to next level | ||
188 | // this level is can be a new controller | ||
189 | // or an item | ||
151 | it = it->firstChild(); | 190 | it = it->firstChild(); |
152 | // do not bother to check other items | ||
153 | break; | ||
154 | } | ||
155 | it = it->nextSibling(); | ||
156 | } | ||
157 | } else { | ||
158 | // check children | ||
159 | it = it->firstChild(); | ||
160 | } | ||
161 | } | 191 | } |
@@ -189,8 +219,7 @@ void EditConnection::setConnection( NodeCollection * NC ) { | |||
189 | while ( it ) { | 219 | while ( it ) { |
190 | // listitem corresponds to netnode | ||
191 | NN = (*Mapping)[it]; | 220 | NN = (*Mapping)[it]; |
192 | if( NN == 0 ) { | 221 | if( NN == 0 ) { |
193 | // child is controller -> has sub radio | 222 | // this item is a controller -> |
194 | QString Ctr = it->text(0); | 223 | // has radio items as children -> |
195 | // check if one radio is selected | 224 | // find selected one |
196 | it = it->firstChild(); | 225 | it = it->firstChild(); |
@@ -211,2 +240,3 @@ void EditConnection::setConnection( NodeCollection * NC ) { | |||
211 | } | 240 | } |
241 | |||
212 | if( ! Found ) { | 242 | if( ! Found ) { |
@@ -218,7 +248,27 @@ void EditConnection::setConnection( NodeCollection * NC ) { | |||
218 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). | 248 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). |
219 | arg(Ctr) ); | 249 | arg(NNI->nodeClass()->name()) ); |
220 | return; | 250 | return; |
221 | } | 251 | } |
252 | |||
253 | // it now contains selected radio | ||
254 | NN = (*Mapping)[it]; | ||
222 | } else { | 255 | } else { |
223 | // automatic item -> check children | 256 | // automatic selection |
257 | if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { | ||
258 | // should exist and be the same | ||
259 | if( NNI ) { | ||
260 | QMessageBox::warning( | ||
261 | 0, | ||
262 | tr( "Error presentig Connection" ), | ||
263 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). | ||
264 | arg(NNI->nodeClass()->name()) ); | ||
265 | } else { | ||
266 | QMessageBox::warning( | ||
267 | 0, | ||
268 | tr( "Error presentig Connection" ), | ||
269 | tr( "<p>Missing connection\"<i>%1</i>\"</p>" ). | ||
270 | arg(it->text(0)) ); | ||
271 | } | ||
272 | return; | ||
273 | } | ||
224 | it = it->firstChild(); | 274 | it = it->firstChild(); |
@@ -271,3 +321,3 @@ void EditConnection::buildFullTree( void ) { | |||
271 | 321 | ||
272 | // find all Nodes that care toplevel nodes -> ie provide | 322 | // find all Nodes that are toplevel nodes -> ie provide |
273 | // TCP/IP Connection | 323 | // TCP/IP Connection |
@@ -286,3 +336,5 @@ void EditConnection::buildFullTree( void ) { | |||
286 | QCheckListItem::RadioButton ); | 336 | QCheckListItem::RadioButton ); |
287 | it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); | 337 | it->setPixmap( 0, |
338 | NSResources->getPixmap( NN->pixmapName() ) | ||
339 | ); | ||
288 | // remember that this node maps to this listitem | 340 | // remember that this node maps to this listitem |
@@ -301,3 +353,3 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { | |||
301 | it, | 353 | it, |
302 | NSResources->netNode2Name(NNL[0]->provides()), | 354 | NSResources->netNode2Name(NN->needs()[0]), |
303 | QCheckListItem::Controller ); | 355 | QCheckListItem::Controller ); |
@@ -389,6 +441,7 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) { | |||
389 | // intermediate node | 441 | // intermediate node |
390 | NN = (*Mapping)[ it->firstChild() ]; | 442 | NN = (*Mapping)[ it->parent() ]; |
391 | if( NN ) { | 443 | if( NN ) { |
392 | // figure out type of this node -> produce mesage | 444 | // figure out type of this node -> produce mesage |
393 | Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); | 445 | Description_LBL->setText( NSResources->netNode2Description( |
446 | NN->needs()[0]) ); | ||
394 | } else { | 447 | } else { |
@@ -541,20 +594,21 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) { | |||
541 | bool EditConnection::haveCompleteConfig( QListViewItem * it ) { | 594 | bool EditConnection::haveCompleteConfig( QListViewItem * it ) { |
542 | if( it == 0 || ((QCheckListItem *)it)->isOn() ) { | 595 | |
543 | // check children | 596 | // check if all below this level is selected |
544 | it = (it) ? it->firstChild() : Nodes_LV->firstChild() ; | 597 | it = ( it ) ?it : Nodes_LV->firstChild(); |
598 | ANetNode *NN; | ||
599 | bool Found; | ||
600 | |||
545 | while ( it ) { | 601 | while ( it ) { |
546 | if( ((QCheckListItem *)it)->type() == | 602 | NN = (*Mapping)[it]; |
547 | QCheckListItem::Controller ) { | 603 | if( NN == 0 ) { |
548 | // child is controller -> has sub radio | 604 | // this item is a controller -> |
549 | // check if one radio is selected | 605 | // has radio items as children -> |
606 | // find selected one | ||
550 | it = it->firstChild(); | 607 | it = it->firstChild(); |
608 | Found = 0; | ||
551 | while( it ) { | 609 | while( it ) { |
552 | if( ((QCheckListItem *)it)->isOn() ) { | 610 | if( ((QCheckListItem *)it)->isOn() ) { |
553 | // this radio is selected -> go deeper | 611 | Found = 1; |
612 | // go deeper | ||
554 | it = it->firstChild(); | 613 | it = it->firstChild(); |
555 | if( ! it ) { | ||
556 | // was deepest level | ||
557 | return 1; | ||
558 | } | ||
559 | // do not bother to check other items | ||
560 | break; | 614 | break; |
@@ -563,8 +617,11 @@ bool EditConnection::haveCompleteConfig( QListViewItem * it ) { | |||
563 | } | 617 | } |
564 | if( ! it ) { | 618 | |
565 | // no radio selected | 619 | if( ! Found ) { |
566 | return 0; | 620 | return 0; // no not complete -> a radio should have been chkd |
567 | } | 621 | } |
622 | |||
623 | // it now contains selected radio | ||
624 | NN = (*Mapping)[it]; | ||
568 | } else { | 625 | } else { |
569 | // check children | 626 | // automatic selection |
570 | it = it->firstChild(); | 627 | it = it->firstChild(); |
@@ -572,6 +629,3 @@ bool EditConnection::haveCompleteConfig( QListViewItem * it ) { | |||
572 | } | 629 | } |
573 | // deepest level -> all is still OK | ||
574 | return 1; | 630 | return 1; |
575 | } // was not ON | ||
576 | return 0; | ||
577 | } | 631 | } |