CHANGED: #1471 Serialize links that belong to the root group too. Also deactivate the active group when serializing.

--HG--
branch : gsoc2012-gui-editor
This commit is contained in:
dfighter1985 2012-08-20 03:34:09 +02:00
parent 0da667bffb
commit efc9890e08
3 changed files with 19 additions and 0 deletions

View file

@ -233,6 +233,7 @@ namespace GUIEditor
WidgetSerializer widgetSerializer; WidgetSerializer widgetSerializer;
widgetSerializer.setFile( guiFile ); widgetSerializer.setFile( guiFile );
widgetSerializer.setActiveGroup( projectFiles.activeGroup );
if( !widgetSerializer.serialize( projectFiles.masterGroup ) ) if( !widgetSerializer.serialize( projectFiles.masterGroup ) )
{ {
QMessageBox::critical( this, QMessageBox::critical( this,

View file

@ -32,6 +32,11 @@ namespace GUIEditor
if( mg == NULL ) if( mg == NULL )
return false; return false;
CInterfaceElement *ag =
CWidgetManager::getInstance()->getElementFromId( activeGroup );
if( ag == NULL )
return false;
out.open( fileName.c_str() ); out.open( fileName.c_str() );
if( !out.is_open() ) if( !out.is_open() )
return false; return false;
@ -88,8 +93,19 @@ namespace GUIEditor
return false; return false;
} }
ag->setActive( false );
if( mg->serializeSubGroups( root ) == NULL ) if( mg->serializeSubGroups( root ) == NULL )
{
ag->setActive( true );
xmlFreeNode( root );
out.close();
return false;
}
ag->setActive( true );
if( !mg->serializeLinks( root ) )
{ {
xmlFreeNode( root ); xmlFreeNode( root );
out.close(); out.close();

View file

@ -37,12 +37,14 @@ namespace GUIEditor
~WidgetSerializer(){} ~WidgetSerializer(){}
void setFile( const std::string &name ){ fileName = name; } void setFile( const std::string &name ){ fileName = name; }
void setActiveGroup( const std::string &name ){ activeGroup = name; }
bool serialize( const std::string &masterGroup ); bool serialize( const std::string &masterGroup );
private: private:
bool serializeTree( _xmlNode *node ); bool serializeTree( _xmlNode *node );
std::string fileName; std::string fileName;
std::string activeGroup;
std::ofstream out; std::ofstream out;
long level; long level;
}; };