summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/nsdata.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp53
1 files changed, 44 insertions, 9 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
@@ -31,8 +31,7 @@ NetworkSettingsData::~NetworkSettingsData( void ) {
31} 31}
32 32
33void NetworkSettingsData::loadSettings( void ) { 33void NetworkSettingsData::loadSettings( void ) {
34 QString S; 34 QString Line, S;
35 ANetNodeInstance* NNI;
36 QString Attr, Value; 35 QString Attr, Value;
37 long idx; 36 long idx;
38 37
@@ -57,7 +56,7 @@ void NetworkSettingsData::loadSettings( void ) {
57 <EMPTYLINE> 56 <EMPTYLINE>
58 */ 57 */
59 while( ! TS.atEnd() ) { 58 while( ! TS.atEnd() ) {
60 S = TS.readLine(); 59 S = Line = TS.readLine();
61 60
62 if ( S.isEmpty() || S[0] != '[' ) 61 if ( S.isEmpty() || S[0] != '[' )
63 continue; 62 continue;
@@ -73,20 +72,26 @@ void NetworkSettingsData::loadSettings( void ) {
73 NodeCollection * NC = new NodeCollection( TS ); 72 NodeCollection * NC = new NodeCollection( TS );
74 NSResources->addConnection( NC ); 73 NSResources->addConnection( NC );
75 } else { 74 } else {
76 // load nodes 75 ANetNode * NN = 0;
76 ANetNodeInstance* NNI = 0;
77 if( S.startsWith( "nodetype " ) ) {
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
77 NNI = NSResources->createNodeInstance( S ); 84 NNI = NSResources->createNodeInstance( S );
78 if( ! NNI ) {
79 printf( "SKIPPING %s\n", S.latin1() );
80 } 85 }
81 86
82 do { 87 do {
83 S = TS.readLine(); 88 S = TS.readLine();
89
90 if( NN || NNI ) {
84 if( S.isEmpty() ) { 91 if( S.isEmpty() ) {
85 // empty line 92 // empty line
86 break; 93 break;
87 } 94 }
88 // node found ?
89 if( NNI ) {
90 idx = S.find( '=' ); 95 idx = S.find( '=' );
91 if( idx > 0 ) { 96 if( idx > 0 ) {
92 Attr = S.left( idx ); 97 Attr = S.left( idx );
@@ -102,10 +107,21 @@ void NetworkSettingsData::loadSettings( void ) {
102 // dequote Attr 107 // dequote Attr
103 Value = deQuote(Value); 108 Value = deQuote(Value);
104 109
110 if( NN ) {
111 // set the attribute
112 NNI->setAttribute( Attr, Value );
113 } else {
105 // set the attribute 114 // set the attribute
106 NNI->setAttribute( Attr, Value ); 115 NNI->setAttribute( Attr, Value );
107 } 116 }
108 117 } else {
118 LeftOvers.append( Line );
119 // add empty line too as delimiter
120 if( S.isEmpty() ) {
121 // empty line
122 break;
123 }
124 }
109 } while( 1 ); 125 } while( 1 );
110 if( NNI ) { 126 if( NNI ) {
111 // loading from file -> exists 127 // loading from file -> exists
@@ -138,6 +154,25 @@ QString NetworkSettingsData::saveSettings( void ) {
138 } 154 }
139 155
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();
142 ANetNodeInstance * NNI; 177 ANetNodeInstance * NNI;
143 178