Skip to content
Permalink
Browse files
Fix output folder selection for split vector layers tool. Patch from …
…alexbruy. Fixes #2725.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13527 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed May 18, 2010
1 parent 160a65e commit 37a82ab8a5ea0bd4ed6777204ba1ad4d1bc3e305
Showing with 34 additions and 6 deletions.
  1. +3 −3 python/plugins/fTools/tools/doVectorSplit.py
  2. +31 −3 python/plugins/fTools/tools/ftools_utils.py
@@ -84,10 +84,10 @@ def accept(self):

def outFile(self):
self.outShape.clear()
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
if self.shapefileName is None or self.encoding is None:
( self.folderName, self.encoding ) = ftools_utils.dirDialog( self )
if self.folderName is None or self.encoding is None:
return
self.outShape.setText( QString( self.shapefileName ) )
self.outShape.setText( QString( self.folderName ) )

def split(self, vlayer, outPath, inField, progressBar):
provider = vlayer.dataProvider()
@@ -261,12 +261,11 @@ def getUniqueValues( provider, index ):
return values

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

# Generate a save file dialog with a dropdown box for choosing encoding style
def openDialog( parent, filtering="Shapefiles (*.shp)"):
settings = QSettings()
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
encode = settings.value( "/UI/encoding" ).toString()
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode )
fileDialog.setFileMode( QFileDialog.AnyFile )
fileDialog.setAcceptMode( QFileDialog.AcceptOpen )
if not fileDialog.exec_() == QDialog.Accepted:
return None, None
files = fileDialog.selectedFiles()
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )

# Generate a select directory dialog with a dropdown box for choosing encoding style
def dirDialog( parent ):
settings = QSettings()
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
encode = settings.value( "/UI/encoding" ).toString()
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, encode )
fileDialog.setFileMode( QFileDialog.DirectoryOnly )
fileDialog.setAcceptMode( QFileDialog.AcceptSave )
fileDialog.setConfirmOverwrite( False )
if not fileDialog.exec_() == QDialog.Accepted:
return None, None
folders = fileDialog.selectedFiles()
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( folders.first() ) ) ) )
return ( unicode( folders.first() ), unicode( fileDialog.encoding() ) )

# Return field type from it's name
def getFieldType(vlayer, fieldName):
fields = vlayer.dataProvider().fields()

0 comments on commit 37a82ab

Please sign in to comment.