mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Revert "Port algorithm countVisibleParameters to c++"
This reverts commit c3c694f8ccfbe0b64df14365f950f5895968a66a.
This commit is contained in:
parent
a4b7af7fad
commit
ae97c333d6
@ -128,13 +128,6 @@ class QgsProcessingAlgorithm
|
||||
:rtype: QgsProcessingParameterDefinition
|
||||
%End
|
||||
|
||||
int countVisibleParameters() const;
|
||||
%Docstring
|
||||
Returns the number of visible (non-hidden) parameters defined by this
|
||||
algorithm.
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
virtual QVariantMap run( const QVariantMap ¶meters,
|
||||
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
|
||||
%Docstring
|
||||
|
@ -430,6 +430,15 @@ class GeoAlgorithm(QgsProcessingAlgorithm):
|
||||
i += 1
|
||||
return i
|
||||
|
||||
def getVisibleParametersCount(self):
|
||||
"""Returns the number of non-hidden parameters.
|
||||
"""
|
||||
i = 0
|
||||
for param in self.parameters:
|
||||
if not param.hidden:
|
||||
i += 1
|
||||
return i
|
||||
|
||||
def getHTMLOutputsCount(self):
|
||||
"""Returns the number of HTML outputs.
|
||||
"""
|
||||
|
@ -170,7 +170,7 @@ class Processing(object):
|
||||
Processing.tr("Processing"))
|
||||
return
|
||||
else:
|
||||
if len(args) != alg.countVisibleParameters() + alg.getVisibleOutputsCount():
|
||||
if len(args) != alg.getVisibleParametersCount() + alg.getVisibleOutputsCount():
|
||||
# fix_print_with_import
|
||||
print('Error: Wrong number of parameters')
|
||||
QgsMessageLog.logMessage(Processing.tr('Error: Wrong number of parameters'),
|
||||
|
@ -102,7 +102,7 @@ class BatchPanel(BASE, WIDGET):
|
||||
nOutputs = 0
|
||||
|
||||
self.tblParameters.setColumnCount(
|
||||
self.alg.countVisibleParameters() + nOutputs)
|
||||
self.alg.getVisibleParametersCount() + nOutputs)
|
||||
|
||||
# Table headers
|
||||
column = 0
|
||||
|
@ -275,7 +275,7 @@ class ProcessingToolbox(BASE, WIDGET):
|
||||
alg = alg.getCopy()
|
||||
alg.setProvider(provider)
|
||||
|
||||
if (alg.countVisibleParameters() + alg.getVisibleOutputsCount()) > 0:
|
||||
if (alg.getVisibleParametersCount() + alg.getVisibleOutputsCount()) > 0:
|
||||
dlg = alg.getCustomParametersDialog()
|
||||
if not dlg:
|
||||
dlg = AlgorithmDialog(alg)
|
||||
|
@ -210,7 +210,7 @@ def _executeAlgorithm(alg):
|
||||
alg.setProvider(provider)
|
||||
|
||||
context = dataobjects.createContext()
|
||||
if (alg.countVisibleParameters() + alg.getVisibleOutputsCount()) > 0:
|
||||
if (alg.getVisibleParametersCount() + alg.getVisibleOutputsCount()) > 0:
|
||||
dlg = alg.getCustomParametersDialog()
|
||||
if not dlg:
|
||||
dlg = AlgorithmDialog(alg)
|
||||
|
@ -87,17 +87,6 @@ const QgsProcessingParameterDefinition *QgsProcessingAlgorithm::parameterDefinit
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int QgsProcessingAlgorithm::countVisibleParameters() const
|
||||
{
|
||||
int count = 0;
|
||||
Q_FOREACH ( const QgsProcessingParameterDefinition *def, mParameters )
|
||||
{
|
||||
if ( !( def->flags() & QgsProcessingParameterDefinition::FlagHidden ) )
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
QString QgsProcessingAlgorithm::parameterAsString( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const
|
||||
{
|
||||
return QgsProcessingParameters::parameterAsString( parameterDefinition( name ), parameters, name, context );
|
||||
|
@ -142,12 +142,6 @@ class CORE_EXPORT QgsProcessingAlgorithm
|
||||
*/
|
||||
const QgsProcessingParameterDefinition *parameterDefinition( const QString &name ) const;
|
||||
|
||||
/**
|
||||
* Returns the number of visible (non-hidden) parameters defined by this
|
||||
* algorithm.
|
||||
*/
|
||||
int countVisibleParameters() const;
|
||||
|
||||
/**
|
||||
* Runs the algorithm using the specified \a parameters. Algorithms should implement
|
||||
* their custom processing logic here.
|
||||
|
@ -62,15 +62,6 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
// parameterDefinition should be case insensitive
|
||||
QCOMPARE( parameterDefinition( "P1" ), parameterDefinitions().at( 0 ) );
|
||||
QVERIFY( !parameterDefinition( "invalid" ) );
|
||||
|
||||
QCOMPARE( countVisibleParameters(), 1 );
|
||||
QgsProcessingParameterBoolean *p3 = new QgsProcessingParameterBoolean( "p3" );
|
||||
QVERIFY( addParameter( p3 ) );
|
||||
QCOMPARE( countVisibleParameters(), 2 );
|
||||
QgsProcessingParameterBoolean *p4 = new QgsProcessingParameterBoolean( "p4" );
|
||||
p4->setFlags( QgsProcessingParameterDefinition::FlagHidden );
|
||||
QVERIFY( addParameter( p4 ) );
|
||||
QCOMPARE( countVisibleParameters(), 2 );
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user