|
|
@ -25,17 +25,28 @@ UBGraphicsItemZLevelUndoCommand::~UBGraphicsItemZLevelUndoCommand(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsItemZLevelUndoCommand::undo(){ |
|
|
|
void UBGraphicsItemZLevelUndoCommand::undo(){ |
|
|
|
if(!mpScene) |
|
|
|
if(!mpScene || mItems.empty()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, mItems){ |
|
|
|
// Getting the difference between the initial z-value and the actual one
|
|
|
|
if(mDest == UBZLayerController::down){ |
|
|
|
qreal zDiff = qAbs(mItems.at(mItems.size()-1)->data(UBGraphicsItemData::ItemOwnZValue).toReal() - mPreviousZLevel); |
|
|
|
mpScene->changeZLevelTo(item, UBZLayerController::up); |
|
|
|
|
|
|
|
}else if(mDest == UBZLayerController::up){ |
|
|
|
if(mDest == UBZLayerController::down || mDest == UBZLayerController::bottom){ |
|
|
|
mpScene->changeZLevelTo(item, UBZLayerController::down); |
|
|
|
// Move up
|
|
|
|
|
|
|
|
QList<QGraphicsItem*>::iterator downIt = mItems.end(); |
|
|
|
|
|
|
|
for(downIt; downIt >= mItems.begin(); downIt--){ |
|
|
|
|
|
|
|
for(int i=0; i<zDiff; i++) |
|
|
|
|
|
|
|
mpScene->changeZLevelTo(*downIt, UBZLayerController::up); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(mDest == UBZLayerController::up || mDest == UBZLayerController::top){ |
|
|
|
|
|
|
|
// Move down
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, mItems){ |
|
|
|
|
|
|
|
for(int i=0; i<zDiff; i++) |
|
|
|
|
|
|
|
mpScene->changeZLevelTo(item, UBZLayerController::down); |
|
|
|
} |
|
|
|
} |
|
|
|
updateLazyScene(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsItemZLevelUndoCommand::redo(){ |
|
|
|
void UBGraphicsItemZLevelUndoCommand::redo(){ |
|
|
|