mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-27 00:03:38 -04:00
[processing] If supported, use memory layers instead of shapefiles
when writing to a temporary result Avoids truncation of field names and other format specific limitations
This commit is contained in:
parent
a064c0a160
commit
001ae44b67
@ -54,6 +54,8 @@ class OutputSelectionPanel(BASE, WIDGET):
|
||||
|
||||
SAVE_TO_TEMP_FILE = QCoreApplication.translate(
|
||||
'OutputSelectionPanel', '[Save to temporary file]')
|
||||
SAVE_TO_TEMP_LAYER = QCoreApplication.translate(
|
||||
'OutputSelectionPanel', '[Create temporary layer]')
|
||||
|
||||
def __init__(self, output, alg):
|
||||
super(OutputSelectionPanel, self).__init__(None)
|
||||
@ -63,6 +65,11 @@ class OutputSelectionPanel(BASE, WIDGET):
|
||||
self.alg = alg
|
||||
|
||||
if hasattr(self.leText, 'setPlaceholderText'):
|
||||
if isinstance(output, OutputVector) \
|
||||
and alg.provider.supportsNonFileBasedOutput():
|
||||
# use memory layers for temporary files if supported
|
||||
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_LAYER)
|
||||
else:
|
||||
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_FILE)
|
||||
|
||||
self.btnSelect.clicked.connect(self.selectOutput)
|
||||
@ -73,6 +80,12 @@ class OutputSelectionPanel(BASE, WIDGET):
|
||||
else:
|
||||
popupMenu = QMenu()
|
||||
|
||||
if isinstance(self.output, OutputVector) \
|
||||
and self.alg.provider.supportsNonFileBasedOutput():
|
||||
# use memory layers for temporary files if supported
|
||||
actionSaveToTempFile = QAction(
|
||||
self.tr('Create temporary layer'), self.btnSelect)
|
||||
else:
|
||||
actionSaveToTempFile = QAction(
|
||||
self.tr('Save to a temporary file'), self.btnSelect)
|
||||
actionSaveToTempFile.triggered.connect(self.saveToTemporaryFile)
|
||||
@ -90,10 +103,6 @@ class OutputSelectionPanel(BASE, WIDGET):
|
||||
|
||||
if isinstance(self.output, OutputVector) \
|
||||
and self.alg.provider.supportsNonFileBasedOutput():
|
||||
actionSaveToMemory = QAction(
|
||||
self.tr('Save to memory layer'), self.btnSelect)
|
||||
actionSaveToMemory.triggered.connect(self.saveToMemory)
|
||||
popupMenu.addAction(actionSaveToMemory)
|
||||
actionSaveToSpatialite = QAction(
|
||||
self.tr('Save to Spatialite table...'), self.btnSelect)
|
||||
actionSaveToSpatialite.triggered.connect(self.saveToSpatialite)
|
||||
@ -188,9 +197,6 @@ class OutputSelectionPanel(BASE, WIDGET):
|
||||
'the_geom' if self.output.hasGeometry() else None)
|
||||
self.leText.setText("spatialite:" + uri.uri())
|
||||
|
||||
def saveToMemory(self):
|
||||
self.leText.setText('memory:')
|
||||
|
||||
def selectFile(self):
|
||||
fileFilter = self.output.getFileFilter(self.alg)
|
||||
|
||||
@ -239,7 +245,12 @@ class OutputSelectionPanel(BASE, WIDGET):
|
||||
fileName = result
|
||||
if fileName.startswith("[") and fileName.endswith("]"):
|
||||
fileName = fileName[1:-1]
|
||||
if fileName.strip() in ['', self.SAVE_TO_TEMP_FILE]:
|
||||
if fileName.strip() in ['', self.SAVE_TO_TEMP_FILE, self.SAVE_TO_TEMP_LAYER]:
|
||||
if isinstance(self.output, OutputVector) \
|
||||
and self.alg.provider.supportsNonFileBasedOutput():
|
||||
# use memory layers for temporary files if supported
|
||||
value = 'memory:'
|
||||
else:
|
||||
value = None
|
||||
elif fileName.startswith('memory:'):
|
||||
value = fileName
|
||||
|
Loading…
x
Reference in New Issue
Block a user