Fixed z level undo issue

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

@ -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(){

Loading…
Cancel
Save