From 00bdf2379b6a216097c57f5566b279987fc2e6e5 Mon Sep 17 00:00:00 2001 From: sbh Date: Thu, 31 Jan 2013 11:07:54 +0000 Subject: [PATCH] refs #2566 import/export settings functionality extending --- src/Qtx/QtxResourceMgr.cxx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 2691df6de..e685a2cdc 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -1071,11 +1071,14 @@ bool QtxResourceMgr::Format::load( Resources* res ) QMap sections; bool status = load( res->myFileName, sections ); - if ( status ) - res->mySections = sections; - else + if ( status ) { + QMap::iterator it = sections.begin(); + for ( ; it != sections.end(); it++ ) { + res->mySections.insert( it.key(), it.value() ); + } + } else { qDebug() << "QtxResourceMgr: Can't load resource file:" << res->myFileName; - + } return status; } @@ -2257,8 +2260,16 @@ bool QtxResourceMgr::saveAs( const QString& theFileName ) if ( myResources.isEmpty() || !myHasUserValues ) return true; - Resources* allResources = myResources[0]; - allResources->setFile( theFileName ); + //Combine all resource in one with given filename + Resources* allResources = new Resources( this, theFileName ); + QStringList sl = sections(); + foreach ( QString sect, sl ) { + QStringList pl = parameters( sect ); + foreach ( QString param, pl ){ + allResources->setValue( sect, param, stringValue( sect, param ) ); + } + } + //Filter sections that shouldn't be exported if( hasValue("import-export-settings", "exportable-sections") ){ QSet allSections = allResources->sections().toSet(); QString expSections; @@ -2269,7 +2280,9 @@ bool QtxResourceMgr::saveAs( const QString& theFileName ) allResources->removeSection( eachSection ); } } - return fmt->save( allResources ); + bool result = fmt->save( allResources ); + delete allResources; + return result; } /*! -- 2.39.2