29 #include <QDomDocument>
30 #include <QDomElement>
31 #include <QFontMetricsF>
39 , mNumUnitsPerSegment( 0 )
40 , mFontColor( QColor( 0, 0, 0 ) )
42 , mSegmentMillimeters( 0.0 )
57 Q_UNUSED( itemStyle );
187 return composerMapRect.
width();
232 mPen = QPen( QColor( 0, 0, 0 ) );
233 mPen.setWidthF( 1.0 );
235 mBrush.setColor( QColor( 0, 0, 0 ) );
236 mBrush.setStyle( Qt::SolidPattern );
238 mFont.setPointSizeF( 12.0 );
252 int nUnitsPerSegment = widthMeter / 10.0;
255 if ( nUnitsPerSegment > 1000 )
312 posWidthList.clear();
318 posWidthList.push_back( qMakePair( mCurrentXCoord,
mSegmentMillimeters / mNumSegmentsLeft ) );
336 if ( styleName ==
"Single Box" )
340 else if ( styleName ==
"Double Box" )
344 else if ( styleName ==
"Line Ticks Middle" || styleName ==
"Line Ticks Down" || styleName ==
"Line Ticks Up" )
347 if ( styleName ==
"Line Ticks Middle" )
351 else if ( styleName ==
"Line Ticks Down" )
355 else if ( styleName ==
"Line Ticks Up" )
361 else if ( styleName ==
"Numeric" )
411 QDomElement composerScaleBarElem = doc.createElement(
"ComposerScaleBar" );
412 composerScaleBarElem.setAttribute(
"height", QString::number(
mHeight ) );
413 composerScaleBarElem.setAttribute(
"labelBarSpace", QString::number(
mLabelBarSpace ) );
414 composerScaleBarElem.setAttribute(
"boxContentSpace", QString::number(
mBoxContentSpace ) );
415 composerScaleBarElem.setAttribute(
"numSegments",
mNumSegments );
417 composerScaleBarElem.setAttribute(
"numUnitsPerSegment", QString::number(
mNumUnitsPerSegment ) );
418 composerScaleBarElem.setAttribute(
"segmentMillimeters", QString::number(
mSegmentMillimeters ) );
420 composerScaleBarElem.setAttribute(
"font",
mFont.toString() );
421 composerScaleBarElem.setAttribute(
"outlineWidth", QString::number(
mPen.widthF() ) );
422 composerScaleBarElem.setAttribute(
"unitLabel",
mUnitLabeling );
423 composerScaleBarElem.setAttribute(
"units",
mUnits );
428 composerScaleBarElem.setAttribute(
"style",
mStyle->
name() );
438 composerScaleBarElem.setAttribute(
"brushColor",
mBrush.color().name() );
439 composerScaleBarElem.setAttribute(
"penColor",
mPen.color().name() );
440 composerScaleBarElem.setAttribute(
"fontColor",
mFontColor.name() );
443 composerScaleBarElem.setAttribute(
"alignment", QString::number((
int )
mAlignment ) );
445 elem.appendChild( composerScaleBarElem );
446 return _writeXML( composerScaleBarElem, doc );
451 if ( itemElem.isNull() )
456 mHeight = itemElem.attribute(
"height",
"5.0" ).toDouble();
457 mLabelBarSpace = itemElem.attribute(
"labelBarSpace",
"3.0" ).toDouble();
458 mBoxContentSpace = itemElem.attribute(
"boxContentSpace",
"1.0" ).toDouble();
459 mNumSegments = itemElem.attribute(
"numSegments",
"2" ).toInt();
464 mPen.setWidthF( itemElem.attribute(
"outlineWidth",
"1.0" ).toDouble() );
466 QString fontString = itemElem.attribute(
"font",
"" );
467 if ( !fontString.isEmpty() )
469 mFont.fromString( fontString );
474 mBrush.setColor( QColor( itemElem.attribute(
"brushColor",
"#000000" ) ) );
475 mPen.setColor( QColor( itemElem.attribute(
"penColor",
"#000000" ) ) );
476 mFontColor.setNamedColor( itemElem.attribute(
"fontColor",
"#000000" ) );
481 QString styleString = itemElem.attribute(
"style",
"" );
482 setStyle(
tr( styleString.toLocal8Bit().data() ) );
488 int mapId = itemElem.attribute(
"mapId",
"-1" ).toInt();
503 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
504 if ( composerItemList.size() > 0 )
506 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
523 move( -( widthAfter - width ) / 2.0, 0 );
527 move( -( widthAfter - width ), 0 );