Skip to content

Commit

Permalink
Applied part of #2832 (show rules in legend).
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14404 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Oct 18, 2010
1 parent 80b5759 commit b1c0053
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/symbology-ng-core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
//! 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
Expand Down
22 changes: 22 additions & 0 deletions src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,28 @@ QDomElement QgsRuleBasedRendererV2::save( QDomDocument& doc )
}


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
Expand Down
7 changes: 7 additions & 0 deletions src/core/symbology-ng/qgsrulebasedrendererv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
//! 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
Expand Down

0 comments on commit b1c0053

Please sign in to comment.