-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
…for GDALTools Build Virtual Raster
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from PyQt4.QtGui import * | ||
from qgis.core import * | ||
from qgis.gui import * | ||
from qgis.utils import * | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
from ui_widgetBuildVRT import Ui_GdalToolsWidget as Ui_Widget | ||
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget | ||
|
@@ -38,6 +39,7 @@ def __init__(self, iface): | |
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit) | ||
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit) | ||
self.connect( self.inputDirCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode ) | ||
self.connect( self.useSelectedLayersCheck, SIGNAL( "stateChanged( int )" ), self.switchLayerMode ) | ||
|
||
def switchToolMode(self): | ||
self.recurseCheck.setVisible( self.inputDirCheck.isChecked() ) | ||
|
@@ -55,6 +57,12 @@ def switchToolMode(self): | |
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit) | ||
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir) | ||
|
||
def switchLayerMode(self): | ||
enableInputFiles = not self.useSelectedLayersCheck.isChecked() | ||
self.inputDirCheck.setEnabled( enableInputFiles ) | ||
self.inSelector.setEnabled( enableInputFiles ) | ||
self.recurseCheck.setEnabled( enableInputFiles ) | ||
|
||
def fillInputFilesEdit(self): | ||
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() | ||
files = Utils.FileDialog.getOpenFileNames(self, self.tr( "Select the files for VRT" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter) | ||
|
@@ -88,10 +96,13 @@ def getArguments(self): | |
if self.allowProjDiffCheck.isChecked(): | ||
arguments << "-allow_projection_difference" | ||
arguments << self.getOutputFileName() | ||
if self.inputDirCheck.isChecked(): | ||
arguments << Utils.getRasterFiles( self.getInputFileName(), self.recurseCheck.isChecked() ) | ||
if self.useSelectedLayersCheck.isChecked(): | ||
arguments << self.getInputFileNamesFromSelectedLayers() | ||
else: | ||
arguments << self.getInputFileName() | ||
if self.inputDirCheck.isChecked(): | ||
arguments << Utils.getRasterFiles( self.getInputFileName(), self.recurseCheck.isChecked() ) | ||
else: | ||
arguments << self.getInputFileName() | ||
return arguments | ||
|
||
def getOutputFileName(self): | ||
|
@@ -102,6 +113,14 @@ def getInputFileName(self): | |
return self.inSelector.filename() | ||
return self.inSelector.filename().split(",") | ||
|
||
def getInputFileNamesFromSelectedLayers(self): | ||
This comment has been minimized.
Sorry, something went wrong.
brushtyler
Contributor
|
||
layers = iface.mapCanvas().layers() | ||
files = list() | ||
for layer in layers: | ||
if layer.type() == QgsMapLayer.RasterLayer and layer.providerType() == "gdal": | ||
files.append( str(layer.source()) ) | ||
return files | ||
|
||
def addLayerIntoCanvas(self, fileInfo): | ||
self.iface.addRasterLayer(fileInfo.filePath()) | ||
|
2 comments
on commit 3c1eb0a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ethienne, thanks for your patch! I'm going to apply it making the changes above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! will look into the changes you make.
this line is not required:
iface
is available yet throughself.iface
(line 15)