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