mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Port getHTMLOutputsCount to c++ API
This commit is contained in:
parent
1f0a3d9719
commit
c1d35a043b
@ -207,6 +207,12 @@ class QgsProcessingAlgorithm
|
||||
:rtype: QgsProcessingOutputDefinition
|
||||
%End
|
||||
|
||||
bool hasHtmlOutputs() const;
|
||||
%Docstring
|
||||
Returns true if this algorithm generates HTML outputs.
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QVariantMap run( const QVariantMap ¶meters,
|
||||
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
|
||||
%Docstring
|
||||
|
@ -297,15 +297,6 @@ class GeoAlgorithm(QgsProcessingAlgorithm):
|
||||
if out.name == outputName:
|
||||
out.setValue(value)
|
||||
|
||||
def getHTMLOutputsCount(self):
|
||||
"""Returns the number of HTML outputs.
|
||||
"""
|
||||
i = 0
|
||||
for out in self.outputs:
|
||||
if isinstance(out, OutputHTML):
|
||||
i += 1
|
||||
return i
|
||||
|
||||
def removeOutputFromName(self, name):
|
||||
for out in self.outputs:
|
||||
if out.name == name:
|
||||
|
@ -268,7 +268,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
self.close()
|
||||
else:
|
||||
self.resetGUI()
|
||||
if self.alg.getHTMLOutputsCount() > 0:
|
||||
if self.alg.hasHtmlOutputs():
|
||||
self.setInfo(
|
||||
self.tr('HTML output has been generated by this algorithm.'
|
||||
'\nOpen the results dialog to check it.'))
|
||||
|
@ -187,6 +187,16 @@ const QgsProcessingOutputDefinition *QgsProcessingAlgorithm::outputDefinition( c
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool QgsProcessingAlgorithm::hasHtmlOutputs() const
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingOutputDefinition *def, mOutputs )
|
||||
{
|
||||
if ( def->type() == QStringLiteral( "outputHtml" ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariantMap QgsProcessingAlgorithm::run( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const
|
||||
{
|
||||
return processAlgorithm( parameters, context, feedback );
|
||||
@ -252,6 +262,11 @@ QString QgsProcessingAlgorithm::parameterAsRasterOutputLayer( const QVariantMap
|
||||
return QgsProcessingParameters::parameterAsRasterOutputLayer( parameterDefinition( name ), parameters, context );
|
||||
}
|
||||
|
||||
QString QgsProcessingAlgorithm::parameterAsFileOutput( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const
|
||||
{
|
||||
return QgsProcessingParameters::parameterAsFileOutput( parameterDefinition( name ), parameters, context );
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsProcessingAlgorithm::parameterAsVectorLayer( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const
|
||||
{
|
||||
return QgsProcessingParameters::parameterAsVectorLayer( parameterDefinition( name ), parameters, context );
|
||||
|
@ -210,6 +210,11 @@ class CORE_EXPORT QgsProcessingAlgorithm
|
||||
*/
|
||||
const QgsProcessingOutputDefinition *outputDefinition( const QString &name ) const;
|
||||
|
||||
/**
|
||||
* Returns true if this algorithm generates HTML outputs.
|
||||
*/
|
||||
bool hasHtmlOutputs() const;
|
||||
|
||||
/**
|
||||
* Executes the algorithm using the specified \a parameters.
|
||||
*
|
||||
|
@ -119,6 +119,11 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
// parameterDefinition should be case insensitive
|
||||
QCOMPARE( outputDefinition( "P1" ), outputDefinitions().at( 0 ) );
|
||||
QVERIFY( !outputDefinition( "invalid" ) );
|
||||
|
||||
QVERIFY( !hasHtmlOutputs() );
|
||||
QgsProcessingOutputHtml *p3 = new QgsProcessingOutputHtml( "p3" );
|
||||
QVERIFY( addOutput( p3 ) );
|
||||
QVERIFY( hasHtmlOutputs() );
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user