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