Skip to content
Permalink
Browse files
QgsScalebar now saves colors in XML
  • Loading branch information
olivierdalang authored and mhugent committed Jan 22, 2013
1 parent d033124 commit c5b8b6908f9bbad5d0a5e2a45d49bacca1531198
Showing with 64 additions and 5 deletions.
  1. +64 −5 src/core/composer/qgscomposerscalebar.cpp
@@ -425,11 +425,24 @@ bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) cons

//fill color
QColor brushColor = mBrush.color();
QDomElement colorElem = doc.createElement( "BrushColor" );
colorElem.setAttribute( "red", brushColor.red() );
colorElem.setAttribute( "green", brushColor.green() );
colorElem.setAttribute( "blue", brushColor.blue() );
composerScaleBarElem.appendChild( colorElem );
QDomElement brushColorElem = doc.createElement( "brushColor" );
brushColorElem.setAttribute( "red", brushColor.red() );
brushColorElem.setAttribute( "green", brushColor.green() );
brushColorElem.setAttribute( "blue", brushColor.blue() );
composerScaleBarElem.appendChild( brushColorElem );
//stroke color
QColor penColor = mPen.color();
QDomElement penColorElem = doc.createElement( "penColor" );
penColorElem.setAttribute( "red", penColor.red() );
penColorElem.setAttribute( "green", penColor.green() );
penColorElem.setAttribute( "blue", penColor.blue() );
composerScaleBarElem.appendChild( penColorElem );
//font color
QDomElement fontColorElem = doc.createElement( "fontColor" );
fontColorElem.setAttribute( "red", mFontColor.red() );
fontColorElem.setAttribute( "green", mFontColor.green() );
fontColorElem.setAttribute( "blue", mFontColor.blue() );
composerScaleBarElem.appendChild( fontColorElem );

//alignment
composerScaleBarElem.setAttribute( "alignment", QString::number(( int ) mAlignment ) );
@@ -461,6 +474,52 @@ bool QgsComposerScaleBar::readXML( const QDomElement& itemElem, const QDomDocume
mFont.fromString( fontString );
}

//colors
//fill color
QDomNodeList fillColorList = itemElem.elementsByTagName( "brushColor" );
if ( fillColorList.size() > 0 )
{
QDomElement fillColorElem = fillColorList.at( 0 ).toElement();
int red = fillColorElem.attribute( "red", "0" ).toInt();
int green = fillColorElem.attribute( "green", "0" ).toInt();
int blue = fillColorElem.attribute( "blue", "0" ).toInt();
mBrush.setColor(QColor( red, green, blue ));
}
else
{
mBrush.setColor(QColor( 0, 0, 0 ));
}
//pen color
QDomNodeList penColorList = itemElem.elementsByTagName( "penColor" );
if ( penColorList.size() > 0 )
{
QDomElement penColorElem = penColorList.at( 0 ).toElement();
int red = penColorElem.attribute( "red", "0" ).toInt();
int green = penColorElem.attribute( "green", "0" ).toInt();
int blue = penColorElem.attribute( "blue", "0" ).toInt();
mPen.setColor(QColor( red, green, blue ));
}
else
{
mPen.setColor(QColor( 0, 0, 0 ));
}
//font color
QDomNodeList fontColorList = itemElem.elementsByTagName( "fontColor" );
if ( fontColorList.size() > 0 )
{
QDomElement fontColorElem = fontColorList.at( 0 ).toElement();
int red = fontColorElem.attribute( "red", "0" ).toInt();
int green = fontColorElem.attribute( "green", "0" ).toInt();
int blue = fontColorElem.attribute( "blue", "0" ).toInt();
mFontColor = QColor( red, green, blue );
}
else
{
mFontColor = QColor( 0, 0, 0 );
}



//style
delete mStyle;
mStyle = 0;

0 comments on commit c5b8b69

Please sign in to comment.