Commit 63429f0 wonder
committed
1 parent e3a71fd commit 63429f0 Copy full SHA for 63429f0
File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,9 @@ class QgsMapCanvas : QGraphicsView
128
128
//! return number of layers on the map
129
129
int layerCount() const;
130
130
131
+ //! return list of layers within map canvas. Added in v1.5
132
+ QList<QgsMapLayer*> layers() const;
133
+
131
134
/*! Freeze/thaw the map canvas. This is used to prevent the canvas from
132
135
* responding to events while layers are being added/removed etc.
133
136
* @param frz Boolean specifying if the canvas should be frozen (true) or
Original file line number Diff line number Diff line change @@ -1164,6 +1164,18 @@ int QgsMapCanvas::layerCount() const
1164
1164
} // layerCount
1165
1165
1166
1166
1167
+ QList<QgsMapLayer*> QgsMapCanvas::layers () const
1168
+ {
1169
+ QList<QgsMapLayer*> lst;
1170
+ foreach ( QString layerID, mMapRenderer ->layerSet () )
1171
+ {
1172
+ QgsMapLayer* layer = QgsMapLayerRegistry::instance ()->mapLayer ( layerID );
1173
+ if ( layer )
1174
+ lst.append (layer);
1175
+ }
1176
+ return lst;
1177
+ }
1178
+
1167
1179
1168
1180
void QgsMapCanvas::layerStateChange ()
1169
1181
{
Original file line number Diff line number Diff line change @@ -185,6 +185,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
185
185
// ! return number of layers on the map
186
186
int layerCount () const ;
187
187
188
+ // ! return list of layers within map canvas. Added in v1.5
189
+ QList<QgsMapLayer*> layers () const ;
190
+
188
191
/* ! Freeze/thaw the map canvas. This is used to prevent the canvas from
189
192
* responding to events while layers are being added/removed etc.
190
193
* @param frz Boolean specifying if the canvas should be frozen (true) or
You can’t perform that action at this time.
0 commit comments