30 mExpressions.removeAt( index );
35 mExpressions[index].field.setName( name );
45 QDomElement expressionFieldsElem = document.createElement( QStringLiteral(
"expressionfields" ) );
46 layerNode.appendChild( expressionFieldsElem );
48 const auto constMExpressions = mExpressions;
51 QDomElement fldElem = document.createElement( QStringLiteral(
"field" ) );
53 fldElem.setAttribute( QStringLiteral(
"expression" ), fld.cachedExpression.expression() );
54 fldElem.setAttribute( QStringLiteral(
"name" ), fld.field.name() );
55 fldElem.setAttribute( QStringLiteral(
"precision" ), fld.field.precision() );
56 fldElem.setAttribute( QStringLiteral(
"comment" ), fld.field.comment() );
57 fldElem.setAttribute( QStringLiteral(
"length" ), fld.field.length() );
58 fldElem.setAttribute( QStringLiteral(
"type" ), fld.field.type() );
59 fldElem.setAttribute( QStringLiteral(
"subType" ), fld.field.subType() );
60 fldElem.setAttribute( QStringLiteral(
"typeName" ), fld.field.typeName() );
62 expressionFieldsElem.appendChild( fldElem );
70 const QDomElement expressionFieldsElem = layerNode.firstChildElement( QStringLiteral(
"expressionfields" ) );
72 if ( !expressionFieldsElem.isNull() )
74 const QDomNodeList fields = expressionFieldsElem.elementsByTagName( QStringLiteral(
"field" ) );
76 for (
int i = 0; i < fields.size(); ++i )
78 const QDomElement
field = fields.at( i ).toElement();
79 const QString exp =
field.attribute( QStringLiteral(
"expression" ) );
80 const QString name =
field.attribute( QStringLiteral(
"name" ) );
81 const QString comment =
field.attribute( QStringLiteral(
"comment" ) );
82 const int precision =
field.attribute( QStringLiteral(
"precision" ) ).toInt();
83 const int length =
field.attribute( QStringLiteral(
"length" ) ).toInt();
84 const QVariant::Type type =
static_cast< QVariant::Type
>(
field.attribute( QStringLiteral(
"type" ) ).toInt() );
85 const QVariant::Type subType =
static_cast< QVariant::Type
>(
field.attribute( QStringLiteral(
"subType" ), QStringLiteral(
"0" ) ).toInt() );
86 const QString
typeName =
field.attribute( QStringLiteral(
"typeName" ) );
96 const auto constMExpressions = mExpressions;
void removeExpression(int index)
Remove an expression from the buffer.
void updateFields(QgsFields &flds)
Adds fields with the expressions buffered in this object to a QgsFields object.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves expressions to xml under the layer node.
void readXml(const QDomNode &layer_node)
Reads expressions from project file.
void addExpression(const QString &exp, const QgsField &fld)
Add an expression to the buffer.
void updateExpression(int index, const QString &exp)
Changes the expression at a given index.
void renameExpression(int index, const QString &name)
Renames an expression field at a given index.
Class for parsing and evaluation of expressions (formerly called "search strings").
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool appendExpressionField(const QgsField &field, int originIndex)
Appends an expression field. The field must have unique name, otherwise it is rejected (returns false...