36 changes: 36 additions & 0 deletions src/app/composer/qgsatlascompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void QgsAtlasCompositionWidget::onLayerAdded( QgsMapLayer* map )
if ( mAtlasCoverageLayerComboBox->count() == 1 )
{
atlasMap->setCoverageLayer( vectorLayer );
updateAtlasFeatures();
checkLayerType( vectorLayer );
}
}
Expand Down Expand Up @@ -191,6 +192,7 @@ void QgsAtlasCompositionWidget::on_mAtlasCoverageLayerComboBox_currentIndexChang
{
checkLayerType( layer );
atlasMap->setCoverageLayer( layer );
updateAtlasFeatures();
}

// update sorting columns
Expand Down Expand Up @@ -333,6 +335,36 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int s
mAtlasSortFeatureKeyComboBox->setEnabled( false );
}
atlasMap->setSortFeatures( state == Qt::Checked );
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::updateAtlasFeatures()
{
//only do this if composer mode is preview
if ( !mComposition->atlasPreviewEnabled() )
{
return;
}

//update atlas features
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
if ( !atlasMap )
{
return;
}

bool updated = atlasMap->updateFeatures();
if ( !updated )
{
QMessageBox::warning( 0, tr( "Atlas preview" ),
tr( "No matching atlas features found!" ),
QMessageBox::Ok,
QMessageBox::Ok );

//Perhaps atlas preview should be disabled now? If so, it may get annoying if user is editing
//the filter expression and it keeps disabling itself.
return;
}
}

void QgsAtlasCompositionWidget::on_mAtlasSortFeatureKeyComboBox_currentIndexChanged( int index )
Expand All @@ -347,6 +379,7 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureKeyComboBox_currentIndexChan
{
atlasMap->setSortKeyAttributeIndex( index );
}
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int state )
Expand All @@ -368,6 +401,7 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int
mAtlasFeatureFilterButton->setEnabled( false );
}
atlasMap->setFilterFeatures( state == Qt::Checked );
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_textChanged( const QString& text )
Expand All @@ -379,6 +413,7 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_textChanged( const QS
}

atlasMap->setFeatureFilter( text );
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
Expand Down Expand Up @@ -415,6 +450,7 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureDirectionButton_clicked()
}

atlasMap->setSortAscending( at == Qt::UpArrow );
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::fillSortColumns()
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgsatlascompositionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class QgsAtlasCompositionWidget:

void updateGuiElements();

void updateAtlasFeatures();

private:
QgsComposition* mComposition;

Expand Down
Loading