Skip to content

Commit

Permalink
Added QgsMapCanvas::layers() method
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12935 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Feb 12, 2010
1 parent a14ed90 commit 63d0a65
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/gui/qgsmapcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class QgsMapCanvas : QGraphicsView
//! 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
Expand Down
12 changes: 12 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,18 @@ int QgsMapCanvas::layerCount() const
} // 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()
{
Expand Down
3 changes: 3 additions & 0 deletions src/gui/qgsmapcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! 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
Expand Down

0 comments on commit 63d0a65

Please sign in to comment.