Skip to content
Permalink
Browse files

Rename set_variable to with_variable

  • Loading branch information
m-kuhn committed Jul 7, 2017
1 parent efff5f1 commit 10dc0d5da9a38a066444f11aaefed118ed300b0d
@@ -0,0 +1,11 @@
{
"name": "with_variable",
"type": "function",
"description": "This function sets a variable for any expression code that will be provided as 3rd argument. This is only useful for complicated expressions, where the same calculated value needs to be used in different places.",
"arguments": [
{"arg":"name","description":"the name of the variable to set"},
{"arg":"value","description":"the value to set"},
{"arg":"node","description":"the expression for which the variable will be available"}
],
"examples": [ { "expression":"with_variable('my_sum', 1 + 2 + 3, @my_sum * 2 + @my_sum * 5)", "returns":"42"}]
}
@@ -4230,7 +4230,7 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()

sFunctions
<< new QgsStaticExpressionFunction( QStringLiteral( "env" ), 1, fcnEnvVar, QStringLiteral( "General" ), QString() )
<< new QgsSetVariableExpressionFunction()
<< new QgsWithVariableExpressionFunction()
<< new QgsStaticExpressionFunction( QStringLiteral( "attribute" ), 2, fcnAttribute, QStringLiteral( "Record" ), QString(), false, QSet<QString>() << QgsFeatureRequest::ALL_ATTRIBUTES )

// functions for arrays
@@ -4276,13 +4276,13 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
return sFunctions;
}

QgsSetVariableExpressionFunction::QgsSetVariableExpressionFunction()
: QgsExpressionFunction( "set_variable", 3, QCoreApplication::tr( "General" ), "help text TODODOODO" )
QgsWithVariableExpressionFunction::QgsWithVariableExpressionFunction()
: QgsExpressionFunction( QStringLiteral("with_variable"), 3, QCoreApplication::tr( "General" ) )
{

}

bool QgsSetVariableExpressionFunction::isStatic( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const
bool QgsWithVariableExpressionFunction::isStatic( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const
{
bool isStatic = false;

@@ -4310,7 +4310,7 @@ bool QgsSetVariableExpressionFunction::isStatic( const QgsExpressionNodeFunction
return false;
}

QVariant QgsSetVariableExpressionFunction::run( QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent )
QVariant QgsWithVariableExpressionFunction::run( QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent )
{
QVariant result;

@@ -4332,7 +4332,7 @@ QVariant QgsSetVariableExpressionFunction::run( QgsExpressionNode::NodeList *arg
return result;
}

QVariant QgsSetVariableExpressionFunction::func( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent )
QVariant QgsWithVariableExpressionFunction::func( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent )
{
// This is a dummy function, all the real handling is in run
Q_UNUSED( values )
@@ -4343,7 +4343,7 @@ QVariant QgsSetVariableExpressionFunction::func( const QVariantList &values, con
return QVariant();
}

bool QgsSetVariableExpressionFunction::prepare( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const
bool QgsWithVariableExpressionFunction::prepare( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const
{
QgsExpressionNode::NodeList *args = node->args();

@@ -455,10 +455,10 @@ class QgsStaticExpressionFunction : public QgsExpressionFunction
bool mIsStatic = false;
};

class QgsSetVariableExpressionFunction : public QgsExpressionFunction
class QgsWithVariableExpressionFunction : public QgsExpressionFunction
{
public:
QgsSetVariableExpressionFunction();
QgsWithVariableExpressionFunction();

bool isStatic( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const override;

0 comments on commit 10dc0d5

Please sign in to comment.
You can’t perform that action at this time.