Skip to content

Commit 0a93f94

Browse files
committedAug 13, 2015
fixups (to be rebased)
- removed the setParent since the parent is already set here - moved the legendNode->invalidateMapBasedData() after size setting (removed dupplicate call) - moved max icon size computation in the loop over layers
1 parent 8776449 commit 0a93f94

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed
 

‎src/core/layertree/qgslayertreemodel.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,34 +1311,33 @@ void QgsLayerTreeModel::legendInvalidateMapBasedData()
13111311
// we do that here because for symbols with size defined in map units
13121312
// the symbol sizes changes depends on the zoom level
13131313

1314-
QList<QgsSymbolV2LegendNode*> symbolNodes;
1315-
QMap<QString, int> widthMax;
13161314
foreach ( const LayerLegendData& data, mLegend )
13171315
{
1316+
QList<QgsSymbolV2LegendNode*> symbolNodes;
1317+
QMap<QString, int> widthMax;
13181318
foreach ( QgsLayerTreeModelLegendNode* legendNode, data.originalNodes )
13191319
{
1320-
legendNode->invalidateMapBasedData();
13211320
QgsSymbolV2LegendNode* n = dynamic_cast<QgsSymbolV2LegendNode*>( legendNode );
13221321
if ( n )
13231322
{
1324-
n->setParent( this ); // map scale are in the model, so the parent needs to be set
13251323
const QSize sz( n->minimumIconSize() );
13261324
const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );
13271325
widthMax[parentKey] = qMax( sz.width(), widthMax.contains( parentKey ) ? widthMax[parentKey] : 0 );
13281326
n->setIconSize( sz );
13291327
symbolNodes.append( n );
13301328
}
13311329
}
1330+
foreach ( QgsSymbolV2LegendNode* n, symbolNodes )
1331+
{
1332+
const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );
1333+
Q_ASSERT( widthMax[parentKey] > 0 );
1334+
const int twiceMarginWidth = 2; // a one pixel margin avoids hugly rendering of icon
1335+
n->setIconSize( QSize( widthMax[parentKey] + twiceMarginWidth, n->iconSize().rheight() + twiceMarginWidth ) );
1336+
}
1337+
foreach ( QgsLayerTreeModelLegendNode* legendNode, data.originalNodes )
1338+
legendNode->invalidateMapBasedData();
13321339
}
13331340

1334-
foreach ( QgsSymbolV2LegendNode* n, symbolNodes )
1335-
{
1336-
const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );
1337-
Q_ASSERT( widthMax[parentKey] > 0 );
1338-
const int twiceMarginWidth = 2; // a one pixel margin avoids hugly rendering of icon
1339-
n->setIconSize( QSize( widthMax[parentKey] + twiceMarginWidth, n->iconSize().rheight() + twiceMarginWidth ) );
1340-
n->invalidateMapBasedData();
1341-
}
13421341
}
13431342

13441343
// Legend nodes routines - end

0 commit comments

Comments
 (0)
Please sign in to comment.