26 #include <QDomElement> 27 #include <QDomDocument> 34 QString defaultFontString = settings.
value( QStringLiteral(
"LayoutDesigner/defaultFont" ), QVariant(),
QgsSettings::Gui ).toString();
35 if ( !defaultFontString.isEmpty() )
37 mFont.setFamily( defaultFontString );
51 if ( elem.isNull() )
return;
53 QDomElement styleElem = doc.createElement( QStringLiteral(
"style" ) );
55 styleElem.setAttribute( QStringLiteral(
"name" ), name );
57 if ( !
qgsDoubleNear( mMarginMap[
Top], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginTop" ), QString::number( mMarginMap[Top] ) );
58 if ( !
qgsDoubleNear( mMarginMap[
Bottom], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginBottom" ), QString::number( mMarginMap[Bottom] ) );
59 if ( !
qgsDoubleNear( mMarginMap[
Left], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginLeft" ), QString::number( mMarginMap[Left] ) );
60 if ( !
qgsDoubleNear( mMarginMap[
Right], 0.0 ) ) styleElem.setAttribute( QStringLiteral(
"marginRight" ), QString::number( mMarginMap[Right] ) );
64 elem.appendChild( styleElem );
70 if ( elem.isNull() )
return;
74 mFont.fromString( elem.attribute( QStringLiteral(
"font" ) ) );
77 mMarginMap[
Top] = elem.attribute( QStringLiteral(
"marginTop" ), QStringLiteral(
"0" ) ).toDouble();
78 mMarginMap[
Bottom] = elem.attribute( QStringLiteral(
"marginBottom" ), QStringLiteral(
"0" ) ).toDouble();
79 mMarginMap[
Left] = elem.attribute( QStringLiteral(
"marginLeft" ), QStringLiteral(
"0" ) ).toDouble();
80 mMarginMap[
Right] = elem.attribute( QStringLiteral(
"marginRight" ), QStringLiteral(
"0" ) ).toDouble();
90 return QStringLiteral(
"hidden" );
92 return QStringLiteral(
"title" );
94 return QStringLiteral(
"group" );
96 return QStringLiteral(
"subgroup" );
98 return QStringLiteral(
"symbol" );
100 return QStringLiteral(
"symbolLabel" );
107 if ( styleName == QLatin1String(
"hidden" ) )
return Hidden;
108 else if ( styleName == QLatin1String(
"title" ) )
return Title;
109 else if ( styleName == QLatin1String(
"group" ) )
return Group;
110 else if ( styleName == QLatin1String(
"subgroup" ) )
return Subgroup;
111 else if ( styleName == QLatin1String(
"symbol" ) )
return Symbol;
112 else if ( styleName == QLatin1String(
"symbolLabel" ) )
return SymbolLabel;
121 return QObject::tr(
"Undefined" );
123 return QObject::tr(
"Hidden" );
125 return QObject::tr(
"Title" );
127 return QObject::tr(
"Group" );
129 return QObject::tr(
"Subgroup" );
131 return QObject::tr(
"Symbol" );
133 return QObject::tr(
"Symbol label" );
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
static Style styleFromName(const QString &styleName)
Gets style from name, used in project file.
Should not happen, only if corrupted project file.
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)
Gets style label, translated, used in UI.
static QString styleName(Style s)
Gets name for style, used in project file.
void readXml(const QDomElement &elem, const QDomDocument &doc)
Special style, item is hidden including margins around.
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.