Skip to content

Commit a7a8a29

Browse files
author
cfarmer
committedMay 18, 2010
Fix output folder selection for split vector layers tool. Patch from alexbruy. Fixes #2725.
git-svn-id: http://svn.osgeo.org/qgis/trunk@13527 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 0d26280 commit a7a8a29

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed
 

‎python/plugins/fTools/tools/doVectorSplit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ def accept(self):
8484

8585
def outFile(self):
8686
self.outShape.clear()
87-
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
88-
if self.shapefileName is None or self.encoding is None:
87+
( self.folderName, self.encoding ) = ftools_utils.dirDialog( self )
88+
if self.folderName is None or self.encoding is None:
8989
return
90-
self.outShape.setText( QString( self.shapefileName ) )
90+
self.outShape.setText( QString( self.folderName ) )
9191

9292
def split(self, vlayer, outPath, inField, progressBar):
9393
provider = vlayer.dataProvider()

‎python/plugins/fTools/tools/ftools_utils.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,11 @@ def getUniqueValues( provider, index ):
261261
return values
262262

263263
# Generate a save file dialog with a dropdown box for choosing encoding style
264-
def saveDialog( parent ):
264+
def saveDialog( parent, filtering="Shapefiles (*.shp)"):
265265
settings = QSettings()
266266
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
267-
filtering = QString( "Shapefiles (*.shp)" )
268267
encode = settings.value( "/UI/encoding" ).toString()
269-
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, filtering, encode )
268+
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode )
270269
fileDialog.setDefaultSuffix( QString( "shp" ) )
271270
fileDialog.setFileMode( QFileDialog.AnyFile )
272271
fileDialog.setAcceptMode( QFileDialog.AcceptSave )
@@ -277,6 +276,35 @@ def saveDialog( parent ):
277276
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
278277
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )
279278

279+
# Generate a save file dialog with a dropdown box for choosing encoding style
280+
def openDialog( parent, filtering="Shapefiles (*.shp)"):
281+
settings = QSettings()
282+
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
283+
encode = settings.value( "/UI/encoding" ).toString()
284+
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode )
285+
fileDialog.setFileMode( QFileDialog.AnyFile )
286+
fileDialog.setAcceptMode( QFileDialog.AcceptOpen )
287+
if not fileDialog.exec_() == QDialog.Accepted:
288+
return None, None
289+
files = fileDialog.selectedFiles()
290+
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
291+
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )
292+
293+
# Generate a select directory dialog with a dropdown box for choosing encoding style
294+
def dirDialog( parent ):
295+
settings = QSettings()
296+
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
297+
encode = settings.value( "/UI/encoding" ).toString()
298+
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, encode )
299+
fileDialog.setFileMode( QFileDialog.DirectoryOnly )
300+
fileDialog.setAcceptMode( QFileDialog.AcceptSave )
301+
fileDialog.setConfirmOverwrite( False )
302+
if not fileDialog.exec_() == QDialog.Accepted:
303+
return None, None
304+
folders = fileDialog.selectedFiles()
305+
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( folders.first() ) ) ) )
306+
return ( unicode( folders.first() ), unicode( fileDialog.encoding() ) )
307+
280308
# Return field type from it's name
281309
def getFieldType(vlayer, fieldName):
282310
fields = vlayer.dataProvider().fields()

0 commit comments

Comments
 (0)
Please sign in to comment.