Skip to content

Commit

Permalink
[processing][gdal] Fix gdal command does not automatically update
Browse files Browse the repository at this point in the history
when destination value is changed
  • Loading branch information
nyalldawson committed May 29, 2018
1 parent ad1fef9 commit ff7c70f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py
Expand Up @@ -48,6 +48,7 @@
from processing.gui.ParametersPanel import ParametersPanel
from processing.gui.MultipleInputPanel import MultipleInputPanel
from processing.gui.NumberInputPanel import NumberInputPanel
from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel
from processing.tools.dataobjects import createContext


Expand Down Expand Up @@ -88,6 +89,8 @@ def connectParameterSignals(self):
self.connectWidgetChangedSignals(w)
for c in w.findChildren(QWidget):
self.connectWidgetChangedSignals(c)
for output_widget in self.outputWidgets.values():
self.connectWidgetChangedSignals(output_widget)

def connectWidgetChangedSignals(self, w):
if isinstance(w, QLineEdit):
Expand All @@ -102,6 +105,8 @@ def connectWidgetChangedSignals(self, w):
w.selectionChanged.connect(self.parametersHaveChanged)
elif isinstance(w, NumberInputPanel):
w.hasChanged.connect(self.parametersHaveChanged)
elif isinstance(w, DestinationSelectionPanel):
w.destinationChanged.connect(self.parametersHaveChanged)

def parametersHaveChanged(self):
context = createContext()
Expand Down
11 changes: 11 additions & 0 deletions python/plugins/processing/gui/DestinationSelectionPanel.py
Expand Up @@ -67,6 +67,7 @@ class DestinationSelectionPanel(BASE, WIDGET):
'DestinationSelectionPanel', '[Skip output]')

skipOutputChanged = pyqtSignal(bool)
destinationChanged = pyqtSignal()

def __init__(self, parameter, alg, default_selection=False):
super(DestinationSelectionPanel, self).__init__(None)
Expand All @@ -86,6 +87,7 @@ def __init__(self, parameter, alg, default_selection=False):

def textChanged(self):
self.use_temporary = False
self.destinationChanged.emit()

def outputIsSkipped(self):
"""
Expand All @@ -98,6 +100,7 @@ def skipOutput(self):
self.leText.setText('')
self.use_temporary = False
self.skipOutputChanged.emit(True)
self.destinationChanged.emit()

def selectOutput(self):
if isinstance(self.parameter, QgsProcessingParameterFolderDestination):
Expand Down Expand Up @@ -159,6 +162,7 @@ def saveToTemporary(self):
self.leText.setText('')
self.use_temporary = True
self.skipOutputChanged.emit(False)
self.destinationChanged.emit()

def saveToPostGIS(self):
dlg = PostgisTableSelector(self, self.parameter.name().lower())
Expand All @@ -184,6 +188,7 @@ def saveToPostGIS(self):
self.leText.setText("postgis:" + uri.uri())

self.skipOutputChanged.emit(False)
self.destinationChanged.emit()

def saveToGeopackage(self):
file_filter = self.tr('GeoPackage files (*.gpkg);;All files (*.*)', 'OutputFile')
Expand Down Expand Up @@ -215,6 +220,7 @@ def saveToGeopackage(self):
self.leText.setText("ogr:" + uri.uri())

self.skipOutputChanged.emit(False)
self.destinationChanged.emit()

def selectFile(self):
file_filter = getFileFilter(self.parameter)
Expand Down Expand Up @@ -257,6 +263,7 @@ def selectFile(self):
settings.setValue(last_ext_path, os.path.splitext(filename)[1].lower())

self.skipOutputChanged.emit(False)
self.destinationChanged.emit()

def selectEncoding(self):
dialog = QgsEncodingSelectionDialog(
Expand All @@ -265,6 +272,7 @@ def selectEncoding(self):
self.encoding = dialog.encoding()
settings = QgsSettings()
settings.setValue('/Processing/encoding', self.encoding)
self.destinationChanged.emit()
dialog.deleteLater()

def selectDirectory(self):
Expand All @@ -280,6 +288,7 @@ def selectDirectory(self):
settings.setValue('/Processing/LastOutputPath', dirName)

self.skipOutputChanged.emit(False)
self.destinationChanged.emit()

def setValue(self, value):
if not value:
Expand All @@ -298,11 +307,13 @@ def setValue(self, value):
self.leText.setText(value.sink.staticValue())
self.use_temporary = False
self.skipOutputChanged.emit(False)
self.destinationChanged.emit()
self.encoding = value.createOptions['fileEncoding']
else:
self.leText.setText(value)
self.use_temporary = False
self.skipOutputChanged.emit(False)
self.destinationChanged.emit()

def getValue(self):
key = None
Expand Down

0 comments on commit ff7c70f

Please sign in to comment.