Skip to content

Commit

Permalink
Report correct count of inserted nodes when adding legend nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jan 22, 2015
1 parent aacb1bd commit ee0e90a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -1079,24 +1079,27 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer* nodeL )

bool isEmbedded = filteredLstNew.count() == 1 && filteredLstNew[0]->isEmbeddedInParent();

if ( ! isEmbedded ) beginInsertRows( node2index( nodeL ), 0, filteredLstNew.count() - 1 );

foreach ( QgsLayerTreeModelLegendNode* n, lstNew )
{
n->setParent( this );
connect( n, SIGNAL( dataChanged() ), this, SLOT( legendNodeDataChanged() ) );
}

LayerLegendData& data = mLegend[nodeL];
LayerLegendData data;
data.originalNodes = lstNew;
data.activeNodes = filteredLstNew;

data.tree = 0;

// maybe the legend nodes form a tree - try to create a tree structure from the list
if ( testFlag( ShowLegendAsTree ) )
tryBuildLegendTree( data );

int count = data.tree ? data.tree->children[0].count() : filteredLstNew.count();

if ( ! isEmbedded ) beginInsertRows( node2index( nodeL ), 0, count - 1 );

mLegend[nodeL] = data;

if ( ! isEmbedded ) endInsertRows();
}

Expand Down

0 comments on commit ee0e90a

Please sign in to comment.