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