[QGIS Commit] r13527 - trunk/qgis/python/plugins/fTools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue May 18 15:01:39 EDT 2010


Author: cfarmer
Date: 2010-05-18 15:01:38 -0400 (Tue, 18 May 2010)
New Revision: 13527

Modified:
   trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py
   trunk/qgis/python/plugins/fTools/tools/ftools_utils.py
Log:
Fix output folder selection for split vector layers tool. Patch from alexbruy. Fixes #2725.

Modified: trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py	2010-05-18 15:18:35 UTC (rev 13526)
+++ trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py	2010-05-18 19:01:38 UTC (rev 13527)
@@ -84,10 +84,10 @@
 
     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()

Modified: trunk/qgis/python/plugins/fTools/tools/ftools_utils.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/ftools_utils.py	2010-05-18 15:18:35 UTC (rev 13526)
+++ trunk/qgis/python/plugins/fTools/tools/ftools_utils.py	2010-05-18 19:01:38 UTC (rev 13527)
@@ -261,12 +261,11 @@
     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 @@
     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()



More information about the QGIS-commit mailing list