Fixed z level undo issue

preferencesAboutTextFull
Didier Clerc 12 years ago
parent a8ed676683
commit 2dbade1a79
  1. 21
      src/domain/UBGraphicsItemZLevelUndoCommand.cpp

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

Loading…
Cancel
Save