Skip to content
Permalink
Browse files

Add method that returns legend item text and symbol pointers to v2 re…

…nderers

git-svn-id: http://svn.osgeo.org/qgis/trunk@13113 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Mar 20, 2010
1 parent 05827a6 commit c03f5b7693f29fed30d387898e445c03e7155f2f
@@ -359,6 +359,25 @@ QgsLegendSymbologyList QgsCategorizedSymbolRendererV2::legendSymbologyItems( QSi
return lst;
}

QgsLegendSymbolList QgsCategorizedSymbolRendererV2::legendSymbolItems()
{
QSettings settings;
bool showClassifiers = settings.value( "/qgis/showLegendClassifiers", false ).toBool();

QgsLegendSymbolList lst;
if ( showClassifiers )
{
lst << qMakePair( classAttribute(), ( QgsSymbolV2* )0 );
}

QgsCategoryList::const_iterator catIt = mCategories.constBegin();
for ( ; catIt != mCategories.constEnd(); ++catIt )
{
lst << qMakePair( catIt->label(), catIt->symbol() );
}
return lst;
}


QgsSymbolV2* QgsCategorizedSymbolRendererV2::sourceSymbol()
{
@@ -83,6 +83,10 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2
//! 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();

QgsSymbolV2* sourceSymbol();
void setSourceSymbol( QgsSymbolV2* sym );

@@ -482,6 +482,25 @@ QgsLegendSymbologyList QgsGraduatedSymbolRendererV2::legendSymbologyItems( QSize
return lst;
}

QgsLegendSymbolList QgsGraduatedSymbolRendererV2::legendSymbolItems()
{
QSettings settings;
bool showClassifiers = settings.value( "/qgis/showLegendClassifiers", false ).toBool();

QgsLegendSymbolList lst;
if ( showClassifiers )
{
lst << qMakePair( classAttribute(), ( QgsSymbolV2* )0 );
}

QgsRangeList::const_iterator rangeIt = mRanges.constBegin();
for ( ; rangeIt != mRanges.constEnd(); ++rangeIt )
{
lst << qMakePair( rangeIt->label(), rangeIt->symbol() );
}
return lst;
}

QgsSymbolV2* QgsGraduatedSymbolRendererV2::sourceSymbol()
{
return mSourceSymbol;
@@ -97,6 +97,10 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2
//! 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();

QgsSymbolV2* sourceSymbol();
void setSourceSymbol( QgsSymbolV2* sym );

@@ -312,7 +312,7 @@ QgsFeatureRendererV2* QgsFeatureRendererV2::load( QDomElement& element )
QString rendererType = element.attribute( "type" );

QgsRendererV2AbstractMetadata* m = QgsRendererV2Registry::instance()->rendererMetadata( rendererType );
if (m == NULL)
if ( m == NULL )
return NULL;

QgsFeatureRendererV2* r = m->createRenderer( element );
@@ -334,6 +334,11 @@ QgsLegendSymbologyList QgsFeatureRendererV2::legendSymbologyItems( QSize iconSiz
return QgsLegendSymbologyList();
}

QgsLegendSymbolList QgsFeatureRendererV2::legendSymbolItems()
{
return QgsLegendSymbolList();
}

void QgsFeatureRendererV2::setVertexMarkerAppearance( int type, int size )
{
mCurrentVertexMarkerType = type;
@@ -22,6 +22,7 @@ typedef QList<QgsSymbolV2*> QgsSymbolV2List;
typedef QMap<QString, QgsSymbolV2* > QgsSymbolV2Map;

typedef QList< QPair<QString, QPixmap> > QgsLegendSymbologyList;
typedef QList< QPair<QString, QgsSymbolV2*> > QgsLegendSymbolList;

#define RENDERER_TAG_NAME "renderer-v2"

@@ -92,6 +93,10 @@ class CORE_EXPORT QgsFeatureRendererV2
//! 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();

//! set type and size of editing vertex markers for subsequent rendering
void setVertexMarkerAppearance( int type, int size );

@@ -110,3 +110,10 @@ QgsLegendSymbologyList QgsSingleSymbolRendererV2::legendSymbologyItems( QSize ic
lst << qMakePair( QString(), pix );
return lst;
}

QgsLegendSymbolList QgsSingleSymbolRendererV2::legendSymbolItems()
{
QgsLegendSymbolList lst;
lst << qMakePair( QString(), mSymbol );
return lst;
}
@@ -37,6 +37,10 @@ class CORE_EXPORT QgsSingleSymbolRendererV2 : public QgsFeatureRendererV2
//! 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();

protected:
QgsSymbolV2* mSymbol;
};

0 comments on commit c03f5b7

Please sign in to comment.
You can’t perform that action at this time.