[QGIS Commit] r13264 - in trunk/qgis: python/gui src/app/legend src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Apr 6 12:12:39 EDT 2010


Author: jef
Date: 2010-04-06 12:12:39 -0400 (Tue, 06 Apr 2010)
New Revision: 13264

Modified:
   trunk/qgis/python/gui/qgslegendinterface.sip
   trunk/qgis/src/app/legend/qgsapplegendinterface.cpp
   trunk/qgis/src/app/legend/qgsapplegendinterface.h
   trunk/qgis/src/gui/qgslegendinterface.h
Log:
[FEATURE] legend interface added to retrieve layers in legend order (supplied by Maxim Dubinin)

Modified: trunk/qgis/python/gui/qgslegendinterface.sip
===================================================================
--- trunk/qgis/python/gui/qgslegendinterface.sip	2010-04-06 15:08:37 UTC (rev 13263)
+++ trunk/qgis/python/gui/qgslegendinterface.sip	2010-04-06 16:12:39 UTC (rev 13264)
@@ -16,8 +16,13 @@
     /** 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

Modified: trunk/qgis/src/app/legend/qgsapplegendinterface.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgsapplegendinterface.cpp	2010-04-06 15:08:37 UTC (rev 13263)
+++ trunk/qgis/src/app/legend/qgsapplegendinterface.cpp	2010-04-06 16:12:39 UTC (rev 13264)
@@ -18,6 +18,7 @@
 #include "qgsapplegendinterface.h"
 
 #include "qgslegend.h"
+#include "qgslegendlayer.h"
 #include "qgsmaplayer.h"
 
 QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
@@ -58,6 +59,22 @@
   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() );

Modified: trunk/qgis/src/app/legend/qgsapplegendinterface.h
===================================================================
--- trunk/qgis/src/app/legend/qgsapplegendinterface.h	2010-04-06 15:08:37 UTC (rev 13263)
+++ trunk/qgis/src/app/legend/qgsapplegendinterface.h	2010-04-06 16:12:39 UTC (rev 13264)
@@ -44,6 +44,9 @@
     //! 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

Modified: trunk/qgis/src/gui/qgslegendinterface.h
===================================================================
--- trunk/qgis/src/gui/qgslegendinterface.h	2010-04-06 15:08:37 UTC (rev 13263)
+++ trunk/qgis/src/gui/qgslegendinterface.h	2010-04-06 16:12:39 UTC (rev 13264)
@@ -44,6 +44,10 @@
     //! 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



More information about the QGIS-commit mailing list