Skip to content

Commit

Permalink
[processing] better update of expression widget when layer is changed…
Browse files Browse the repository at this point in the history
… in fields calculator
  • Loading branch information
volaya committed Sep 29, 2016
1 parent 5191d0c commit b01d3b0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,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):
Expand Down

0 comments on commit b01d3b0

Please sign in to comment.