diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index ed75f550..5500ec9b 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -528,6 +528,8 @@ Here we determines cases when items should to get mouse press event at pressing return true; case DelegateButton::Type: + return true; + case UBGraphicsMediaItem::Type: return false; @@ -1123,6 +1125,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) else { if (isUBItem(movingItem) && + DelegateButton::Type != movingItem->type() && QGraphicsSvgItem::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() && UBToolWidget::Type != movingItem->type() && diff --git a/src/domain/UBGraphicsGroupContainerItem.cpp b/src/domain/UBGraphicsGroupContainerItem.cpp index 10be1c4d..95b95af3 100644 --- a/src/domain/UBGraphicsGroupContainerItem.cpp +++ b/src/domain/UBGraphicsGroupContainerItem.cpp @@ -79,6 +79,8 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) item->setPos(mapFromItem(item, 0, 0)); item->scene()->removeItem(item); + if (corescene()) + corescene()->removeItemFromDeletion(item); item->setParentItem(this); // removing position from translation component of the new transform @@ -225,6 +227,18 @@ void UBGraphicsGroupContainerItem::destroy() { remove(); } +void UBGraphicsGroupContainerItem::clearSource() +{ + foreach(QGraphicsItem *child, childItems()) + { + UBGraphicsItem *item = dynamic_cast(child); + if (item) + { + item->clearSource(); + } + } +} + void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (mDelegate->mousePressEvent(event)) { diff --git a/src/domain/UBGraphicsGroupContainerItem.h b/src/domain/UBGraphicsGroupContainerItem.h index 00f643d3..e8fa77eb 100644 --- a/src/domain/UBGraphicsGroupContainerItem.h +++ b/src/domain/UBGraphicsGroupContainerItem.h @@ -39,6 +39,8 @@ public: virtual void setUuid(const QUuid &pUuid); void destroy(); + virtual void clearSource(); + protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index a34d8aac..677b3e28 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1384,7 +1384,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListaddToGroup(chItem); - mFastAccessItems.removeAll(item); + mFastAccessItems.removeAll(chItem); } } else { groupItem->addToGroup(item); diff --git a/src/frameworks/UBCoreGraphicsScene.cpp b/src/frameworks/UBCoreGraphicsScene.cpp index a67d2b1c..b39eef0d 100644 --- a/src/frameworks/UBCoreGraphicsScene.cpp +++ b/src/frameworks/UBCoreGraphicsScene.cpp @@ -53,6 +53,8 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene() void UBCoreGraphicsScene::addItem(QGraphicsItem* item) { + addItemToDeletion(item); + if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { foreach (QGraphicsItem *curItem, item->childItems()) { removeItemFromDeletion(curItem); @@ -80,17 +82,7 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item) { if(mItemsToDelete.contains(item)) { - UBGraphicsItem* item_casted = 0; - switch (item->type()) - { - case UBGraphicsMediaItem::Type: - item_casted = dynamic_cast(item); - break; - case UBGraphicsW3CWidgetItem::Type: - item_casted = dynamic_cast(item); - break; - } - + UBGraphicsItem *item_casted = dynamic_cast(item); if (0 != item_casted) item_casted->clearSource();