Skip to content
Permalink
Browse files
Also add API to determine if group layers should be expanded when cal…
…ling QgsMapCanvas::layers()
  • Loading branch information
nyalldawson committed Nov 23, 2021
1 parent a5b9c7b commit b063d477b67913d9119d07319bdb1859faf7923b
Showing with 16 additions and 8 deletions.
  1. +5 −2 python/gui/auto_generated/qgsmapcanvas.sip.in
  2. +3 −4 src/gui/qgsmapcanvas.cpp
  3. +8 −2 src/gui/qgsmapcanvas.h
@@ -460,13 +460,16 @@ layers which may be visible in the canvas, but not associated with a :py:class:`

int layerCount() const;
%Docstring
Returns number of layers on the map
Returns number of layers on the map.
%End

QList<QgsMapLayer *> layers() const;
QList<QgsMapLayer *> layers( bool expandGroupLayers = false ) const;
%Docstring
Returns the list of layers shown within the map canvas.

Since QGIS 3.24, if the ``expandGroupLayers`` option is ``True`` then group layers will be converted to
all their child layers.

.. seealso:: :py:func:`setLayers`
%End

@@ -2430,12 +2430,11 @@ QColor QgsMapCanvas::selectionColor() const
int QgsMapCanvas::layerCount() const
{
return mapSettings().layers().size();
} // layerCount

}

QList<QgsMapLayer *> QgsMapCanvas::layers() const
QList<QgsMapLayer *> QgsMapCanvas::layers( bool expandGroupLayers ) const
{
return mapSettings().layers();
return mapSettings().layers( expandGroupLayers );
}

void QgsMapCanvas::layerStateChange()
@@ -471,14 +471,20 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView, public QgsExpressionContex
*/
QgsMapLayer *layer( const QString &id );

//! Returns number of layers on the map
/**
* Returns number of layers on the map.
*/
int layerCount() const;

/**
* Returns the list of layers shown within the map canvas.
*
* Since QGIS 3.24, if the \a expandGroupLayers option is TRUE then group layers will be converted to
* all their child layers.
*
* \see setLayers()
*/
QList<QgsMapLayer *> layers() const;
QList<QgsMapLayer *> layers( bool expandGroupLayers = false ) const;

/**
* Freeze/thaw the map canvas. This is used to prevent the canvas from

0 comments on commit b063d47

Please sign in to comment.