Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index b4d9aaa..13979ce 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -33,4 +33,3 @@ NetworkSettingsData::~NetworkSettingsData( void ) { | |||
33 | void NetworkSettingsData::loadSettings( void ) { | 33 | void NetworkSettingsData::loadSettings( void ) { |
34 | QString S; | 34 | QString Line, S; |
35 | ANetNodeInstance* NNI; | ||
36 | QString Attr, Value; | 35 | QString Attr, Value; |
@@ -59,3 +58,3 @@ void NetworkSettingsData::loadSettings( void ) { | |||
59 | while( ! TS.atEnd() ) { | 58 | while( ! TS.atEnd() ) { |
60 | S = TS.readLine(); | 59 | S = Line = TS.readLine(); |
61 | 60 | ||
@@ -75,6 +74,12 @@ void NetworkSettingsData::loadSettings( void ) { | |||
75 | } else { | 74 | } else { |
76 | // load nodes | 75 | ANetNode * NN = 0; |
77 | NNI = NSResources->createNodeInstance( S ); | 76 | ANetNodeInstance* NNI = 0; |
78 | if( ! NNI ) { | 77 | if( S.startsWith( "nodetype " ) ) { |
79 | printf( "SKIPPING %s\n", S.latin1() ); | 78 | S = S.mid( 9, S.length()-9-1 ); |
79 | fprintf( stderr, "Node %s\n", S.latin1() ); | ||
80 | // try to find netnode | ||
81 | NN = NSResources->findNetNode( S ); | ||
82 | } else { | ||
83 | // try to find instance | ||
84 | NNI = NSResources->createNodeInstance( S ); | ||
80 | } | 85 | } |
@@ -83,8 +88,8 @@ void NetworkSettingsData::loadSettings( void ) { | |||
83 | S = TS.readLine(); | 88 | S = TS.readLine(); |
84 | if( S.isEmpty() ) { | 89 | |
85 | // empty line | 90 | if( NN || NNI ) { |
86 | break; | 91 | if( S.isEmpty() ) { |
87 | } | 92 | // empty line |
88 | // node found ? | 93 | break; |
89 | if( NNI ) { | 94 | } |
90 | idx = S.find( '=' ); | 95 | idx = S.find( '=' ); |
@@ -104,6 +109,17 @@ void NetworkSettingsData::loadSettings( void ) { | |||
104 | 109 | ||
105 | // set the attribute | 110 | if( NN ) { |
106 | NNI->setAttribute( Attr, Value ); | 111 | // set the attribute |
112 | NNI->setAttribute( Attr, Value ); | ||
113 | } else { | ||
114 | // set the attribute | ||
115 | NNI->setAttribute( Attr, Value ); | ||
116 | } | ||
117 | } else { | ||
118 | LeftOvers.append( Line ); | ||
119 | // add empty line too as delimiter | ||
120 | if( S.isEmpty() ) { | ||
121 | // empty line | ||
122 | break; | ||
123 | } | ||
107 | } | 124 | } |
108 | |||
109 | } while( 1 ); | 125 | } while( 1 ); |
@@ -140,2 +156,21 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
140 | QTextStream TS( &F ); | 156 | QTextStream TS( &F ); |
157 | |||
158 | // save leftovers | ||
159 | for ( QStringList::Iterator it = LeftOvers.begin(); | ||
160 | it != LeftOvers.end(); ++it ) { | ||
161 | TS << (*it) << endl; | ||
162 | } | ||
163 | |||
164 | // save global configs | ||
165 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); | ||
166 | it.current(); | ||
167 | ++it ) { | ||
168 | TS << "[nodetype " | ||
169 | << it.current()->NetNode->name() | ||
170 | << "]" | ||
171 | << endl; | ||
172 | |||
173 | it.current()->NetNode->saveAttributes( TS ); | ||
174 | } | ||
175 | |||
141 | { Name2Connection_t & M = NSResources->connections(); | 176 | { Name2Connection_t & M = NSResources->connections(); |