Skip to content
Permalink
Browse files

composer legend optional space between columns

  • Loading branch information
blazek committed Nov 21, 2012
1 parent 86c2118 commit e029bc77f39bc6e389168dab21d003f4b359262f
@@ -96,6 +96,7 @@ void QgsComposerLegendWidget::setGuiElements()
mSymbolSpaceSpinBox->setValue( mLegend->symbolSpace() );
mIconLabelSpaceSpinBox->setValue( mLegend->iconLabelSpace() );
mBoxSpaceSpinBox->setValue( mLegend->boxSpace() );
mColumnSpaceSpinBox->setValue( mLegend->columnSpace() );
if ( mLegend->model() )
{
mCheckBoxAutoUpdate->setChecked( mLegend->model()->autoUpdate() );
@@ -336,7 +337,6 @@ void QgsComposerLegendWidget::on_mItemFontButton_clicked()
}
}


void QgsComposerLegendWidget::on_mBoxSpaceSpinBox_valueChanged( double d )
{
if ( mLegend )
@@ -349,6 +349,18 @@ void QgsComposerLegendWidget::on_mBoxSpaceSpinBox_valueChanged( double d )
}
}

void QgsComposerLegendWidget::on_mColumnSpaceSpinBox_valueChanged( double d )
{
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend box space" ), QgsComposerMergeCommand::LegendColumnSpace );
mLegend->setColumnSpace( d );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mMoveDownToolButton_clicked()
{
if ( !mLegend )
@@ -767,6 +779,7 @@ void QgsComposerLegendWidget::blockAllSignals( bool b )
mSymbolSpaceSpinBox->blockSignals( b );
mIconLabelSpaceSpinBox->blockSignals( b );
mBoxSpaceSpinBox->blockSignals( b );
mColumnSpaceSpinBox->blockSignals( b );
}

void QgsComposerLegendWidget::refreshMapComboBox()
@@ -55,6 +55,7 @@ class QgsComposerLegendWidget: public QWidget, private Ui::QgsComposerLegendWidg
void on_mLayerFontButton_clicked();
void on_mItemFontButton_clicked();
void on_mBoxSpaceSpinBox_valueChanged( double d );
void on_mColumnSpaceSpinBox_valueChanged( double d );
void on_mCheckBoxAutoUpdate_stateChanged( int state );
void on_mMapComboBox_currentIndexChanged( int index );

@@ -90,6 +90,7 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
LegendSymbolSpace,
LegendIconSymbolSpace,
LegendBoxSpace,
LegendColumnSpace,
//composer picture
ComposerPictureRotation,
// composer scalebar
@@ -34,6 +34,7 @@ QgsComposerLegend::QgsComposerLegend( QgsComposition* composition )
: QgsComposerItem( composition )
, mTitle( tr( "Legend" ) )
, mBoxSpace( 2 )
, mColumnSpace( 2 )
, mGroupSpace( 2 )
, mLayerSpace( 2 )
, mSymbolSpace( 2 )
@@ -117,14 +118,13 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
if ( atom.column > column )
{
// Switch to next column
// Using mBoxSpace for inter column space
if ( mEqualColumnWidth )
{
point.rx() += mBoxSpace + maxColumnWidth;
point.rx() += mColumnSpace + maxColumnWidth;
}
else
{
point.rx() += mBoxSpace + columnWidth;
point.rx() += mColumnSpace + columnWidth;
}
point.ry() = columnTop;
columnWidth = 0;
@@ -290,7 +290,6 @@ QSizeF QgsComposerLegend::drawLayerItemTitle( QgsComposerLayerItem* layerItem, Q

void QgsComposerLegend::adjustBoxSize()
{
mColumns.clear();
QSizeF size = paintAndDetermineSize( 0 );
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( size.width() ).arg( size.height() ) );
if ( size.isValid() )
@@ -642,7 +641,6 @@ QStringList QgsComposerLegend::layerIdList() const
void QgsComposerLegend::synchronizeWithModel()
{
QgsDebugMsg( "Entered" );
mColumns.clear();
adjustBoxSize();
update();
}
@@ -656,23 +654,20 @@ void QgsComposerLegend::setTitleFont( const QFont& f )

void QgsComposerLegend::setGroupFont( const QFont& f )
{
mColumns.clear();
mGroupFont = f;
adjustBoxSize();
update();
}

void QgsComposerLegend::setLayerFont( const QFont& f )
{
mColumns.clear();
mLayerFont = f;
adjustBoxSize();
update();
}

void QgsComposerLegend::setItemFont( const QFont& f )
{
mColumns.clear();
mItemFont = f;
adjustBoxSize();
update();
@@ -724,6 +719,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( "columnSpace", QString::number( mColumnSpace ) );
composerLegendElem.setAttribute( "groupSpace", QString::number( mGroupSpace ) );
composerLegendElem.setAttribute( "layerSpace", QString::number( mLayerSpace ) );
composerLegendElem.setAttribute( "symbolSpace", QString::number( mSymbolSpace ) );
@@ -785,6 +781,7 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument

//spaces
mBoxSpace = itemElem.attribute( "boxSpace", "2.0" ).toDouble();
mColumnSpace = itemElem.attribute( "columnSpace", "2.0" ).toDouble();
mGroupSpace = itemElem.attribute( "groupSpace", "3.0" ).toDouble();
mLayerSpace = itemElem.attribute( "layerSpace", "3.0" ).toDouble();
mSymbolSpace = itemElem.attribute( "symbolSpace", "2.0" ).toDouble();
@@ -822,7 +819,6 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument

void QgsComposerLegend::setComposerMap( const QgsComposerMap* map )
{
mColumns.clear();
mComposerMap = map;
if ( map )
{
@@ -832,7 +828,10 @@ void QgsComposerLegend::setComposerMap( const QgsComposerMap* map )

void QgsComposerLegend::invalidateCurrentMap()
{
disconnect( mComposerMap, SIGNAL( destroyed( QObject* ) ), this, SLOT( invalidateCurrentMap() ) );
if ( mComposerMap )
{
disconnect( mComposerMap, SIGNAL( destroyed( QObject* ) ), this, SLOT( invalidateCurrentMap() ) );
}
mComposerMap = 0;
}

@@ -73,31 +73,34 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
void setItemFont( const QFont& f );

double boxSpace() const {return mBoxSpace;}
void setBoxSpace( double s ) {mBoxSpace = s; mColumns.clear();}
void setBoxSpace( double s ) {mBoxSpace = s;}

double columnSpace() const {return mColumnSpace;}
void setColumnSpace( double s ) { mColumnSpace = s;}

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

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

double symbolSpace() const {return mSymbolSpace;}
void setSymbolSpace( double s ) {mSymbolSpace = s;mColumns.clear();}
void setSymbolSpace( double s ) {mSymbolSpace = s;}

double iconLabelSpace() const {return mIconLabelSpace;}
void setIconLabelSpace( double s ) {mIconLabelSpace = s;mColumns.clear();}
void setIconLabelSpace( double s ) {mIconLabelSpace = s;}

double symbolWidth() const {return mSymbolWidth;}
void setSymbolWidth( double w ) {mSymbolWidth = w;mColumns.clear();}
void setSymbolWidth( double w ) {mSymbolWidth = w;}

double symbolHeight() const {return mSymbolHeight;}
void setSymbolHeight( double h ) {mSymbolHeight = h;mColumns.clear();}
void setSymbolHeight( double h ) {mSymbolHeight = h;}

void setWrapChar( const QString& t ) {mWrapChar = t;mColumns.clear();}
void setWrapChar( const QString& t ) {mWrapChar = t;}
QString wrapChar() const {return mWrapChar;}

int columnCount() const { return mColumnCount; }
void setColumnCount( int c ) { mColumnCount = c;mColumns.clear();}
void setColumnCount( int c ) { mColumnCount = c;}

int splitLayer() const { return mSplitLayer; }
void setSplitLayer( bool s ) { mSplitLayer = s;}
@@ -141,6 +144,8 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem

/**Space between item box and contents*/
double mBoxSpace;
/**Space between columns*/
double mColumnSpace;
/**Vertical space between group entries*/
double mGroupSpace;
/**Vertical space between layer entries*/
@@ -159,8 +164,6 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem

/** Number of legend columns */
int mColumnCount;
/** Cached division of items to columns */
QMap<QStandardItem *, int> mColumns;

QgsLegendModel mLegendModel;

@@ -50,9 +50,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-115</y>
<width>370</width>
<height>533</height>
<height>562</height>
</rect>
</property>
<attribute name="label">
@@ -153,7 +153,7 @@
</property>
</widget>
</item>
<item row="24" column="1">
<item row="25" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -166,10 +166,10 @@
</property>
</spacer>
</item>
<item row="20" column="1">
<item row="21" column="1">
<widget class="QComboBox" name="mMapComboBox"/>
</item>
<item row="19" column="1">
<item row="20" column="1">
<widget class="QLabel" name="mMapLabel">
<property name="text">
<string>Map</string>
@@ -186,14 +186,14 @@
</property>
</widget>
</item>
<item row="22" column="1">
<item row="23" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Wrap text on</string>
</property>
</widget>
</item>
<item row="23" column="1">
<item row="24" column="1">
<widget class="QLineEdit" name="mWrapCharLineEdit">
<property name="frame">
<bool>true</bool>
@@ -247,6 +247,16 @@
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QDoubleSpinBox" name="mColumnSpaceSpinBox">
<property name="prefix">
<string>Column space </string>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
@@ -255,7 +265,7 @@
<x>0</x>
<y>0</y>
<width>427</width>
<height>401</height>
<height>139</height>
</rect>
</property>
<attribute name="label">

0 comments on commit e029bc7

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