Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.cpp') (more/less context) (ignore 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 | |||
@@ -132,78 +132,83 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | |||
132 | // | 132 | // |
133 | // NODECOLLECTION | 133 | // NODECOLLECTION |
134 | // | 134 | // |
135 | // | 135 | // |
136 | 136 | ||
137 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { | 137 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { |
138 | IsModified = 0; | 138 | IsModified = 0; |
139 | Index = -1; | 139 | Index = -1; |
140 | Name=""; | 140 | Name=""; |
141 | IsNew = 1; | 141 | IsNew = 1; |
142 | CurrentState = Unchecked; | 142 | CurrentState = Unchecked; |
143 | AssignedInterface = 0; | 143 | AssignedInterface = 0; |
144 | Number = -1; | ||
145 | Done = 0; | ||
144 | } | 146 | } |
145 | 147 | ||
146 | NodeCollection::NodeCollection( QTextStream & TS ) : | 148 | NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : |
147 | QList<ANetNodeInstance>() { | 149 | QList<ANetNodeInstance>() { |
148 | long idx; | 150 | long idx; |
149 | bool InError = 0; | ||
150 | QString S, A, N; | 151 | QString S, A, N; |
152 | |||
153 | Number = -1; | ||
154 | Done = 0; | ||
151 | IsModified = 0; | 155 | IsModified = 0; |
152 | Index = -1; | 156 | Index = -1; |
153 | Name=""; | 157 | Name=""; |
154 | IsNew = 0; | 158 | IsNew = 0; |
155 | AssignedInterface = 0; | 159 | AssignedInterface = 0; |
156 | CurrentState = Unchecked; | 160 | CurrentState = Unchecked; |
157 | 161 | ||
162 | Dangling = 0; // by default node collection is ok | ||
163 | |||
158 | do { | 164 | do { |
159 | S = TS.readLine(); | 165 | S = TS.readLine(); |
160 | if( S.isEmpty() ) { | 166 | if( S.isEmpty() ) { |
161 | if( InError ) { | ||
162 | // remove all nodes | ||
163 | clear(); | ||
164 | } | ||
165 | // empty line | 167 | // empty line |
166 | break; | 168 | break; |
167 | } | 169 | } |
168 | 170 | ||
169 | idx = S.find('='); | 171 | idx = S.find('='); |
170 | S.stripWhiteSpace(); | 172 | S.stripWhiteSpace(); |
171 | A = S.left( idx ); | 173 | A = S.left( idx ); |
172 | A.lower(); | 174 | A.lower(); |
173 | N = S.mid( idx+1, S.length() ); | 175 | N = S.mid( idx+1, S.length() ); |
174 | N.stripWhiteSpace(); | 176 | N.stripWhiteSpace(); |
175 | N = deQuote( N ); | 177 | N = deQuote( N ); |
176 | 178 | ||
177 | if( A == "name" ) { | 179 | if( A == "name" ) { |
178 | Name = N; | 180 | Name = N; |
179 | } else if( A == "number" ) { | 181 | } else if( A == "number" ) { |
180 | setNumber( N.toLong() ); | 182 | setNumber( N.toLong() ); |
181 | } else if( A == "node" ) { | 183 | } else if( A == "node" ) { |
182 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); | 184 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); |
183 | Log(( "Find node %s : %p\n", N.latin1(), NNI )); | 185 | Log(( "Find node %s : %p\n", N.latin1(), NNI )); |
184 | if( NNI && ! InError ) { | 186 | if( NNI ) { |
185 | append( NNI ); | 187 | append( NNI ); |
186 | } else { | 188 | } else { |
187 | // could not find a node type -> collection invalid | 189 | // could not find a node type -> collection invalid |
188 | InError = 1; | 190 | Log(( "Node %s missing -> connection dangling\n", |
191 | N.latin1() )); | ||
192 | // create placeholder for this dangling NNI | ||
193 | NNI = new ErrorNNI( N ); | ||
194 | Dangling = 1; | ||
189 | } | 195 | } |
190 | } | 196 | } |
191 | } while( 1 ); | 197 | } while( 1 ); |
192 | 198 | ||
193 | Log(( "Profile number %s : %d nodes\n", | 199 | Log(( "Profile number %s : %d nodes\n", |
194 | Name.latin1(), count() )); | 200 | Name.latin1(), count() )); |
195 | } | 201 | } |
196 | 202 | ||
197 | |||
198 | NodeCollection::~NodeCollection( void ) { | 203 | NodeCollection::~NodeCollection( void ) { |
199 | } | 204 | } |
200 | 205 | ||
201 | const QString & NodeCollection::description( void ) { | 206 | const QString & NodeCollection::description( void ) { |
202 | ANetNodeInstance * NNI = getToplevel(); | 207 | ANetNodeInstance * NNI = getToplevel(); |
203 | return (NNI) ? NNI->runtime()->description() : Name; | 208 | return (NNI) ? NNI->runtime()->description() : Name; |
204 | } | 209 | } |
205 | 210 | ||
206 | void NodeCollection::append( ANetNodeInstance * NNI ) { | 211 | void NodeCollection::append( ANetNodeInstance * NNI ) { |
207 | NNI->setConnection( this ); | 212 | NNI->setConnection( this ); |
208 | QList<ANetNodeInstance>::append( NNI ); | 213 | QList<ANetNodeInstance>::append( NNI ); |
209 | } | 214 | } |
@@ -220,40 +225,42 @@ void NodeCollection::save( QTextStream & TS ) { | |||
220 | TS << "node=" << NNI->name() << endl; | 225 | TS << "node=" << NNI->name() << endl; |
221 | } | 226 | } |
222 | TS << endl; | 227 | TS << endl; |
223 | IsNew = 0; | 228 | IsNew = 0; |
224 | } | 229 | } |
225 | 230 | ||
226 | ANetNodeInstance * NodeCollection::getToplevel( void ) { | 231 | ANetNodeInstance * NodeCollection::getToplevel( void ) { |
227 | ANetNodeInstance * NNI = 0; | 232 | ANetNodeInstance * NNI = 0; |
228 | for( QListIterator<ANetNodeInstance> it(*this); | 233 | for( QListIterator<ANetNodeInstance> it(*this); |
229 | it.current(); | 234 | it.current(); |
230 | ++it ) { | 235 | ++it ) { |
231 | NNI = it.current(); | 236 | NNI = it.current(); |
232 | if( NNI->nodeClass()->isToplevel() ) | 237 | if( NNI->nodeClass()->isToplevel() ) { |
233 | break; | 238 | return NNI; |
239 | } | ||
234 | } | 240 | } |
235 | return NNI; | 241 | return 0; |
236 | } | 242 | } |
237 | 243 | ||
238 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { | 244 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { |
239 | ANetNodeInstance * NNI = 0; | 245 | ANetNodeInstance * NNI = 0; |
240 | for( QListIterator<ANetNodeInstance> it(*this); | 246 | for( QListIterator<ANetNodeInstance> it(*this); |
241 | it.current(); | 247 | it.current(); |
242 | ++it ) { | 248 | ++it ) { |
243 | NNI = it.current(); | 249 | NNI = it.current(); |
244 | if( NNI->name() == S ) | 250 | if( NNI->name() == S ) { |
245 | break; | 251 | return NNI; |
252 | } | ||
246 | } | 253 | } |
247 | return NNI; | 254 | return 0; |
248 | } | 255 | } |
249 | 256 | ||
250 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | 257 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { |
251 | ANetNodeInstance * NNNI; | 258 | ANetNodeInstance * NNNI; |
252 | 259 | ||
253 | if( ! NNI ) | 260 | if( ! NNI ) |
254 | getToplevel(); | 261 | getToplevel(); |
255 | 262 | ||
256 | for( QListIterator<ANetNodeInstance> it(*this); | 263 | for( QListIterator<ANetNodeInstance> it(*this); |
257 | it.current(); | 264 | it.current(); |
258 | ++it ) { | 265 | ++it ) { |
259 | NNNI = it.current(); | 266 | NNNI = it.current(); |