Skip to content
Permalink
Browse files

Grouped items are not selectable

  • Loading branch information
nyalldawson committed Oct 9, 2017
1 parent 606ad21 commit 7c81a1516dd09ca0466ec7a9e21fa3912bbbdbea
Showing with 5 additions and 0 deletions.
  1. +1 −0 src/core/layout/qgslayoutitem.cpp
  2. +4 −0 tests/src/core/testqgslayoutitemgroup.cpp
@@ -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 * )
@@ -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 );
@@ -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 );
@@ -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 ) );
@@ -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()

0 comments on commit 7c81a15

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