36
36
from qgis .core import (QgsProcessingParameterDefinition ,
37
37
QgsProcessingParameterPoint ,
38
38
QgsProcessingParameterExtent ,
39
- QgsProcessingModelAlgorithm )
39
+ QgsProcessingModelAlgorithm ,
40
+ QgsProcessingParameterFeatureSink ,
41
+ QgsProcessingParameterRasterOutput ,
42
+ QgsProcessingParameterFileOutput ,
43
+ QgsProcessingParameterFolderOutput )
40
44
41
45
from qgis .gui import (QgsMessageBar ,
42
46
QgsScrollArea )
43
47
44
48
from processing .gui .wrappers import WidgetWrapperFactory
45
49
from processing .gui .wrappers import InvalidParameterValue
46
50
from processing .gui .MultipleInputPanel import MultipleInputPanel
47
- from processing .core .outputs import (OutputRaster ,
48
- OutputVector ,
49
- OutputTable ,
50
- OutputHTML ,
51
- OutputFile ,
52
- OutputDirectory )
53
- from processing .core .parameters import ParameterPoint , ParameterExtent
54
51
55
52
56
53
class ModelerParametersDialog (QDialog ):
@@ -149,19 +146,18 @@ def setupUi(self):
149
146
self .verticalLayout .addWidget (label )
150
147
self .verticalLayout .addWidget (widget )
151
148
152
- # for output in self._alg.outputs:
153
- # if output.flags() & QgsProcessingParameterDefinition.FlagHidden:
154
- # continue
155
- # if isinstance(output, (OutputRaster, OutputVector, OutputTable,
156
- # OutputHTML, OutputFile, OutputDirectory)):
157
- # label = QLabel(output.description() + '<' +
158
- # output.__class__.__name__ + '>')
159
- # item = QLineEdit()
160
- # if hasattr(item, 'setPlaceholderText'):
161
- # item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
162
- # self.verticalLayout.addWidget(label)
163
- # self.verticalLayout.addWidget(item)
164
- # self.valueItems[output.name] = item
149
+ for dest in self ._alg .destinationParameterDefinitions ():
150
+ if dest .flags () & QgsProcessingParameterDefinition .FlagHidden :
151
+ continue
152
+ if isinstance (dest , (QgsProcessingParameterRasterOutput , QgsProcessingParameterFeatureSink ,
153
+ QgsProcessingParameterFileOutput , QgsProcessingParameterFolderOutput )):
154
+ label = QLabel (dest .description ())
155
+ item = QLineEdit ()
156
+ if hasattr (item , 'setPlaceholderText' ):
157
+ item .setPlaceholderText (ModelerParametersDialog .ENTER_NAME )
158
+ self .verticalLayout .addWidget (label )
159
+ self .verticalLayout .addWidget (item )
160
+ self .valueItems [dest .name ()] = item
165
161
166
162
label = QLabel (' ' )
167
163
self .verticalLayout .addWidget (label )
@@ -309,7 +305,10 @@ def setPreviousValues(self):
309
305
310
306
def createAlgorithm (self ):
311
307
alg = QgsProcessingModelAlgorithm .ChildAlgorithm (self ._alg .id ())
312
- alg .generateChildId (self .model )
308
+ if not self ._algName :
309
+ alg .generateChildId (self .model )
310
+ else :
311
+ alg .setChildId (self ._algName )
313
312
alg .setDescription (self .descriptionBox .text ())
314
313
for param in self ._alg .parameterDefinitions ():
315
314
if param .isDestination () or param .flags () & QgsProcessingParameterDefinition .FlagHidden :
@@ -332,12 +331,16 @@ def createAlgorithm(self):
332
331
else :
333
332
alg .addParameterSource (param .name (), QgsProcessingModelAlgorithm .ChildParameterSource .fromStaticValue (val ))
334
333
335
- # outputs = self._alg.outputDefinitions()
336
- # for output in outputs:
337
- # if not output.flags() & QgsProcessingParameterDefinition.FlagHidden:
338
- # name = str(self.valueItems[output.name()].text())
339
- # if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
340
- # alg.outputs[output.name()] = QgsProcessingModelAlgorithm.ModelOutput(name)
334
+ outputs = {}
335
+ for dest in self ._alg .destinationParameterDefinitions ():
336
+ if not dest .flags () & QgsProcessingParameterDefinition .FlagHidden :
337
+ name = str (self .valueItems [dest .name ()].text ())
338
+ if name .strip () != '' and name != ModelerParametersDialog .ENTER_NAME :
339
+ output = QgsProcessingModelAlgorithm .ModelOutput (name )
340
+ output .setChildId (alg .childId ())
341
+ output .setOutputName (dest .name ())
342
+ outputs [dest .name ()] = output
343
+ alg .setModelOutputs (outputs )
341
344
342
345
selectedOptions = self .dependenciesPanel .selectedoptions
343
346
availableDependencies = self .getAvailableDependencies () # spellok
0 commit comments