Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/netnode.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index f8f2d1e..f00e0b3 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp @@ -138,33 +138,35 @@ NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { IsModified = 0; Index = -1; Name=""; IsNew = 1; CurrentState = Unchecked; AssignedInterface = 0; + Number = -1; + Done = 0; } -NodeCollection::NodeCollection( QTextStream & TS ) : +NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : QList<ANetNodeInstance>() { long idx; - bool InError = 0; QString S, A, N; + + Number = -1; + Done = 0; IsModified = 0; Index = -1; Name=""; IsNew = 0; AssignedInterface = 0; CurrentState = Unchecked; + Dangling = 0; // by default node collection is ok + do { S = TS.readLine(); if( S.isEmpty() ) { - if( InError ) { - // remove all nodes - clear(); - } // empty line break; } idx = S.find('='); S.stripWhiteSpace(); @@ -178,26 +180,29 @@ NodeCollection::NodeCollection( QTextStream & TS ) : Name = N; } else if( A == "number" ) { setNumber( N.toLong() ); } else if( A == "node" ) { ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); Log(( "Find node %s : %p\n", N.latin1(), NNI )); - if( NNI && ! InError ) { + if( NNI ) { append( NNI ); } else { // could not find a node type -> collection invalid - InError = 1; + Log(( "Node %s missing -> connection dangling\n", + N.latin1() )); + // create placeholder for this dangling NNI + NNI = new ErrorNNI( N ); + Dangling = 1; } } } while( 1 ); Log(( "Profile number %s : %d nodes\n", Name.latin1(), count() )); } - NodeCollection::~NodeCollection( void ) { } const QString & NodeCollection::description( void ) { ANetNodeInstance * NNI = getToplevel(); return (NNI) ? NNI->runtime()->description() : Name; @@ -226,29 +231,31 @@ void NodeCollection::save( QTextStream & TS ) { ANetNodeInstance * NodeCollection::getToplevel( void ) { ANetNodeInstance * NNI = 0; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); - if( NNI->nodeClass()->isToplevel() ) - break; - } + if( NNI->nodeClass()->isToplevel() ) { return NNI; } + } + return 0; +} ANetNodeInstance * NodeCollection::findByName( const QString & S ) { ANetNodeInstance * NNI = 0; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); - if( NNI->name() == S ) - break; - } + if( NNI->name() == S ) { return NNI; } + } + return 0; +} ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { ANetNodeInstance * NNNI; if( ! NNI ) getToplevel(); |