Skip to content

Commit

Permalink
[layout] Add printLayouts to return all print layouts contained in th…
Browse files Browse the repository at this point in the history
…e manager
  • Loading branch information
elpaso committed Jan 10, 2018
1 parent 880d853 commit f868bcc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/core/layout/qgslayoutmanager.sip
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Removes and deletes all layouts from the manager.
Returns a list of all layouts contained in the manager.
%End

QList< QgsPrintLayout * > printLayouts() const;
%Docstring
Returns a list of all print layouts contained in the manager.
%End


QgsMasterLayoutInterface *layoutByName( const QString &name ) const;
%Docstring
Expand Down
13 changes: 13 additions & 0 deletions src/core/layout/qgslayoutmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ QList<QgsMasterLayoutInterface *> QgsLayoutManager::layouts() const
return mLayouts;
}

QList<QgsPrintLayout *> QgsLayoutManager::printLayouts() const
{
QList<QgsPrintLayout *> result;
const QList<QgsMasterLayoutInterface *> _layouts( mLayouts );
for ( const auto &layout : _layouts )
{
QgsPrintLayout *_item( dynamic_cast<QgsPrintLayout *>( layout ) );
if ( _item )
result.push_back( _item );
}
return result;
}

QgsComposition *QgsLayoutManager::compositionByName( const QString &name ) const
{
Q_FOREACH ( QgsComposition *c, mCompositions )
Expand Down
6 changes: 6 additions & 0 deletions src/core/layout/qgslayoutmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QObject>

class QgsProject;
class QgsPrintLayout;

/**
* \ingroup core
Expand Down Expand Up @@ -110,6 +111,11 @@ class CORE_EXPORT QgsLayoutManager : public QObject
*/
QList< QgsMasterLayoutInterface * > layouts() const;

/**
* Returns a list of all print layouts contained in the manager.
*/
QList< QgsPrintLayout * > printLayouts() const;

/**
* Returns the composition with a matching name, or nullptr if no matching compositions
* were found.
Expand Down

0 comments on commit f868bcc

Please sign in to comment.