50 #include "BackupData.hh"
83 if ( currentState_ != 0 )
84 undoStates_.push_back( currentState_ );
86 currentState_ = _backup;
89 while( !redoStates_.empty() ){
90 delete redoStates_.back();
91 redoStates_.pop_back();
95 while( undoStates_.size() > maxBackups_ ){
96 delete undoStates_.front();
97 undoStates_.erase( undoStates_.begin() );
105 if ( undoStates_.empty() )
115 undoStates_.pop_back();
116 redoStates_.push_back( currentState_ );
117 currentState_ = backup;
124 if ( redoStates_.empty() )
134 redoStates_.pop_back();
135 undoStates_.push_back( currentState_ );
136 currentState_ = backup;
143 if ( undoStates_.empty() )
146 return currentState_->
name();
153 if ( redoStates_.empty() )
156 return redoStates_.back()->name();
163 if ( undoStates_.empty() )
166 return undoStates_.back()->id();
173 if ( redoStates_.empty() )
176 return redoStates_.back()->id();
183 if ( currentState_ == 0 )
186 return currentState_->
id();
192 return !undoStates_.empty();
198 return !redoStates_.empty();
205 if( !undoStates_.empty() )
206 return currentState_->
blocked();
215 if( !redoStates_.empty() )
216 return redoStates_.back()->blocked();
224 while( !undoStates_.empty() ){
225 delete undoStates_.back();
226 undoStates_.pop_back();
229 while( !redoStates_.empty() ){
230 delete redoStates_.back();
231 redoStates_.pop_back();
234 if ( currentState_ != 0 )
235 delete currentState_;
243 if ( currentState_ != 0 )
244 currentState_->
setLinks(_objectIDs);
250 return currentState_;
int redoID()
return the id of the next redo backup
Class that encapsulates a backup.
int undoID()
return the id of the next undo backup
void undo()
perform an undo if possible
void storeBackup(BaseBackup *_backup)
store a backup
void clear()
remove all backups
bool redoBlocked()
return if a redo backup is blocked
BackupData(BaseObjectData *_object=0)
Constructor.
void redo()
perform a redo if possible
void setLinks(IdList _objectIDs)
Set links to corresponding backups.
int currentID()
return the id of the current backup state
std::vector< int > IdList
Standard Type for id Lists used for scripting.
QString name()
Get the backups name)
bool undoBlocked()
return if an undo backup is blocked
int id()
get id of this backup
BaseBackup * currentState()
return the current state
bool blocked()
Returns if this backup is blocked.
bool undoAvailable()
return if an undo backup is available
void setLinks(IdList _objectIDs)
size_t maxBackups()
return the maximum of backups which are saved
virtual void apply()
Revert this backup.
QString undoName()
return the name of the next undo backup
bool redoAvailable()
return if a redo backup is available
virtual ~BackupData()
Destructor.
QString redoName()
return the name of the next redo backup
void setMaxBackups(size_t _max)
set the maximum of saved backups