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" ) );
bool appendExpressionField(const QgsField &field, int originIndex)
Appends an expression field. The field must have unique name, otherwise it is rejected (returns false...