Skip to content

Commit a8b364e

Browse files
committed
Port another member to c++
1 parent 3249015 commit a8b364e

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎python/core/processing/qgsprocessingmodelalgorithm.sip‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ Copies are protected to avoid slicing
573573

574574
virtual bool canExecute( QString *errorMessage /Out/ = 0 ) const;
575575

576+
virtual QString asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const;
577+
576578

577579
void setName( const QString &name );
578580
%Docstring

‎python/plugins/processing/modeler/ModelerAlgorithm.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@ def resolveValue(self, value, param):
224224
v = value
225225
return param.evaluateForModeler(v, self)
226226

227-
def asPythonCommand(self, parameters, context):
228-
if self.sourceFilePath():
229-
return QgsProcessingAlgorithm.asPythonCommand(self, parameters, context)
230-
else:
231-
return None
232-
233227
def toPython(self):
234228
s = ['##%s=name' % self.name()]
235229
for param in list(self.parameterComponents().values()):

‎src/core/processing/qgsprocessingmodelalgorithm.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,14 @@ bool QgsProcessingModelAlgorithm::canExecute( QString *errorMessage ) const
915915
return true;
916916
}
917917

918+
QString QgsProcessingModelAlgorithm::asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const
919+
{
920+
if ( mSourceFile.isEmpty() )
921+
return QString(); // temporary model - can't run as python command
922+
923+
return QgsProcessingAlgorithm::asPythonCommand( parameters, context );
924+
}
925+
918926

919927
bool QgsProcessingModelAlgorithm::ChildParameterSource::operator==( const QgsProcessingModelAlgorithm::ChildParameterSource &other ) const
920928
{

‎src/core/processing/qgsprocessingmodelalgorithm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ class CORE_EXPORT QgsProcessingModelAlgorithm : public QgsProcessingAlgorithm
573573
QString helpUrl() const override;
574574

575575
bool canExecute( QString *errorMessage SIP_OUT = nullptr ) const override;
576+
QString asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const override;
576577

577578
/**
578579
* Sets the model \a name.

0 commit comments

Comments
 (0)