@@ -54,6 +54,8 @@ class OutputSelectionPanel(BASE, WIDGET):
54
54
55
55
SAVE_TO_TEMP_FILE = QCoreApplication .translate (
56
56
'OutputSelectionPanel' , '[Save to temporary file]' )
57
+ SAVE_TO_TEMP_LAYER = QCoreApplication .translate (
58
+ 'OutputSelectionPanel' , '[Create temporary layer]' )
57
59
58
60
def __init__ (self , output , alg ):
59
61
super (OutputSelectionPanel , self ).__init__ (None )
@@ -63,7 +65,12 @@ def __init__(self, output, alg):
63
65
self .alg = alg
64
66
65
67
if hasattr (self .leText , 'setPlaceholderText' ):
66
- self .leText .setPlaceholderText (self .SAVE_TO_TEMP_FILE )
68
+ if isinstance (output , OutputVector ) \
69
+ and alg .provider .supportsNonFileBasedOutput ():
70
+ # use memory layers for temporary files if supported
71
+ self .leText .setPlaceholderText (self .SAVE_TO_TEMP_LAYER )
72
+ else :
73
+ self .leText .setPlaceholderText (self .SAVE_TO_TEMP_FILE )
67
74
68
75
self .btnSelect .clicked .connect (self .selectOutput )
69
76
@@ -73,8 +80,14 @@ def selectOutput(self):
73
80
else :
74
81
popupMenu = QMenu ()
75
82
76
- actionSaveToTempFile = QAction (
77
- self .tr ('Save to a temporary file' ), self .btnSelect )
83
+ if isinstance (self .output , OutputVector ) \
84
+ and self .alg .provider .supportsNonFileBasedOutput ():
85
+ # use memory layers for temporary files if supported
86
+ actionSaveToTempFile = QAction (
87
+ self .tr ('Create temporary layer' ), self .btnSelect )
88
+ else :
89
+ actionSaveToTempFile = QAction (
90
+ self .tr ('Save to a temporary file' ), self .btnSelect )
78
91
actionSaveToTempFile .triggered .connect (self .saveToTemporaryFile )
79
92
popupMenu .addAction (actionSaveToTempFile )
80
93
@@ -90,10 +103,6 @@ def selectOutput(self):
90
103
91
104
if isinstance (self .output , OutputVector ) \
92
105
and self .alg .provider .supportsNonFileBasedOutput ():
93
- actionSaveToMemory = QAction (
94
- self .tr ('Save to memory layer' ), self .btnSelect )
95
- actionSaveToMemory .triggered .connect (self .saveToMemory )
96
- popupMenu .addAction (actionSaveToMemory )
97
106
actionSaveToSpatialite = QAction (
98
107
self .tr ('Save to Spatialite table...' ), self .btnSelect )
99
108
actionSaveToSpatialite .triggered .connect (self .saveToSpatialite )
@@ -188,9 +197,6 @@ def saveToSpatialite(self):
188
197
'the_geom' if self .output .hasGeometry () else None )
189
198
self .leText .setText ("spatialite:" + uri .uri ())
190
199
191
- def saveToMemory (self ):
192
- self .leText .setText ('memory:' )
193
-
194
200
def selectFile (self ):
195
201
fileFilter = self .output .getFileFilter (self .alg )
196
202
@@ -239,8 +245,13 @@ def getValue(self):
239
245
fileName = result
240
246
if fileName .startswith ("[" ) and fileName .endswith ("]" ):
241
247
fileName = fileName [1 :- 1 ]
242
- if fileName .strip () in ['' , self .SAVE_TO_TEMP_FILE ]:
243
- value = None
248
+ if fileName .strip () in ['' , self .SAVE_TO_TEMP_FILE , self .SAVE_TO_TEMP_LAYER ]:
249
+ if isinstance (self .output , OutputVector ) \
250
+ and self .alg .provider .supportsNonFileBasedOutput ():
251
+ # use memory layers for temporary files if supported
252
+ value = 'memory:'
253
+ else :
254
+ value = None
244
255
elif fileName .startswith ('memory:' ):
245
256
value = fileName
246
257
elif fileName .startswith ('postgis:' ):
0 commit comments