Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
create VRT with recurse scan of dirs, to fix #3095
some code cleanup, 
updated labels when in batch mode to follow up the QGis HIG guideline


git-svn-id: http://svn.osgeo.org/qgis/trunk@14963 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler committed Dec 22, 2010
1 parent 9673931 commit 6fcb671
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 223 deletions.
26 changes: 26 additions & 0 deletions python/plugins/GdalTools/tools/GdalTools_utils.py
Expand Up @@ -117,6 +117,32 @@ def getVectorLayers():
count = count +1
return (layers, names)

def getRasterFiles(path, recursive=False):
rasters = QStringList()
if not QFileInfo(path).exists():
return rasters

filter = getRasterExtensions()
workDir = QDir( path )
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
workDir.setNameFilters( filter )
files = workDir.entryList()
for f in files:
rasters << path + "/" + f

if recursive:
import os
for myRoot, myDirs, myFiles in os.walk( unicode(path) ):
for dir in myDirs:
workDir = QDir( myRoot + "/" + dir )
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
workDir.setNameFilters( filter )
workFiles = workDir.entryList()
for f in workFiles:
rasters << myRoot + "/" + dir + "/" + f

return rasters

def fillRasterOutputFormat(aFilter = None, filename = None):
shortName = QString()

Expand Down
38 changes: 36 additions & 2 deletions python/plugins/GdalTools/tools/doBuildVRT.py
Expand Up @@ -18,18 +18,42 @@ def __init__(self, iface):
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdalbuildvrt")

self.recurseCheck.hide()

self.setParamsStatus(
[
(self.inputFilesEdit, SIGNAL("textChanged(const QString &)")),
(self.outputFileEdit, SIGNAL("textChanged(const QString &)")),
(self.resolutionComboBox, SIGNAL("currentIndexChanged(int)"), self.resolutionCheck),
(self.srcNoDataSpin, SIGNAL("valueChanged(int)"), self.srcNoDataCheck, "1.7.0"),
(self.separateCheck, SIGNAL("stateChanged(int)"), None, "1.7.0")
(self.separateCheck, SIGNAL("stateChanged(int)"), None, "1.7.0"),
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck)
]
)

self.connect(self.selectInputFilesButton, SIGNAL("clicked()"), self.fillInputFilesEdit)
self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
self.connect( self.inputDirCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )

def switchToolMode(self):
self.inputFilesEdit.clear()

if self.inputDirCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText( QCoreApplication.translate( "GdalTools", "&Input directory" ) )

self.recurseCheck.show()

QObject.disconnect( self.selectInputFilesButton, SIGNAL( "clicked()" ), self.fillInputFilesEdit )
QObject.connect( self.selectInputFilesButton, SIGNAL( "clicked()" ), self.fillInputDir )
else:
self.label.setText( self.inFileLabel )

self.recurseCheck.hide()

QObject.connect( self.selectInputFilesButton, SIGNAL( "clicked()" ), self.fillInputFilesEdit )
QObject.disconnect( self.selectInputFilesButton, SIGNAL( "clicked()" ), self.fillInputDir )

def fillInputFilesEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
Expand All @@ -47,6 +71,13 @@ def fillOutputFileEdit(self):

self.outputFileEdit.setText(outputFile)

def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files for VRT" ))
if inputDir.isEmpty():
return

self.inputFilesEdit.setText( inputDir )

def getArguments(self):
arguments = QStringList()
if self.resolutionCheck.isChecked() and self.resolutionComboBox.currentIndex() >= 0:
Expand All @@ -58,7 +89,10 @@ def getArguments(self):
arguments << "-srcnodata"
arguments << str(self.srcNoDataSpin.value())
arguments << self.outputFileEdit.text()
arguments << self.inputFilesEdit.text().split(",")
if self.inputDirCheck.isChecked():
arguments << Utils.getRasterFiles( self.inputFilesEdit.text(), self.recurseCheck.isChecked() )
else:
arguments << self.inputFilesEdit.text().split(",")
return arguments

def getOutputFileName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doOverview.py
Expand Up @@ -56,7 +56,7 @@ def switchToolMode( self ):
self.inputLayerCombo.setCurrentIndex(-1)
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText( QCoreApplication.translate( "GdalTools", "&Input directory:" ) )
self.label.setText( QCoreApplication.translate( "GdalTools", "&Input directory" ) )

self.progressBar.show()

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/GdalTools/tools/doPctRgb.py
Expand Up @@ -53,8 +53,8 @@ def switchToolMode( self ):
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.outFileLabel = self.label_2.text()
self.label.setText( QCoreApplication.translate( "GdalTools", "&Input directory:" ) )
self.label_2.setText( QCoreApplication.translate( "GdalTools", "&Output directory:" ) )
self.label.setText( QCoreApplication.translate( "GdalTools", "&Input directory" ) )
self.label_2.setText( QCoreApplication.translate( "GdalTools", "&Output directory" ) )

self.progressBar.show()

Expand Down

0 comments on commit 6fcb671

Please sign in to comment.