Skip to content
Permalink
Browse files

Composer Legend: Add spacing for groups. Fixes #4247 Patch by Anna

Kratochvilova. Thanks!
  • Loading branch information
NathanW2 committed Feb 7, 2012
1 parent c2fee79 commit c5f7f1ea6331d187704f752d9d3550578f22cd71
@@ -81,6 +81,7 @@ void QgsComposerLegendWidget::setGuiElements()
mTitleLineEdit->setText( mLegend->title() );
mSymbolWidthSpinBox->setValue( mLegend->symbolWidth() );
mSymbolHeightSpinBox->setValue( mLegend->symbolHeight() );
mGroupSpaceSpinBox->setValue( mLegend->groupSpace() );
mLayerSpaceSpinBox->setValue( mLegend->layerSpace() );
mSymbolSpaceSpinBox->setValue( mLegend->symbolSpace() );
mIconLabelSpaceSpinBox->setValue( mLegend->iconLabelSpace() );
@@ -140,6 +141,18 @@ void QgsComposerLegendWidget::on_mSymbolHeightSpinBox_valueChanged( double d )
}
}

void QgsComposerLegendWidget::on_mGroupSpaceSpinBox_valueChanged( double d )
{
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend group space" ), QgsComposerMergeCommand::LegendGroupSpace );
mLegend->setGroupSpace( d );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mLayerSpaceSpinBox_valueChanged( double d )
{
if ( mLegend )
@@ -641,6 +654,7 @@ void QgsComposerLegendWidget::blockAllSignals( bool b )
mMapComboBox->blockSignals( b );
mSymbolWidthSpinBox->blockSignals( b );
mSymbolHeightSpinBox->blockSignals( b );
mGroupSpaceSpinBox->blockSignals( b );
mLayerSpaceSpinBox->blockSignals( b );
mSymbolSpaceSpinBox->blockSignals( b );
mIconLabelSpaceSpinBox->blockSignals( b );
@@ -42,6 +42,7 @@ class QgsComposerLegendWidget: public QWidget, private Ui::QgsComposerLegendWidg
void on_mTitleLineEdit_textChanged( const QString& text );
void on_mSymbolWidthSpinBox_valueChanged( double d );
void on_mSymbolHeightSpinBox_valueChanged( double d );
void on_mGroupSpaceSpinBox_valueChanged( double d );
void on_mLayerSpaceSpinBox_valueChanged( double d );
void on_mSymbolSpaceSpinBox_valueChanged( double d );
void on_mIconLabelSpaceSpinBox_valueChanged( double d );
@@ -79,6 +79,7 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
ComposerLegendText,
LegendSymbolWidth,
LegendSymbolHeight,
LegendGroupSpace,
LegendLayerSpace,
LegendSymbolSpace,
LegendIconSymbolSpace,
@@ -32,6 +32,7 @@ QgsComposerLegend::QgsComposerLegend( QgsComposition* composition )
: QgsComposerItem( composition )
, mTitle( tr( "Legend" ) )
, mBoxSpace( 2 )
, mGroupSpace( 2 )
, mLayerSpace( 2 )
, mSymbolSpace( 2 )
, mIconLabelSpace( 2 ), mComposerMap( 0 )
@@ -165,7 +166,7 @@ void QgsComposerLegend::drawGroupItem( QPainter* p, QgsComposerGroupItem* groupI
return;
}

currentYCoord += mLayerSpace;
currentYCoord += mGroupSpace;
currentYCoord += fontAscentMillimeters( mGroupFont );

p->setPen( QColor( 0, 0, 0 ) );
@@ -642,6 +643,7 @@ bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const
composerLegendElem.setAttribute( "layerFont", mLayerFont.toString() );
composerLegendElem.setAttribute( "itemFont", mItemFont.toString() );
composerLegendElem.setAttribute( "boxSpace", QString::number( mBoxSpace ) );
composerLegendElem.setAttribute( "groupSpace", QString::number( mGroupSpace ) );
composerLegendElem.setAttribute( "layerSpace", QString::number( mLayerSpace ) );
composerLegendElem.setAttribute( "symbolSpace", QString::number( mSymbolSpace ) );
composerLegendElem.setAttribute( "iconLabelSpace", QString::number( mIconLabelSpace ) );
@@ -697,6 +699,7 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument

//spaces
mBoxSpace = itemElem.attribute( "boxSpace", "2.0" ).toDouble();
mGroupSpace = itemElem.attribute( "groupSpace", "3.0" ).toDouble();
mLayerSpace = itemElem.attribute( "layerSpace", "3.0" ).toDouble();
mSymbolSpace = itemElem.attribute( "symbolSpace", "2.0" ).toDouble();
mIconLabelSpace = itemElem.attribute( "iconLabelSpace", "2.0" ).toDouble();
@@ -72,6 +72,9 @@ class CORE_EXPORT QgsComposerLegend: public QgsComposerItem
double boxSpace() const {return mBoxSpace;}
void setBoxSpace( double s ) {mBoxSpace = s;}

double groupSpace() const {return mGroupSpace;}
void setGroupSpace( double s ) {mGroupSpace = s;}

double layerSpace() const {return mLayerSpace;}
void setLayerSpace( double s ) {mLayerSpace = s;}

@@ -122,6 +125,8 @@ class CORE_EXPORT QgsComposerLegend: public QgsComposerItem

/**Space between item box and contents*/
double mBoxSpace;
/**Vertical space between group entries*/
double mGroupSpace;
/**Vertical space between layer entries*/
double mLayerSpace;
/**Vertical space between symbol entries*/
@@ -44,15 +44,15 @@
<item row="0" column="0">
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>-26</y>
<y>0</y>
<width>370</width>
<height>440</height>
<height>471</height>
</rect>
</property>
<attribute name="label">
@@ -116,7 +116,7 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QDoubleSpinBox" name="mLayerSpaceSpinBox">
<property name="prefix">
<string>Layer space </string>
@@ -126,7 +126,7 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="12" column="0">
<widget class="QDoubleSpinBox" name="mSymbolSpaceSpinBox">
<property name="prefix">
<string>Symbol space </string>
@@ -136,7 +136,7 @@
</property>
</widget>
</item>
<item row="11" column="0">
<item row="13" column="0">
<widget class="QDoubleSpinBox" name="mIconLabelSpaceSpinBox">
<property name="prefix">
<string>Icon label space </string>
@@ -146,7 +146,7 @@
</property>
</widget>
</item>
<item row="12" column="0">
<item row="14" column="0">
<widget class="QDoubleSpinBox" name="mBoxSpaceSpinBox">
<property name="prefix">
<string>Box space </string>
@@ -156,7 +156,7 @@
</property>
</widget>
</item>
<item row="15" column="0">
<item row="17" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -169,10 +169,10 @@
</property>
</spacer>
</item>
<item row="14" column="0">
<item row="16" column="0">
<widget class="QComboBox" name="mMapComboBox"/>
</item>
<item row="13" column="0">
<item row="15" column="0">
<widget class="QLabel" name="mMapLabel">
<property name="text">
<string>Map</string>
@@ -189,6 +189,16 @@
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QDoubleSpinBox" name="mGroupSpaceSpinBox">
<property name="prefix">
<string>Group Space </string>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">

0 comments on commit c5f7f1e

Please sign in to comment.
You can’t perform that action at this time.