Skip to content
Permalink
Browse files

[processing] Expose correct expression context in Refactor fields alg

  • Loading branch information
nyalldawson committed Feb 19, 2019
1 parent 521ebdc commit 346f33544c716ed881b06a1cf9031e54778a78a2
Showing with 14 additions and 0 deletions.
  1. +14 −0 python/plugins/processing/algs/qgis/ui/FieldsMappingPanel.py
@@ -87,6 +87,7 @@ def __init__(self, parent=None):
self._mapping = []
self._layer = None
self.configure()
self._generator = None

def configure(self):
self.columns = [{
@@ -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()
@@ -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),
@@ -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)
@@ -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)

0 comments on commit 346f335

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