Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layout] Added template method to retrieve QgsLayoutObjects
  • Loading branch information
elpaso committed Jan 9, 2018
1 parent 8f3692a commit 3f081b8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/core/layout/qgslayout.sip
Expand Up @@ -87,6 +87,7 @@ Returns the items model attached to the layout.
%End



QList<QgsLayoutItem *> selectedLayoutItems( const bool includeLockedItems = true );
%Docstring
Returns list of selected layout items.
Expand Down
27 changes: 27 additions & 0 deletions src/core/layout/qgslayout.h
Expand Up @@ -133,6 +133,33 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
}
}

/**
* Returns a list of layout objects (items and multiframes) of a specific type.
* \note not available in Python bindings
*/
template<class T> void layoutObjects( QList<T *> &objectList ) const SIP_SKIP
{
objectList.clear();
const QList<QGraphicsItem *> itemList( items() );
const QList<QgsLayoutMultiFrame *> frameList( multiFrames() );
for ( const auto &obj : itemList )
{
T *item = dynamic_cast<T *>( obj );
if ( item )
{
objectList.push_back( item );
}
}
for ( const auto &obj : frameList )
{
T *item = dynamic_cast<T *>( obj );
if ( item )
{
objectList.push_back( item );
}
}
}

/**
* Returns list of selected layout items.
*
Expand Down

0 comments on commit 3f081b8

Please sign in to comment.