Index: python/gui/qgslegendinterface.sip =================================================================== --- python/gui/qgslegendinterface.sip (revision 13348) +++ python/gui/qgslegendinterface.sip (working copy) @@ -39,8 +39,16 @@ //! Move a layer to a group virtual void moveLayer( QgsMapLayer * layer, int groupIndex ) =0; + //! Collapse or expand a group + //! @note added in 1.5 + virtual void setGroupExpanded( int groupIndex, bool expand ) =0; + + //! Set visibility of a layer or group + //! @note added in 1.5 + virtual void setItemVisible( int index, bool visible ) =0; + //! refresh layer symbology - //! \note added in 1.5 + //! @note added in 1.5 virtual void refreshLayerSymbology( QgsMapLayer *layer ) =0; }; Index: src/app/legend/qgsapplegendinterface.h =================================================================== --- src/app/legend/qgsapplegendinterface.h (revision 13348) +++ src/app/legend/qgsapplegendinterface.h (working copy) @@ -61,6 +61,12 @@ //! Update an index void updateIndex( QModelIndex oldIndex, QModelIndex newIndex ); + //! Collapse or expand a group + void setGroupExpanded( int groupIndex, bool expand ); + + //! Set the visibility of a layer or group + void setItemVisible( int index, bool visible ); + //! refresh layer symbology void refreshLayerSymbology( QgsMapLayer *ml ); Index: src/app/legend/qgsapplegendinterface.cpp =================================================================== --- src/app/legend/qgsapplegendinterface.cpp (revision 13348) +++ src/app/legend/qgsapplegendinterface.cpp (working copy) @@ -54,6 +54,22 @@ } } +void QgsAppLegendInterface::setGroupExpanded( int groupIndex, bool expand ) +{ + mLegend->setExpanded( mLegend->model()->index( groupIndex, 0 ), expand ); +} + +void QgsAppLegendInterface::setItemVisible( int index, bool visible ) +{ + if ( mLegend->topLevelItemCount() <= index || 0 > index ) + { + return; + } + + Qt::CheckState state = visible ? Qt::Checked : Qt::Unchecked; + mLegend->topLevelItem( index )->setCheckState( 0, state ); +} + QStringList QgsAppLegendInterface::groups() { return mLegend->groups(); Index: src/gui/qgslegendinterface.h =================================================================== --- src/gui/qgslegendinterface.h (revision 13348) +++ src/gui/qgslegendinterface.h (working copy) @@ -64,8 +64,16 @@ //! Move a layer to a group virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0; + //! Collapse or expand a group + //! @note added in 1.5 + virtual void setGroupExpanded( int groupIndex, bool expand ) = 0; + + //! Set the visibility of a layer or group + //! @note added in 1.5 + virtual void setItemVisible( int index, bool visible ) = 0; + //! Refresh layer symbology - // @noted added in 1.5 + //! @note added in 1.5 virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0; };