22 #include <QDomElement> 28 mStoredExpressions.append( storedExpression );
30 return storedExpression.
id;
40 mStoredExpressions.removeAt( i );
56 newStoredExpression.
name = name;
58 newStoredExpression.
tag = tag;
59 mStoredExpressions.replace( i, newStoredExpression );
69 mStoredExpressions.append( storedExpressions );
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() ) );
QString addStoredExpression(const QString &name, const QString &expression, const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::FilterExpression)
Adds an expression to the list.
Category
Categories of use cases FilterExpression for stored expressions to filter attribute table DefaultValu...
QgsStoredExpression storedExpression(const QString &id) const
Returns an expression according to the id.
void updateStoredExpression(const QString &id, const QString &name, const QString &expression, const QgsStoredExpression::Category &tag)
Updates an expression by id.
Category tag
category of the expression use case
bool writeXml(QDomNode &layerNode) const
Writes the stored expressions out in XML format.
void addStoredExpressions(const QList< QgsStoredExpression > &storedExpressions)
Appends a list of expressions to the existing list.
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.
QString id
generated uuid used for identification
QString expression
expression text
bool readXml(const QDomNode &layerNode)
Reads the stored expressions in in XML format.
void removeStoredExpression(const QString &id)
Removes an expression to the list.
QString name
descriptive name of the expression
void clearStoredExpressions()
Clears list of stored expressions.
Stored expression containing name, content (expression text) and a category tag.