32 QDomElement elem = doc.createElement( typeIdentifier() );
33 elem.setAttribute( QStringLiteral(
"name" ),
mName );
34 elem.setAttribute( QStringLiteral(
"showLabel" ),
mShowLabel );
38 saveConfiguration( elem, doc );
66 const QString
name = element.attribute( QStringLiteral(
"name" ) );
68 if ( element.tagName() == QLatin1String(
"attributeEditorContainer" ) )
73 else if ( element.tagName() == QLatin1String(
"attributeEditorField" ) )
78 else if ( element.tagName() == QLatin1String(
"attributeEditorRelation" ) )
84 else if ( element.tagName() == QLatin1String(
"attributeEditorQmlElement" ) )
88 else if ( element.tagName() == QLatin1String(
"attributeEditorHtmlElement" ) )
92 else if ( element.tagName() == QLatin1String(
"attributeEditorTextElement" ) )
96 else if ( element.tagName() == QLatin1String(
"attributeEditorSpacerElement" ) )
100 else if ( element.tagName() == QLatin1String(
"attributeEditorAction" ) )
107 if ( element.hasAttribute( QStringLiteral(
"showLabel" ) ) )
108 newElement->
setShowLabel( element.attribute( QStringLiteral(
"showLabel" ) ).toInt() );
112 newElement->
setHorizontalStretch( element.attribute( QStringLiteral(
"horizontalStretch" ), QStringLiteral(
"0" ) ).toInt() );
113 newElement->
setVerticalStretch( element.attribute( QStringLiteral(
"verticalStretch" ), QStringLiteral(
"0" ) ).toInt() );
120 newElement->loadConfiguration( element, layerId, context, fields );
129 QDomElement element { node.firstChildElement( QStringLiteral(
"labelStyle" ) ) };
131 if ( ! element.isNull() )
135 if ( element.hasAttribute( QStringLiteral(
"labelColor" ) ) )
145 if ( element.hasAttribute( QStringLiteral(
"overrideLabelColor" ) ) )
147 overrideColor = element.attribute( QStringLiteral(
"overrideLabelColor" ) ) == QChar(
'1' );
150 if ( element.hasAttribute( QStringLiteral(
"overrideLabelFont" ) ) )
152 overrideFont = element.attribute( QStringLiteral(
"overrideLabelFont" ) ) == QChar(
'1' );
159 QDomElement elem { document.createElement( QStringLiteral(
"labelStyle" ) ) };
162 elem.setAttribute( QStringLiteral(
"overrideLabelColor" ), overrideColor ? QChar(
'1' ) : QChar(
'0' ) );
163 elem.setAttribute( QStringLiteral(
"overrideLabelFont" ), overrideFont ? QChar(
'1' ) : QChar(
'0' ) );
This element will load a layer action onto the form.
This is a container for attribute editors, used to group them visually in the attribute form if it is...
This is an abstract base class for any elements of a drag and drop form.
void setHorizontalStretch(int stretch)
Sets the horizontal stretch factor for the element.
QDomElement toDomElement(QDomDocument &doc) const
Gets the XML Dom element to save this element.
QgsAttributeEditorElement * parent() const
Gets the parent of this element.
LabelStyle labelStyle() const
Returns the label style.
void setLabelStyle(const LabelStyle &labelStyle)
Sets the labelStyle.
bool showLabel() const
Controls if this element should be labeled with a title (field, relation or groupname).
QString name() const
Returns the name of this element.
static QgsAttributeEditorElement * create(const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent=nullptr)
Constructs the editor element from the given element.
void setVerticalStretch(int stretch)
Sets the vertical stretch factor for the element.
void setShowLabel(bool showLabel)
Controls if this element should be labeled with a title (field, relation or groupname).
This element will load a field's widget onto the form.
An attribute editor widget that will represent arbitrary HTML code.
An attribute editor widget that will represent arbitrary QML code.
This element will load a relation editor onto the form.
An attribute editor widget that will represent a spacer.
An attribute editor widget that will represent arbitrary text code.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
Container of fields for a vector layer.
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
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.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
virtual QString translate(const QString &context, const QString &sourceText, const char *disambiguation=nullptr, int n=-1) const =0
The derived translate() translates with QTranslator and qm file the sourceText.
The class is used as a container of context for various read/write operations on other objects.
const QgsProjectTranslator * projectTranslator() const
Returns the project translator.
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.
void readXml(const QDomNode &node)
Reads configuration from node.
bool overrideColor
Override label color.
QDomElement writeXml(QDomDocument &document) const
Creates the XML configuration from document.
bool overrideFont
Override label font.
bool operator==(LabelStyle const &other) const
Returns true if the style is equal to other.