[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db
Giuseppe Sucameli
brush.tyler at gmail.com
Tue Mar 20 13:43:30 UTC 2012
The following commit has been merged in the master branch:
commit d6ea1a037ef3755f7989bbf4c44c320f12eeba43
Author: Giuseppe Sucameli <brush.tyler at gmail.com>
Date: Sat Mar 10 05:39:52 2012 +0100
refresh BuildVRT command when input layers changes, cleanup (follow 9da5d0345)
diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py b/python/plugins/GdalTools/tools/doBuildVRT.py
index 9dbdca2..d2483a9 100644
--- a/python/plugins/GdalTools/tools/doBuildVRT.py
+++ b/python/plugins/GdalTools/tools/doBuildVRT.py
@@ -3,7 +3,6 @@ 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
@@ -22,6 +21,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
self.inSelector.setType( self.inSelector.FILE )
self.outSelector.setType( self.outSelector.FILE )
self.recurseCheck.hide()
+ self.visibleRasterLayers = QStringList()
self.setParamsStatus(
[
@@ -32,14 +32,38 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
(self.separateCheck, SIGNAL("stateChanged(int)"), None, "1.7.0"),
(self.allowProjDiffCheck, SIGNAL("stateChanged(int)"), None, "1.7.0"),
- (self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck)
+ (self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
+ (self.inputSelLayersCheck, SIGNAL("stateChanged(int)"))
]
)
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 )
+ self.connect( self.inputSelLayersCheck, SIGNAL( "stateChanged( int )" ), self.switchLayerMode )
+ self.connect( self.iface.mapCanvas(), SIGNAL( "stateChanged( int )" ), self.switchLayerMode )
+
+
+ def initialize(self):
+ # connect to mapCanvas.layerChanged() signal
+ self.connect(self.iface.mapCanvas(), SIGNAL("layersChanged()"), self.onVisibleLayersChanged)
+ BasePluginWidget.initialize(self)
+
+ def onClosing(self):
+ # disconnect from mapCanvas.layerChanged() signal
+ self.disconnect(self.iface.mapCanvas(), SIGNAL("layersChanged()"), self.onVisibleLayersChanged)
+ BasePluginWidget.onClosing(self)
+
+
+ def onVisibleLayersChanged(self):
+ # refresh list of visible raster layers
+ self.visibleRasterLayers = QStringList()
+ for layer in self.iface.mapCanvas().layers():
+ if Utils.LayerRegistry.isRaster( layer ):
+ self.visibleRasterLayers << layer.source()
+
+ # refresh the text in the command viewer
+ self.someValueChanged()
def switchToolMode(self):
self.recurseCheck.setVisible( self.inputDirCheck.isChecked() )
@@ -58,7 +82,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
def switchLayerMode(self):
- enableInputFiles = not self.useSelectedLayersCheck.isChecked()
+ enableInputFiles = not self.inputSelLayersCheck.isChecked()
self.inputDirCheck.setEnabled( enableInputFiles )
self.inSelector.setEnabled( enableInputFiles )
self.recurseCheck.setEnabled( enableInputFiles )
@@ -96,13 +120,12 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
if self.allowProjDiffCheck.isChecked():
arguments << "-allow_projection_difference"
arguments << self.getOutputFileName()
- if self.useSelectedLayersCheck.isChecked():
- arguments << self.getInputFileNamesFromSelectedLayers()
+ if self.inputSelLayersCheck.isChecked():
+ arguments << self.visibleRasterLayers
+ elif self.inputDirCheck.isChecked():
+ arguments << Utils.getRasterFiles( self.getInputFileName(), self.recurseCheck.isChecked() )
else:
- if self.inputDirCheck.isChecked():
- arguments << Utils.getRasterFiles( self.getInputFileName(), self.recurseCheck.isChecked() )
- else:
- arguments << self.getInputFileName()
+ arguments << self.getInputFileName()
return arguments
def getOutputFileName(self):
@@ -113,14 +136,6 @@ 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 b0df505..b8ced38 100644
--- a/python/plugins/GdalTools/tools/widgetBuildVRT.ui
+++ b/python/plugins/GdalTools/tools/widgetBuildVRT.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>348</width>
- <height>238</height>
+ <height>266</height>
</rect>
</property>
<property name="sizePolicy">
@@ -26,9 +26,9 @@
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="0" column="0" colspan="2">
- <widget class="QCheckBox" name="useSelectedLayersCheck">
+ <widget class="QCheckBox" name="inputSelLayersCheck">
<property name="text">
- <string>Use selected layers for input</string>
+ <string>Use visible raster layers for input</string>
</property>
</widget>
</item>
diff --git a/python/plugins/GdalTools/tools/widgetPluginBase.py b/python/plugins/GdalTools/tools/widgetPluginBase.py
index 75ab85b..5f59318 100644
--- a/python/plugins/GdalTools/tools/widgetPluginBase.py
+++ b/python/plugins/GdalTools/tools/widgetPluginBase.py
@@ -30,20 +30,19 @@ class GdalToolsBasePluginWidget:
def onLayersChanged(self):
pass
- def exec_(self):
+ def initialize(self):
if not self.initialized:
self.connect(Utils.LayerRegistry.instance(), SIGNAL("layersChanged"), self.onLayersChanged)
self.onLayersChanged()
self.someValueChanged()
self.initialized = True
+
+ def exec_(self):
+ self.initialize()
return self.base.exec_()
def show_(self):
- if not self.initialized:
- self.connect(Utils.LayerRegistry.instance(), SIGNAL("layersChanged"), self.onLayersChanged)
- self.onLayersChanged()
- self.someValueChanged()
- self.initialized = True
+ self.initialize()
return self.base.show()
def setCommandViewerEnabled(self, enable):
--
The Quantum GIS in Debian project
More information about the Pkg-grass-devel
mailing list