prepare view provider for undo/redo

This commit is contained in:
wmayer
2016-06-20 12:50:21 +02:00
parent f0e00311cd
commit 9ec06b47c6
12 changed files with 181 additions and 70 deletions

View File

@@ -1937,6 +1937,12 @@ DocumentObject * Document::addObject(const char* sType, const char* pObjectName,
// mark the object as new (i.e. set status bit 2) and send the signal
pcObject->StatusBits.set(2);
signalNewObject(*pcObject);
// do no transactions if we do a rollback!
if (!d->rollback && d->activeUndoTransaction) {
signalTransactionAppend(*pcObject, d->activeUndoTransaction);
}
signalActivatedObject(*pcObject);
// return the Object
@@ -1979,6 +1985,12 @@ void Document::addObject(DocumentObject* pcObject, const char* pObjectName)
// mark the object as new (i.e. set status bit 2) and send the signal
pcObject->StatusBits.set(2);
signalNewObject(*pcObject);
// do no transactions if we do a rollback!
if (!d->rollback && d->activeUndoTransaction) {
signalTransactionAppend(*pcObject, d->activeUndoTransaction);
}
signalActivatedObject(*pcObject);
}
@@ -1991,14 +2003,20 @@ void Document::_addObject(DocumentObject* pcObject, const char* pObjectName)
pcObject->pcNameInDocument = &(d->objectMap.find(ObjectName)->first);
// do no transactions if we do a rollback!
if(!d->rollback){
if (!d->rollback) {
// Undo stuff
if (d->activeUndoTransaction)
d->activeUndoTransaction->addObjectDel(pcObject);
}
// send the signal
signalNewObject(*pcObject);
// do no transactions if we do a rollback!
if (!d->rollback && d->activeUndoTransaction) {
signalTransactionAppend(*pcObject, d->activeUndoTransaction);
}
d->activeObject = pcObject;
signalActivatedObject(*pcObject);
}
@@ -2022,9 +2040,20 @@ void Document::remObject(const char* sName)
if (!d->undoing && !d->rollback) {
pos->second->unsetupObject();
}
signalDeletedObject(*(pos->second));
pos->second->StatusBits.reset (ObjectStatus::Delete); // Unset the bit to be on the safe side
// do no transactions if we do a rollback!
if (!d->rollback && d->activeUndoTransaction) {
// in this case transaction delete or save the object
signalTransactionRemove(*pos->second, d->activeUndoTransaction);
}
else {
// if not saved in undo -> delete object
signalTransactionRemove(*pos->second, 0);
}
if (!d->vertexMap.empty()) {
// recompute of document is running
for (std::map<Vertex,DocumentObject*>::iterator it = d->vertexMap.begin(); it != d->vertexMap.end(); ++it) {
@@ -2051,9 +2080,10 @@ void Document::remObject(const char* sName)
// in this case transaction delete or save the object
d->activeUndoTransaction->addObjectNew(pos->second);
}
else
else {
// if not saved in undo -> delete object
delete pos->second;
}
}
for (std::vector<DocumentObject*>::iterator obj = d->objectArray.begin(); obj != d->objectArray.end(); ++obj) {
@@ -2098,9 +2128,12 @@ void Document::_remObject(DocumentObject* pcObject)
// do no transactions if we do a rollback!
if (!d->rollback) {
// Undo stuff
if (d->activeUndoTransaction)
if (d->activeUndoTransaction) {
signalTransactionRemove(*pcObject, d->activeUndoTransaction);
d->activeUndoTransaction->addObjectNew(pcObject);
}
}
// remove from map
d->objectMap.erase(pos);