42#include "BackupData.hh"
75 if ( currentState_ != 0 )
76 undoStates_.push_back( currentState_ );
78 currentState_ = _backup;
81 while( !redoStates_.empty() ){
82 delete redoStates_.back();
83 redoStates_.pop_back();
87 while( undoStates_.size() > maxBackups_ ){
88 delete undoStates_.front();
89 undoStates_.erase( undoStates_.begin() );
97 if ( undoStates_.empty() )
107 undoStates_.pop_back();
108 redoStates_.push_back( currentState_ );
109 currentState_ = backup;
116 if ( redoStates_.empty() )
126 redoStates_.pop_back();
127 undoStates_.push_back( currentState_ );
128 currentState_ = backup;
135 if ( undoStates_.empty() )
138 return currentState_->
name();
145 if ( redoStates_.empty() )
148 return redoStates_.back()->name();
155 if ( undoStates_.empty() )
158 return undoStates_.back()->id();
165 if ( redoStates_.empty() )
168 return redoStates_.back()->id();
175 if ( currentState_ == 0 )
178 return currentState_->
id();
184 return !undoStates_.empty();
190 return !redoStates_.empty();
197 if( !undoStates_.empty() )
198 return currentState_->
blocked();
207 if( !redoStates_.empty() )
208 return redoStates_.back()->blocked();
216 while( !undoStates_.empty() ){
217 delete undoStates_.back();
218 undoStates_.pop_back();
221 while( !redoStates_.empty() ){
222 delete redoStates_.back();
223 redoStates_.pop_back();
226 if ( currentState_ != 0 )
227 delete currentState_;
235 if ( currentState_ != 0 )
236 currentState_->
setLinks(_objectIDs);
242 return currentState_;
std::vector< int > IdList
Standard Type for id Lists used for scripting.
void setMaxBackups(size_t _max)
set the maximum of saved backups
size_t maxBackups()
return the maximum of backups which are saved
BackupData(BaseObjectData *_object=0)
Constructor.
BaseBackup * currentState()
return the current state
bool undoAvailable()
return if an undo backup is available
void setLinks(IdList _objectIDs)
void storeBackup(BaseBackup *_backup)
store a backup
bool redoAvailable()
return if a redo backup is available
int currentID()
return the id of the current backup state
void clear()
remove all backups
virtual ~BackupData()
Destructor.
bool redoBlocked()
return if a redo backup is blocked
void undo()
perform an undo if possible
int redoID()
return the id of the next redo backup
bool undoBlocked()
return if an undo backup is blocked
QString redoName()
return the name of the next redo backup
void redo()
perform a redo if possible
QString undoName()
return the name of the next undo backup
int undoID()
return the id of the next undo backup
Class that encapsulates a backup.
bool blocked()
Returns if this backup is blocked.
virtual void apply()
Revert this backup.
int id()
get id of this backup
void setLinks(IdList _objectIDs)
Set links to corresponding backups.
QString name()
Get the backups name)