mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Rename set_variable to with_variable
This commit is contained in:
parent
efff5f1670
commit
10dc0d5da9
11
resources/function_help/json/with_variable
Normal file
11
resources/function_help/json/with_variable
Normal file
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user