Skip to content
Permalink
Browse files
[FEATURE] legend interface added to retrieve layers in legend order (…
…supplied by Maxim Dubinin)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13264 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 6, 2010
1 parent a049be1 commit 6fc3dc0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
@@ -16,8 +16,13 @@ class QgsLegendInterface : QObject
/** Virtual destructor */
~QgsLegendInterface();

//! Return a string list of groups
virtual QStringList groups() =0;

//! Return all layers in the project in legend order
//! @note added in 1.5
virtual QList< QgsMapLayer * > layers() const = 0;

signals:

//! emitted when a group index has changed
@@ -18,6 +18,7 @@
#include "qgsapplegendinterface.h"

#include "qgslegend.h"
#include "qgslegendlayer.h"
#include "qgsmaplayer.h"

QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
@@ -58,6 +59,22 @@ QStringList QgsAppLegendInterface::groups()
return mLegend->groups();
}

QList< QgsMapLayer * > QgsAppLegendInterface::layers() const
{
QList< QgsMapLayer * > items;
QTreeWidgetItemIterator it( mLegend );
while ( *it )
{
QgsLegendLayer *llayer = dynamic_cast<QgsLegendLayer *>( *it );
if ( llayer )
items.append( llayer->layer() );

++it;
}

return items;
}

void QgsAppLegendInterface::refreshLayerSymbology( QgsMapLayer *ml )
{
mLegend->refreshLayerSymbology( ml->getLayerID() );
@@ -44,6 +44,9 @@ class QgsAppLegendInterface : public QgsLegendInterface
//! Return a string list of groups
QStringList groups();

//! Return all layers in the project in legend order
QList< QgsMapLayer * > layers() const;

public slots:

//! Add a new group
@@ -44,6 +44,10 @@ class GUI_EXPORT QgsLegendInterface : public QObject
//! Return a string list of groups
virtual QStringList groups() = 0;

//! Return all layers in the project in legend order
//! @note added in 1.5
virtual QList< QgsMapLayer * > layers() const = 0;

signals:

//! emitted when a group index has changed

0 comments on commit 6fc3dc0

Please sign in to comment.