Skip to content
Permalink
Browse files

Port getCustomParametersDialog to QgsProcessingAlgorithm

  • Loading branch information
nyalldawson committed Jun 5, 2017
1 parent fb81176 commit 1e788556f093bf0fdf8ce8c42a9c2b4c9053108f
@@ -184,6 +184,15 @@ class QgsProcessingAlgorithm
:rtype: QVariantMap
%End

virtual QWidget *createCustomParametersWidget( QWidget *parent = 0 ) const /Factory/;
%Docstring
If an algorithm subclass implements a custom parameters widget, a copy of this widget
should be constructed and returned by this method.
The base class implementation returns None, which indicates that an autogenerated
parameters widget should be used.
:rtype: QWidget
%End

protected:

bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );
@@ -55,7 +55,7 @@ def icon(self):
def svgIconPath(self):
return QgsApplication.iconPath("providerGdal.svg")

def getCustomParametersDialog(self):
def createCustomParametersWidget(self, parent):
return GdalAlgorithmDialog(self)

def processAlgorithm(self, context, feedback):
@@ -169,5 +169,5 @@ def checkParameterValuesBeforeExecuting(self):
if newField and len(fieldName) == 0:
return self.tr('Field name is not set. Please enter a field name')

def getCustomParametersDialog(self):
def createCustomParametersWidget(self, parent):
return FieldsCalculatorDialog(self)
@@ -106,12 +106,6 @@ def defineCharacteristics(self):
def getParametersPanel(self, parent):
return ParametersPanel(parent, self)

def getCustomParametersDialog(self):
"""If the algorithm has a custom parameters dialog, it should
be returned here, ready to be executed.
"""
return None

def getCustomModelerParametersDialog(self, modelAlg, algName=None):
"""If the algorithm has a custom parameters dialog when called
from the modeler, it should be returned here, ready to be
@@ -266,7 +266,7 @@ def executeAlgorithm(self):
return

if alg.countVisibleParameters() > 0:
dlg = alg.getCustomParametersDialog()
dlg = alg.createCustomParametersWidget(self)
if not dlg:
dlg = AlgorithmDialog(alg)
canvas = iface.mapCanvas()
@@ -269,7 +269,7 @@ def runAlgorithm(self):
if self.algType == self.SCRIPT_PYTHON:
alg = ScriptAlgorithm(None, self.editor.text())

dlg = alg.getCustomParametersDialog()
dlg = alg.createCustomParametersWidget(self)
if not dlg:
dlg = AlgorithmDialog(alg)

@@ -205,7 +205,7 @@ def _executeAlgorithm(alg):

context = dataobjects.createContext()
if (alg.countVisibleParameters()) > 0:
dlg = alg.getCustomParametersDialog()
dlg = alg.createCustomParametersWidget(None)
if not dlg:
dlg = AlgorithmDialog(alg)
canvas = iface.mapCanvas()
@@ -71,6 +71,11 @@ QVariantMap QgsProcessingAlgorithm::run( const QVariantMap &, QgsProcessingConte
return QVariantMap();
}

QWidget *QgsProcessingAlgorithm::createCustomParametersWidget( QWidget * ) const
{
return nullptr;
}

bool QgsProcessingAlgorithm::addParameter( QgsProcessingParameterDefinition *definition )
{
if ( !definition )
@@ -29,6 +29,7 @@
class QgsProcessingProvider;
class QgsProcessingContext;
class QgsProcessingFeedback;
class QWidget;

/**
* \class QgsProcessingAlgorithm
@@ -189,6 +190,14 @@ class CORE_EXPORT QgsProcessingAlgorithm
virtual QVariantMap run( const QVariantMap &parameters,
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;

/**
* If an algorithm subclass implements a custom parameters widget, a copy of this widget
* should be constructed and returned by this method.
* The base class implementation returns nullptr, which indicates that an autogenerated
* parameters widget should be used.
*/
virtual QWidget *createCustomParametersWidget( QWidget *parent = nullptr ) const SIP_FACTORY;

protected:

/**

0 comments on commit 1e78855

Please sign in to comment.
You can’t perform that action at this time.