@@ -54,11 +54,59 @@ void QgsAppLegendInterface::updateIndex( QModelIndex oldIndex, QModelIndex newIn
5454 }
5555}
5656
57+ void QgsAppLegendInterface::setGroupExpanded ( int groupIndex, bool expand )
58+ {
59+ mLegend ->setExpanded ( mLegend ->model ()->index ( groupIndex, 0 ), expand );
60+ }
61+
62+ void QgsAppLegendInterface::setGroupVisible ( int groupIndex, bool visible )
63+ {
64+ if ( !groupExists ( groupIndex ) )
65+ {
66+ return ;
67+ }
68+
69+ Qt::CheckState state = visible ? Qt::Checked : Qt::Unchecked;
70+ mLegend ->topLevelItem ( groupIndex )->setCheckState ( 0 , state );
71+ }
72+
73+ void QgsAppLegendInterface::setLayerVisible ( QgsMapLayer * ml, bool visible )
74+ {
75+ mLegend ->setLayerVisible ( ml, visible );
76+ }
77+
5778QStringList QgsAppLegendInterface::groups ()
5879{
5980 return mLegend ->groups ();
6081}
6182
83+ bool QgsAppLegendInterface::groupExists ( int groupIndex )
84+ {
85+ QModelIndex mi = mLegend ->model ()->index ( groupIndex, 0 );
86+ return ( mi.isValid () &&
87+ mLegend ->isLegendGroup ( mi ) );
88+ }
89+
90+ bool QgsAppLegendInterface::isGroupExpanded ( int groupIndex )
91+ {
92+ return mLegend ->isExpanded ( mLegend ->model ()->index ( groupIndex, 0 ) );
93+ }
94+
95+ bool QgsAppLegendInterface::isGroupVisible ( int groupIndex )
96+ {
97+ if ( !groupExists ( groupIndex ) )
98+ {
99+ return false ;
100+ }
101+
102+ return ( Qt::Checked == mLegend ->topLevelItem ( groupIndex )->checkState ( 0 ) );
103+ }
104+
105+ bool QgsAppLegendInterface::isLayerVisible ( QgsMapLayer * ml )
106+ {
107+ return ( Qt::Checked == mLegend ->layerCheckState ( ml ) );
108+ }
109+
62110QList< QgsMapLayer * > QgsAppLegendInterface::layers () const
63111{
64112 QList< QgsMapLayer * > items;
0 commit comments