Skip to content

Commit

Permalink
Grouped items are not selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 9, 2017
1 parent 606ad21 commit 7c81a15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitem.cpp
Expand Up @@ -198,6 +198,7 @@ void QgsLayoutItem::setParentGroup( QgsLayoutItemGroup *group )
mParentGroupUuid.clear();
else
mParentGroupUuid = group->uuid();
setFlag( QGraphicsItem::ItemIsSelectable, !static_cast< bool>( group ) ); //item in groups cannot be selected
}

void QgsLayoutItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget * )
Expand Down
4 changes: 4 additions & 0 deletions tests/src/core/testqgslayoutitemgroup.cpp
Expand Up @@ -100,6 +100,7 @@ void TestQgsLayoutItemGroup::createGroupDirect()
QVERIFY( !item->isGroupMember() );
QVERIFY( !item2->parentGroup() );
QVERIFY( !item2->isGroupMember() );
QVERIFY( item->flags() & QGraphicsItem::ItemIsSelectable );

QgsLayoutItemGroup *group = new QgsLayoutItemGroup( &l );
l.addLayoutItem( group );
Expand All @@ -112,6 +113,7 @@ void TestQgsLayoutItemGroup::createGroupDirect()
group->addItem( item );
QCOMPARE( item->parentGroup(), group );
QVERIFY( item->isGroupMember() );
QVERIFY( !( item->flags() & QGraphicsItem::ItemIsSelectable ) ); // group items are not selectable
QVERIFY( !item2->parentGroup() );
QVERIFY( !item2->isGroupMember() );
QCOMPARE( group->items().count(), 1 );
Expand All @@ -124,6 +126,7 @@ void TestQgsLayoutItemGroup::createGroupDirect()
QVERIFY( item->isGroupMember() );
QCOMPARE( item2->parentGroup(), group );
QVERIFY( item2->isGroupMember() );
QVERIFY( !( item2->flags() & QGraphicsItem::ItemIsSelectable ) ); // group items are not selectable
QCOMPARE( group->items().count(), 2 );
QVERIFY( group->items().contains( item ) );
QVERIFY( group->items().contains( item2 ) );
Expand Down Expand Up @@ -151,6 +154,7 @@ void TestQgsLayoutItemGroup::createGroupDirect()
QVERIFY( !item2->parentGroup() );
QCOMPARE( item2->layout(), &l );
QVERIFY( l.items().contains( item2 ) );
QVERIFY( item2->flags() & QGraphicsItem::ItemIsSelectable ); // should be selectable again
}

void TestQgsLayoutItemGroup::createGroup()
Expand Down

0 comments on commit 7c81a15

Please sign in to comment.