Skip to content

Commit

Permalink
composer multicolumn legend: division to columns heuristic, optional …
Browse files Browse the repository at this point in the history
…splitting layers into multiple columns, optional equal column width
  • Loading branch information
blazek committed Nov 21, 2012
1 parent b177abf commit 86c2118
Show file tree
Hide file tree
Showing 6 changed files with 626 additions and 446 deletions.
31 changes: 30 additions & 1 deletion src/app/composer/qgscomposerlegendwidget.cpp
Expand Up @@ -62,7 +62,6 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): m
mWrapCharLineEdit->setText( legend->wrapChar() );

setGuiElements();
connect( mItemTreeView, SIGNAL( itemChanged() ), this, SLOT( setGuiElements() ) );

connect( mItemTreeView->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
this, SLOT( selectedChanged( const QModelIndex &, const QModelIndex & ) ) );
Expand All @@ -88,6 +87,8 @@ void QgsComposerLegendWidget::setGuiElements()
blockAllSignals( true );
mTitleLineEdit->setText( mLegend->title() );
mColumnCountSpinBox->setValue( mLegend->columnCount() );
mSplitLayerCheckBox->setChecked( mLegend->splitLayer() );
mEqualColumnWidthCheckBox->setChecked( mLegend->equalColumnWidth() );
mSymbolWidthSpinBox->setValue( mLegend->symbolWidth() );
mSymbolHeightSpinBox->setValue( mLegend->symbolHeight() );
mGroupSpaceSpinBox->setValue( mLegend->groupSpace() );
Expand Down Expand Up @@ -147,6 +148,32 @@ void QgsComposerLegendWidget::on_mColumnCountSpinBox_valueChanged( int c )
mLegend->update();
mLegend->endCommand();
}
mSplitLayerCheckBox->setEnabled( c > 1 );
mEqualColumnWidthCheckBox->setEnabled( c > 1 );
}

void QgsComposerLegendWidget::on_mSplitLayerCheckBox_toggled( bool checked )
{
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend split layers" ), QgsComposerMergeCommand::LegendSplitLayer );
mLegend->setSplitLayer( checked );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mEqualColumnWidthCheckBox_toggled( bool checked )
{
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend equal column width" ), QgsComposerMergeCommand::LegendEqualColumnWidth );
mLegend->setEqualColumnWidth( checked );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mSymbolWidthSpinBox_valueChanged( double d )
Expand Down Expand Up @@ -731,6 +758,8 @@ void QgsComposerLegendWidget::blockAllSignals( bool b )
mCheckBoxAutoUpdate->blockSignals( b );
mMapComboBox->blockSignals( b );
mColumnCountSpinBox->blockSignals( b );
mSplitLayerCheckBox->blockSignals( b );
mEqualColumnWidthCheckBox->blockSignals( b );
mSymbolWidthSpinBox->blockSignals( b );
mSymbolHeightSpinBox->blockSignals( b );
mGroupSpaceSpinBox->blockSignals( b );
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposerlegendwidget.h
Expand Up @@ -42,6 +42,8 @@ class QgsComposerLegendWidget: public QWidget, private Ui::QgsComposerLegendWidg
void on_mWrapCharLineEdit_textChanged( const QString& text );
void on_mTitleLineEdit_textChanged( const QString& text );
void on_mColumnCountSpinBox_valueChanged( int c );
void on_mSplitLayerCheckBox_toggled( bool checked );
void on_mEqualColumnWidthCheckBox_toggled( bool checked );
void on_mSymbolWidthSpinBox_valueChanged( double d );
void on_mSymbolHeightSpinBox_valueChanged( double d );
void on_mGroupSpaceSpinBox_valueChanged( double d );
Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposeritemcommand.h
Expand Up @@ -81,6 +81,8 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
//composer legend
ComposerLegendText,
LegendColumnCount,
LegendSplitLayer,
LegendEqualColumnWidth,
LegendSymbolWidth,
LegendSymbolHeight,
LegendGroupSpace,
Expand Down

0 comments on commit 86c2118

Please sign in to comment.