diff --git a/python/gui/qgslegendinterface.sip b/python/gui/qgslegendinterface.sip index 56a0e884755..61e06b63862 100644 --- a/python/gui/qgslegendinterface.sip +++ b/python/gui/qgslegendinterface.sip @@ -43,6 +43,10 @@ class QgsLegendInterface : QObject //! @note added in 1.5 virtual bool isGroupVisible( int groupIndex ) = 0; + //! Check if a layer is expanded + //! @note added in 2.0 + virtual bool isLayerExpanded( QgsMapLayer * ml ) = 0; + //! Check if a layer is visible //! @note added in 1.5 virtual bool isLayerVisible( QgsMapLayer * ml ) = 0; diff --git a/src/app/legend/qgsapplegendinterface.cpp b/src/app/legend/qgsapplegendinterface.cpp index d8fdee840ea..c8b6a50886a 100644 --- a/src/app/legend/qgsapplegendinterface.cpp +++ b/src/app/legend/qgsapplegendinterface.cpp @@ -167,6 +167,11 @@ bool QgsAppLegendInterface::isGroupVisible( int groupIndex ) return ( Qt::Checked == getItem( groupIndex )->checkState( 0 ) ); } +bool QgsAppLegendInterface::isLayerExpanded( QgsMapLayer * ml ) +{ + return mLegend->layerIsExpanded( ml ); +} + bool QgsAppLegendInterface::isLayerVisible( QgsMapLayer * ml ) { return ( Qt::Checked == mLegend->layerCheckState( ml ) ); diff --git a/src/app/legend/qgsapplegendinterface.h b/src/app/legend/qgsapplegendinterface.h index dabb922d644..9897e39890f 100644 --- a/src/app/legend/qgsapplegendinterface.h +++ b/src/app/legend/qgsapplegendinterface.h @@ -61,6 +61,9 @@ class QgsAppLegendInterface : public QgsLegendInterface //! Check if a group is visible bool isGroupVisible( int groupIndex ); + //! Check if a layer is expanded + bool isLayerExpanded( QgsMapLayer * ml ); + //! Check if a layer is visible bool isLayerVisible( QgsMapLayer * ml ); diff --git a/src/app/legend/qgslegend.cpp b/src/app/legend/qgslegend.cpp index 6da03f2197a..c1c93126b05 100644 --- a/src/app/legend/qgslegend.cpp +++ b/src/app/legend/qgslegend.cpp @@ -831,6 +831,13 @@ Qt::CheckState QgsLegend::layerCheckState( QgsMapLayer * layer ) return ll ? ll->checkState( 0 ) : Qt::Unchecked; } +bool QgsLegend::layerIsExpanded( QgsMapLayer * layer ) +{ + QgsLegendLayer * ll = findLegendLayer( layer ); + + return ll->isExpanded(); +} + QgsLegendGroup* QgsLegend::addEmbeddedGroup( const QString& groupName, const QString& projectFilePath, QgsLegendItem* parent ) { mEmbeddedGroups.insert( groupName, projectFilePath ); diff --git a/src/app/legend/qgslegend.h b/src/app/legend/qgslegend.h index 2126b261401..9dee16f1c16 100644 --- a/src/app/legend/qgslegend.h +++ b/src/app/legend/qgslegend.h @@ -221,6 +221,9 @@ class QgsLegend : public QTreeWidget /**Returns a layers check state*/ Qt::CheckState layerCheckState( QgsMapLayer * layer ); + /**Returns a layers expanded state*/ + bool layerIsExpanded( QgsMapLayer * layer ); + /**Add group from other project file. Returns a pointer to the new group in case of success or 0 in case of error*/ QgsLegendGroup* addEmbeddedGroup( const QString& groupName, const QString& projectFilePath, QgsLegendItem* parent = 0 ); diff --git a/src/gui/qgslegendinterface.h b/src/gui/qgslegendinterface.h index 8ffdf339e8e..343bd9b86ea 100644 --- a/src/gui/qgslegendinterface.h +++ b/src/gui/qgslegendinterface.h @@ -75,6 +75,10 @@ class GUI_EXPORT QgsLegendInterface : public QObject //! @note added in 1.5 virtual bool isGroupVisible( int groupIndex ) = 0; + //! Check if a layer is expanded + //! @note added in 2.0 + virtual bool isLayerExpanded( QgsMapLayer * ml ) = 0; + //! Check if a layer is visible //! @note added in 1.5 virtual bool isLayerVisible( QgsMapLayer * ml ) = 0;