Navigation Menu

Skip to content

Commit

Permalink
[processing] enable temporary outputs in QGIS Field Calculator (fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 26, 2014
1 parent aefc892 commit e484500
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/plugins/processing/algs/FieldsCalculator.py
Expand Up @@ -37,7 +37,7 @@
from processing.parameters.ParameterBoolean import ParameterBoolean
from processing.parameters.ParameterSelection import ParameterSelection
from processing.outputs.OutputVector import OutputVector
from processing.tools import dataobjects, vector
from processing.tools import dataobjects, vector, system

from processing.algs.ui.FieldsCalculatorDialog import FieldsCalculatorDialog

Expand Down Expand Up @@ -85,6 +85,10 @@ def processAlgorithm(self, progress):

output = self.getOutputFromName(self.OUTPUT_LAYER)

if output.value == '':
ext = output.getDefaultFileExtension(self)
output.value = system.getTempFilenameInTempFolder(output.name + '.' + ext)

provider = layer.dataProvider()
fields = layer.pendingFields()
if newField:
Expand Down Expand Up @@ -143,7 +147,6 @@ def processAlgorithm(self, progress):
'An error occured while evaluating the calculation '
'string:\n' + error)


def checkParameterValuesBeforeExecuting(self):
newField = self.getParameterValue(self.NEW_FIELD)
fieldName = self.getParameterValue(self.FIELD_NAME)
Expand All @@ -156,6 +159,5 @@ def checkParameterValuesBeforeExecuting(self):
raise GeoAlgorithmExecutionException('Output is not set. '
'Please specify valid filename')


def getCustomParametersDialog(self):
return FieldsCalculatorDialog(self)
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/ui/FieldsCalculatorDialog.py
Expand Up @@ -71,6 +71,10 @@ def __init__(self, alg):
self.manageGui()

def manageGui(self):
if hasattr(self.leOutputFile, 'setPlaceholderText'):
self.leOutputFile.setPlaceholderText(
self.tr('[Save to temporary file]'))

self.mOutputFieldTypeComboBox.blockSignals(True)
for t in self.alg.TYPE_NAMES:
self.mOutputFieldTypeComboBox.addItem(t)
Expand Down

0 comments on commit e484500

Please sign in to comment.