def edit(self, edit_comment=False):
        elemAlg = self.component().algorithm()
        dlg = ModelerParametersDialog(elemAlg, self.model(),
                                      self.component().childId(),
                                      self.component().configuration())
        dlg.setComments(self.component().comment().description())
        dlg.setCommentColor(self.component().comment().color())
        if edit_comment:
            dlg.switchToCommentTab()
        if dlg.exec_():
            alg = dlg.createAlgorithm()
            alg.setChildId(self.component().childId())
            alg.copyNonDefinitionPropertiesFromModel(self.model())
            self.aboutToChange.emit(
                self.tr('Edit {}').format(alg.description()))
            self.model().setChildAlgorithm(alg)
            self.requestModelRepaint.emit()
            self.changed.emit()

            res, errors = self.model().validateChildAlgorithm(alg.childId())
            if not res:
                self.scene().showWarning(
                    QCoreApplication.translate(
                        'ModelerGraphicItem',
                        'Algorithm “{}” is invalid').format(alg.description()),
                    self.tr('Algorithm is Invalid'),
                    QCoreApplication.translate(
                        'ModelerGraphicItem',
                        "<p>The “{}” algorithm is invalid, because:</p><ul><li>{}</li></ul>"
                    ).format(alg.description(), '</li><li>'.join(errors)),
                    level=Qgis.Warning)
            else:
                self.scene().messageBar().clearWidgets()
Esempio n. 2
0
 def edit(self, edit_comment=False):
     elemAlg = self.component().algorithm()
     dlg = ModelerParametersDialog(elemAlg, self.model(),
                                   self.component().childId(),
                                   self.component().configuration())
     dlg.setComments(self.component().comment().description())
     dlg.setCommentColor(self.component().comment().color())
     if edit_comment:
         dlg.switchToCommentTab()
     if dlg.exec_():
         alg = dlg.createAlgorithm()
         alg.setChildId(self.component().childId())
         alg.copyNonDefinitionPropertiesFromModel(self.model())
         self.aboutToChange.emit(
             self.tr('Edit {}').format(alg.description()))
         self.model().setChildAlgorithm(alg)
         self.requestModelRepaint.emit()
         self.changed.emit()