54 foreach (
int id, order )
55 orderStr << QString::number(
id );
56 QString str = orderStr.isEmpty() ?
"empty" : orderStr.join(
"," );
65 int numNodes = lst.count();
74 QgsDebugMsg(
"Legend node order manipulation is invalid without existing legend" );
81 for (
int i = 0; i < numNodes; ++i )
88 QString orderStr = nodeLayer->
customProperty(
"legend/node-order" ).toString();
90 if ( orderStr.isEmpty() )
93 if ( orderStr ==
"empty" )
99 foreach ( QString item, orderStr.split(
"," ) )
102 int id = item.toInt( &ok );
103 if ( !ok || id < 0 || id >= numNodes )
119 nodeLayer->
setCustomProperty(
"legend/label-" + QString::number( originalIndex ), newLabel );
124 return nodeLayer->
customProperty(
"legend/label-" + QString::number( originalIndex ) ).toString();
129 return nodeLayer->
customProperties().contains(
"legend/label-" + QString::number( originalIndex ) );
140 if ( !userLabel.isNull() )
149 QList<QgsLayerTreeModelLegendNode*> newOrder;
150 QSet<int> usedIndices;
151 foreach (
int idx, order )
153 if ( usedIndices.contains( idx ) )
159 newOrder << nodes[idx];
164 for (
int i = 0; i < nodes.count(); ++i )
166 if ( !usedIndices.contains( i ) )
181 connect( mLayer, SIGNAL( rendererChanged() ),
this, SIGNAL(
itemsChanged() ) );
186 QList<QgsLayerTreeModelLegendNode*> nodes;
192 if ( nodeLayer->
customProperty(
"showFeatureCount", 0 ).toBool() )
206 if ( nodes.count() == 1 && nodes[0]->data( Qt::EditRole ).toString().isEmpty() )
207 nodes[0]->setEmbeddedInParent(
true );
220 connect( mLayer, SIGNAL( rendererChanged() ),
this, SIGNAL(
itemsChanged() ) );
225 QList<QgsLayerTreeModelLegendNode*> nodes;
234 if ( rasterItemList.count() == 0 )
240 int max_count = 1000;
242 for ( QgsLegendColorList::const_iterator itemIt = rasterItemList.constBegin();
243 itemIt != rasterItemList.constEnd(); ++itemIt, ++count )
247 if ( count == max_count )
249 QString label =
tr(
"following %1 items\nnot displayed" ).arg( rasterItemList.size() - max_count );
269 QList<QgsLayerTreeModelLegendNode*> nodes;
271 QSize iconSize( 16, 16 );
274 if ( symbologyList.count() == 0 )
277 typedef QPair<QString, QPixmap> XY;
278 foreach ( XY item, symbologyList )