Skip to content
Permalink
Browse files

Atlas sort can be an expression

  • Loading branch information
nyalldawson committed Dec 19, 2017
1 parent 520c2aa commit 108c9548a7d7b899580474dd60134ae00cf29c14
@@ -43,15 +43,15 @@ QgsLayoutAtlasWidget::QgsLayoutAtlasWidget( QWidget *parent, QgsPrintLayout *lay

mAtlasCoverageLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );

connect( mAtlasCoverageLayerComboBox, &QgsMapLayerComboBox::layerChanged, mAtlasSortFeatureKeyComboBox, &QgsFieldComboBox::setLayer );
connect( mAtlasCoverageLayerComboBox, &QgsMapLayerComboBox::layerChanged, mAtlasSortExpressionWidget, &QgsFieldExpressionWidget::setLayer );
connect( mAtlasCoverageLayerComboBox, &QgsMapLayerComboBox::layerChanged, mPageNameWidget, &QgsFieldExpressionWidget::setLayer );
connect( mAtlasCoverageLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsLayoutAtlasWidget::changeCoverageLayer );
connect( mAtlasSortFeatureKeyComboBox, &QgsFieldComboBox::fieldChanged, this, &QgsLayoutAtlasWidget::changesSortFeatureField );
connect( mAtlasSortExpressionWidget, static_cast < void ( QgsFieldExpressionWidget::* )( const QString &, bool ) > ( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsLayoutAtlasWidget::changesSortFeatureExpression );
connect( mPageNameWidget, static_cast < void ( QgsFieldExpressionWidget::* )( const QString &, bool ) > ( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsLayoutAtlasWidget::pageNameExpressionChanged );

// Sort direction
mAtlasSortFeatureDirectionButton->setEnabled( false );
mAtlasSortFeatureKeyComboBox->setEnabled( false );
mAtlasSortExpressionWidget->setEnabled( false );

// connect to updates
connect( mAtlas, &QgsLayoutAtlas::changed, this, &QgsLayoutAtlasWidget::updateGuiElements );
@@ -182,19 +182,27 @@ void QgsLayoutAtlasWidget::mAtlasSortFeatureCheckBox_stateChanged( int state )
if ( state == Qt::Checked )
{
mAtlasSortFeatureDirectionButton->setEnabled( true );
mAtlasSortFeatureKeyComboBox->setEnabled( true );
mAtlasSortExpressionWidget->setEnabled( true );
}
else
{
mAtlasSortFeatureDirectionButton->setEnabled( false );
mAtlasSortFeatureKeyComboBox->setEnabled( false );
mAtlasSortExpressionWidget->setEnabled( false );
}
mLayout->undoStack()->beginCommand( mAtlas, tr( "Toggle Atlas Sorting" ) );
mAtlas->setSortFeatures( state == Qt::Checked );
mLayout->undoStack()->endCommand();
updateAtlasFeatures();
}

void QgsLayoutAtlasWidget::changesSortFeatureExpression( const QString &expression, bool )
{
mLayout->undoStack()->beginCommand( mAtlas, tr( "Change Atlas Sort" ) );
mAtlas->setSortExpression( expression );
mLayout->undoStack()->endCommand();
updateAtlasFeatures();
}

void QgsLayoutAtlasWidget::updateAtlasFeatures()
{
#if 0 //TODO
@@ -213,14 +221,6 @@ void QgsLayoutAtlasWidget::updateAtlasFeatures()
#endif
}

void QgsLayoutAtlasWidget::changesSortFeatureField( const QString &fieldName )
{
mLayout->undoStack()->beginCommand( mAtlas, tr( "Change Atlas Sort" ) );
mAtlas->setSortExpression( fieldName );
mLayout->undoStack()->endCommand();
updateAtlasFeatures();
}

void QgsLayoutAtlasWidget::mAtlasFeatureFilterCheckBox_stateChanged( int state )
{
if ( state == Qt::Checked )
@@ -319,8 +319,8 @@ void QgsLayoutAtlasWidget::updateGuiElements()
mPageNameWidget->setLayer( mAtlas->coverageLayer() );
mPageNameWidget->setField( mAtlas->pageNameExpression() );

mAtlasSortFeatureKeyComboBox->setLayer( mAtlas->coverageLayer() );
mAtlasSortFeatureKeyComboBox->setField( mAtlas->sortExpression() );
mAtlasSortExpressionWidget->setLayer( mAtlas->coverageLayer() );
mAtlasSortExpressionWidget->setField( mAtlas->sortExpression() );

mAtlasFilenamePatternEdit->setText( mAtlas->filenameExpression() );
mAtlasHideCoverageCheckBox->setCheckState( mAtlas->hideCoverage() ? Qt::Checked : Qt::Unchecked );
@@ -333,7 +333,7 @@ void QgsLayoutAtlasWidget::updateGuiElements()

mAtlasSortFeatureCheckBox->setCheckState( mAtlas->sortFeatures() ? Qt::Checked : Qt::Unchecked );
mAtlasSortFeatureDirectionButton->setEnabled( mAtlas->sortFeatures() );
mAtlasSortFeatureKeyComboBox->setEnabled( mAtlas->sortFeatures() );
mAtlasSortExpressionWidget->setEnabled( mAtlas->sortFeatures() );

mAtlasSortFeatureDirectionButton->setArrowType( mAtlas->sortAscending() ? Qt::UpArrow : Qt::DownArrow );
mAtlasFeatureFilterEdit->setText( mAtlas->filterExpression() );
@@ -356,7 +356,7 @@ void QgsLayoutAtlasWidget::blockAllSignals( bool b )
mOutputGroup->blockSignals( b );
mAtlasCoverageLayerComboBox->blockSignals( b );
mPageNameWidget->blockSignals( b );
mAtlasSortFeatureKeyComboBox->blockSignals( b );
mAtlasSortExpressionWidget->blockSignals( b );
mAtlasFilenamePatternEdit->blockSignals( b );
mAtlasHideCoverageCheckBox->blockSignals( b );
mAtlasSingleFileCheckBox->blockSignals( b );
@@ -29,27 +29,22 @@ class QgsLayoutAtlasWidget: public QWidget, private Ui::QgsLayoutAtlasWidgetBase
public:
QgsLayoutAtlasWidget( QWidget *parent, QgsPrintLayout *layout );

public slots:
private slots:
void mUseAtlasCheckBox_stateChanged( int state );
void changeCoverageLayer( QgsMapLayer *layer );
void mAtlasFilenamePatternEdit_editingFinished();
void mAtlasFilenameExpressionButton_clicked();
void mAtlasHideCoverageCheckBox_stateChanged( int state );
void mAtlasSingleFileCheckBox_stateChanged( int state );

void mAtlasSortFeatureCheckBox_stateChanged( int state );
void changesSortFeatureField( const QString &fieldName );
void changesSortFeatureExpression( const QString &expression, bool valid );
void mAtlasSortFeatureDirectionButton_clicked();
void mAtlasFeatureFilterEdit_editingFinished();
void mAtlasFeatureFilterButton_clicked();
void mAtlasFeatureFilterCheckBox_stateChanged( int state );
void pageNameExpressionChanged( const QString &expression, bool valid );

void changeFileFormat();

private slots:
void updateGuiElements();

void updateAtlasFeatures();

private:
@@ -109,10 +109,10 @@
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>-63</y>
<width>417</width>
<height>389</height>
<x>-122</x>
<y>-223</y>
<width>525</width>
<height>673</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
@@ -154,7 +154,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QgsFieldComboBox" name="mAtlasSortFeatureKeyComboBox"/>
<widget class="QgsFieldExpressionWidget" name="mAtlasSortExpressionWidget" native="true"/>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="mAtlasFeatureFilterCheckBox">
@@ -342,11 +342,6 @@
<extends>QComboBox</extends>
<header location="global">qgsmaplayercombobox.h</header>
</customwidget>
<customwidget>
<class>QgsFieldComboBox</class>
<extends>QComboBox</extends>
<header location="global">qgsfieldcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsFieldExpressionWidget</class>
<extends>QWidget</extends>
@@ -362,7 +357,7 @@
<tabstop>mAtlasFeatureFilterEdit</tabstop>
<tabstop>mAtlasFeatureFilterButton</tabstop>
<tabstop>mAtlasSortFeatureCheckBox</tabstop>
<tabstop>mAtlasSortFeatureKeyComboBox</tabstop>
<tabstop>mAtlasSortExpressionWidget</tabstop>
<tabstop>mAtlasSortFeatureDirectionButton</tabstop>
<tabstop>mOutputGroup</tabstop>
<tabstop>mAtlasFilenamePatternEdit</tabstop>
@@ -398,7 +393,6 @@
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit 108c954

Please sign in to comment.
You can’t perform that action at this time.