Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #6755 from m-kuhn/minimal_processing_fixes
Browse files Browse the repository at this point in the history
Some fixes for processing
  • Loading branch information
m-kuhn committed Apr 9, 2018
2 parents f378a23 + 4a14a36 commit 5b7b7be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
8 changes: 1 addition & 7 deletions python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -643,13 +643,7 @@ def addAlgorithm(self):
self._addAlgorithm(alg)

def _addAlgorithm(self, alg, pos=None):
dlg = None
try:
dlg = alg.getCustomModelerParametersDialog(self.model)
except:
pass
if not dlg:
dlg = ModelerParametersDialog(alg, self.model)
dlg = ModelerParametersDialog(alg, self.model)
if dlg.exec_():
alg = dlg.createAlgorithm()
if pos is None:
Expand Down
6 changes: 1 addition & 5 deletions python/plugins/processing/modeler/ModelerGraphicItem.py
Expand Up @@ -207,12 +207,8 @@ def editElement(self):
self.text = dlg.param.description()
self.scene.dialog.repaintModel()
elif isinstance(self.element, QgsProcessingModelChildAlgorithm):
dlg = None
elemAlg = self.element.algorithm()
if hasattr(elemAlg, 'getCustomModelerParametersDialog'):
dlg = elemAlg.getCustomModelerParametersDialog(self.model, self.element.childId())
if not dlg:
dlg = ModelerParametersDialog(elemAlg, self.model, self.element.childId())
dlg = ModelerParametersDialog(elemAlg, self.model, self.element.childId())
if dlg.exec_():
alg = dlg.createAlgorithm()
alg.setChildId(self.element.childId())
Expand Down
21 changes: 8 additions & 13 deletions python/plugins/processing/modeler/ModelerParametersDialog.py
Expand Up @@ -63,19 +63,14 @@


class ModelerParametersDialog(QDialog):
ENTER_NAME = '[Enter name if this is a final result]'
NOT_SELECTED = '[Not selected]'
USE_MIN_COVERING_EXTENT = '[Use min covering extent]'

def __init__(self, alg, model, algName=None):
QDialog.__init__(self)
self.setModal(True)
# The algorithm to define in this dialog. It is an instance of QgsProcessingModelAlgorithm
self._alg = alg
# The model this algorithm is going to be added to
self.model = model
# The name of the algorithm in the model, in case we are editing it and not defining it for the first time
self.childId = algName

self._alg = alg # The algorithm to define in this dialog. It is an instance of QgsProcessingAlgorithm
self.model = model # The model this algorithm is going to be added to. It is an instance of QgsProcessingModelAlgorithm
self.childId = algName # The name of the algorithm in the model, in case we are editing it and not defining it for the first time

self.setupUi()
self.params = None
settings = QgsSettings()
Expand Down Expand Up @@ -157,7 +152,7 @@ def setupUi(self):
label = QLabel(dest.description())
item = QgsFilterLineEdit()
if hasattr(item, 'setPlaceholderText'):
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
item.setPlaceholderText(self.tr('[Enter name if this is a final result]'))
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[dest.name()] = item
Expand Down Expand Up @@ -319,8 +314,8 @@ def createAlgorithm(self):
outputs = {}
for dest in self._alg.destinationParameterDefinitions():
if not dest.flags() & QgsProcessingParameterDefinition.FlagHidden:
name = str(self.valueItems[dest.name()].text())
if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
name = self.valueItems[dest.name()].text()
if name.strip() != '':
output = QgsProcessingModelOutput(name, name)
output.setChildId(alg.childId())
output.setChildOutputName(dest.name())
Expand Down

0 comments on commit 5b7b7be

Please sign in to comment.