Skip to content
Permalink
Browse files
[composer] Improved method for setting/checking whether items are in …
…a group
  • Loading branch information
nyalldawson committed Jul 4, 2014
1 parent 6cddd05 commit 55ed6286785edec9d76a5bd84fd87b470858ec13
@@ -453,6 +453,20 @@ class QgsComposerItem : QObject, QGraphicsRectItem
@note this method was added in version 2.0
@note there is not setter since one can't manually set the id*/
QString uuid() const;

/**Returns whether this item is part of a group
* @returns true if item is in a group
* @note added in version 2.5
* @see setIsGroupMember
*/
bool isGroupMember() const;

/**Sets whether this item is part of a group
* @param isGroupMember set to true if item is in a group
* @note added in version 2.5
* @see isGroupMember
*/
void setIsGroupMember( bool isGroupMember );

/**Get the number of layers that this item requires for exporting as layers
* @returns 0 if this item is to be placed on the same layer as the previous item,
@@ -64,6 +64,7 @@ QgsComposerItem::QgsComposerItem( QgsComposition* composition, bool manageZValue
, mEffectsEnabled( true )
, mTransparency( 0 )
, mLastUsedPositionMode( UpperLeft )
, mIsGroupMember( false )
, mCurrentExportLayer( -1 )
, mId( "" )
, mUuid( QUuid::createUuid().toString() )
@@ -89,6 +90,7 @@ QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, Q
, mEffectsEnabled( true )
, mTransparency( 0 )
, mLastUsedPositionMode( UpperLeft )
, mIsGroupMember( false )
, mCurrentExportLayer( -1 )
, mId( "" )
, mUuid( QUuid::createUuid().toString() )
@@ -1178,3 +1180,9 @@ void QgsComposerItem::setId( const QString& id )
setToolTip( id );
mId = id;
}

void QgsComposerItem::setIsGroupMember( bool isGroupMember )
{
mIsGroupMember = isGroupMember;
setFlag( QGraphicsItem::ItemIsSelectable, !isGroupMember ); //item in groups cannot be selected
}
@@ -409,6 +409,20 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
@note there is not setter since one can't manually set the id*/
QString uuid() const { return mUuid; }

/**Returns whether this item is part of a group
* @returns true if item is in a group
* @note added in version 2.5
* @see setIsGroupMember
*/
bool isGroupMember() const { return mIsGroupMember; }

/**Sets whether this item is part of a group
* @param isGroupMember set to true if item is in a group
* @note added in version 2.5
* @see isGroupMember
*/
void setIsGroupMember( bool isGroupMember );

/**Get the number of layers that this item requires for exporting as layers
* @returns 0 if this item is to be placed on the same layer as the previous item,
* 1 if it should be placed on its own layer, and >1 if it requires multiple export layers
@@ -484,6 +498,9 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
@note: this member was added in version 2.0*/
ItemPositionMode mLastUsedPositionMode;

/**Whether or not this item is part of a group*/
bool mIsGroupMember;

/**The layer that needs to be exported
@note: if -1, all layers are to be exported
@note: this member was added in version 2.4*/
@@ -37,7 +37,7 @@ QgsComposerItemGroup::~QgsComposerItemGroup()
if ( *itemIt )
{
mComposition->removeItem( *itemIt );
( *itemIt )->setFlag( QGraphicsItem::ItemIsSelectable, true );
( *itemIt )->setIsGroupMember( false );
}
}
}
@@ -58,7 +58,7 @@ void QgsComposerItemGroup::addItem( QgsComposerItem* item )

mItems.insert( item );
item->setSelected( false );
item->setFlag( QGraphicsItem::ItemIsSelectable, false ); //item in groups cannot be selected
item->setIsGroupMember( true );

//update extent
if ( mBoundingRectangle.isEmpty() ) //we add the first item
@@ -100,7 +100,7 @@ void QgsComposerItemGroup::removeItems()
QSet<QgsComposerItem*>::iterator item_it = mItems.begin();
for ( ; item_it != mItems.end(); ++item_it )
{
( *item_it )->setFlag( QGraphicsItem::ItemIsSelectable, true ); //enable item selection again
( *item_it )->setIsGroupMember( false );
( *item_it )->setSelected( true );
}
mItems.clear();

0 comments on commit 55ed628

Please sign in to comment.