Skip to content

Commit

Permalink
[layouts] Alternate fix for #29821
Browse files Browse the repository at this point in the history
The previous fix resulted in #32465
  • Loading branch information
nyalldawson committed Oct 29, 2019
1 parent 42f9b67 commit dabfb94
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
38 changes: 37 additions & 1 deletion src/app/layout/qgslayoutatlaswidget.cpp
Expand Up @@ -91,6 +91,9 @@ void QgsLayoutAtlasWidget::mUseAtlasCheckBox_stateChanged( int state )

void QgsLayoutAtlasWidget::changeCoverageLayer( QgsMapLayer *layer )
{
if ( !mLayout )
return;

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );

mLayout->undoStack()->beginCommand( mAtlas, tr( "Change Atlas Layer" ) );
Expand All @@ -109,6 +112,9 @@ void QgsLayoutAtlasWidget::changeCoverageLayer( QgsMapLayer *layer )

void QgsLayoutAtlasWidget::mAtlasFilenamePatternEdit_editingFinished()
{
if ( !mLayout )
return;

QString error;
mBlockUpdates = true;
mLayout->undoStack()->beginCommand( mAtlas, tr( "Change Atlas Filename" ) );
Expand All @@ -126,7 +132,7 @@ void QgsLayoutAtlasWidget::mAtlasFilenamePatternEdit_editingFinished()

void QgsLayoutAtlasWidget::mAtlasFilenameExpressionButton_clicked()
{
if ( !mAtlas || !mAtlas->coverageLayer() )
if ( !mLayout || !mAtlas || !mAtlas->coverageLayer() )
{
return;
}
Expand Down Expand Up @@ -160,6 +166,9 @@ void QgsLayoutAtlasWidget::mAtlasFilenameExpressionButton_clicked()

void QgsLayoutAtlasWidget::mAtlasHideCoverageCheckBox_stateChanged( int state )
{
if ( !mLayout )
return;

mBlockUpdates = true;
mLayout->undoStack()->beginCommand( mAtlas, tr( "Toggle Atlas Layer" ) );
mAtlas->setHideCoverage( state == Qt::Checked );
Expand All @@ -169,6 +178,9 @@ void QgsLayoutAtlasWidget::mAtlasHideCoverageCheckBox_stateChanged( int state )

void QgsLayoutAtlasWidget::mAtlasSingleFileCheckBox_stateChanged( int state )
{
if ( !mLayout )
return;

if ( state == Qt::Checked )
{
mAtlasFilenamePatternEdit->setEnabled( false );
Expand All @@ -185,6 +197,9 @@ void QgsLayoutAtlasWidget::mAtlasSingleFileCheckBox_stateChanged( int state )

void QgsLayoutAtlasWidget::mAtlasSortFeatureCheckBox_stateChanged( int state )
{
if ( !mLayout )
return;

if ( state == Qt::Checked )
{
mAtlasSortFeatureDirectionButton->setEnabled( true );
Expand All @@ -205,6 +220,9 @@ void QgsLayoutAtlasWidget::mAtlasSortFeatureCheckBox_stateChanged( int state )

void QgsLayoutAtlasWidget::changesSortFeatureExpression( const QString &expression, bool )
{
if ( !mLayout )
return;

mBlockUpdates = true;
mLayout->undoStack()->beginCommand( mAtlas, tr( "Change Atlas Sort" ) );
mAtlas->setSortExpression( expression );
Expand All @@ -228,6 +246,9 @@ void QgsLayoutAtlasWidget::updateAtlasFeatures()

void QgsLayoutAtlasWidget::mAtlasFeatureFilterCheckBox_stateChanged( int state )
{
if ( !mLayout )
return;

if ( state == Qt::Checked )
{
mAtlasFeatureFilterEdit->setEnabled( true );
Expand All @@ -248,6 +269,9 @@ void QgsLayoutAtlasWidget::mAtlasFeatureFilterCheckBox_stateChanged( int state )

void QgsLayoutAtlasWidget::pageNameExpressionChanged( const QString &, bool valid )
{
if ( !mLayout )
return;

QString expression = mPageNameWidget->asExpression();
if ( !valid && !expression.isEmpty() )
{
Expand All @@ -263,6 +287,9 @@ void QgsLayoutAtlasWidget::pageNameExpressionChanged( const QString &, bool vali

void QgsLayoutAtlasWidget::mAtlasFeatureFilterEdit_editingFinished()
{
if ( !mLayout )
return;

QString error;
mLayout->undoStack()->beginCommand( mAtlas, tr( "Change Atlas Filter" ) );

Expand All @@ -281,6 +308,9 @@ void QgsLayoutAtlasWidget::mAtlasFeatureFilterEdit_editingFinished()

void QgsLayoutAtlasWidget::mAtlasFeatureFilterButton_clicked()
{
if ( !mLayout )
return;

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mAtlasCoverageLayerComboBox->currentLayer() );

if ( !vl )
Expand Down Expand Up @@ -319,6 +349,9 @@ void QgsLayoutAtlasWidget::mAtlasFeatureFilterButton_clicked()

void QgsLayoutAtlasWidget::mAtlasSortFeatureDirectionButton_clicked()
{
if ( !mLayout )
return;

Qt::ArrowType at = mAtlasSortFeatureDirectionButton->arrowType();
at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
mAtlasSortFeatureDirectionButton->setArrowType( at );
Expand All @@ -333,6 +366,9 @@ void QgsLayoutAtlasWidget::mAtlasSortFeatureDirectionButton_clicked()

void QgsLayoutAtlasWidget::changeFileFormat()
{
if ( !mLayout )
return;

mLayout->setCustomProperty( QStringLiteral( "atlasRasterFormat" ), mAtlasFileFormat->currentText() );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/layout/qgslayoutatlaswidget.h
Expand Up @@ -50,7 +50,7 @@ class QgsLayoutAtlasWidget: public QWidget, private Ui::QgsLayoutAtlasWidgetBase
void updateAtlasFeatures();

private:
QgsPrintLayout *mLayout = nullptr;
QPointer< QgsPrintLayout > mLayout;
QgsLayoutAtlas *mAtlas = nullptr;
QgsMessageBar *mMessageBar = nullptr;
bool mBlockUpdates = false;
Expand Down

0 comments on commit dabfb94

Please sign in to comment.