[QGIS Commit] r14404 - in trunk/qgis: python/core src/core/symbology-ng

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Oct 18 16:04:51 EDT 2010


Author: wonder
Date: 2010-10-18 13:04:51 -0700 (Mon, 18 Oct 2010)
New Revision: 14404

Modified:
   trunk/qgis/python/core/symbology-ng-core.sip
   trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.cpp
   trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.h
Log:
Applied part of #2832 (show rules in legend).


Modified: trunk/qgis/python/core/symbology-ng-core.sip
===================================================================
--- trunk/qgis/python/core/symbology-ng-core.sip	2010-10-18 20:00:43 UTC (rev 14403)
+++ trunk/qgis/python/core/symbology-ng-core.sip	2010-10-18 20:04:51 UTC (rev 14404)
@@ -448,6 +448,9 @@
     //! store renderer info to XML element
     virtual QDomElement save( QDomDocument& doc );
 
+    //! return a list of symbology items for the legend 
+    virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize ); 
+
     /////
 
     //! return the total number of rules

Modified: trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.cpp	2010-10-18 20:00:43 UTC (rev 14403)
+++ trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.cpp	2010-10-18 20:04:51 UTC (rev 14404)
@@ -244,6 +244,28 @@
 }
 
 
+QgsLegendSymbologyList QgsRuleBasedRendererV2::legendSymbologyItems( QSize iconSize )
+{
+  QgsLegendSymbologyList lst;
+  for ( QList<Rule>::iterator it = mRules.begin(); it != mRules.end(); ++it )
+  {
+    QPixmap pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( it->symbol(), iconSize );
+    lst << qMakePair( it->filterExpression(), pix );
+  }
+  return lst;
+}
+
+QgsLegendSymbolList QgsRuleBasedRendererV2::legendSymbolItems()
+{
+  QgsLegendSymbolList lst;
+  for ( QList<Rule>::iterator it = mRules.begin(); it != mRules.end(); ++it )
+  {
+    lst << qMakePair( it->filterExpression(), it->symbol() );
+  }
+  return lst;
+}
+
+
 QgsFeatureRendererV2* QgsRuleBasedRendererV2::create( QDomElement& element )
 {
   // load symbols

Modified: trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.h	2010-10-18 20:00:43 UTC (rev 14403)
+++ trunk/qgis/src/core/symbology-ng/qgsrulebasedrendererv2.h	2010-10-18 20:04:51 UTC (rev 14404)
@@ -102,6 +102,13 @@
     //! store renderer info to XML element
     virtual QDomElement save( QDomDocument& doc );
 
+    //! return a list of symbology items for the legend
+    virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
+
+    //! return a list of item text / symbol
+    //! @note: this method was added in version 1.5
+    virtual QgsLegendSymbolList legendSymbolItems();
+
     /////
 
     //! return the total number of rules



More information about the QGIS-commit mailing list