Skip to content
Permalink
Browse files

Show helper text in expression builder for CRS values in modeler

  • Loading branch information
nyalldawson committed Sep 6, 2018
1 parent 7b85fd9 commit f83b3ecc8490983217b55786a8b4ea5129652b45
@@ -73,6 +73,13 @@ various available values for QgsProcessingParameterDefinition.type() (for

The ``compatibleDataTypes`` list corresponds to the compatible data types
from QgsProcessing.SourceType.
%End

void setExpressionHelpText( const QString &text );
%Docstring
Set the expected expression format ``text``, which is shown in the expression builder dialog for the widget
when in the "pre-calculated" expression mode. This is purely a text format and no expression validation is made
against it.
%End

const QgsProcessingParameterDefinition *parameterDefinition() const;
@@ -305,6 +305,17 @@ values which can be used as values for the parameter.
.. seealso:: :py:func:`compatibleParameterTypes`

.. seealso:: :py:func:`compatibleOutputTypes`
%End

virtual QString modelerExpressionFormatString() const;
%Docstring
Returns the expected expression format string for expression results for the parameter
within model child algorithms.

This is shown in modeler widget wrappers when using the "pre-calculated" expression mode,
and should give helpful text to users to indicate the expected results from the expression.

This is purely a text format and no expression validation is made against it.
%End

};
@@ -293,5 +293,9 @@ void QgsProcessingModelerParameterWidget::populateSources( const QStringList &co
}

}
}

void QgsProcessingModelerParameterWidget::setExpressionHelpText( const QString &text )
{
mExpressionWidget->setExpectedOutputFormat( text );
}
@@ -100,6 +100,13 @@ class GUI_EXPORT QgsProcessingModelerParameterWidget : public QWidget
const QStringList &compatibleOutputTypes,
const QList< int > &compatibleDataTypes );

/**
* Set the expected expression format \a text, which is shown in the expression builder dialog for the widget
* when in the "pre-calculated" expression mode. This is purely a text format and no expression validation is made
* against it.
*/
void setExpressionHelpText( const QString &text );

/**
* Returns the parameter definition associated with this wrapper.
*/
@@ -211,5 +211,11 @@ QgsProcessingModelerParameterWidget *QgsProcessingParameterWidgetFactoryInterfac
{
std::unique_ptr< QgsProcessingModelerParameterWidget > widget = qgis::make_unique< QgsProcessingModelerParameterWidget >( model, childId, parameter, context );
widget->populateSources( compatibleParameterTypes(), compatibleOutputTypes(), compatibleDataTypes() );
widget->setExpressionHelpText( modelerExpressionFormatString() );
return widget.release();
}

QString QgsProcessingParameterWidgetFactoryInterface::modelerExpressionFormatString() const
{
return QString();
}
@@ -345,6 +345,17 @@ class GUI_EXPORT QgsProcessingParameterWidgetFactoryInterface
*/
virtual QList< int > compatibleDataTypes() const = 0;

/**
* Returns the expected expression format string for expression results for the parameter
* within model child algorithms.
*
* This is shown in modeler widget wrappers when using the "pre-calculated" expression mode,
* and should give helpful text to users to indicate the expected results from the expression.
* This is purely a text format and no expression validation is made against it.
*/
virtual QString modelerExpressionFormatString() const;

};

#endif // QGSPROCESSINGWIDGETWRAPPER_H
@@ -273,6 +273,11 @@ QList<int> QgsProcessingCrsWidgetWrapper::compatibleDataTypes() const
return QList< int >();
}

QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString() const
{
return tr( "string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
}

QString QgsProcessingCrsWidgetWrapper::parameterType() const
{
return QgsProcessingParameterCrs::typeName();
@@ -88,10 +88,9 @@ class GUI_EXPORT QgsProcessingCrsWidgetWrapper : public QgsAbstractProcessingPar
QVariant widgetValue() const override;

QStringList compatibleParameterTypes() const override;

QStringList compatibleOutputTypes() const override;

QList< int > compatibleDataTypes() const override;
QString modelerExpressionFormatString() const override;

private:

0 comments on commit f83b3ec

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