File tree 4 files changed +29
-0
lines changed
4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,13 @@ class QgsLegendInterface : QObject
16
16
/** Virtual destructor */
17
17
~QgsLegendInterface();
18
18
19
+ //! Return a string list of groups
19
20
virtual QStringList groups() =0;
20
21
22
+ //! Return all layers in the project in legend order
23
+ //! @note added in 1.5
24
+ virtual QList< QgsMapLayer * > layers() const = 0;
25
+
21
26
signals:
22
27
23
28
//! emitted when a group index has changed
Original file line number Diff line number Diff line change 18
18
#include " qgsapplegendinterface.h"
19
19
20
20
#include " qgslegend.h"
21
+ #include " qgslegendlayer.h"
21
22
#include " qgsmaplayer.h"
22
23
23
24
QgsAppLegendInterface::QgsAppLegendInterface ( QgsLegend * legend )
@@ -58,6 +59,22 @@ QStringList QgsAppLegendInterface::groups()
58
59
return mLegend ->groups ();
59
60
}
60
61
62
+ QList< QgsMapLayer * > QgsAppLegendInterface::layers () const
63
+ {
64
+ QList< QgsMapLayer * > items;
65
+ QTreeWidgetItemIterator it ( mLegend );
66
+ while ( *it )
67
+ {
68
+ QgsLegendLayer *llayer = dynamic_cast <QgsLegendLayer *>( *it );
69
+ if ( llayer )
70
+ items.append ( llayer->layer () );
71
+
72
+ ++it;
73
+ }
74
+
75
+ return items;
76
+ }
77
+
61
78
void QgsAppLegendInterface::refreshLayerSymbology ( QgsMapLayer *ml )
62
79
{
63
80
mLegend ->refreshLayerSymbology ( ml->getLayerID () );
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ class QgsAppLegendInterface : public QgsLegendInterface
44
44
// ! Return a string list of groups
45
45
QStringList groups ();
46
46
47
+ // ! Return all layers in the project in legend order
48
+ QList< QgsMapLayer * > layers () const ;
49
+
47
50
public slots:
48
51
49
52
// ! Add a new group
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ class GUI_EXPORT QgsLegendInterface : public QObject
44
44
// ! Return a string list of groups
45
45
virtual QStringList groups () = 0;
46
46
47
+ // ! Return all layers in the project in legend order
48
+ // ! @note added in 1.5
49
+ virtual QList< QgsMapLayer * > layers () const = 0;
50
+
47
51
signals:
48
52
49
53
// ! emitted when a group index has changed
You can’t perform that action at this time.
0 commit comments