33 mExpressions.removeAt( index );
38 QDomElement expressionFieldsElem = document.createElement(
"expressionfields" );
39 layerNode.appendChild( expressionFieldsElem );
43 QDomElement fldElem = document.createElement(
"field" );
45 fldElem.setAttribute(
"expression", fld.
expression );
46 fldElem.setAttribute(
"name", fld.
field.
name() );
49 fldElem.setAttribute(
"length", fld.
field.
length() );
50 fldElem.setAttribute(
"type", fld.
field.
type() );
53 expressionFieldsElem.appendChild( fldElem );
61 const QDomElement expressionFieldsElem = layerNode.firstChildElement(
"expressionfields" );
63 if ( !expressionFieldsElem.isNull() )
65 QDomNodeList fields = expressionFieldsElem.elementsByTagName(
"field" );
67 for (
unsigned int i = 0; i < fields.length(); ++i )
69 QDomElement field = fields.at( i ).toElement();
70 QString exp = field.attribute(
"expression" );
71 QString name = field.attribute(
"name" );
72 QString comment = field.attribute(
"comment" );
73 int precision = field.attribute(
"precision" ).toInt();
74 int length = field.attribute(
"length" ).toInt();
75 QVariant::Type type = ( QVariant::Type )( field.attribute(
"type" ).toInt() );
76 QString typeName = field.attribute(
"typeName" );
const QString & name() const
Gets the name of the field.
struct QgsExpressionFieldBuffer::ExpressionField ExpressionField
void addExpression(const QString &exp, const QgsField &fld)
Add an expression to the buffer.
int precision() const
Gets the precision of the field.
Container of fields for a vector layer.
bool appendExpressionField(const QgsField &field, int originIndex)
Append an expression field. The field must have unique name, otherwise it is rejected (returns false)...
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves expressions to xml under the layer node.
Encapsulate a field in an attribute table or data source.
void updateFields(QgsFields &flds)
Adds fields with the expressions buffered in this object to a QgsFields object.
const QString & typeName() const
Gets the field type.
void readXml(const QDomNode &layer_node)
Reads expressions from project file.
void removeExpression(int index)
Remove an expression from the buffer.
int length() const
Gets the length of the field.
const QString & comment() const
Returns the field comment.
QgsExpressionFieldBuffer()
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.