Additional fix to Sankore-979 - improved cleaning mechanism for items on board.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent b21e009108
commit 05f6cc364f
  1. 14
      src/domain/UBGraphicsGroupContainerItem.cpp
  2. 2
      src/domain/UBGraphicsGroupContainerItem.h
  3. 14
      src/frameworks/UBCoreGraphicsScene.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<UBGraphicsItem *>(child);
if (item)
{
item->clearSource();
}
}
}
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event)) {

@ -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);

@ -52,6 +52,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);
@ -76,17 +78,7 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
{
if(mItemsToDelete.contains(item))
{
UBGraphicsItem* item_casted = 0;
switch (item->type())
{
case UBGraphicsMediaItem::Type:
item_casted = dynamic_cast<UBGraphicsMediaItem*>(item);
break;
case UBGraphicsW3CWidgetItem::Type:
item_casted = dynamic_cast<UBGraphicsWidgetItem*>(item);
break;
}
UBGraphicsItem *item_casted = dynamic_cast<UBGraphicsItem *>(item);
if (0 != item_casted)
item_casted->clearSource();

Loading…
Cancel
Save