Skip to content
Permalink
Browse files

[processing] changes to allow custom parameter dialog adapt to new pa…

…rameter architecture
  • Loading branch information
volaya committed Oct 5, 2016
1 parent dfb4cdd commit c491c012664aa0d5a7836a0f6c4ada0f7d8d95eb
@@ -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()
@@ -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):
@@ -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):
@@ -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()
@@ -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()
@@ -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

@@ -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()
@@ -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)

@@ -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

0 comments on commit c491c01

Please sign in to comment.
You can’t perform that action at this time.