Skip to content

Commit 1e78855

Browse files
committed
Port getCustomParametersDialog to QgsProcessingAlgorithm
1 parent fb81176 commit 1e78855

9 files changed

Lines changed: 28 additions & 11 deletions

File tree

python/core/processing/qgsprocessingalgorithm.sip

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ class QgsProcessingAlgorithm
184184
:rtype: QVariantMap
185185
%End
186186

187+
virtual QWidget *createCustomParametersWidget( QWidget *parent = 0 ) const /Factory/;
188+
%Docstring
189+
If an algorithm subclass implements a custom parameters widget, a copy of this widget
190+
should be constructed and returned by this method.
191+
The base class implementation returns None, which indicates that an autogenerated
192+
parameters widget should be used.
193+
:rtype: QWidget
194+
%End
195+
187196
protected:
188197

189198
bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );

python/plugins/processing/algs/gdal/GdalAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def icon(self):
5555
def svgIconPath(self):
5656
return QgsApplication.iconPath("providerGdal.svg")
5757

58-
def getCustomParametersDialog(self):
58+
def createCustomParametersWidget(self, parent):
5959
return GdalAlgorithmDialog(self)
6060

6161
def processAlgorithm(self, context, feedback):

python/plugins/processing/algs/qgis/FieldsCalculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,5 @@ def checkParameterValuesBeforeExecuting(self):
169169
if newField and len(fieldName) == 0:
170170
return self.tr('Field name is not set. Please enter a field name')
171171

172-
def getCustomParametersDialog(self):
172+
def createCustomParametersWidget(self, parent):
173173
return FieldsCalculatorDialog(self)

python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ def defineCharacteristics(self):
106106
def getParametersPanel(self, parent):
107107
return ParametersPanel(parent, self)
108108

109-
def getCustomParametersDialog(self):
110-
"""If the algorithm has a custom parameters dialog, it should
111-
be returned here, ready to be executed.
112-
"""
113-
return None
114-
115109
def getCustomModelerParametersDialog(self, modelAlg, algName=None):
116110
"""If the algorithm has a custom parameters dialog when called
117111
from the modeler, it should be returned here, ready to be

python/plugins/processing/gui/ProcessingToolbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def executeAlgorithm(self):
266266
return
267267

268268
if alg.countVisibleParameters() > 0:
269-
dlg = alg.getCustomParametersDialog()
269+
dlg = alg.createCustomParametersWidget(self)
270270
if not dlg:
271271
dlg = AlgorithmDialog(alg)
272272
canvas = iface.mapCanvas()

python/plugins/processing/gui/ScriptEditorDialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def runAlgorithm(self):
269269
if self.algType == self.SCRIPT_PYTHON:
270270
alg = ScriptAlgorithm(None, self.editor.text())
271271

272-
dlg = alg.getCustomParametersDialog()
272+
dlg = alg.createCustomParametersWidget(self)
273273
if not dlg:
274274
dlg = AlgorithmDialog(alg)
275275

python/plugins/processing/gui/menus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _executeAlgorithm(alg):
205205

206206
context = dataobjects.createContext()
207207
if (alg.countVisibleParameters()) > 0:
208-
dlg = alg.getCustomParametersDialog()
208+
dlg = alg.createCustomParametersWidget(None)
209209
if not dlg:
210210
dlg = AlgorithmDialog(alg)
211211
canvas = iface.mapCanvas()

src/core/processing/qgsprocessingalgorithm.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ QVariantMap QgsProcessingAlgorithm::run( const QVariantMap &, QgsProcessingConte
7171
return QVariantMap();
7272
}
7373

74+
QWidget *QgsProcessingAlgorithm::createCustomParametersWidget( QWidget * ) const
75+
{
76+
return nullptr;
77+
}
78+
7479
bool QgsProcessingAlgorithm::addParameter( QgsProcessingParameterDefinition *definition )
7580
{
7681
if ( !definition )

src/core/processing/qgsprocessingalgorithm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
class QgsProcessingProvider;
3030
class QgsProcessingContext;
3131
class QgsProcessingFeedback;
32+
class QWidget;
3233

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

193+
/**
194+
* If an algorithm subclass implements a custom parameters widget, a copy of this widget
195+
* should be constructed and returned by this method.
196+
* The base class implementation returns nullptr, which indicates that an autogenerated
197+
* parameters widget should be used.
198+
*/
199+
virtual QWidget *createCustomParametersWidget( QWidget *parent = nullptr ) const SIP_FACTORY;
200+
192201
protected:
193202

194203
/**

0 commit comments

Comments
 (0)