mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[Processing] Define boolean output
In processing, if an algorithm has a boolean as an output, it cannot be defined as boolean but as a number. To be more precise in algorithms description, the commit add QgsProcessingOutputBoolean.
This commit is contained in:
parent
4a6bc7d75f
commit
943c7d5d90
@ -41,6 +41,8 @@ as generated layers or calculated values.
|
||||
sipType = sipType_QgsProcessingOutputNumber;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputString::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputString;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputBoolean::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputBoolean;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputFolder;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFile::typeName() )
|
||||
@ -313,6 +315,31 @@ Returns the type name for the output class.
|
||||
|
||||
};
|
||||
|
||||
class QgsProcessingOutputBoolean : QgsProcessingOutputDefinition
|
||||
{
|
||||
%Docstring
|
||||
A boolean output for processing algorithms.
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsprocessingoutputs.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsProcessingOutputBoolean( const QString &name, const QString &description = QString() );
|
||||
%Docstring
|
||||
Constructor for :py:class:`QgsProcessingOutputNumber`.
|
||||
%End
|
||||
|
||||
static QString typeName();
|
||||
%Docstring
|
||||
Returns the type name for the output class.
|
||||
%End
|
||||
virtual QString type() const;
|
||||
};
|
||||
|
||||
class QgsProcessingOutputFolder : QgsProcessingOutputDefinition
|
||||
{
|
||||
%Docstring
|
||||
|
@ -42,6 +42,7 @@ from qgis.core import (QgsExpressionContext,
|
||||
QgsProcessingOutputHtml,
|
||||
QgsProcessingOutputNumber,
|
||||
QgsProcessingOutputString,
|
||||
QgsProcessingOutputBoolean,
|
||||
QgsProcessingOutputFolder,
|
||||
QgsProcessingOutputMultipleLayers)
|
||||
|
||||
@ -93,6 +94,8 @@ def getOutputFromString(s):
|
||||
out = QgsProcessingOutputNumber(name, description)
|
||||
elif token.lower().strip().startswith('outputstring'):
|
||||
out = QgsProcessingOutputString(name, description)
|
||||
elif token.lower().strip().startswith('outputboolean'):
|
||||
out = QgsProcessingOutputBoolean(name, description)
|
||||
# elif token.lower().strip().startswith('extent'):
|
||||
# out = OutputExtent()
|
||||
|
||||
|
@ -164,7 +164,7 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
createTable = False
|
||||
|
||||
for out in self.algorithm().outputDefinitions():
|
||||
if isinstance(out, (QgsProcessingOutputNumber, QgsProcessingOutputString)):
|
||||
if isinstance(out, (QgsProcessingOutputNumber, QgsProcessingOutputString, QgsProcessingOutputBoolean)):
|
||||
createTable = True
|
||||
break
|
||||
|
||||
|
@ -655,7 +655,8 @@ QMap<QString, QgsProcessingModelAlgorithm::VariableDefinition> QgsProcessingMode
|
||||
<< QgsProcessingParameterString::typeName()
|
||||
<< QgsProcessingParameterAuthConfig::typeName(),
|
||||
QStringList() << QgsProcessingOutputNumber::typeName()
|
||||
<< QgsProcessingOutputString::typeName() );
|
||||
<< QgsProcessingOutputString::typeName()
|
||||
<< QgsProcessingOutputBoolean::typeName() );
|
||||
|
||||
for ( const QgsProcessingModelChildParameterSource &source : qgis::as_const( sources ) )
|
||||
{
|
||||
|
@ -55,6 +55,10 @@ QgsProcessingOutputString::QgsProcessingOutputString( const QString &name, const
|
||||
: QgsProcessingOutputDefinition( name, description )
|
||||
{}
|
||||
|
||||
QgsProcessingOutputBoolean::QgsProcessingOutputBoolean( const QString &name, const QString &description )
|
||||
: QgsProcessingOutputDefinition( name, description )
|
||||
{}
|
||||
|
||||
QgsProcessingOutputFolder::QgsProcessingOutputFolder( const QString &name, const QString &description )
|
||||
: QgsProcessingOutputDefinition( name, description )
|
||||
{}
|
||||
|
@ -57,6 +57,8 @@ class CORE_EXPORT QgsProcessingOutputDefinition
|
||||
sipType = sipType_QgsProcessingOutputNumber;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputString::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputString;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputBoolean::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputBoolean;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputFolder;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFile::typeName() )
|
||||
@ -309,6 +311,28 @@ class CORE_EXPORT QgsProcessingOutputString : public QgsProcessingOutputDefiniti
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* \class QgsProcessingOutputBoolean
|
||||
* \ingroup core
|
||||
* A boolean output for processing algorithms.
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
class CORE_EXPORT QgsProcessingOutputBoolean : public QgsProcessingOutputDefinition
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsProcessingOutputNumber.
|
||||
*/
|
||||
QgsProcessingOutputBoolean( const QString &name, const QString &description = QString() );
|
||||
|
||||
/**
|
||||
* Returns the type name for the output class.
|
||||
*/
|
||||
static QString typeName() { return QStringLiteral( "outputBoolean" ); }
|
||||
QString type() const override { return typeName(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* \class QgsProcessingOutputFolder
|
||||
* \ingroup core
|
||||
|
@ -171,7 +171,8 @@ QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes() const
|
||||
<< QgsProcessingOutputFile::typeName()
|
||||
<< QgsProcessingOutputRasterLayer::typeName()
|
||||
<< QgsProcessingOutputVectorLayer::typeName()
|
||||
<< QgsProcessingOutputString::typeName();
|
||||
<< QgsProcessingOutputString::typeName()
|
||||
<< QgsProcessingOutputBoolean::typeName();
|
||||
}
|
||||
|
||||
QList<int> QgsProcessingBooleanWidgetWrapper::compatibleDataTypes() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user