36
36
from qgis .gui import QgsEncodingFileDialog , QgsExpressionBuilderDialog
37
37
from qgis .core import (QgsDataSourceUri ,
38
38
QgsCredentials ,
39
- QgsSettings )
39
+ QgsSettings ,
40
+ QgsProcessingOutputVectorLayer )
40
41
from processing .core .ProcessingConfig import ProcessingConfig
41
42
from processing .core .outputs import OutputVector
42
43
from processing .core .outputs import OutputDirectory
47
48
os .path .join (pluginPath , 'ui' , 'widgetBaseSelector.ui' ))
48
49
49
50
50
- class OutputSelectionPanel (BASE , WIDGET ):
51
+ class DestinationSelectionPanel (BASE , WIDGET ):
51
52
52
53
SAVE_TO_TEMP_FILE = QCoreApplication .translate (
53
- 'OutputSelectionPanel ' , '[Save to temporary file]' )
54
+ 'DestinationSelectionPanel ' , '[Save to temporary file]' )
54
55
SAVE_TO_TEMP_LAYER = QCoreApplication .translate (
55
- 'OutputSelectionPanel ' , '[Create temporary layer]' )
56
+ 'DestinationSelectionPanel ' , '[Create temporary layer]' )
56
57
57
- def __init__ (self , output , alg ):
58
- super (OutputSelectionPanel , self ).__init__ (None )
58
+ def __init__ (self , parameter , alg ):
59
+ super (DestinationSelectionPanel , self ).__init__ (None )
59
60
self .setupUi (self )
60
61
61
- self .output = output
62
+ self .parameter = parameter
62
63
self .alg = alg
63
64
64
65
if hasattr (self .leText , 'setPlaceholderText' ):
65
- if isinstance (output , OutputVector ) \
66
+ if isinstance (self . parameter , QgsProcessingOutputVectorLayer ) \
66
67
and alg .provider ().supportsNonFileBasedOutput ():
67
68
# use memory layers for temporary files if supported
68
69
self .leText .setPlaceholderText (self .SAVE_TO_TEMP_LAYER )
@@ -72,12 +73,12 @@ def __init__(self, output, alg):
72
73
self .btnSelect .clicked .connect (self .selectOutput )
73
74
74
75
def selectOutput (self ):
75
- if isinstance (self .output , OutputDirectory ):
76
+ if isinstance (self .parameter , OutputDirectory ):
76
77
self .selectDirectory ()
77
78
else :
78
79
popupMenu = QMenu ()
79
80
80
- if isinstance (self .output , OutputVector ) \
81
+ if isinstance (self .parameter , QgsProcessingOutputVectorLayer ) \
81
82
and self .alg .provider ().supportsNonFileBasedOutput ():
82
83
# use memory layers for temporary layers if supported
83
84
actionSaveToTemp = QAction (
@@ -98,7 +99,7 @@ def selectOutput(self):
98
99
actionShowExpressionsBuilder .triggered .connect (self .showExpressionsBuilder )
99
100
popupMenu .addAction (actionShowExpressionsBuilder )
100
101
101
- if isinstance (self .output , OutputVector ) \
102
+ if isinstance (self .parameter , QgsProcessingOutputVectorLayer ) \
102
103
and self .alg .provider ().supportsNonFileBasedOutput ():
103
104
actionSaveToSpatialite = QAction (
104
105
self .tr ('Save to Spatialite table...' ), self .btnSelect )
@@ -118,7 +119,7 @@ def selectOutput(self):
118
119
119
120
def showExpressionsBuilder (self ):
120
121
dlg = QgsExpressionBuilderDialog (None , self .leText .text (), self , 'generic' ,
121
- self .output .expressionContext (self .alg ))
122
+ self .parameter .expressionContext (self .alg ))
122
123
dlg .setWindowTitle (self .tr ('Expression based output' ))
123
124
if dlg .exec_ () == QDialog .Accepted :
124
125
self .leText .setText (dlg .expressionText ())
@@ -127,7 +128,7 @@ def saveToTemporary(self):
127
128
self .leText .setText ('' )
128
129
129
130
def saveToPostGIS (self ):
130
- dlg = PostgisTableSelector (self , self .output .name .lower ())
131
+ dlg = PostgisTableSelector (self , self .parameter .name () .lower ())
131
132
dlg .exec_ ()
132
133
if dlg .connection :
133
134
settings = QgsSettings ()
@@ -140,7 +141,7 @@ def saveToPostGIS(self):
140
141
uri = QgsDataSourceUri ()
141
142
uri .setConnection (host , str (port ), dbname , user , password )
142
143
uri .setDataSource (dlg .schema , dlg .table ,
143
- "the_geom" if self .output .hasGeometry () else None )
144
+ "the_geom" if self .parameter .hasGeometry () else None )
144
145
145
146
connInfo = uri .connectionInfo ()
146
147
(success , user , passwd ) = QgsCredentials .instance ().get (connInfo , None , None )
@@ -149,7 +150,7 @@ def saveToPostGIS(self):
149
150
self .leText .setText ("postgis:" + uri .uri ())
150
151
151
152
def saveToSpatialite (self ):
152
- fileFilter = self .output . tr ('SpatiaLite files (*.sqlite)' , 'OutputFile' )
153
+ fileFilter = self .tr ('SpatiaLite files (*.sqlite)' , 'OutputFile' )
153
154
154
155
settings = QgsSettings ()
155
156
if settings .contains ('/Processing/LastOutputPath' ):
@@ -167,7 +168,7 @@ def saveToSpatialite(self):
167
168
if fileDialog .exec_ () == QDialog .Accepted :
168
169
files = fileDialog .selectedFiles ()
169
170
encoding = str (fileDialog .encoding ())
170
- self .output .encoding = encoding
171
+ self .parameter .encoding = encoding
171
172
fileName = str (files [0 ])
172
173
selectedFileFilter = str (fileDialog .selectedNameFilter ())
173
174
if not fileName .lower ().endswith (
@@ -181,12 +182,12 @@ def saveToSpatialite(self):
181
182
182
183
uri = QgsDataSourceUri ()
183
184
uri .setDatabase (fileName )
184
- uri .setDataSource ('' , self .output .name .lower (),
185
- 'the_geom' if self .output .hasGeometry () else None )
185
+ uri .setDataSource ('' , self .parameter .name () .lower (),
186
+ 'the_geom' if self .parameter .hasGeometry () else None )
186
187
self .leText .setText ("spatialite:" + uri .uri ())
187
188
188
189
def selectFile (self ):
189
- fileFilter = self .output .getFileFilter (self .alg )
190
+ fileFilter = self .parameter .getFileFilter (self .alg )
190
191
191
192
settings = QgsSettings ()
192
193
if settings .contains ('/Processing/LastOutputPath' ):
@@ -204,7 +205,7 @@ def selectFile(self):
204
205
if fileDialog .exec_ () == QDialog .Accepted :
205
206
files = fileDialog .selectedFiles ()
206
207
encoding = str (fileDialog .encoding ())
207
- self .output .encoding = encoding
208
+ self .parameter .encoding = encoding
208
209
fileName = str (files [0 ])
209
210
selectedFileFilter = str (fileDialog .selectedNameFilter ())
210
211
if not fileName .lower ().endswith (
0 commit comments