Skip to content
Permalink
Browse files

Revert "Port algorithm countVisibleParameters to c++"

This reverts commit c3c694f.
  • Loading branch information
nyalldawson committed May 15, 2017
1 parent a4b7af7 commit ae97c333d693d3e85cb92d2dfbb50abbb44b0e36
@@ -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 &parameters,
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
%Docstring
@@ -430,6 +430,15 @@ def getVisibleOutputsCount(self):
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 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
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 @@ def initWidgets(self):
nOutputs = 0

self.tblParameters.setColumnCount(
self.alg.countVisibleParameters() + nOutputs)
self.alg.getVisibleParametersCount() + nOutputs)

# Table headers
column = 0
@@ -275,7 +275,7 @@ def executeAlgorithm(self):
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 &parameters, 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 );
}

};

0 comments on commit ae97c33

Please sign in to comment.