Commit eda14009 authored by Matthias Möller's avatar Matthias Möller

update redo/undo stack of object is removed

closes #2407

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20389 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 80b96dd2
......@@ -223,6 +223,8 @@ void BackupPlugin::slotKeyEvent( QKeyEvent* _event ){
//-----------------------------------------------------------------------------
void BackupPlugin::objectDeleted(int _objectid) {
globalBackup_.eraseBackups(_objectid);
updateButtons();
}
//-----------------------------------------------------------------------------
......
......@@ -3,6 +3,8 @@
#include "GroupBackup.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <algorithm>
//-----------------------------------------------------------------------------
GroupData::GroupData() : BackupData(0)
......@@ -245,3 +247,45 @@ void GroupData::redo(int _objectid){
}
//-----------------------------------------------------------------------------
struct ContainsId_deleter
{
ContainsId_deleter(int _id):id_(_id){}
bool operator()(const BaseBackup* _b)
{
if (dynamic_cast<const GroupBackup* >(_b) && dynamic_cast<const GroupBackup* >(_b)->contains(id_))
{
delete _b;
return true;
}
return false;
}
private:
int id_;
};
void GroupData::eraseBackups(int _objectid)
{
// remove all backups in undo
undoStates_.erase(std::remove_if(undoStates_.begin(),undoStates_.end(),ContainsId_deleter(_objectid)), undoStates_.end());
redoStates_.erase(std::remove_if(redoStates_.begin(),redoStates_.end(),ContainsId_deleter(_objectid)), redoStates_.end());
//reset current state
if (ContainsId_deleter(_objectid)(currentState_))
{
currentState_ = 0;
if (!undoStates_.empty())
{
currentState_ = undoStates_.back();
undoStates_.pop_back();
}else if (!redoStates_.empty())
{
currentState_ = redoStates_.back();
redoStates_.pop_back();
}
}
}
//-----------------------------------------------------------------------------
......@@ -64,6 +64,9 @@ class GroupData : public BackupData
/// remove object from data
void updateBackupData(int _objectid, bool _isUndo);
/// erase all backups containing given id
void eraseBackups(int _objectid);
/// perform an undo if possible
void undo();
/// perform an redo if possible
......
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