Skip to content
Permalink
Browse files

[layout] add missing interface to set atlas feature (#36432)

  • Loading branch information
3nids committed May 15, 2020
1 parent 2e8e158 commit 8866021fe1097fa3abce75905509ee13cec55533
@@ -109,6 +109,17 @@ Returns whether the atlas preview mode is enabled in the designer.
.. seealso:: :py:func:`setAtlasPreviewEnabled`

.. versionadded:: 3.4
%End

virtual void setAtlasFeature( const QgsFeature &feature ) = 0;
%Docstring
Sets the specified feature as the current atlas feature

.. warning::

it is the caller's responsibility to ensure that ``feature`` is a feature from the layout's current atlas coverage layer.

.. versionadded:: 3.14
%End

virtual void showItemOptions( QgsLayoutItem *item, bool bringPanelToFront = true ) = 0;
@@ -146,6 +146,11 @@ void QgsAppLayoutDesignerInterface::setAtlasPreviewEnabled( bool enabled )
mDesigner->setAtlasPreviewEnabled( enabled );
}

void QgsAppLayoutDesignerInterface::setAtlasFeature( const QgsFeature &feature )
{
mDesigner->setAtlasFeature( feature );
}

bool QgsAppLayoutDesignerInterface::atlasPreviewEnabled() const
{
return mDesigner->atlasPreviewEnabled();
@@ -4771,12 +4776,11 @@ bool QgsLayoutDesignerDialog::atlasPreviewEnabled() const
return mActionAtlasPreview->isChecked();
}

void QgsLayoutDesignerDialog::setAtlasFeature( QgsMapLayer *layer, const QgsFeature &feat )
void QgsLayoutDesignerDialog::setAtlasFeature( const QgsFeature &feature )
{
QgsLayoutAtlas *layoutAtlas = atlas();
if ( !layoutAtlas || !layoutAtlas->enabled() || layoutAtlas->coverageLayer() != layer )
if ( !layoutAtlas || !layoutAtlas->enabled() )
{
//either atlas isn't enabled, or layer doesn't match
return;
}

@@ -4788,7 +4792,7 @@ void QgsLayoutDesignerDialog::setAtlasFeature( QgsMapLayer *layer, const QgsFeat
}

//set current preview feature id
layoutAtlas->seekTo( feat );
layoutAtlas->seekTo( feature );

//bring layout window to foreground
activate();
@@ -64,6 +64,7 @@ class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
QgsMessageBar *messageBar() override;
void selectItems( const QList< QgsLayoutItem * > &items ) override;
void setAtlasPreviewEnabled( bool enabled ) override;
void setAtlasFeature( const QgsFeature &feature ) override;
bool atlasPreviewEnabled() const override;
void showItemOptions( QgsLayoutItem *item, bool bringPanelToFront = true ) override;
QMenu *layoutMenu() override;
@@ -178,7 +179,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
/**
* Sets the specified feature as the current atlas feature
*/
void setAtlasFeature( QgsMapLayer *layer, const QgsFeature &feat );
void setAtlasFeature( const QgsFeature &feature );

/**
* Sets a section \a title, to use to update the dialog title to display
@@ -9418,16 +9418,17 @@ void QgisApp::setupAtlasMapLayerAction( QgsPrintLayout *layout, bool enableActio
QgsGui::mapLayerActionRegistry()->addMapLayerAction( action );
connect( action, &QgsMapLayerAction::triggeredForFeature, this, [this, layout]( QgsMapLayer * layer, const QgsFeature & feat )
{
setLayoutAtlasFeature( layout, layer, feat );
Q_UNUSED( layer )
setLayoutAtlasFeature( layout, feat );
}
);
}
}

void QgisApp::setLayoutAtlasFeature( QgsPrintLayout *layout, QgsMapLayer *layer, const QgsFeature &feat )
void QgisApp::setLayoutAtlasFeature( QgsPrintLayout *layout, const QgsFeature &feat )
{
QgsLayoutDesignerDialog *designer = openLayoutDesignerDialog( layout );
designer->setAtlasFeature( layer, feat );
designer->setAtlasFeature( feat );
}

void QgisApp::layoutsMenuAboutToShow()
@@ -2023,7 +2023,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

void setupAtlasMapLayerAction( QgsPrintLayout *layout, bool enableAction );

void setLayoutAtlasFeature( QgsPrintLayout *layout, QgsMapLayer *layer, const QgsFeature &feat );
void setLayoutAtlasFeature( QgsPrintLayout *layout, const QgsFeature &feat );

QString saveAsVectorFileGeneral( QgsVectorLayer *vlayer = nullptr, bool symbologyOption = true, bool onlySelected = false, bool defaultToAddToMap = true );

@@ -24,6 +24,7 @@ class QgsLayout;
class QgsLayoutView;
class QgsLayoutItem;
class QgsMessageBar;
class QgsFeature;
class QgsMasterLayoutInterface;
class QMenu;
class QDockWidget;
@@ -131,6 +132,13 @@ class GUI_EXPORT QgsLayoutDesignerInterface: public QObject
*/
virtual bool atlasPreviewEnabled() const = 0;

/**
* Sets the specified feature as the current atlas feature
* \warning it is the caller's responsibility to ensure that \a feature is a feature from the layout's current atlas coverage layer.
* \since QGIS 3.14
*/
virtual void setAtlasFeature( const QgsFeature &feature ) = 0;

/**
* Shows the configuration widget for the specified layout \a item.
*

0 comments on commit 8866021

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