Skip to content
Permalink
Browse files

Fix for restoring paper settings in compositionwidget

git-svn-id: http://svn.osgeo.org/qgis/trunk@12086 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Nov 11, 2009
1 parent 3e33b9e commit 21e0a63ac42d56e1ca325c38e86d800550b8444e
Showing with 23 additions and 38 deletions.
  1. +21 −38 src/app/composer/qgscompositionwidget.cpp
  2. +2 −0 src/app/composer/qgscompositionwidget.h
@@ -24,17 +24,16 @@
QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c ): QWidget( parent ), mComposition( c )
{
setupUi( this );
blockSignals( true );
createPaperEntries();

//unit
mPaperUnitsComboBox->addItem( tr( "mm" ) );
mPaperUnitsComboBox->addItem( tr( "inch" ) );

//orientation
mPaperOrientationComboBox->blockSignals( true );
mPaperOrientationComboBox->insertItem( 0, tr( "Landscape" ) );
mPaperOrientationComboBox->insertItem( 1, tr( "Portrait" ) );
mPaperOrientationComboBox->blockSignals( false );
mPaperOrientationComboBox->setCurrentIndex( 0 );

//read with/height from composition and find suitable entries to display
@@ -70,16 +69,11 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )


//grid pen width
mPenWidthSpinBox->blockSignals( true );
mPenWidthSpinBox->setValue( mComposition->gridPen().widthF() );
mPenWidthSpinBox->blockSignals( false );

//grid pen color
mGridColorButton->blockSignals( true );
mGridColorButton->setColor( mComposition->gridPen().color() );
mGridColorButton->blockSignals( false );

mGridStyleComboBox->blockSignals( true );
mGridStyleComboBox->insertItem( 0, tr( "Solid" ) );
mGridStyleComboBox->insertItem( 1, tr( "Dots" ) );
mGridStyleComboBox->insertItem( 2, tr( "Crosses" ) );
@@ -97,8 +91,8 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )
{
mGridStyleComboBox->setCurrentIndex( 2 );
}
mGridStyleComboBox->blockSignals( false );
}
blockSignals( false );
}

QgsCompositionWidget::QgsCompositionWidget(): QWidget( 0 ), mComposition( 0 )
@@ -143,17 +137,13 @@ void QgsCompositionWidget::createPaperEntries()
<< QgsCompositionPaper( tr( "Arch E (36x48 inches)" ), 914.4, 1219.2 )
<< QgsCompositionPaper( tr( "Arch E1 (30x42 inches)" ), 762, 1066.8 )
;

mPaperSizeComboBox->blockSignals( true );
mPaperSizeComboBox->addItem( tr( "Custom" ) );

for ( QList<QgsCompositionPaper>::const_iterator it = formats.begin(); it != formats.end(); it++ )
{
mPaperSizeComboBox->addItem( it->mName );
mPaperMap.insert( it->mName, *it );
}

mPaperSizeComboBox->blockSignals( false );
mPaperSizeComboBox->setCurrentIndex( 2 ); //A4
}

@@ -266,7 +256,7 @@ void QgsCompositionWidget::setSize( QDoubleSpinBox *spin, double v )
else
{
// inch (show width in inch)
spin->setValue( v / 25.4 );
spin->setValue( v / 25.4 );
}
}

@@ -337,14 +327,6 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
return;
}

//block all signals to avoid infinite recursion
mPaperSizeComboBox->blockSignals( true );
mPaperUnitsComboBox->blockSignals( true );
mPaperWidthDoubleSpinBox->blockSignals( true );
mPaperHeightDoubleSpinBox->blockSignals( true );
mPaperOrientationComboBox->blockSignals( true );
mResolutionSpinBox->blockSignals( true );

double paperWidth = mComposition->paperWidth();
setSize( mPaperWidthDoubleSpinBox, paperWidth );

@@ -383,13 +365,6 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
//custom
mPaperSizeComboBox->setCurrentIndex( 0 );
}

mPaperSizeComboBox->blockSignals( false );
mPaperUnitsComboBox->blockSignals( false );
mPaperWidthDoubleSpinBox->blockSignals( false );
mPaperHeightDoubleSpinBox->blockSignals( false );
mPaperOrientationComboBox->blockSignals( false );
mResolutionSpinBox->blockSignals( false );
}

void QgsCompositionWidget::displaySnapingSettings()
@@ -399,11 +374,6 @@ void QgsCompositionWidget::displaySnapingSettings()
return;
}

mSnapToGridCheckBox->blockSignals( true );
mGridResolutionSpinBox->blockSignals( true );
mOffsetXSpinBox->blockSignals( true );
mOffsetYSpinBox->blockSignals( true );

if ( mComposition->snapToGridEnabled() )
{
mSnapToGridCheckBox->setCheckState( Qt::Checked );
@@ -416,11 +386,6 @@ void QgsCompositionWidget::displaySnapingSettings()
mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() );
mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() );
mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() );

mSnapToGridCheckBox->blockSignals( false );
mGridResolutionSpinBox->blockSignals( false );
mOffsetXSpinBox->blockSignals( false );
mOffsetYSpinBox->blockSignals( false );
}

void QgsCompositionWidget::on_mResolutionSpinBox_valueChanged( const int value )
@@ -529,3 +494,21 @@ void QgsCompositionWidget::on_mPenWidthSpinBox_valueChanged( double d )
mComposition->setGridPen( pen );
}
}

void QgsCompositionWidget::blockSignals( bool block )
{
mPaperSizeComboBox->blockSignals( block );
mPaperUnitsComboBox->blockSignals( block );
mPaperWidthDoubleSpinBox->blockSignals( block );
mPaperHeightDoubleSpinBox->blockSignals( block );
mPaperOrientationComboBox->blockSignals( block );
mResolutionSpinBox->blockSignals( block );
mPrintAsRasterCheckBox->blockSignals( block );
mSnapToGridCheckBox->blockSignals( block );
mGridResolutionSpinBox->blockSignals( block );
mOffsetXSpinBox->blockSignals( block );
mOffsetYSpinBox->blockSignals( block );
mPenWidthSpinBox->blockSignals( block );
mGridColorButton->blockSignals( block );
mGridStyleComboBox->blockSignals( block );
}
@@ -77,4 +77,6 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase

double size( QDoubleSpinBox *spin );
void setSize( QDoubleSpinBox *spin, double v );
/**Blocks / unblocks the signals of all items*/
void blockSignals( bool block );
};

0 comments on commit 21e0a63

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