44 QDomElement expressionFieldsElem = document.createElement( QStringLiteral(
"expressionfields" ) );
45 layerNode.appendChild( expressionFieldsElem );
47 const auto constMExpressions = mExpressions;
50 QDomElement fldElem = document.createElement( QStringLiteral(
"field" ) );
52 fldElem.setAttribute( QStringLiteral(
"expression" ), fld.cachedExpression.expression() );
53 fldElem.setAttribute( QStringLiteral(
"name" ), fld.field.name() );
54 fldElem.setAttribute( QStringLiteral(
"precision" ), fld.field.precision() );
55 fldElem.setAttribute( QStringLiteral(
"comment" ), fld.field.comment() );
56 fldElem.setAttribute( QStringLiteral(
"length" ), fld.field.length() );
57 fldElem.setAttribute( QStringLiteral(
"type" ), fld.field.type() );
58 fldElem.setAttribute( QStringLiteral(
"subType" ), fld.field.subType() );
59 fldElem.setAttribute( QStringLiteral(
"typeName" ), fld.field.typeName() );
61 expressionFieldsElem.appendChild( fldElem );
69 const QDomElement expressionFieldsElem = layerNode.firstChildElement( QStringLiteral(
"expressionfields" ) );
71 if ( !expressionFieldsElem.isNull() )
73 const QDomNodeList fields = expressionFieldsElem.elementsByTagName( QStringLiteral(
"field" ) );
75 for (
int i = 0; i < fields.size(); ++i )
77 const QDomElement field = fields.at( i ).toElement();
78 const QString exp = field.attribute( QStringLiteral(
"expression" ) );
79 const QString name = field.attribute( QStringLiteral(
"name" ) );
80 const QString comment = field.attribute( QStringLiteral(
"comment" ) );
81 const int precision = field.attribute( QStringLiteral(
"precision" ) ).toInt();
82 const int length = field.attribute( QStringLiteral(
"length" ) ).toInt();
83 const QMetaType::Type type =
static_cast< QMetaType::Type
>( field.attribute( QStringLiteral(
"type" ) ).toInt() );
84 const QMetaType::Type subType =
static_cast< QMetaType::Type
>( field.attribute( QStringLiteral(
"subType" ), QStringLiteral(
"0" ) ).toInt() );
85 const QString typeName = field.attribute( QStringLiteral(
"typeName" ) );
87 mExpressions.append(
ExpressionField( exp,
QgsField( name, type, typeName, length, precision, comment, subType ) ) );