Skip to content
Permalink
Browse files

GDAL tools: put tif back to top for save file dialog formats (fixes #…

  • Loading branch information
jef-n committed Oct 29, 2014
1 parent 75bfc1b commit ef56c53cc623958e27cad46d49a0e8d23cade69c
@@ -430,6 +430,30 @@ def allRastersFilter(self):

return self.rastersFilter

# Retrieves the filter for supported raster files to save
# Skip *, *.zip and *.vrt and move tif to top
# TODO: only the formats with GDAL_DCAP_CREATE
@classmethod
def saveRastersFilter(self):
# move tif to top if available
available = self.allRastersFilter().split(";;")

filters = []

for f in available:
if "*.tif" in f:
filters.append( f )
break

for f in available:
if "*.tif" in f or "*.zip" in f or "(*)" in f:
continue

filters.append( f )

return ";;".join( filters )


# Retrieves the last used filter for raster files
# Note: filter string is in a list
@classmethod
@@ -112,7 +112,7 @@ def fillInputFileEdit(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if outputFile == '':
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -108,7 +108,7 @@ def fillInputFileEdit(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -118,7 +118,7 @@ def fillInputFile( self ):

def fillOutputFile( self ):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName( self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName( self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )
@@ -113,7 +113,7 @@ def fillInputFileEdit(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -121,7 +121,7 @@ def refreshExtent(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select where to save the Merge output" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select where to save the Merge output" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -73,7 +73,7 @@ def fillInputFileEdit(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -109,7 +109,7 @@ def fillInputFile(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -76,7 +76,7 @@ def fillInputFileEdit(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -96,10 +96,12 @@ def fillOutputFileEdit(self):
gdalVersion = Utils.GdalConfig.versionNum()
if gdalVersion >= 1800:
fileDialogFunc = Utils.FileDialog.getSaveFileName
filters = Utils.FileFilter.saveRastersFilter()
else:
fileDialogFunc = Utils.FileDialog.getOpenFileName
filters = Utils.FileFilter.allRastersFilter()

outputFile = fileDialogFunc(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
outputFile = fileDialogFunc(self, self.tr( "Select the raster file to save the results to" ), filters, lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -106,7 +106,7 @@ def fillInputFile(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -71,7 +71,7 @@ def fillInputFileEdit(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -158,7 +158,7 @@ def fillInputDir( self ):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
@@ -126,7 +126,7 @@ def fillInputFile(self):

def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select the raster file to save the results to" ), Utils.FileFilter.saveRastersFilter(), lastUsedFilter )
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)

0 comments on commit ef56c53

Please sign in to comment.
You can’t perform that action at this time.