Skip to content

Commit

Permalink
Fix #11331 (hidden group still occupies space in composer legend)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 20, 2014
1 parent ac5ff27 commit 0c7bc40
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/core/qgslegendrenderer.cpp
Expand Up @@ -162,28 +162,31 @@ QList<QgsLegendRenderer::Atom> QgsLegendRenderer::createAtomList( QgsLayerTreeGr
// Group subitems
QList<Atom> groupAtoms = createAtomList( nodeGroup, splitLayer );

Nucleon nucleon;
nucleon.item = node;
nucleon.size = drawGroupTitle( nodeGroup );

if ( groupAtoms.size() > 0 )
{
// Add internal space between this group title and the next nucleon
groupAtoms[0].size.rheight() += spaceAboveAtom( groupAtoms[0] );
// Prepend this group title to the first atom
groupAtoms[0].nucleons.prepend( nucleon );
groupAtoms[0].size.rheight() += nucleon.size.height();
groupAtoms[0].size.rwidth() = qMax( nucleon.size.width(), groupAtoms[0].size.width() );
}
else
if ( nodeLegendStyle( nodeGroup ) != QgsComposerLegendStyle::Hidden )
{
// no subitems, append new atom
Atom atom;
atom.nucleons.append( nucleon );
atom.size.rwidth() += nucleon.size.width();
atom.size.rheight() += nucleon.size.height();
atom.size.rwidth() = qMax( nucleon.size.width(), atom.size.width() );
groupAtoms.append( atom );
Nucleon nucleon;
nucleon.item = node;
nucleon.size = drawGroupTitle( nodeGroup );

if ( groupAtoms.size() > 0 )
{
// Add internal space between this group title and the next nucleon
groupAtoms[0].size.rheight() += spaceAboveAtom( groupAtoms[0] );
// Prepend this group title to the first atom
groupAtoms[0].nucleons.prepend( nucleon );
groupAtoms[0].size.rheight() += nucleon.size.height();
groupAtoms[0].size.rwidth() = qMax( nucleon.size.width(), groupAtoms[0].size.width() );
}
else
{
// no subitems, append new atom
Atom atom;
atom.nucleons.append( nucleon );
atom.size.rwidth() += nucleon.size.width();
atom.size.rheight() += nucleon.size.height();
atom.size.rwidth() = qMax( nucleon.size.width(), atom.size.width() );
groupAtoms.append( atom );
}
}
atoms.append( groupAtoms );
}
Expand Down

0 comments on commit 0c7bc40

Please sign in to comment.