Added QgsMapCanvas::layers() method

git-svn-id: http://svn.osgeo.org/qgis/trunk@12935 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2010-02-12 09:49:51 +00:00
parent a14ed90360
commit 63d0a6520d
3 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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()
{

View File

@ -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