def editElement(self): if isinstance(self.element, QgsProcessingModelParameter): dlg = ModelerParameterDefinitionDialog(self.model, param=self.model.parameterDefinition(self.element.parameterName())) if dlg.exec_() and dlg.param is not None: self.model.removeModelParameter(self.element.parameterName()) self.element.setParameterName(dlg.param.name()) self.element.setDescription(dlg.param.name()) self.model.addModelParameter(dlg.param, self.element) self.text = dlg.param.description() self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelChildAlgorithm): elemAlg = self.element.algorithm() dlg = ModelerParametersDialog(elemAlg, self.model, self.element.childId(), self.element.configuration()) if dlg.exec_(): alg = dlg.createAlgorithm() alg.setChildId(self.element.childId()) self.updateAlgorithm(alg) self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelOutput): child_alg = self.model.childAlgorithm(self.element.childId()) param_name = '{}:{}'.format(self.element.childId(), self.element.name()) dlg = ModelerParameterDefinitionDialog(self.model, param=self.model.parameterDefinition(param_name)) if dlg.exec_() and dlg.param is not None: model_output = child_alg.modelOutput(self.element.name()) model_output.setDescription(dlg.param.description()) model_output.setDefaultValue(dlg.param.defaultValue()) model_output.setMandatory(not (dlg.param.flags() & QgsProcessingParameterDefinition.FlagOptional)) self.model.updateDestinationParameters()
def editElement(self): if isinstance(self.element, QgsProcessingModelParameter): dlg = ModelerParameterDefinitionDialog(self.model, param=self.model.parameterDefinition(self.element.parameterName())) if dlg.exec_() and dlg.param is not None: self.model.removeModelParameter(self.element.parameterName()) self.element.setParameterName(dlg.param.name()) self.element.setDescription(dlg.param.name()) self.model.addModelParameter(dlg.param, self.element) self.text = dlg.param.description() self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelChildAlgorithm): elemAlg = self.element.algorithm() dlg = ModelerParametersDialog(elemAlg, self.model, self.element.childId(), self.element.configuration()) if dlg.exec_(): alg = dlg.createAlgorithm() alg.setChildId(self.element.childId()) self.updateAlgorithm(alg) self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelOutput): child_alg = self.model.childAlgorithm(self.element.childId()) param_name = '{}:{}'.format(self.element.childId(), self.element.name()) dlg = ModelerParameterDefinitionDialog(self.model, param=self.model.parameterDefinition(param_name)) if dlg.exec_() and dlg.param is not None: model_output = child_alg.modelOutput(self.element.name()) model_output.setDescription(dlg.param.description()) model_output.setDefaultValue(dlg.param.defaultValue()) model_output.setMandatory(not (dlg.param.flags() & QgsProcessingParameterDefinition.FlagOptional)) self.model.updateDestinationParameters()
def editElement(self): if isinstance(self.element, QgsProcessingModelParameter): dlg = ModelerParameterDefinitionDialog( self.model, param=self.model.parameterDefinition( self.element.parameterName())) if dlg.exec_() and dlg.param is not None: self.model.removeModelParameter(self.element.parameterName()) self.element.setParameterName(dlg.param.name()) self.element.setDescription(dlg.param.name()) self.model.addModelParameter(dlg.param, self.element) self.text = dlg.param.description() self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelChildAlgorithm): dlg = None try: dlg = self.element.algorithm( ).getCustomModelerParametersDialog(self.model, self.element.childId()) except: pass if not dlg: dlg = ModelerParametersDialog(self.element.algorithm(), self.model, self.element.childId()) if dlg.exec_(): alg = dlg.createAlgorithm() alg.setChildId(self.element.childId()) self.updateAlgorithm(alg) self.scene.dialog.repaintModel()
def editElement(self): if isinstance(self.element, QgsProcessingModelParameter): existing_param = self.model.parameterDefinition( self.element.parameterName()) new_param = None if ModelerParameterDefinitionDialog.use_legacy_dialog( param=existing_param): # boo, old api dlg = ModelerParameterDefinitionDialog(self.model, param=existing_param) if dlg.exec_(): new_param = dlg.param else: # yay, use new API! context = createContext() widget_context = self.create_widget_context() dlg = QgsProcessingParameterDefinitionDialog( type=existing_param.type(), context=context, widgetContext=widget_context, definition=existing_param, algorithm=self.model) if dlg.exec_(): new_param = dlg.createParameter(existing_param.name()) if new_param is not None: self.model.removeModelParameter(self.element.parameterName()) self.element.setParameterName(new_param.name()) self.element.setDescription(new_param.name()) self.model.addModelParameter(new_param, self.element) self.text = new_param.description() self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelChildAlgorithm): elemAlg = self.element.algorithm() dlg = ModelerParametersDialog(elemAlg, self.model, self.element.childId(), self.element.configuration()) if dlg.exec_(): alg = dlg.createAlgorithm() alg.setChildId(self.element.childId()) self.updateAlgorithm(alg) self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelOutput): child_alg = self.model.childAlgorithm(self.element.childId()) param_name = '{}:{}'.format(self.element.childId(), self.element.name()) dlg = ModelerParameterDefinitionDialog( self.model, param=self.model.parameterDefinition(param_name)) if dlg.exec_() and dlg.param is not None: model_output = child_alg.modelOutput(self.element.name()) model_output.setDescription(dlg.param.description()) model_output.setDefaultValue(dlg.param.defaultValue()) model_output.setMandatory(not ( dlg.param.flags() & QgsProcessingParameterDefinition.FlagOptional)) self.model.updateDestinationParameters()
def editElement(self): if isinstance(self.element, QgsProcessingModelParameter): dlg = ModelerParameterDefinitionDialog(self.model, param=self.model.parameterDefinition(self.element.parameterName())) if dlg.exec_() and dlg.param is not None: self.model.removeModelParameter(self.element.parameterName()) self.element.setParameterName(dlg.param.name()) self.element.setDescription(dlg.param.name()) self.model.addModelParameter(dlg.param, self.element) self.text = dlg.param.description() self.scene.dialog.repaintModel() elif isinstance(self.element, QgsProcessingModelChildAlgorithm): elemAlg = self.element.algorithm() dlg = ModelerParametersDialog(elemAlg, self.model, self.element.childId(), self.element.configuration()) if dlg.exec_(): alg = dlg.createAlgorithm() alg.setChildId(self.element.childId()) self.updateAlgorithm(alg) self.scene.dialog.repaintModel()