Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] legend interface added to retrieve layers in legend order (…
…supplied by Maxim Dubinin)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13264 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 6, 2010
1 parent ba73157 commit d975c89
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/gui/qgslegendinterface.sip
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/app/legend/qgsapplegendinterface.cpp
Expand Up @@ -18,6 +18,7 @@
#include "qgsapplegendinterface.h"

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

QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
Expand Down Expand Up @@ -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() );
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgsapplegendinterface.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgslegendinterface.h
Expand Up @@ -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
Expand Down

0 comments on commit d975c89

Please sign in to comment.