summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/managerimpl.cpp
Unidiff
Diffstat (limited to 'microkde/kresources/managerimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kresources/managerimpl.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index 1baa6be..785b6b4 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -208,102 +208,107 @@ QStringList ManagerImpl::resourceNames()
208 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 208 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
209 result.append( (*it)->resourceName() ); 209 result.append( (*it)->resourceName() );
210 } 210 }
211 return result; 211 return result;
212} 212}
213 213
214Resource::List *ManagerImpl::resourceList() 214Resource::List *ManagerImpl::resourceList()
215{ 215{
216 return &mResources; 216 return &mResources;
217} 217}
218 218
219QPtrList<Resource> ManagerImpl::resources() 219QPtrList<Resource> ManagerImpl::resources()
220{ 220{
221 QPtrList<Resource> result; 221 QPtrList<Resource> result;
222 222
223 Resource::List::ConstIterator it; 223 Resource::List::ConstIterator it;
224 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 224 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
225 result.append( *it ); 225 result.append( *it );
226 } 226 }
227 return result; 227 return result;
228} 228}
229 229
230QPtrList<Resource> ManagerImpl::resources( bool active ) 230QPtrList<Resource> ManagerImpl::resources( bool active )
231{ 231{
232 QPtrList<Resource> result; 232 QPtrList<Resource> result;
233 233
234 Resource::List::ConstIterator it; 234 Resource::List::ConstIterator it;
235 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 235 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
236 if ( (*it)->isActive() == active ) { 236 if ( (*it)->isActive() == active ) {
237 result.append( *it ); 237 result.append( *it );
238 } 238 }
239 } 239 }
240 return result; 240 return result;
241} 241}
242 242
243void ManagerImpl::setListener( ManagerImplListener *listener ) 243void ManagerImpl::setListener( ManagerImplListener *listener )
244{ 244{
245 mListener = listener; 245 mListener = listener;
246} 246}
247 247
248Resource* ManagerImpl::readResourceConfig( const QString& identifier, 248Resource* ManagerImpl::readResourceConfig( const QString& identifier,
249 bool checkActive ) 249 bool checkActive )
250{ 250{
251 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; 251 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
252 252
253// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); 253// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
254 254
255 mConfig->setGroup( "Resource_" + identifier ); 255 mConfig->setGroup( "Resource_" + identifier );
256 256#ifdef _WIN32_
257 // we use plugins on win32. the group is stored in a static variable
258 // such that gourp info not avail on win32 plugins
259 // to fix that, it would be a looooot of work
260 mConfig->setTempGroup( "Resource_" + identifier );
261#endif
257 QString type = mConfig->readEntry( "ResourceType" ); 262 QString type = mConfig->readEntry( "ResourceType" );
258 QString name = mConfig->readEntry( "ResourceName" ); 263 QString name = mConfig->readEntry( "ResourceName" );
259 Resource *resource = mFactory->resource( type, mConfig ); 264 Resource *resource = mFactory->resource( type, mConfig );
260 if ( !resource ) { 265 if ( !resource ) {
261 kdDebug(5650) << "Failed to create resource with id " << identifier << endl; 266 qDebug("Failed to create resource with id %s ",identifier.latin1() );
262 return 0; 267 return 0;
263 } 268 }
264 269
265 if ( resource->identifier().isEmpty() ) 270 if ( resource->identifier().isEmpty() )
266 resource->setIdentifier( identifier ); 271 resource->setIdentifier( identifier );
267 272
268 mConfig->setGroup( "General" ); 273 mConfig->setGroup( "General" );
269 274
270 QString standardKey = mConfig->readEntry( "Standard" ); 275 QString standardKey = mConfig->readEntry( "Standard" );
271 if ( standardKey == identifier ) { 276 if ( standardKey == identifier ) {
272 mStandard = resource; 277 mStandard = resource;
273 } 278 }
274 279
275 if ( checkActive ) { 280 if ( checkActive ) {
276 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 281 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
277 resource->setActive( activeKeys.contains( identifier ) ); 282 resource->setActive( activeKeys.contains( identifier ) );
278 } 283 }
279 mResources.append( resource ); 284 mResources.append( resource );
280 285
281 return resource; 286 return resource;
282} 287}
283 288
284void ManagerImpl::writeResourceConfig( Resource *resource, 289void ManagerImpl::writeResourceConfig( Resource *resource,
285 bool checkActive ) 290 bool checkActive )
286{ 291{
287 QString key = resource->identifier(); 292 QString key = resource->identifier();
288 293
289 kdDebug(5650) << "Saving resource " << key << endl; 294 kdDebug(5650) << "Saving resource " << key << endl;
290 295
291 if ( !mConfig ) createStandardConfig(); 296 if ( !mConfig ) createStandardConfig();
292 297
293 mConfig->setGroup( "Resource_" + key ); 298 mConfig->setGroup( "Resource_" + key );
294 resource->writeConfig( mConfig ); 299 resource->writeConfig( mConfig );
295 300
296 mConfig->setGroup( "General" ); 301 mConfig->setGroup( "General" );
297 QString standardKey = mConfig->readEntry( "Standard" ); 302 QString standardKey = mConfig->readEntry( "Standard" );
298 303
299 if ( resource == mStandard && standardKey != key ) 304 if ( resource == mStandard && standardKey != key )
300 mConfig->writeEntry( "Standard", resource->identifier() ); 305 mConfig->writeEntry( "Standard", resource->identifier() );
301 else if ( resource != mStandard && standardKey == key ) 306 else if ( resource != mStandard && standardKey == key )
302 mConfig->writeEntry( "Standard", "" ); 307 mConfig->writeEntry( "Standard", "" );
303 308
304 if ( checkActive ) { 309 if ( checkActive ) {
305 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 310 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
306 if ( resource->isActive() && !activeKeys.contains( key ) ) { 311 if ( resource->isActive() && !activeKeys.contains( key ) ) {
307 activeKeys.append( resource->identifier() ); 312 activeKeys.append( resource->identifier() );
308 mConfig->writeEntry( "ResourceKeys", activeKeys ); 313 mConfig->writeEntry( "ResourceKeys", activeKeys );
309 } else if ( !resource->isActive() && activeKeys.contains( key ) ) { 314 } else if ( !resource->isActive() && activeKeys.contains( key ) ) {