mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[composer] Add an apply button for atlas settings, prevents
numerous refetching/redrawing when tweaking atlas configuration
This commit is contained in:
parent
8088e35415
commit
7934a92519
@ -33,9 +33,7 @@ QgsAtlasCompositionWidget::QgsAtlasCompositionWidget( QWidget* parent, QgsCompos
|
||||
mAtlasCoverageLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );
|
||||
|
||||
connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mAtlasSortFeatureKeyComboBox, SLOT( setLayer( QgsMapLayer* ) ) );
|
||||
connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( changeCoverageLayer( QgsMapLayer* ) ) );
|
||||
connect( mAtlasSortFeatureKeyComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( changesSortFeatureField( QString ) ) );
|
||||
connect( mPageNameWidget, SIGNAL( fieldChanged( QString, bool ) ), this, SLOT( pageNameExpressionChanged( QString, bool ) ) );
|
||||
connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mPageNameWidget, SLOT( setLayer( QgsMapLayer* ) ) );
|
||||
|
||||
// Sort direction
|
||||
mAtlasSortFeatureDirectionButton->setEnabled( false );
|
||||
@ -68,27 +66,6 @@ void QgsAtlasCompositionWidget::on_mUseAtlasCheckBox_stateChanged( int state )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::changeCoverageLayer( QgsMapLayer *layer )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer );
|
||||
|
||||
if ( !vl )
|
||||
{
|
||||
atlasMap->setCoverageLayer( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
atlasMap->setCoverageLayer( vl );
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasFilenamePatternEdit_editingFinished()
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
@ -140,16 +117,6 @@ void QgsAtlasCompositionWidget::on_mAtlasFilenameExpressionButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasHideCoverageCheckBox_stateChanged( int state )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
atlasMap->setHideCoverage( state == Qt::Checked );
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasSingleFileCheckBox_stateChanged( int state )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
@ -172,12 +139,6 @@ void QgsAtlasCompositionWidget::on_mAtlasSingleFileCheckBox_stateChanged( int st
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int state )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( state == Qt::Checked )
|
||||
{
|
||||
mAtlasSortFeatureDirectionButton->setEnabled( true );
|
||||
@ -188,8 +149,6 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int s
|
||||
mAtlasSortFeatureDirectionButton->setEnabled( false );
|
||||
mAtlasSortFeatureKeyComboBox->setEnabled( false );
|
||||
}
|
||||
atlasMap->setSortFeatures( state == Qt::Checked );
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::updateAtlasFeatures()
|
||||
@ -215,31 +174,12 @@ void QgsAtlasCompositionWidget::updateAtlasFeatures()
|
||||
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::changesSortFeatureField( QString fieldName )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
atlasMap->setSortKeyAttributeName( fieldName );
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int state )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( state == Qt::Checked )
|
||||
{
|
||||
mAtlasFeatureFilterEdit->setEnabled( true );
|
||||
@ -250,22 +190,9 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int
|
||||
mAtlasFeatureFilterEdit->setEnabled( false );
|
||||
mAtlasFeatureFilterButton->setEnabled( false );
|
||||
}
|
||||
atlasMap->setFilterFeatures( state == Qt::Checked );
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::pageNameExpressionChanged( QString expression, bool valid )
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap || ( !valid && !expression.isEmpty() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
atlasMap->setPageNameExpression( expression );
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_editingFinished()
|
||||
void QgsAtlasCompositionWidget::on_mApplyConfigButton_clicked()
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
@ -273,19 +200,40 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_editingFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mAtlasCoverageLayerComboBox->currentLayer() );
|
||||
if ( !vl )
|
||||
{
|
||||
atlasMap->setCoverageLayer( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
atlasMap->setCoverageLayer( vl );
|
||||
}
|
||||
|
||||
atlasMap->setSortFeatures( mAtlasSortFeatureCheckBox->isChecked() );
|
||||
atlasMap->setSortKeyAttributeName( mAtlasSortFeatureKeyComboBox->currentField() );
|
||||
Qt::ArrowType at = mAtlasSortFeatureDirectionButton->arrowType();
|
||||
at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
|
||||
atlasMap->setSortAscending( at == Qt::UpArrow );
|
||||
atlasMap->setFilterFeatures( mAtlasFeatureFilterCheckBox->isChecked() );
|
||||
atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
|
||||
atlasMap->setPageNameExpression( mPageNameWidget->currentField() );
|
||||
atlasMap->setHideCoverage( mAtlasHideCoverageCheckBox->isChecked() );
|
||||
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
|
||||
{
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap || !atlasMap->coverageLayer() )
|
||||
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mAtlasCoverageLayerComboBox->currentLayer() );
|
||||
|
||||
if ( !atlasMap || !vl )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsExpressionBuilderDialog exprDlg( atlasMap->coverageLayer(), mAtlasFeatureFilterEdit->text(), this );
|
||||
QgsExpressionBuilderDialog exprDlg( vl, mAtlasFeatureFilterEdit->text(), this );
|
||||
exprDlg.setWindowTitle( tr( "Expression based filter" ) );
|
||||
if ( exprDlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
@ -293,8 +241,6 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
|
||||
if ( !expression.isEmpty() )
|
||||
{
|
||||
mAtlasFeatureFilterEdit->setText( expression );
|
||||
atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -304,15 +250,6 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureDirectionButton_clicked()
|
||||
Qt::ArrowType at = mAtlasSortFeatureDirectionButton->arrowType();
|
||||
at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
|
||||
mAtlasSortFeatureDirectionButton->setArrowType( at );
|
||||
|
||||
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
|
||||
if ( !atlasMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
atlasMap->setSortAscending( at == Qt::UpArrow );
|
||||
updateAtlasFeatures();
|
||||
}
|
||||
|
||||
void QgsAtlasCompositionWidget::updateGuiElements()
|
||||
|
@ -36,19 +36,15 @@ class QgsAtlasCompositionWidget:
|
||||
|
||||
public slots:
|
||||
void on_mUseAtlasCheckBox_stateChanged( int state );
|
||||
void changeCoverageLayer( QgsMapLayer* layer );
|
||||
void on_mAtlasFilenamePatternEdit_editingFinished();
|
||||
void on_mAtlasFilenameExpressionButton_clicked();
|
||||
void on_mAtlasHideCoverageCheckBox_stateChanged( int state );
|
||||
void on_mAtlasSingleFileCheckBox_stateChanged( int state );
|
||||
|
||||
void on_mAtlasSortFeatureCheckBox_stateChanged( int state );
|
||||
void changesSortFeatureField( QString fieldName );
|
||||
void on_mAtlasSortFeatureDirectionButton_clicked();
|
||||
void on_mAtlasFeatureFilterEdit_editingFinished();
|
||||
void on_mAtlasFeatureFilterButton_clicked();
|
||||
void on_mAtlasFeatureFilterCheckBox_stateChanged( int state );
|
||||
void pageNameExpressionChanged( QString expression, bool valid );
|
||||
void on_mApplyConfigButton_clicked();
|
||||
|
||||
private slots:
|
||||
void updateGuiElements();
|
||||
|
@ -997,9 +997,6 @@ void QgsComposer::toggleAtlasControls( bool atlasEnabled )
|
||||
|
||||
void QgsComposer::updateAtlasPageComboBox( int pageCount )
|
||||
{
|
||||
if ( pageCount == mAtlasPageComboBox->count() )
|
||||
return;
|
||||
|
||||
if ( !mComposition )
|
||||
return;
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>596</height>
|
||||
<width>310</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -93,8 +93,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>567</height>
|
||||
<width>306</width>
|
||||
<height>352</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="mainLayout">
|
||||
@ -121,7 +121,7 @@
|
||||
<property name="collapsed" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,0">
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
|
||||
<item row="4" column="2">
|
||||
<widget class="QToolButton" name="mAtlasSortFeatureDirectionButton">
|
||||
<property name="toolTip">
|
||||
@ -219,6 +219,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mApplyConfigButton">
|
||||
<property name="text">
|
||||
<string>Apply configuration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -274,13 +298,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>GroupBox</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -328,12 +345,17 @@
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>mUseAtlasCheckBox</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>mConfigurationGroup</tabstop>
|
||||
<tabstop>mAtlasCoverageLayerComboBox</tabstop>
|
||||
<tabstop>mAtlasHideCoverageCheckBox</tabstop>
|
||||
<tabstop>mAtlasFeatureFilterCheckBox</tabstop>
|
||||
<tabstop>mAtlasFeatureFilterEdit</tabstop>
|
||||
<tabstop>mAtlasFeatureFilterButton</tabstop>
|
||||
<tabstop>mAtlasSortFeatureCheckBox</tabstop>
|
||||
<tabstop>mAtlasSortFeatureKeyComboBox</tabstop>
|
||||
<tabstop>mAtlasSortFeatureDirectionButton</tabstop>
|
||||
<tabstop>mApplyConfigButton</tabstop>
|
||||
<tabstop>mOutputGroup</tabstop>
|
||||
<tabstop>mAtlasFilenamePatternEdit</tabstop>
|
||||
<tabstop>mAtlasFilenameExpressionButton</tabstop>
|
||||
|
Loading…
x
Reference in New Issue
Block a user