Skip to content

Commit 457b180

Browse files
author
jef
committed
show classification attribute above the classes in legend
git-svn-id: http://svn.osgeo.org/qgis/trunk@12587 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 69bb75f commit 457b180

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/app/legend/qgslegendlayer.cpp

+20-21
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ void QgsLegendLayer::vectorLayerSymbology( const QgsVectorLayer* layer, double w
216216
const QgsRenderer* renderer = layer->renderer();
217217
const QList<QgsSymbol*> sym = renderer->symbols();
218218

219+
//create an item for each classification field (only one for most renderers)
220+
QSettings settings;
221+
if ( settings.value( "/qgis/showLegendClassifiers", false ).toBool() )
222+
{
223+
if ( renderer->needsAttributes() )
224+
{
225+
QgsAttributeList classfieldlist = renderer->classificationAttributes();
226+
const QgsFieldMap& fields = layer->pendingFields();
227+
for ( QgsAttributeList::iterator it = classfieldlist.begin(); it != classfieldlist.end(); ++it )
228+
{
229+
QString classfieldname = layer->attributeAlias( *it );
230+
if ( classfieldname.isEmpty() )
231+
{
232+
classfieldname = fields[*it].name();
233+
}
234+
itemList.append( qMakePair( classfieldname, QPixmap() ) );
235+
}
236+
}
237+
}
238+
219239
for ( QList<QgsSymbol*>::const_iterator it = sym.begin(); it != sym.end(); ++it )
220240
{
221241
QImage img;
@@ -255,27 +275,6 @@ void QgsLegendLayer::vectorLayerSymbology( const QgsVectorLayer* layer, double w
255275
itemList.append( qMakePair( values, pix ) );
256276
}
257277

258-
259-
//create an item for each classification field (only one for most renderers)
260-
QSettings settings;
261-
if ( settings.value( "/qgis/showLegendClassifiers", false ).toBool() )
262-
{
263-
if ( renderer->needsAttributes() )
264-
{
265-
QgsAttributeList classfieldlist = renderer->classificationAttributes();
266-
const QgsFieldMap& fields = layer->pendingFields();
267-
for ( QgsAttributeList::iterator it = classfieldlist.begin(); it != classfieldlist.end(); ++it )
268-
{
269-
QString classfieldname = layer->attributeAlias( *it );
270-
if ( classfieldname.isEmpty() )
271-
{
272-
classfieldname = fields[*it].name();
273-
}
274-
itemList.append( qMakePair( classfieldname, QPixmap() ) );
275-
}
276-
}
277-
}
278-
279278
changeSymbologySettings( layer, itemList );
280279
}
281280

0 commit comments

Comments
 (0)