Wed, 22 Sep 2021 00:25:31 +0300
Merge commit
133 | 1 | #pragma once |
2 | #include "main.h" | |
3 | #include "model.h" | |
4 | #include "modeleditcontext.h" | |
5 | ||
6 | class AbstractHistoryEntry | |
7 | { | |
8 | public: | |
9 | virtual void undo(Model::EditContext& editContext) = 0; | |
10 | virtual void redo(Model::EditContext& editContext) = 0; | |
11 | }; | |
12 | ||
13 | class InsertHistoryEntry : public AbstractHistoryEntry | |
14 | { | |
15 | public: | |
16 | InsertHistoryEntry(int position, const QString& code) : | |
17 | position{position}, | |
18 | code{code} {} | |
19 | void undo(Model::EditContext& editContext) override; | |
20 | void redo(Model::EditContext& editContext) override; | |
21 | protected: | |
22 | int position; | |
23 | QString code; | |
24 | }; | |
25 | ||
26 | class DeleteHistoryEntry : public InsertHistoryEntry | |
27 | { | |
28 | public: | |
29 | void undo(Model::EditContext& editContext) override; | |
30 | void redo(Model::EditContext& editContext) override; | |
31 | }; | |
32 | ||
33 | class EditHistoryEntry : public AbstractHistoryEntry | |
34 | { | |
35 | public: | |
36 | EditHistoryEntry(int position, const QString& codeBefore, const QString& codeAfter) : | |
37 | position{position}, | |
38 | codeBefore{codeBefore}, | |
39 | codeAfter{codeAfter} {} | |
40 | void undo(Model::EditContext& editContext) override; | |
41 | void redo(Model::EditContext& editContext) override; | |
42 | private: | |
43 | int position; | |
44 | QString codeBefore; | |
45 | QString codeAfter; | |
46 | }; | |
47 | ||
48 | class EditHistory | |
49 | { | |
50 | public: | |
51 | using Changeset = QVector<std::unique_ptr<AbstractHistoryEntry>>; | |
52 | EditHistory(); | |
53 | }; |