Skip to content
Permalink
Browse files

[layout] Added template method to retrieve QgsLayoutObjects

  • Loading branch information
elpaso committed Jan 9, 2018
1 parent 8f3692a commit 3f081b858832510d8987ff0ff2d67012f602dcb0
Showing with 28 additions and 0 deletions.
  1. +1 −0 python/core/layout/qgslayout.sip
  2. +27 −0 src/core/layout/qgslayout.h
@@ -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.
@@ -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.
*

0 comments on commit 3f081b8

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