@@ -31,8 +31,8 @@ QgsComposerLegendStyle::~QgsComposerLegendStyle()
31
31
{
32
32
}
33
33
34
- void QgsComposerLegendStyle::setMargin ( double margin )
35
- {
34
+ void QgsComposerLegendStyle::setMargin ( double margin )
35
+ {
36
36
mMarginMap [Top] = margin;
37
37
mMarginMap [Bottom] = margin;
38
38
mMarginMap [Left] = margin;
@@ -47,32 +47,32 @@ void QgsComposerLegendStyle::writeXML( QString name, QDomElement& elem, QDomDocu
47
47
48
48
styleElem.setAttribute ( " name" , name );
49
49
50
- styleElem.setAttribute ( " marginTop" , QString::number ( mMarginMap [Top] ) );
51
- styleElem.setAttribute ( " marginBottom" , QString::number ( mMarginMap [Bottom] ) );
52
- styleElem.setAttribute ( " marginLeft" , QString::number ( mMarginMap [Left] ) );
53
- styleElem.setAttribute ( " marginRight" , QString::number ( mMarginMap [Right] ) );
50
+ if ( mMarginMap [Top] != 0 ) styleElem.setAttribute ( " marginTop" , QString::number ( mMarginMap [Top] ) );
51
+ if ( mMarginMap [Bottom] != 0 ) styleElem.setAttribute ( " marginBottom" , QString::number ( mMarginMap [Bottom] ) );
52
+ if ( mMarginMap [Left] != 0 ) styleElem.setAttribute ( " marginLeft" , QString::number ( mMarginMap [Left] ) );
53
+ if ( mMarginMap [Right] != 0 ) styleElem.setAttribute ( " marginRight" , QString::number ( mMarginMap [Right] ) );
54
54
55
55
styleElem.setAttribute ( " font" , mFont .toString () );
56
56
57
57
elem.appendChild ( styleElem );
58
58
}
59
59
60
- void QgsComposerLegendStyle::readXML ( const QDomElement& elem, const QDomDocument& doc )
60
+ void QgsComposerLegendStyle::readXML ( const QDomElement& elem, const QDomDocument& doc )
61
61
{
62
62
Q_UNUSED ( doc );
63
63
if ( elem.isNull () ) return ;
64
64
65
65
mFont .fromString ( elem.attribute ( " font" ) );
66
66
67
- mMarginMap [Top] = elem.attribute ( " marginTop" ).toDouble ();
68
- mMarginMap [Bottom] = elem.attribute ( " marginBottom" ).toDouble ();
69
- mMarginMap [Left] = elem.attribute ( " marginLeft" ).toDouble ();
70
- mMarginMap [Right] = elem.attribute ( " marginRight" ).toDouble ();
67
+ mMarginMap [Top] = elem.attribute ( " marginTop" , " 0 " ).toDouble ();
68
+ mMarginMap [Bottom] = elem.attribute ( " marginBottom" , " 0 " ).toDouble ();
69
+ mMarginMap [Left] = elem.attribute ( " marginLeft" , " 0 " ).toDouble ();
70
+ mMarginMap [Right] = elem.attribute ( " marginRight" , " 0 " ).toDouble ();
71
71
}
72
72
73
- QString QgsComposerLegendStyle::styleName ( Style s )
73
+ QString QgsComposerLegendStyle::styleName ( Style s )
74
74
{
75
- switch ( s )
75
+ switch ( s )
76
76
{
77
77
case Undefined:
78
78
return " " ;
@@ -92,7 +92,7 @@ QString QgsComposerLegendStyle::styleName ( Style s )
92
92
return " " ;
93
93
}
94
94
95
- QgsComposerLegendStyle::Style QgsComposerLegendStyle::styleFromName ( QString styleName )
95
+ QgsComposerLegendStyle::Style QgsComposerLegendStyle::styleFromName ( QString styleName )
96
96
{
97
97
if ( styleName == " hidden" ) return Hidden;
98
98
else if ( styleName == " title" ) return Title;
@@ -103,24 +103,24 @@ QgsComposerLegendStyle::Style QgsComposerLegendStyle::styleFromName ( QString st
103
103
return Undefined;
104
104
}
105
105
106
- QString QgsComposerLegendStyle::styleLabel ( Style s )
106
+ QString QgsComposerLegendStyle::styleLabel ( Style s )
107
107
{
108
- switch ( s )
108
+ switch ( s )
109
109
{
110
110
case Undefined:
111
- return QObject::tr (" Undefined" );
111
+ return QObject::tr ( " Undefined" );
112
112
case Hidden:
113
- return QObject::tr (" Hidden" );
113
+ return QObject::tr ( " Hidden" );
114
114
case Title:
115
- return QObject::tr (" Title" );
115
+ return QObject::tr ( " Title" );
116
116
case Group:
117
- return QObject::tr (" Group" );
117
+ return QObject::tr ( " Group" );
118
118
case Subgroup:
119
- return QObject::tr (" Subgroup" );
119
+ return QObject::tr ( " Subgroup" );
120
120
case Symbol:
121
- return QObject::tr (" Symbol" );
121
+ return QObject::tr ( " Symbol" );
122
122
case SymbolLabel:
123
- return QObject::tr (" Symbol label" );
123
+ return QObject::tr ( " Symbol label" );
124
124
}
125
125
return " " ;
126
126
}
0 commit comments