diff -r f77d2230e87c -r d384df40c8e7 src/edithistory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/edithistory.h Wed Sep 22 00:25:31 2021 +0300 @@ -0,0 +1,53 @@ +#pragma once +#include "main.h" +#include "model.h" +#include "modeleditcontext.h" + +class AbstractHistoryEntry +{ +public: + virtual void undo(Model::EditContext& editContext) = 0; + virtual void redo(Model::EditContext& editContext) = 0; +}; + +class InsertHistoryEntry : public AbstractHistoryEntry +{ +public: + InsertHistoryEntry(int position, const QString& code) : + position{position}, + code{code} {} + void undo(Model::EditContext& editContext) override; + void redo(Model::EditContext& editContext) override; +protected: + int position; + QString code; +}; + +class DeleteHistoryEntry : public InsertHistoryEntry +{ +public: + void undo(Model::EditContext& editContext) override; + void redo(Model::EditContext& editContext) override; +}; + +class EditHistoryEntry : public AbstractHistoryEntry +{ +public: + EditHistoryEntry(int position, const QString& codeBefore, const QString& codeAfter) : + position{position}, + codeBefore{codeBefore}, + codeAfter{codeAfter} {} + void undo(Model::EditContext& editContext) override; + void redo(Model::EditContext& editContext) override; +private: + int position; + QString codeBefore; + QString codeAfter; +}; + +class EditHistory +{ +public: + using Changeset = QVector>; + EditHistory(); +}; \ No newline at end of file