Commit 90144b76 authored by Aleksei Kanash's avatar Aleksei Kanash

Undo for duplicated items works for groups.

parent 3b1e4715
......@@ -648,6 +648,8 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync)
QList<QGraphicsItem*> duplicatedItems;
QList<QGraphicsItem*> children = groupItem->childItems();
mActiveScene->setURStackEnable(false);
foreach(QGraphicsItem* pIt, children){
UBItem* pItem = dynamic_cast<UBItem*>(pIt);
if(pItem){ // we diong sync duplication of all childs.
......@@ -668,6 +670,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync)
mActiveScene->addItem(itemToAdd);
itemToAdd->setSelected(true);
}
mActiveScene->setURStackEnable(true);
}break;
case UBMimeType::UNKNOWN:
......@@ -687,9 +690,9 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync)
if (retItem)
{
QGraphicsItem *graphicsRetItem = dynamic_cast<QGraphicsItem *>(retItem);
if (graphicsRetItem && mActiveScene->isURStackIsEnabled()) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(mActiveScene, 0, graphicsRetItem);
UBApplication::undoStack->push(uc);
if (mActiveScene->isURStackIsEnabled()) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(mActiveScene, 0, graphicsRetItem);
UBApplication::undoStack->push(uc);
}
return retItem;
}
......
......@@ -92,14 +92,6 @@ void UBGraphicsItemUndoCommand::undo()
{
QGraphicsItem* item = itAdded.next();
//if removing group
if (item->type() == UBGraphicsGroupContainerItem::Type) {
UBGraphicsGroupContainerItem *curGroup = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item);
if (curGroup) {
curGroup->destroy();
}
}
UBApplication::boardController->freezeW3CWidget(item, true);
item->setSelected(false);
mScene->removeItem(item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment