Skip to content

Commit

Permalink
Fix output folder selection for split vector layers tool. Patch from …
Browse files Browse the repository at this point in the history
…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 37a82ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
6 changes: 3 additions & 3 deletions python/plugins/fTools/tools/doVectorSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
34 changes: 31 additions & 3 deletions python/plugins/fTools/tools/ftools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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()
Expand Down

0 comments on commit 37a82ab

Please sign in to comment.