CuteLogger
Fast and simple logging solution for Qt based applications
undohelper.h
1 /*
2  * Copyright (c) 2015-2019 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef UNDOHELPER_H
19 #define UNDOHELPER_H
20 
21 #include "models/multitrackmodel.h"
22 #include <MltPlaylist.h>
23 #include <QString>
24 #include <QMap>
25 #include <QList>
26 
27 class UndoHelper
28 {
29 public:
30  enum OptimizationHints
31  {
32  NoHints,
33  SkipXML
34  };
35  UndoHelper(MultitrackModel & model);
36 
37  void recordBeforeState();
38  void recordAfterState();
39  void undoChanges();
40  void setHints(OptimizationHints hints);
41 
42 private:
43  void debugPrintState();
44 
45  enum ChangeFlags {
46  NoChange = 0x0,
47  ClipInfoModified = 0x1,
48  XMLModified = 0x2,
49  Moved = 0x4,
50  Removed = 0x8
51  };
52 
53  struct Info {
54  int oldTrackIndex;
55  int oldClipIndex;
56  int newTrackIndex;
57  int newClipIndex;
58  bool isBlank;
59  QString xml;
60  int frame_in;
61  int frame_out;
62  int in_delta;
63  int out_delta;
64 
65  int changes;
66  Info()
67  : oldTrackIndex(-1)
68  , oldClipIndex(-1)
69  , newTrackIndex(-1)
70  , newClipIndex(-1)
71  , isBlank(false)
72  , frame_in(-1)
73  , frame_out(-1)
74  , in_delta(0)
75  , out_delta(0)
76  , changes(NoChange)
77  {}
78  };
79  QMap<QUuid,Info> m_state;
80  QList<QUuid> m_clipsAdded;
81  QList<QUuid> m_insertedOrder;
82  MultitrackModel & m_model;
83  OptimizationHints m_hints;
84 };
85 
86 #endif // UNDOHELPER_H