Skip to content

Commit

Permalink
Revert "[composer] Add an apply button for atlas settings, prevents"
Browse files Browse the repository at this point in the history
This reverts commit 7934a92.

Change proved to have little value and was too easy to overlook.
  • Loading branch information
nyalldawson committed Sep 28, 2015
1 parent 8a9009d commit b713b4a
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 55 deletions.
103 changes: 84 additions & 19 deletions src/app/composer/qgsatlascompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ QgsAtlasCompositionWidget::QgsAtlasCompositionWidget( QWidget* parent, QgsCompos
mAtlasCoverageLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );

connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mAtlasSortFeatureKeyComboBox, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mAtlasCoverageLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mPageNameWidget, 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 ) ) );

// Sort direction
mAtlasSortFeatureDirectionButton->setEnabled( false );
Expand Down Expand Up @@ -80,6 +82,27 @@ 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();
Expand Down Expand Up @@ -133,6 +156,16 @@ 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();
Expand All @@ -155,6 +188,12 @@ 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 );
Expand All @@ -165,6 +204,8 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int s
mAtlasSortFeatureDirectionButton->setEnabled( false );
mAtlasSortFeatureKeyComboBox->setEnabled( false );
}
atlasMap->setSortFeatures( state == Qt::Checked );
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::updateAtlasFeatures()
Expand All @@ -190,12 +231,31 @@ 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 );
Expand All @@ -206,36 +266,30 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int
mAtlasFeatureFilterEdit->setEnabled( false );
mAtlasFeatureFilterButton->setEnabled( false );
}
atlasMap->setFilterFeatures( state == Qt::Checked );
updateAtlasFeatures();
}

void QgsAtlasCompositionWidget::on_mApplyConfigButton_clicked()
void QgsAtlasCompositionWidget::pageNameExpressionChanged( QString expression, bool valid )
{
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
if ( !atlasMap )
if ( !atlasMap || ( !valid && !expression.isEmpty() ) )
{
return;
}

QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mAtlasCoverageLayerComboBox->currentLayer() );
if ( !vl )
{
atlasMap->setCoverageLayer( 0 );
}
else
atlasMap->setPageNameExpression( expression );
}

void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_editingFinished()
{
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
if ( !atlasMap )
{
atlasMap->setCoverageLayer( vl );
return;
}

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();
}

Expand All @@ -259,6 +313,8 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
if ( !expression.isEmpty() )
{
mAtlasFeatureFilterEdit->setText( expression );
atlasMap->setFeatureFilter( mAtlasFeatureFilterEdit->text() );
updateAtlasFeatures();
}
}
}
Expand All @@ -268,6 +324,15 @@ 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()
Expand Down
6 changes: 5 additions & 1 deletion src/app/composer/qgsatlascompositionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ 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 on_mApplyConfigButton_clicked();
void pageNameExpressionChanged( QString expression, bool valid );

private slots:
void updateGuiElements();
Expand Down
41 changes: 6 additions & 35 deletions src/ui/composer/qgsatlascompositionwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>381</height>
<width>435</width>
<height>596</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -111,8 +111,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>306</width>
<height>352</height>
<width>431</width>
<height>567</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand All @@ -139,7 +139,7 @@
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,0">
<item row="4" column="2">
<widget class="QToolButton" name="mAtlasSortFeatureDirectionButton">
<property name="toolTip">
Expand Down Expand Up @@ -237,30 +237,6 @@
</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>
Expand Down Expand Up @@ -342,7 +318,7 @@
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
Expand All @@ -363,17 +339,12 @@
</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>
Expand Down

0 comments on commit b713b4a

Please sign in to comment.