Skip to content

Commit 5773d0d

Browse files
committed
[processing] fixes and better warning messages in modeler
1 parent 797826e commit 5773d0d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

python/plugins/processing/modeler/ModelerParametersDialog.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
***************************************************************************
1818
"""
1919

20+
2021
__author__ = 'Victor Olaya'
2122
__date__ = 'August 2012'
2223
__copyright__ = '(C) 2012, Victor Olaya'
@@ -29,11 +30,14 @@
2930
from qgis.PyQt.QtWidgets import (QDialog, QDialogButtonBox, QLabel, QLineEdit,
3031
QFrame, QPushButton, QSizePolicy, QVBoxLayout,
3132
QHBoxLayout, QTabWidget, QWidget, QScrollArea,
32-
QComboBox, QTableWidgetItem, QMessageBox)
33+
QComboBox, QTableWidgetItem, QMessageBox,
34+
QTextBrowser)
3335
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply
3436

3537
from qgis.core import QgsNetworkAccessManager
3638

39+
from qgis.gui import QgsMessageBar
40+
3741
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
3842
from processing.gui.MultipleInputPanel import MultipleInputPanel
3943
from processing.gui.FixedTablePanel import FixedTablePanel
@@ -82,13 +86,13 @@ class ModelerParametersDialog(QDialog):
8286
def __init__(self, alg, model, algName=None):
8387
QDialog.__init__(self)
8488
self.setModal(True)
85-
#The algorithm to define in this dialog. It is an instance of GeoAlgorithm
89+
# The algorithm to define in this dialog. It is an instance of GeoAlgorithm
8690
self._alg = alg
87-
#The resulting algorithm after the user clicks on OK. it is an instance of the container Algorithm class
91+
# The resulting algorithm after the user clicks on OK. it is an instance of the container Algorithm class
8892
self.alg = None
89-
#The model this algorithm is going to be added to
93+
# The model this algorithm is going to be added to
9094
self.model = model
91-
#The name of the algorithm in the model, in case we are editing it and not defining it for the first time
95+
# The name of the algorithm in the model, in case we are editing it and not defining it for the first time
9296
self._algName = algName
9397
self.setupUi()
9498
self.params = None
@@ -112,6 +116,10 @@ def setupUi(self):
112116
self.verticalLayout.setSpacing(5)
113117
self.verticalLayout.setMargin(20)
114118

119+
self.bar = QgsMessageBar()
120+
self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
121+
self.verticalLayout.addWidget(self.bar)
122+
115123
hLayout = QHBoxLayout()
116124
hLayout.setSpacing(5)
117125
hLayout.setMargin(0)
@@ -203,7 +211,6 @@ def setupUi(self):
203211
self.txtHelp = QTextBrowser()
204212

205213
html = None
206-
url = None
207214
isText, algHelp = self._alg.help()
208215
if algHelp is not None:
209216
algHelp = algHelp if isText else QUrl(algHelp)
@@ -526,6 +533,8 @@ def createAlgorithm(self):
526533
if param.hidden:
527534
continue
528535
if not self.setParamValue(alg, param, self.valueItems[param.name]):
536+
self.bar.pushMessage("Error", "Wrong or missing value for parameter '%s'" % param.description,
537+
level=QgsMessageBar.WARNING)
529538
return None
530539
for output in outputs:
531540
if not output.hidden:
@@ -732,9 +741,7 @@ def okPressed(self):
732741
self.alg = self.createAlgorithm()
733742
if self.alg is not None:
734743
self.close()
735-
else:
736-
QMessageBox.warning(self, self.tr('Unable to add algorithm'),
737-
self.tr('Wrong or missing parameter values'))
744+
738745

739746
def cancelPressed(self):
740747
self.alg = None

0 commit comments

Comments
 (0)