mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Hide contextual functions from builder unless provided by context
This commit is contained in:
parent
2a951ec945
commit
f74db81b9a
@ -247,7 +247,8 @@ class QgsExpression
|
|||||||
bool usesGeometry = false,
|
bool usesGeometry = false,
|
||||||
QStringList referencedColumns = QStringList(),
|
QStringList referencedColumns = QStringList(),
|
||||||
bool lazyEval = false,
|
bool lazyEval = false,
|
||||||
bool handlesNull = false );
|
bool handlesNull = false,
|
||||||
|
bool isContextual = false );
|
||||||
|
|
||||||
virtual ~Function();
|
virtual ~Function();
|
||||||
|
|
||||||
@ -272,6 +273,11 @@ class QgsExpression
|
|||||||
|
|
||||||
virtual QStringList referencedColumns() const;
|
virtual QStringList referencedColumns() const;
|
||||||
|
|
||||||
|
/** Returns whether the function is only available if provided by a QgsExpressionContext object.
|
||||||
|
* @note added in QGIS 2.12
|
||||||
|
*/
|
||||||
|
bool isContextual() const;
|
||||||
|
|
||||||
/** The group the function belongs to. */
|
/** The group the function belongs to. */
|
||||||
QString group();
|
QString group();
|
||||||
/** The help text for the function. */
|
/** The help text for the function. */
|
||||||
|
@ -19,7 +19,8 @@ class QgsScopedExpressionFunction : QgsExpression::Function
|
|||||||
bool usesGeometry = false,
|
bool usesGeometry = false,
|
||||||
QStringList referencedColumns = QStringList(),
|
QStringList referencedColumns = QStringList(),
|
||||||
bool lazyEval = false,
|
bool lazyEval = false,
|
||||||
bool handlesNull = false );
|
bool handlesNull = false,
|
||||||
|
bool isContextual = true );
|
||||||
|
|
||||||
virtual ~QgsScopedExpressionFunction();
|
virtual ~QgsScopedExpressionFunction();
|
||||||
|
|
||||||
|
@ -341,7 +341,8 @@ class CORE_EXPORT QgsExpression
|
|||||||
bool usesGeometry = false,
|
bool usesGeometry = false,
|
||||||
QStringList referencedColumns = QStringList(),
|
QStringList referencedColumns = QStringList(),
|
||||||
bool lazyEval = false,
|
bool lazyEval = false,
|
||||||
bool handlesNull = false )
|
bool handlesNull = false,
|
||||||
|
bool isContextual = false )
|
||||||
: mName( fnname )
|
: mName( fnname )
|
||||||
, mParams( params )
|
, mParams( params )
|
||||||
, mUsesGeometry( usesGeometry )
|
, mUsesGeometry( usesGeometry )
|
||||||
@ -350,6 +351,7 @@ class CORE_EXPORT QgsExpression
|
|||||||
, mReferencedColumns( referencedColumns )
|
, mReferencedColumns( referencedColumns )
|
||||||
, mLazyEval( lazyEval )
|
, mLazyEval( lazyEval )
|
||||||
, mHandlesNull( handlesNull )
|
, mHandlesNull( handlesNull )
|
||||||
|
, mIsContextual( isContextual )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~Function() {}
|
virtual ~Function() {}
|
||||||
@ -375,6 +377,11 @@ class CORE_EXPORT QgsExpression
|
|||||||
|
|
||||||
virtual QStringList referencedColumns() const { return mReferencedColumns; }
|
virtual QStringList referencedColumns() const { return mReferencedColumns; }
|
||||||
|
|
||||||
|
/** Returns whether the function is only available if provided by a QgsExpressionContext object.
|
||||||
|
* @note added in QGIS 2.12
|
||||||
|
*/
|
||||||
|
bool isContextual() const { return mIsContextual; }
|
||||||
|
|
||||||
/** The group the function belongs to. */
|
/** The group the function belongs to. */
|
||||||
QString group() { return mGroup; }
|
QString group() { return mGroup; }
|
||||||
/** The help text for the function. */
|
/** The help text for the function. */
|
||||||
@ -409,6 +416,7 @@ class CORE_EXPORT QgsExpression
|
|||||||
QStringList mReferencedColumns;
|
QStringList mReferencedColumns;
|
||||||
bool mLazyEval;
|
bool mLazyEval;
|
||||||
bool mHandlesNull;
|
bool mHandlesNull;
|
||||||
|
bool mIsContextual; //if true function is only available through an expression context
|
||||||
};
|
};
|
||||||
|
|
||||||
class StaticFunction : public Function
|
class StaticFunction : public Function
|
||||||
|
@ -46,8 +46,9 @@ class CORE_EXPORT QgsScopedExpressionFunction : public QgsExpression::Function
|
|||||||
bool usesGeometry = false,
|
bool usesGeometry = false,
|
||||||
QStringList referencedColumns = QStringList(),
|
QStringList referencedColumns = QStringList(),
|
||||||
bool lazyEval = false,
|
bool lazyEval = false,
|
||||||
bool handlesNull = false )
|
bool handlesNull = false,
|
||||||
: QgsExpression::Function( fnname, params, group, helpText, usesGeometry, referencedColumns, lazyEval, handlesNull )
|
bool isContextual = true )
|
||||||
|
: QgsExpression::Function( fnname, params, group, helpText, usesGeometry, referencedColumns, lazyEval, handlesNull, isContextual )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~QgsScopedExpressionFunction() {}
|
virtual ~QgsScopedExpressionFunction() {}
|
||||||
|
@ -445,6 +445,12 @@ void QgsExpressionBuilderWidget::updateFunctionTree()
|
|||||||
QString name = func->name();
|
QString name = func->name();
|
||||||
if ( name.startsWith( "_" ) ) // do not display private functions
|
if ( name.startsWith( "_" ) ) // do not display private functions
|
||||||
continue;
|
continue;
|
||||||
|
if ( func->isContextual() )
|
||||||
|
{
|
||||||
|
//don't show contextual functions by default - it's up the the QgsExpressionContext
|
||||||
|
//object to provide them if supported
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( func->params() != 0 )
|
if ( func->params() != 0 )
|
||||||
name += "(";
|
name += "(";
|
||||||
else if ( !name.startsWith( "$" ) )
|
else if ( !name.startsWith( "$" ) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user