22 #include <QDomElement>
40 mStoredExpressions.removeAt( i );
56 newStoredExpression.
name = name;
58 newStoredExpression.
tag = tag;
59 mStoredExpressions.replace( i, newStoredExpression );
112 mStoredExpressions.clear();
117 QDomElement aStoredExpressions = layerNode.ownerDocument().createElement( QStringLiteral(
"storedexpressions" ) );
121 QDomElement aStoredExpression = layerNode.ownerDocument().createElement( QStringLiteral(
"storedexpression" ) );
125 aStoredExpressions.appendChild( aStoredExpression );
127 layerNode.appendChild( aStoredExpressions );
136 QDomNode aaNode = layerNode.namedItem( QStringLiteral(
"storedexpressions" ) );
138 if ( !aaNode.isNull() )
140 QDomNodeList aStoredExpressions = aaNode.toElement().elementsByTagName( QStringLiteral(
"storedexpression" ) );
141 for (
int i = 0; i < aStoredExpressions.size(); ++i )
143 QDomElement aStoredExpression = aStoredExpressions.at( i ).toElement();
144 addStoredExpression( aStoredExpression.attribute( QStringLiteral(
"name" ) ), aStoredExpression.attribute( QStringLiteral(
"expression" ) ),
QgsStoredExpression::Category( aStoredExpression.attribute( QStringLiteral(
"tag" ) ).toInt() ) );
void removeStoredExpression(const QString &id)
Removes an expression to the list.
QgsStoredExpression storedExpression(const QString &id) const
Returns an expression according to the id.
bool writeXml(QDomNode &layerNode) const
Writes the stored expressions out in XML format.
void clearStoredExpressions()
Clears list of stored expressions.
QgsStoredExpression findStoredExpressionByExpression(const QString &expression, const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::All) const
Returns an expression according to the expression text.
QList< QgsStoredExpression > storedExpressions(const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::All)
Returns the list of named expressions.
void addStoredExpressions(const QList< QgsStoredExpression > &storedExpressions)
Appends a list of expressions to the existing list.
void updateStoredExpression(const QString &id, const QString &name, const QString &expression, const QgsStoredExpression::Category &tag)
Updates an expression by id.
bool readXml(const QDomNode &layerNode)
Reads the stored expressions in in XML format.
QString addStoredExpression(const QString &name, const QString &expression, const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::FilterExpression)
Adds an expression to the list.
Stored expression containing name, content (expression text) and a category tag.
QString expression
expression text
Category
Categories of use cases FilterExpression for stored expressions to filter attribute table DefaultValu...
QString id
generated uuid used for identification
Category tag
category of the expression use case
QString name
descriptive name of the expression