Skip to content

Commit

Permalink
[processing] changes to allow custom parameter dialog adapt to new pa…
Browse files Browse the repository at this point in the history
…rameter architecture
  • Loading branch information
volaya committed Oct 5, 2016
1 parent dfb4cdd commit c491c01
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def __init__(self, alg):
AlgorithmDialogBase.__init__(self, alg)

self.alg = alg

self.mainWidget = GdalParametersPanel(self, alg)
self.setMainWidget()

self.setMainWidget(GdalParametersPanel(self, alg))

cornerWidget = QWidget()
layout = QVBoxLayout()
Expand All @@ -56,10 +55,6 @@ def __init__(self, alg):

self.mainWidget.parametersHaveChanged()

QgsMapLayerRegistry.instance().layerWasAdded.connect(self.mainWidget.layerAdded)
QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.mainWidget.layersWillBeRemoved)


class GdalParametersPanel(ParametersPanel):

def __init__(self, parent, alg):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def __init__(self, alg):

self.alg = alg

self.mainWidget = FieldsMapperParametersPanel(self, alg)
self.setMainWidget()
self.setMainWidget(FieldsMapperParametersPanel(self, alg))

def setParamValue(self, param, widget, alg=None):
if isinstance(param, ParameterFieldsMapping):
Expand Down
5 changes: 1 addition & 4 deletions python/plugins/processing/gui/AlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def __init__(self, alg):

self.alg = alg

self.mainWidget = ParametersPanel(self, alg)
self.setMainWidget()
self.setMainWidget(ParametersPanel(self, alg))

self.cornerWidget = QWidget()
layout = QVBoxLayout()
Expand All @@ -82,8 +81,6 @@ def __init__(self, alg):
self.cornerWidget.setLayout(layout)
self.tabWidget.setCornerWidget(self.cornerWidget)

QgsMapLayerRegistry.instance().layerWasAdded.connect(self.mainWidget.layerRegistryChanged)
QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.mainWidget.layerRegistryChanged)

def runAsBatch(self):
self.close()
Expand Down
11 changes: 9 additions & 2 deletions python/plugins/processing/gui/AlgorithmDialogBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply

from qgis.utils import iface
from qgis.core import QgsNetworkAccessManager
from qgis.core import QgsNetworkAccessManager, QgsMapLayerRegistry

from processing.core.ProcessingConfig import ProcessingConfig

Expand Down Expand Up @@ -122,8 +122,15 @@ def closeEvent(self, evt):
self.settings.setValue("/Processing/dialogBase", self.saveGeometry())
super(AlgorithmDialogBase, self).closeEvent(evt)

def setMainWidget(self):
def setMainWidget(self, widget):
if self.mainWidget is not None:
QgsMapLayerRegistry.instance().layerWasAdded.disconnect(self.mainWidget.layerRegistryChanged)
QgsMapLayerRegistry.instance().layersWillBeRemoved.disconnect(self.mainWidget.layerRegistryChanged)
self.mainWidget = widget
self.tabWidget.widget(0).layout().addWidget(self.mainWidget)
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.mainWidget.layerRegistryChanged)
QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.mainWidget.layerRegistryChanged)


def error(self, msg):
QApplication.restoreOverrideCursor()
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/processing/gui/BatchAlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def __init__(self, alg):

self.setWindowTitle(self.tr('Batch Processing - %s') % self.alg.name)

self.mainWidget = BatchPanel(self, self.alg)
self.setMainWidget()
self.setMainWidget(BatchPanel(self, self.alg))

self.textShortHelp.setVisible(False)

Expand Down
4 changes: 4 additions & 0 deletions python/plugins/processing/gui/BatchPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def __init__(self, parent, alg):
self.fillParameterValues)

self.initWidgets()


def layerRegistryChanged(self):
pass

def initWidgets(self):
# If there are advanced parameters — show corresponding button
Expand Down

0 comments on commit c491c01

Please sign in to comment.