25 #include <QDomElement> 26 #include <QDomDocument> 33 QString defaultFontString = settings.
value( QStringLiteral(
"LayoutDesigner/defaultFont" ), QVariant(),
QgsSettings::Gui ).toString();
34 if ( !defaultFontString.isEmpty() )
36 mFont.setFamily( defaultFontString );
50 if ( elem.isNull() )
return;
52 QDomElement styleElem = doc.createElement( QStringLiteral(
"style" ) );
54 styleElem.setAttribute( QStringLiteral(
"name" ), name );
56 if ( !
qgsDoubleNear( mMarginMap[
Top], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginTop" ), QString::number( mMarginMap[Top] ) );
57 if ( !
qgsDoubleNear( mMarginMap[
Bottom], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginBottom" ), QString::number( mMarginMap[Bottom] ) );
58 if ( !
qgsDoubleNear( mMarginMap[
Left], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginLeft" ), QString::number( mMarginMap[Left] ) );
59 if ( !
qgsDoubleNear( mMarginMap[
Right], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginRight" ), QString::number( mMarginMap[Right] ) );
63 elem.appendChild( styleElem );
69 if ( elem.isNull() )
return;
73 mFont.fromString( elem.attribute( QStringLiteral(
"font" ) ) );
76 mMarginMap[
Top] = elem.attribute( QStringLiteral(
"marginTop" ), QStringLiteral(
"0" ) ).toDouble();
77 mMarginMap[
Bottom] = elem.attribute( QStringLiteral(
"marginBottom" ), QStringLiteral(
"0" ) ).toDouble();
78 mMarginMap[
Left] = elem.attribute( QStringLiteral(
"marginLeft" ), QStringLiteral(
"0" ) ).toDouble();
79 mMarginMap[
Right] = elem.attribute( QStringLiteral(
"marginRight" ), QStringLiteral(
"0" ) ).toDouble();
87 return QLatin1String(
"" );
89 return QStringLiteral(
"hidden" );
91 return QStringLiteral(
"title" );
93 return QStringLiteral(
"group" );
95 return QStringLiteral(
"subgroup" );
97 return QStringLiteral(
"symbol" );
99 return QStringLiteral(
"symbolLabel" );
101 return QLatin1String(
"" );
106 if ( styleName == QLatin1String(
"hidden" ) )
return Hidden;
107 else if ( styleName == QLatin1String(
"title" ) )
return Title;
108 else if ( styleName == QLatin1String(
"group" ) )
return Group;
109 else if ( styleName == QLatin1String(
"subgroup" ) )
return Subgroup;
110 else if ( styleName == QLatin1String(
"symbol" ) )
return Symbol;
111 else if ( styleName == QLatin1String(
"symbolLabel" ) )
return SymbolLabel;
120 return QObject::tr(
"Undefined" );
122 return QObject::tr(
"Hidden" );
124 return QObject::tr(
"Title" );
126 return QObject::tr(
"Group" );
128 return QObject::tr(
"Subgroup" );
130 return QObject::tr(
"Symbol" );
132 return QObject::tr(
"Symbol label" );
134 return QLatin1String(
"" );
This class is a composition of two QSettings instances:
static Style styleFromName(const QString &styleName)
Get style from name, used in project file.
Should not happen, only if corrupted project file.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
void setMargin(Side side, double margin)
static QString styleLabel(Style s)
Get style label, translated, used in UI.
static QString styleName(Style s)
Get name for style, used in project file.
void readXml(const QDomElement &elem, const QDomDocument &doc)
Special style, item is hidden including margins around.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
void writeXml(const QString &name, QDomElement &elem, QDomDocument &doc) const
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.