[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db
Giuseppe Sucameli
brush.tyler at gmail.com
Tue Mar 20 13:43:29 UTC 2012
The following commit has been merged in the master branch:
commit 9da5d0345ba165970a4fca5a05bb8b1bf108ad6a
Author: Etienne Tourigny <etourigny.dev at gmail.com>
Date: Thu Mar 8 23:20:10 2012 -0300
allow to use loaded layers as input files (instead of file selector) for GDALTools Build Virtual Raster
diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py b/python/plugins/GdalTools/tools/doBuildVRT.py
index 67df116..9dbdca2 100644
--- a/python/plugins/GdalTools/tools/doBuildVRT.py
+++ b/python/plugins/GdalTools/tools/doBuildVRT.py
@@ -3,6 +3,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
+from qgis.utils import *
from ui_widgetBuildVRT import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
@@ -38,6 +39,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
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 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
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 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
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 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
return self.inSelector.filename()
return self.inSelector.filename().split(",")
+ def getInputFileNamesFromSelectedLayers(self):
+ 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())
diff --git a/python/plugins/GdalTools/tools/widgetBuildVRT.ui b/python/plugins/GdalTools/tools/widgetBuildVRT.ui
index 2192538..b0df505 100644
--- a/python/plugins/GdalTools/tools/widgetBuildVRT.ui
+++ b/python/plugins/GdalTools/tools/widgetBuildVRT.ui
@@ -26,13 +26,20 @@
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="0" column="0" colspan="2">
+ <widget class="QCheckBox" name="useSelectedLayersCheck">
+ <property name="text">
+ <string>Use selected layers for input</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="inputDirCheck">
<property name="text">
<string>Choose input directory instead of files</string>
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&Input files</string>
@@ -42,14 +49,14 @@
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="3" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&Output file</string>
@@ -59,14 +66,14 @@
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QCheckBox" name="resolutionCheck">
<property name="text">
<string>&Resolution</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="QComboBox" name="resolutionComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -94,14 +101,14 @@
</item>
</widget>
</item>
- <item row="5" column="0">
+ <item row="6" column="0">
<widget class="QCheckBox" name="srcNoDataCheck">
<property name="text">
<string>&Source No Data</string>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<widget class="QSpinBox" name="srcNoDataSpin">
<property name="minimum">
<number>-100000</number>
@@ -111,20 +118,20 @@
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="7" column="0">
<widget class="QCheckBox" name="separateCheck">
<property name="text">
<string>Se¶te</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
- <item row="7" column="0" colspan="2">
+ <item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="allowProjDiffCheck">
<property name="text">
<string>Allow projection difference</string>
--
The Quantum GIS in Debian project
More information about the Pkg-grass-devel
mailing list