@@ -36,11 +36,11 @@ QgsComposerScaleBar::QgsComposerScaleBar( QgsComposition* composition )
36
36
: QgsComposerItem( composition )
37
37
, mComposerMap( 0 )
38
38
, mNumUnitsPerSegment( 0 )
39
+ , mFontColor( QColor( 0 , 0 , 0 ) )
39
40
, mStyle( 0 )
40
41
, mSegmentMillimeters( 0.0 )
41
42
, mAlignment( Left )
42
43
, mUnits( MapUnits )
43
- , mFontColor( QColor( 0 , 0 , 0 ) )
44
44
{
45
45
applyDefaultSettings ();
46
46
applyDefaultSize ();
@@ -423,26 +423,10 @@ bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) cons
423
423
composerScaleBarElem.setAttribute ( " mapId" , mComposerMap ->id () );
424
424
}
425
425
426
- // fill color
427
- QColor brushColor = mBrush .color ();
428
- QDomElement brushColorElem = doc.createElement ( " brushColor" );
429
- brushColorElem.setAttribute ( " red" , brushColor.red () );
430
- brushColorElem.setAttribute ( " green" , brushColor.green () );
431
- brushColorElem.setAttribute ( " blue" , brushColor.blue () );
432
- composerScaleBarElem.appendChild ( brushColorElem );
433
- // stroke color
434
- QColor penColor = mPen .color ();
435
- QDomElement penColorElem = doc.createElement ( " penColor" );
436
- penColorElem.setAttribute ( " red" , penColor.red () );
437
- penColorElem.setAttribute ( " green" , penColor.green () );
438
- penColorElem.setAttribute ( " blue" , penColor.blue () );
439
- composerScaleBarElem.appendChild ( penColorElem );
440
- // font color
441
- QDomElement fontColorElem = doc.createElement ( " fontColor" );
442
- fontColorElem.setAttribute ( " red" , mFontColor .red () );
443
- fontColorElem.setAttribute ( " green" , mFontColor .green () );
444
- fontColorElem.setAttribute ( " blue" , mFontColor .blue () );
445
- composerScaleBarElem.appendChild ( fontColorElem );
426
+ // colors
427
+ composerScaleBarElem.setAttribute ( " brushColor" , mBrush .color ().name () );
428
+ composerScaleBarElem.setAttribute ( " penColor" , mPen .color ().name () );
429
+ composerScaleBarElem.setAttribute ( " fontColor" , mFontColor .name () );
446
430
447
431
// alignment
448
432
composerScaleBarElem.setAttribute ( " alignment" , QString::number (( int ) mAlignment ) );
@@ -476,37 +460,9 @@ bool QgsComposerScaleBar::readXML( const QDomElement& itemElem, const QDomDocume
476
460
477
461
// colors
478
462
// fill color
479
- QDomNodeList fillColorList = itemElem.elementsByTagName ( " brushColor" );
480
- if ( fillColorList.size () > 0 )
481
- {
482
- QDomElement fillColorElem = fillColorList.at ( 0 ).toElement ();
483
- int red = fillColorElem.attribute ( " red" , " 0" ).toInt ();
484
- int green = fillColorElem.attribute ( " green" , " 0" ).toInt ();
485
- int blue = fillColorElem.attribute ( " blue" , " 0" ).toInt ();
486
- mBrush .setColor (QColor ( red, green, blue ));
487
- }
488
- // pen color
489
- QDomNodeList penColorList = itemElem.elementsByTagName ( " penColor" );
490
- if ( penColorList.size () > 0 )
491
- {
492
- QDomElement penColorElem = penColorList.at ( 0 ).toElement ();
493
- int red = penColorElem.attribute ( " red" , " 0" ).toInt ();
494
- int green = penColorElem.attribute ( " green" , " 0" ).toInt ();
495
- int blue = penColorElem.attribute ( " blue" , " 0" ).toInt ();
496
- mPen .setColor (QColor ( red, green, blue ));
497
- }
498
- // font color
499
- QDomNodeList fontColorList = itemElem.elementsByTagName ( " fontColor" );
500
- if ( fontColorList.size () > 0 )
501
- {
502
- QDomElement fontColorElem = fontColorList.at ( 0 ).toElement ();
503
- int red = fontColorElem.attribute ( " red" , " 0" ).toInt ();
504
- int green = fontColorElem.attribute ( " green" , " 0" ).toInt ();
505
- int blue = fontColorElem.attribute ( " blue" , " 0" ).toInt ();
506
- mFontColor = QColor ( red, green, blue );
507
- }
508
-
509
-
463
+ mBrush .setColor ( QColor ( itemElem.attribute ( " brushColor" , " #000000" ) ) );
464
+ mPen .setColor ( QColor ( itemElem.attribute ( " penColor" , " #000000" ) ) );
465
+ mFontColor .setNamedColor ( itemElem.attribute ( " fontColor" , " #000000" ) );
510
466
511
467
// style
512
468
delete mStyle ;
0 commit comments