Skip to content

Commit

Permalink
GDAL tools: put tif back to top for save file dialog formats (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Oct 29, 2014
1 parent 75bfc1b commit ef56c53
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 13 deletions.
24 changes: 24 additions & 0 deletions python/plugins/GdalTools/tools/GdalTools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doClipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doDEM.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doFillNodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doMerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doNearBlack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doPctRgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doProximity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/GdalTools/tools/doRasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doRgbPct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doSieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doTranslate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/doWarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ef56c53

Please sign in to comment.