Skip to content

Commit

Permalink
Added layerIsExpanded() to QgsLegendInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang authored and jef-n committed Jan 26, 2013
1 parent e7c34ea commit 85b684c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/gui/qgslegendinterface.sip
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/app/legend/qgsapplegendinterface.cpp
Expand Up @@ -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 ) );
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgsapplegendinterface.h
Expand Up @@ -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 );

Expand Down
7 changes: 7 additions & 0 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgslegend.h
Expand Up @@ -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 );

Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgslegendinterface.h
Expand Up @@ -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;
Expand Down

0 comments on commit 85b684c

Please sign in to comment.