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_;
bool redoBlocked()
return if a redo backup is blocked
void setLinks(IdList _objectIDs)
Set links to corresponding backups.
void clear()
remove all backups
void setLinks(IdList _objectIDs)
std::vector< int > IdList
Standard Type for id Lists used for scripting.
void redo()
perform a redo if possible
bool redoAvailable()
return if a redo backup is available
bool undoBlocked()
return if an undo backup is blocked
QString undoName()
return the name of the next undo backup
void setMaxBackups(size_t _max)
set the maximum of saved backups
virtual void apply()
Revert this backup.
int redoID()
return the id of the next redo backup
size_t maxBackups()
return the maximum of backups which are saved
int undoID()
return the id of the next undo backup
Class that encapsulates a backup.
virtual ~BackupData()
Destructor.
QString redoName()
return the name of the next redo backup
int currentID()
return the id of the current backup state
BackupData(BaseObjectData *_object=0)
Constructor.
void undo()
perform an undo if possible
void storeBackup(BaseBackup *_backup)
store a backup
BaseBackup * currentState()
return the current state
int id()
get id of this backup
QString name()
Get the backups name)
bool blocked()
Returns if this backup is blocked.
bool undoAvailable()
return if an undo backup is available