Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Expose correct expression context in Refactor fields alg
  • Loading branch information
nyalldawson committed Feb 19, 2019
1 parent 521ebdc commit 346f335
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/plugins/processing/algs/qgis/ui/FieldsMappingPanel.py
Expand Up @@ -87,6 +87,7 @@ def __init__(self, parent=None):
self._mapping = []
self._layer = None
self.configure()
self._generator = None

def configure(self):
self.columns = [{
Expand Down Expand Up @@ -126,7 +127,12 @@ def setMapping(self, value):
self._mapping = value
self.endResetModel()

def setContextGenerator(self, generator):
self._generator = generator

def contextGenerator(self):
if self._generator:
return self._generator
if self._layer:
return self._layer
return QgsProject.instance()
Expand Down Expand Up @@ -319,6 +325,9 @@ def configure(self):
self.setDelegate('expression', ExpressionDelegate(self))
self.setDelegate('type', FieldTypeDelegate(self))

def setContextGenerator(self, generator):
self.model.setContextGenerator(generator)

def setDelegate(self, column_name, delegate):
self.fieldsView.setItemDelegateForColumn(
self.model.columnIndex(column_name),
Expand Down Expand Up @@ -488,6 +497,8 @@ def createWidget(self):
self.panel = self.createPanel()
self.panel.dialogType = self.dialogType

self.panel.setContextGenerator(self)

if self.dialogType == DIALOG_MODELER:
self.combobox = QComboBox()
self.combobox.addItem(QCoreApplication.translate('Processing', '[Preconfigure]'), None)
Expand Down Expand Up @@ -542,6 +553,9 @@ def setLayer(self, layer):
self._layer = layer
self.panel.setLayer(self._layer)

def linkedVectorLayer(self):
return self._layer

def setValue(self, value):
self.panel.setValue(value)

Expand Down

0 comments on commit 346f335

Please sign in to comment.