Undo/redo fix

This commit is contained in:
Jakub Melka
2020-05-03 18:52:22 +02:00
parent f604dd77b2
commit f70ff229ac
11 changed files with 189 additions and 36 deletions

View File

@ -45,7 +45,7 @@ void PDFUndoRedoManager::doUndo()
clampUndoRedoSteps();
emit undoRedoStateChanged();
emit documentChangeRequest(item.document, item.flags);
emit documentChangeRequest(pdf::PDFModifiedDocument(item.oldDocument, nullptr, item.flags));
}
void PDFUndoRedoManager::doRedo()
@ -62,7 +62,7 @@ void PDFUndoRedoManager::doRedo()
clampUndoRedoSteps();
emit undoRedoStateChanged();
emit documentChangeRequest(item.document, item.flags);
emit documentChangeRequest(pdf::PDFModifiedDocument(item.newDocument, nullptr, item.flags));
}
void PDFUndoRedoManager::clear()
@ -75,6 +75,25 @@ void PDFUndoRedoManager::clear()
}
}
void PDFUndoRedoManager::createUndo(pdf::PDFModifiedDocument document, pdf::PDFDocumentPointer oldDocument)
{
m_undoSteps.emplace_back(oldDocument, document, document.getFlags());
m_redoSteps.clear();
clampUndoRedoSteps();
emit undoRedoStateChanged();
}
void PDFUndoRedoManager::setMaximumSteps(size_t undoLimit, size_t redoLimit)
{
if (m_undoLimit != undoLimit || m_redoLimit != redoLimit)
{
m_undoLimit = undoLimit;
m_redoLimit = redoLimit;
clampUndoRedoSteps();
emit undoRedoStateChanged();
}
}
void PDFUndoRedoManager::clampUndoRedoSteps()
{
if (m_undoSteps.size() > m_undoLimit)