Skip to content
Permalink
Browse files

[processing] better update of expression widget when layer is changed…

… in fields calculator
  • Loading branch information
volaya authored and alexbruy committed Oct 18, 2016
1 parent c0e3b8f commit 128da3002a72b9d88e355ada3087cee25e8dbbdf
Showing with 8 additions and 9 deletions.
  1. +8 −9 python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py
@@ -90,22 +90,21 @@ def manageGui(self):

self.builder.loadRecent('fieldcalc')

self.updateLayer()
self.initContext()

def updateLayer(self):
self.layer = dataobjects.getObject(self.cmbInputLayer.currentText())

self.builder.setLayer(self.layer)
self.builder.loadFieldNames()

exp_context = QgsExpressionContext()
def initContext(self):
exp_context = self.builder.expressionContext()
exp_context.appendScope(QgsExpressionContextUtils.globalScope())
exp_context.appendScope(QgsExpressionContextUtils.projectScope())
exp_context.appendScope(QgsExpressionContextUtils.layerScope(self.layer))
exp_context.lastScope().setVariable("row_number", 1)
exp_context.setHighlightedVariables(["row_number"])
self.builder.setExpressionContext(exp_context)


def updateLayer(self):
self.layer = dataobjects.getObject(self.cmbInputLayer.currentText())
self.builder.setLayer(self.layer)
self.builder.loadFieldNames()
self.populateFields()

def setupSpinboxes(self, index):

0 comments on commit 128da30

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