MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / createGroup

Method createGroup

src/domain/UBGraphicsScene.cpp:1782–1813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1780
1781
1782UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *> items)
1783{
1784 UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem();
1785
1786 addItem(groupItem);
1787 foreach (QGraphicsItem *item, items) {
1788 if (item->type() == UBGraphicsGroupContainerItem::Type) {
1789 QList<QGraphicsItem*> childItems = item->childItems();
1790 UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
1791 if (currentGroup) {
1792 currentGroup->destroy();
1793 }
1794 foreach (QGraphicsItem *chItem, childItems) {
1795 groupItem->addToGroup(chItem);
1796 }
1797 } else {
1798 groupItem->addToGroup(item);
1799 }
1800 }
1801
1802 groupItem->setVisible(true);
1803 groupItem->setFocus();
1804
1805 if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
1806 UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(shared_from_this(), groupItem);
1807 UBApplication::undoStack->push(uc);
1808 }
1809
1810 setDocumentUpdated();
1811
1812 return groupItem;
1813}
1814
1815void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
1816{

Callers 2

duplicateItemMethod · 0.80
groupItemsMethod · 0.80

Calls 1

setVisibleMethod · 0.45

Tested by

no test coverage detected