mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Port getCustomParametersDialog to QgsProcessingAlgorithm
This commit is contained in:
parent
fb811766f8
commit
1e788556f0
@ -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 @@ class GdalAlgorithm(GeoAlgorithm):
|
||||
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 @@ class FieldsCalculator(GeoAlgorithm):
|
||||
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 @@ class GeoAlgorithm(QgsProcessingAlgorithm):
|
||||
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 @@ class ProcessingToolbox(BASE, WIDGET):
|
||||
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 @@ class ScriptEditorDialog(BASE, WIDGET):
|
||||
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 ¶meters,
|
||||
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:
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user