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->insertItem( 0, tr( "Landscape" ) ); mPaperOrientationComboBox->insertItem( 1, tr( "Portrait" ) ); mPaperOrientationComboBox->setCurrentIndex( 0 ); //read with/height from composition and find suitable entries to display displayCompositionWidthHeight(); if ( mComposition ) { //read printout resolution from composition mResolutionSpinBox->setValue( mComposition->printResolution() ); //print as raster if ( mComposition->printAsRaster() ) { mPrintAsRasterCheckBox->setCheckState( Qt::Checked ); } else { mPrintAsRasterCheckBox->setCheckState( Qt::Unchecked ); } //snap grid if ( mComposition->snapToGridEnabled() ) { mSnapToGridCheckBox->setCheckState( Qt::Checked ); } else { mSnapToGridCheckBox->setCheckState( Qt::Unchecked ); } mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() ); mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() ); mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() ); //grid pen width mPenWidthSpinBox->setValue( mComposition->gridPen().widthF() ); //grid pen color mGridColorButton->setColor( mComposition->gridPen().color() ); mGridStyleComboBox->insertItem( 0, tr( "Solid" ) ); mGridStyleComboBox->insertItem( 1, tr( "Dots" ) ); mGridStyleComboBox->insertItem( 2, tr( "Crosses" ) ); QgsComposition::GridStyle snapGridStyle = mComposition->gridStyle(); if ( snapGridStyle == QgsComposition::Solid ) { mGridStyleComboBox->setCurrentIndex( 0 ); } else if ( snapGridStyle == QgsComposition::Dots ) { mGridStyleComboBox->setCurrentIndex( 1 ); } else { mGridStyleComboBox->setCurrentIndex( 2 ); } } blockSignals( false ); }
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->insertItem( 0, tr( "Landscape" ) ); mPaperOrientationComboBox->insertItem( 1, tr( "Portrait" ) ); mPaperOrientationComboBox->setCurrentIndex( 0 ); //read with/height from composition and find suitable entries to display displayCompositionWidthHeight(); if ( mComposition ) { mNumPagesSpinBox->setValue( mComposition->numPages() ); updatePageStyle(); //read printout resolution from composition mResolutionSpinBox->setValue( mComposition->printResolution() ); //print as raster mPrintAsRasterCheckBox->setChecked( mComposition->printAsRaster() ); // world file generation mGenerateWorldFileCheckBox->setChecked( mComposition->generateWorldFile() ); // populate the map list mWorldFileMapComboBox->clear(); QList<const QgsComposerMap*> availableMaps = mComposition->composerMapItems(); QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin(); for ( ; mapItemIt != availableMaps.constEnd(); ++mapItemIt ) { mWorldFileMapComboBox->addItem( tr( "Map %1" ).arg(( *mapItemIt )->id() ), qVariantFromValue(( void* )*mapItemIt ) ); } int idx = mWorldFileMapComboBox->findData( qVariantFromValue(( void* )mComposition->worldFileMap() ) ); if ( idx != -1 ) { mWorldFileMapComboBox->setCurrentIndex( idx ); } // Connect to addition / removal of maps connect( mComposition, SIGNAL( composerMapAdded( QgsComposerMap* ) ), this, SLOT( onComposerMapAdded( QgsComposerMap* ) ) ); connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( onItemRemoved( QgsComposerItem* ) ) ); mAlignmentToleranceSpinBox->setValue( mComposition->alignmentSnapTolerance() ); //snap grid mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() ); mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() ); mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() ); mGridToleranceSpinBox->setValue( mComposition->snapGridTolerance() ); } blockSignals( false ); }
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->insertItem( 0, tr( "Landscape" ) ); mPaperOrientationComboBox->insertItem( 1, tr( "Portrait" ) ); mPaperOrientationComboBox->setCurrentIndex( 0 ); //read with/height from composition and find suitable entries to display displayCompositionWidthHeight(); if ( mComposition ) { mNumPagesSpinBox->setValue( mComposition->numPages() ); connect( mComposition, SIGNAL( nPagesChanged() ), this, SLOT( setNumberPages() ) ); updatePageStyle(); //read printout resolution from composition mResolutionSpinBox->setValue( mComposition->printResolution() ); //print as raster mPrintAsRasterCheckBox->setChecked( mComposition->printAsRaster() ); // world file generation mGenerateWorldFileCheckBox->setChecked( mComposition->generateWorldFile() ); // populate the map list mWorldFileMapComboBox->clear(); QList<const QgsComposerMap*> availableMaps = mComposition->composerMapItems(); QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin(); for ( ; mapItemIt != availableMaps.constEnd(); ++mapItemIt ) { mWorldFileMapComboBox->addItem( tr( "Map %1" ).arg(( *mapItemIt )->id() ), qVariantFromValue(( void* )*mapItemIt ) ); } int idx = mWorldFileMapComboBox->findData( qVariantFromValue(( void* )mComposition->worldFileMap() ) ); if ( idx != -1 ) { mWorldFileMapComboBox->setCurrentIndex( idx ); } // Connect to addition / removal of maps connect( mComposition, SIGNAL( composerMapAdded( QgsComposerMap* ) ), this, SLOT( onComposerMapAdded( QgsComposerMap* ) ) ); connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( onItemRemoved( QgsComposerItem* ) ) ); mSnapToleranceSpinBox->setValue( mComposition->snapTolerance() ); //snap grid mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() ); mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() ); mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() ); QgsAtlasComposition* atlas = &mComposition->atlasComposition(); if ( atlas ) { // repopulate data defined buttons if atlas layer changes connect( atlas, SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ), this, SLOT( populateDataDefinedButtons() ) ); connect( atlas, SIGNAL( toggled( bool ) ), this, SLOT( populateDataDefinedButtons() ) ); } } connect( mPaperSizeDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperSizeComboBox, SLOT( setDisabled( bool ) ) ); connect( mPaperWidthDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperWidthDoubleSpinBox, SLOT( setDisabled( bool ) ) ); connect( mPaperHeightDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperHeightDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperHeightDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperHeightDoubleSpinBox, SLOT( setDisabled( bool ) ) ); connect( mNumPagesDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mNumPagesDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mNumPagesDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mNumPagesSpinBox, SLOT( setDisabled( bool ) ) ); connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) ); connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperOrientationComboBox, SLOT( setDisabled( bool ) ) ); //initialize data defined buttons populateDataDefinedButtons(); blockSignals( false ); }