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