Include variables in glabels project file.

This commit is contained in:
Jim Evins
2019-03-17 22:38:45 -04:00
parent 879092deaa
commit 3a425f932a
8 changed files with 150 additions and 13 deletions
+35
View File
@@ -29,6 +29,7 @@
#include "ModelImageObject.h"
#include "ModelTextObject.h"
#include "DataCache.h"
#include "Variables.h"
#include "XmlTemplateCreator.h"
#include "XmlUtil.h"
@@ -116,6 +117,11 @@ namespace glabels
createMergeNode( root, label );
}
if ( label->variables()->size() != 0 )
{
createVariablesNode( root, label );
}
createDataNode( root, label->objectList() );
}
@@ -466,6 +472,35 @@ namespace glabels
}
void
XmlLabelCreator::createVariablesNode( QDomElement &parent, const Model* label )
{
QDomDocument doc = parent.ownerDocument();
QDomElement node = doc.createElement( "Variables" );
parent.appendChild( node );
for ( const auto& v : *label->variables() )
{
createVariableNode( node, v );
}
}
void
XmlLabelCreator::createVariableNode( QDomElement &parent, const Variable& v )
{
QDomDocument doc = parent.ownerDocument();
QDomElement node = doc.createElement( "Variable" );
parent.appendChild( node );
XmlUtil::setStringAttr( node, "type", Variable::typeToIdString( v.type() ) );
XmlUtil::setStringAttr( node, "name", v.name() );
XmlUtil::setStringAttr( node, "value", v.value() );
XmlUtil::setStringAttr( node, "increment", Variable::incrementToIdString( v.increment() ) );
XmlUtil::setStringAttr( node, "stepSize", v.stepSize() );
}
void
XmlLabelCreator::createDataNode( QDomElement &parent, const QList<ModelObject*>& objects )
{