Wed, 22 Sep 2021 00:25:31 +0300
Merge commit
#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<std::unique_ptr<AbstractHistoryEntry>>; EditHistory(); };