[QGIS Commit] r10072 - trunk/qgis/python/plugins/ftools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jan 31 14:47:19 EST 2009


Author: cfarmer
Date: 2009-01-31 14:47:19 -0500 (Sat, 31 Jan 2009)
New Revision: 10072

Modified:
   trunk/qgis/python/plugins/ftools/tools/doVectorGrid.py
   trunk/qgis/python/plugins/ftools/tools/ftools_utils.py
Log:
fix bug with extents for raster layers


Modified: trunk/qgis/python/plugins/ftools/tools/doVectorGrid.py
===================================================================
--- trunk/qgis/python/plugins/ftools/tools/doVectorGrid.py	2009-01-31 18:54:34 UTC (rev 10071)
+++ trunk/qgis/python/plugins/ftools/tools/doVectorGrid.py	2009-01-31 19:47:19 UTC (rev 10072)
@@ -50,10 +50,9 @@
 		self.xMax.setValidator(QDoubleValidator(self.xMax))
 		self.yMin.setValidator(QDoubleValidator(self.yMin))
 		self.yMax.setValidator(QDoubleValidator(self.yMax))
-		layers = ftools_utils.getLayerNames( 
-		[ QGis.Point, QGis.Line, QGis.Polygon ] )
-		for layer in layers:
-			self.inShape.addItem( layer )
+		layermap = QgsMapLayerRegistry.instance().mapLayers()
+		for name, layer in layermap.iteritems():
+			self.inShape.addItem( unicode( layer.name() ) )
 
 	def offset(self, value):
 		if self.chkLock.isChecked():
@@ -62,7 +61,7 @@
 	def updateLayer( self ):
 		mLayerName = self.inShape.currentText()
 		if not mLayerName == "":
-			mLayer = self.getMapLayerByName( unicode( mLayerName ) )
+			mLayer = ftools_utils.getMapLayerByName( unicode( mLayerName ) )
 			boundBox = mLayer.extent()
 			self.updateExtents( boundBox )
 			

Modified: trunk/qgis/python/plugins/ftools/tools/ftools_utils.py
===================================================================
--- trunk/qgis/python/plugins/ftools/tools/ftools_utils.py	2009-01-31 18:54:34 UTC (rev 10071)
+++ trunk/qgis/python/plugins/ftools/tools/ftools_utils.py	2009-01-31 19:47:19 UTC (rev 10072)
@@ -183,6 +183,16 @@
 				return layer
 			else:
 				return None
+				
+# Return QgsMapLayer from a layer name ( as string )
+def getMapLayerByName( myName ):
+	layermap = QgsMapLayerRegistry.instance().mapLayers()
+	for name, layer in layermap.iteritems():
+		if layer.name() == myName:
+			if layer.isValid():
+				return layer
+			else:
+				return None
 
 # Return the field list of a vector layer
 def getFieldList( vlayer ):



More information about the QGIS-commit mailing list