mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
[processing] Show complete expression context in expression builder
for pre-calculated expressions Correctly exposes ALL the variables and functions available for use in pre-calculated expressions so that users actually know they can use these in their models!
This commit is contained in:
parent
8e49e94d92
commit
8f9f975ed6
@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsProcessingModelerParameterWidget : QWidget
|
||||
class QgsProcessingModelerParameterWidget : QWidget, QgsExpressionContextGenerator
|
||||
{
|
||||
%Docstring
|
||||
|
||||
@ -117,6 +117,9 @@ Returns the current value of the parameter.
|
||||
.. seealso:: :py:func:`setWidgetValue`
|
||||
%End
|
||||
|
||||
virtual QgsExpressionContext createExpressionContext() const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgsprocessingguiregistry.h"
|
||||
#include "models/qgsprocessingmodelalgorithm.h"
|
||||
#include "qgsgui.h"
|
||||
#include "qgsexpressioncontext.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QToolButton>
|
||||
#include <QStackedWidget>
|
||||
@ -172,7 +173,23 @@ QgsProcessingModelChildParameterSource QgsProcessingModelerParameterWidget::valu
|
||||
|
||||
QgsExpressionContext QgsProcessingModelerParameterWidget::createExpressionContext() const
|
||||
{
|
||||
return QgsExpressionContext();
|
||||
QgsExpressionContext c = mContext.expressionContext();
|
||||
if ( mModel )
|
||||
{
|
||||
QgsExpressionContextScope *algorithmScope = QgsExpressionContextUtils::processingAlgorithmScope( mModel->childAlgorithm( mChildId ).algorithm(), QVariantMap(), mContext );
|
||||
c << algorithmScope;
|
||||
QgsExpressionContextScope *childScope = mModel->createExpressionContextScopeForChildAlgorithm( mChildId, mContext, QVariantMap(), QVariantMap() );
|
||||
c << childScope;
|
||||
|
||||
QStringList highlightedVariables = childScope->variableNames();
|
||||
QStringList highlightedFunctions = childScope->functionNames();
|
||||
highlightedVariables += algorithmScope->variableNames();
|
||||
highlightedFunctions += algorithmScope->functionNames();
|
||||
c.setHighlightedVariables( highlightedVariables );
|
||||
c.setHighlightedFunctions( highlightedFunctions );
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void QgsProcessingModelerParameterWidget::sourceMenuAboutToShow()
|
||||
|
@ -143,6 +143,8 @@ class GUI_EXPORT QgsProcessingModelerParameterWidget : public QWidget, public Qg
|
||||
*/
|
||||
virtual QgsProcessingModelChildParameterSource value() const;
|
||||
|
||||
QgsExpressionContext createExpressionContext() const override;
|
||||
|
||||
private slots:
|
||||
|
||||
void sourceMenuAboutToShow();
|
||||
|
Loading…
x
Reference in New Issue
Block a user