| 1780 | |
| 1781 | |
| 1782 | UBGraphicsGroupContainerItem *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 | |
| 1815 | void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem) |
| 1816 | { |
no test coverage detected