Grouped items doesn't manages by mFastAccessItems now.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 0b108d466a
commit 4b7939b6c3
  1. 5
      src/board/UBBoardController.cpp
  2. 6
      src/domain/UBGraphicsGroupContainerItem.cpp
  3. 4
      src/domain/UBGraphicsPolygonItem.cpp
  4. 11
      src/domain/UBGraphicsScene.cpp

@ -1482,11 +1482,12 @@ void UBBoardController::ClearUndoStack()
UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i); UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i);
// go through all added and removed objects, for create list of unique objects // go through all added and removed objects, for create list of unique objects
// grouped items will be deleted by groups, so we don't need do delete that items.
QSetIterator<QGraphicsItem*> itAdded(cmd->GetAddedList()); QSetIterator<QGraphicsItem*> itAdded(cmd->GetAddedList());
while (itAdded.hasNext()) while (itAdded.hasNext())
{ {
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
if( !uniqueItems.contains(item) ) if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
uniqueItems.insert(item); uniqueItems.insert(item);
} }
@ -1494,7 +1495,7 @@ void UBBoardController::ClearUndoStack()
while (itRemoved.hasNext()) while (itRemoved.hasNext())
{ {
QGraphicsItem* item = itRemoved.next(); QGraphicsItem* item = itRemoved.next();
if( !uniqueItems.contains(item) ) if( !uniqueItems.contains(item) && (item->parentItem() && UBGraphicsGroupContainerItem::Type != item->parentItem()->type()))
uniqueItems.insert(item); uniqueItems.insert(item);
} }
} }

@ -324,6 +324,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());

@ -67,8 +67,8 @@ void UBGraphicsPolygonItem::clearStroke()
if (mStroke!=NULL) if (mStroke!=NULL)
{ {
mStroke->remove(this); mStroke->remove(this);
if (mStroke->polygons().empty()) //if (mStroke->polygons().empty())
delete mStroke; // delete mStroke;
mStroke = NULL; mStroke = NULL;
} }
} }

@ -1374,9 +1374,11 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
} }
foreach (QGraphicsItem *chItem, childItems) { foreach (QGraphicsItem *chItem, childItems) {
groupItem->addToGroup(chItem); groupItem->addToGroup(chItem);
mFastAccessItems.removeAll(item);
} }
} else { } else {
groupItem->addToGroup(item); groupItem->addToGroup(item);
mFastAccessItems.removeAll(item);
} }
} }
@ -1396,6 +1398,15 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem) void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
{ {
addItem(groupItem); addItem(groupItem);
for (int i = 0; i < groupItem->childItems().count(); i++)
{
QGraphicsItem *it = qgraphicsitem_cast<QGraphicsItem *>(groupItem->childItems().at(i));
if (it)
{
mFastAccessItems.removeAll(it);
}
}
groupItem->setVisible(true); groupItem->setVisible(true);
groupItem->setFocus(); groupItem->setFocus();

Loading…
Cancel
Save