mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -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
|
:rtype: QgsProcessingParameterDefinition
|
||||||
%End
|
%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,
|
virtual QVariantMap run( const QVariantMap ¶meters,
|
||||||
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
|
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
@ -430,6 +430,15 @@ class GeoAlgorithm(QgsProcessingAlgorithm):
|
|||||||
i += 1
|
i += 1
|
||||||
return i
|
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):
|
def getHTMLOutputsCount(self):
|
||||||
"""Returns the number of HTML outputs.
|
"""Returns the number of HTML outputs.
|
||||||
"""
|
"""
|
||||||
|
@ -170,7 +170,7 @@ class Processing(object):
|
|||||||
Processing.tr("Processing"))
|
Processing.tr("Processing"))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if len(args) != alg.countVisibleParameters() + alg.getVisibleOutputsCount():
|
if len(args) != alg.getVisibleParametersCount() + alg.getVisibleOutputsCount():
|
||||||
# fix_print_with_import
|
# fix_print_with_import
|
||||||
print('Error: Wrong number of parameters')
|
print('Error: Wrong number of parameters')
|
||||||
QgsMessageLog.logMessage(Processing.tr('Error: Wrong number of parameters'),
|
QgsMessageLog.logMessage(Processing.tr('Error: Wrong number of parameters'),
|
||||||
|
@ -102,7 +102,7 @@ class BatchPanel(BASE, WIDGET):
|
|||||||
nOutputs = 0
|
nOutputs = 0
|
||||||
|
|
||||||
self.tblParameters.setColumnCount(
|
self.tblParameters.setColumnCount(
|
||||||
self.alg.countVisibleParameters() + nOutputs)
|
self.alg.getVisibleParametersCount() + nOutputs)
|
||||||
|
|
||||||
# Table headers
|
# Table headers
|
||||||
column = 0
|
column = 0
|
||||||
|
@ -275,7 +275,7 @@ class ProcessingToolbox(BASE, WIDGET):
|
|||||||
alg = alg.getCopy()
|
alg = alg.getCopy()
|
||||||
alg.setProvider(provider)
|
alg.setProvider(provider)
|
||||||
|
|
||||||
if (alg.countVisibleParameters() + alg.getVisibleOutputsCount()) > 0:
|
if (alg.getVisibleParametersCount() + alg.getVisibleOutputsCount()) > 0:
|
||||||
dlg = alg.getCustomParametersDialog()
|
dlg = alg.getCustomParametersDialog()
|
||||||
if not dlg:
|
if not dlg:
|
||||||
dlg = AlgorithmDialog(alg)
|
dlg = AlgorithmDialog(alg)
|
||||||
|
@ -210,7 +210,7 @@ def _executeAlgorithm(alg):
|
|||||||
alg.setProvider(provider)
|
alg.setProvider(provider)
|
||||||
|
|
||||||
context = dataobjects.createContext()
|
context = dataobjects.createContext()
|
||||||
if (alg.countVisibleParameters() + alg.getVisibleOutputsCount()) > 0:
|
if (alg.getVisibleParametersCount() + alg.getVisibleOutputsCount()) > 0:
|
||||||
dlg = alg.getCustomParametersDialog()
|
dlg = alg.getCustomParametersDialog()
|
||||||
if not dlg:
|
if not dlg:
|
||||||
dlg = AlgorithmDialog(alg)
|
dlg = AlgorithmDialog(alg)
|
||||||
|
@ -87,17 +87,6 @@ const QgsProcessingParameterDefinition *QgsProcessingAlgorithm::parameterDefinit
|
|||||||
return nullptr;
|
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
|
QString QgsProcessingAlgorithm::parameterAsString( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const
|
||||||
{
|
{
|
||||||
return QgsProcessingParameters::parameterAsString( parameterDefinition( name ), parameters, name, context );
|
return QgsProcessingParameters::parameterAsString( parameterDefinition( name ), parameters, name, context );
|
||||||
|
@ -142,12 +142,6 @@ class CORE_EXPORT QgsProcessingAlgorithm
|
|||||||
*/
|
*/
|
||||||
const QgsProcessingParameterDefinition *parameterDefinition( const QString &name ) const;
|
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
|
* Runs the algorithm using the specified \a parameters. Algorithms should implement
|
||||||
* their custom processing logic here.
|
* their custom processing logic here.
|
||||||
|
@ -62,15 +62,6 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
|||||||
// parameterDefinition should be case insensitive
|
// parameterDefinition should be case insensitive
|
||||||
QCOMPARE( parameterDefinition( "P1" ), parameterDefinitions().at( 0 ) );
|
QCOMPARE( parameterDefinition( "P1" ), parameterDefinitions().at( 0 ) );
|
||||||
QVERIFY( !parameterDefinition( "invalid" ) );
|
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