|
|
@ -28,18 +28,12 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent |
|
|
|
setUuid(QUuid::createUuid()); |
|
|
|
setUuid(QUuid::createUuid()); |
|
|
|
|
|
|
|
|
|
|
|
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
|
|
|
|
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem() |
|
|
|
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem() |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (QGraphicsItem *item, childItems()) |
|
|
|
if (mDelegate) |
|
|
|
{
|
|
|
|
delete mDelegate; |
|
|
|
removeFromGroup(item); |
|
|
|
|
|
|
|
if (item && item->scene()) |
|
|
|
|
|
|
|
item->scene()->removeItem(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) |
|
|
|
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) |
|
|
@ -83,6 +77,8 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) |
|
|
|
|
|
|
|
|
|
|
|
QTransform newItemTransform(itemTransform); |
|
|
|
QTransform newItemTransform(itemTransform); |
|
|
|
item->setPos(mapFromItem(item, 0, 0)); |
|
|
|
item->setPos(mapFromItem(item, 0, 0)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
item->scene()->removeItem(item); |
|
|
|
item->setParentItem(this); |
|
|
|
item->setParentItem(this); |
|
|
|
|
|
|
|
|
|
|
|
// removing position from translation component of the new transform
|
|
|
|
// removing position from translation component of the new transform
|
|
|
@ -113,10 +109,12 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!item) { |
|
|
|
if (!item) { |
|
|
|
qDebug() << "can't specify the item because of the null pointer"; |
|
|
|
qDebug() << "can't specify the item because of the null pointer"; |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsScene *groupScene = scene(); |
|
|
|
UBCoreGraphicsScene *groupScene = corescene(); |
|
|
|
if (groupScene) { |
|
|
|
if (groupScene) |
|
|
|
|
|
|
|
{
|
|
|
|
groupScene->addItemToDeletion(item); |
|
|
|
groupScene->addItemToDeletion(item); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -170,9 +168,9 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsScene *UBGraphicsGroupContainerItem::scene() |
|
|
|
UBCoreGraphicsScene *UBGraphicsGroupContainerItem::corescene() |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsScene *castScene = dynamic_cast<UBGraphicsScene*>(QGraphicsItem::scene()); |
|
|
|
UBCoreGraphicsScene *castScene = dynamic_cast<UBCoreGraphicsScene*>(QGraphicsItem::scene()); |
|
|
|
|
|
|
|
|
|
|
|
return castScene; |
|
|
|
return castScene; |
|
|
|
} |
|
|
|
} |
|
|
@ -218,15 +216,7 @@ void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid) |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsGroupContainerItem::destroy() { |
|
|
|
void UBGraphicsGroupContainerItem::destroy() { |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsScene *groupScene = scene(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (QGraphicsItem *item, childItems()) { |
|
|
|
foreach (QGraphicsItem *item, childItems()) { |
|
|
|
|
|
|
|
|
|
|
|
if (groupScene) { |
|
|
|
|
|
|
|
groupScene->addItemToDeletion(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pRemoveFromGroup(item); |
|
|
|
pRemoveFromGroup(item); |
|
|
|
item->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
item->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
item->setFlag(QGraphicsItem::ItemIsFocusable, true); |
|
|
|
item->setFlag(QGraphicsItem::ItemIsFocusable, true); |
|
|
@ -327,6 +317,12 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item) |
|
|
|
item->setParentItem(newParent); |
|
|
|
item->setParentItem(newParent); |
|
|
|
item->setPos(oldPos); |
|
|
|
item->setPos(oldPos); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsScene *Scene = dynamic_cast<UBGraphicsScene *>(item->scene()); |
|
|
|
|
|
|
|
if (Scene) |
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Scene->addItem(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// removing position from translation component of the new transform
|
|
|
|
// removing position from translation component of the new transform
|
|
|
|
if (!item->pos().isNull()) |
|
|
|
if (!item->pos().isNull()) |
|
|
|
itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); |
|
|
|
itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); |
|
|
|