Skip to content

Commit

Permalink
allow users to enter path to shapefiles manually in Merge shapefiles …
Browse files Browse the repository at this point in the history
…tool (apply #2897)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13963 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
alexbruy committed Jul 25, 2010
1 parent 621698f commit 72c7def
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions python/plugins/fTools/tools/doMergeShapes.py
Expand Up @@ -17,6 +17,7 @@ def __init__( self, iface ):
self.iface = iface

self.mergeThread = None
self.inputFiles = None

self.btnOk = self.buttonBox.button( QDialogButtonBox.Ok )
self.btnClose = self.buttonBox.button( QDialogButtonBox.Close )
Expand All @@ -32,18 +33,18 @@ def inputDir( self ):
if inDir.isEmpty():
return

workDir = QDir( inDir )
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
nameFilter = QStringList() << "*.shp" << "*.SHP"
workDir.setNameFilters( nameFilter )
self.inputFiles = workDir.entryList()
if self.inputFiles.count() == 0:
QMessageBox.warning( self, self.tr( "No shapefiles found" ),
self.tr( "There are no shapefiles in this directory. Please select another one." ) )
self.inputFiles = None
return

self.progressFiles.setRange( 0, self.inputFiles.count() )
#workDir = QDir( inDir )
#workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
#nameFilter = QStringList() << "*.shp" << "*.SHP"
#workDir.setNameFilters( nameFilter )
#self.inputFiles = workDir.entryList()
#if self.inputFiles.count() == 0:
# QMessageBox.warning( self, self.tr( "No shapefiles found" ),
# self.tr( "There are no shapefiles in this directory. Please select another one." ) )
# self.inputFiles = None
# return

#self.progressFiles.setRange( 0, self.inputFiles.count() )
self.leInputDir.setText( inDir )

def outFile( self ):
Expand All @@ -56,6 +57,20 @@ def reject( self ):
QDialog.reject( self )

def accept( self ):
if self.inputFiles is None:
workDir = QDir( self.leInputDir.text() )
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
nameFilter = QStringList() << "*.shp" << "*.SHP"
workDir.setNameFilters( nameFilter )
self.inputFiles = workDir.entryList()
if self.inputFiles.count() == 0:
QMessageBox.warning( self, self.tr( "No shapefiles found" ),
self.tr( "There are no shapefiles in this directory. Please select another one." ) )
self.inputFiles = None
return

self.progressFiles.setRange( 0, self.inputFiles.count() )

outFile = QFile( self.outFileName )
if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile( self.outFileName ):
Expand Down

0 comments on commit 72c7def

Please sign in to comment.