[QGIS Commit] r12935 - in trunk/qgis: python/gui src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Feb 12 04:49:52 EST 2010


Author: wonder
Date: 2010-02-12 04:49:51 -0500 (Fri, 12 Feb 2010)
New Revision: 12935

Modified:
   trunk/qgis/python/gui/qgsmapcanvas.sip
   trunk/qgis/src/gui/qgsmapcanvas.cpp
   trunk/qgis/src/gui/qgsmapcanvas.h
Log:
Added QgsMapCanvas::layers() method


Modified: trunk/qgis/python/gui/qgsmapcanvas.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvas.sip	2010-02-12 09:20:39 UTC (rev 12934)
+++ trunk/qgis/python/gui/qgsmapcanvas.sip	2010-02-12 09:49:51 UTC (rev 12935)
@@ -128,6 +128,9 @@
     //! return number of layers on the map
     int layerCount() const;
 
+    //! return list of layers within map canvas. Added in v1.5
+    QList<QgsMapLayer*> layers() const;
+
     /*! Freeze/thaw the map canvas. This is used to prevent the canvas from
      * responding to events while layers are being added/removed etc.
      * @param frz Boolean specifying if the canvas should be frozen (true) or

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2010-02-12 09:20:39 UTC (rev 12934)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2010-02-12 09:49:51 UTC (rev 12935)
@@ -1164,7 +1164,19 @@
 } // layerCount
 
 
+QList<QgsMapLayer*> QgsMapCanvas::layers() const
+{
+  QList<QgsMapLayer*> lst;
+  foreach ( QString layerID, mMapRenderer->layerSet() )
+  {
+    QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerID );
+    if ( layer )
+      lst.append(layer);
+  }
+  return lst;
+}
 
+
 void QgsMapCanvas::layerStateChange()
 {
   // called when a layer has changed visibility setting

Modified: trunk/qgis/src/gui/qgsmapcanvas.h
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.h	2010-02-12 09:20:39 UTC (rev 12934)
+++ trunk/qgis/src/gui/qgsmapcanvas.h	2010-02-12 09:49:51 UTC (rev 12935)
@@ -185,6 +185,9 @@
     //! return number of layers on the map
     int layerCount() const;
 
+    //! return list of layers within map canvas. Added in v1.5
+    QList<QgsMapLayer*> layers() const;
+
     /*! Freeze/thaw the map canvas. This is used to prevent the canvas from
      * responding to events while layers are being added/removed etc.
      * @param frz Boolean specifying if the canvas should be frozen (true) or



More information about the QGIS-commit mailing list