Skip to content

Commit e484500

Browse files
committed
[processing] enable temporary outputs in QGIS Field Calculator (fix #9401)
1 parent aefc892 commit e484500

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

python/plugins/processing/algs/FieldsCalculator.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from processing.parameters.ParameterBoolean import ParameterBoolean
3838
from processing.parameters.ParameterSelection import ParameterSelection
3939
from processing.outputs.OutputVector import OutputVector
40-
from processing.tools import dataobjects, vector
40+
from processing.tools import dataobjects, vector, system
4141

4242
from processing.algs.ui.FieldsCalculatorDialog import FieldsCalculatorDialog
4343

@@ -85,6 +85,10 @@ def processAlgorithm(self, progress):
8585

8686
output = self.getOutputFromName(self.OUTPUT_LAYER)
8787

88+
if output.value == '':
89+
ext = output.getDefaultFileExtension(self)
90+
output.value = system.getTempFilenameInTempFolder(output.name + '.' + ext)
91+
8892
provider = layer.dataProvider()
8993
fields = layer.pendingFields()
9094
if newField:
@@ -143,7 +147,6 @@ def processAlgorithm(self, progress):
143147
'An error occured while evaluating the calculation '
144148
'string:\n' + error)
145149

146-
147150
def checkParameterValuesBeforeExecuting(self):
148151
newField = self.getParameterValue(self.NEW_FIELD)
149152
fieldName = self.getParameterValue(self.FIELD_NAME)
@@ -156,6 +159,5 @@ def checkParameterValuesBeforeExecuting(self):
156159
raise GeoAlgorithmExecutionException('Output is not set. '
157160
'Please specify valid filename')
158161

159-
160162
def getCustomParametersDialog(self):
161163
return FieldsCalculatorDialog(self)

python/plugins/processing/algs/ui/FieldsCalculatorDialog.py

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def __init__(self, alg):
7171
self.manageGui()
7272

7373
def manageGui(self):
74+
if hasattr(self.leOutputFile, 'setPlaceholderText'):
75+
self.leOutputFile.setPlaceholderText(
76+
self.tr('[Save to temporary file]'))
77+
7478
self.mOutputFieldTypeComboBox.blockSignals(True)
7579
for t in self.alg.TYPE_NAMES:
7680
self.mOutputFieldTypeComboBox.addItem(t)

0 commit comments

Comments
 (0)