MythTV  master
deletemap.h
Go to the documentation of this file.
1 #ifndef DELETEMAP_H
2 #define DELETEMAP_H
3 
4 #include <QCoreApplication>
5 
6 #include "mythtvexp.h"
7 #include "programtypes.h" // for frm_dir_map_t, MarkTypes
8 
9 class OSD;
10 class PlayerContext;
11 
12 typedef struct DeleteMapUndoEntry
13 {
15  QString message; // how we got from previous map to this map
16  DeleteMapUndoEntry(const frm_dir_map_t &dm, const QString &msg);
17  DeleteMapUndoEntry(void);
19 
21 {
22  Q_DECLARE_TR_FUNCTIONS(DeleteMap)
23  public:
24  DeleteMap(): m_editing(false),
25  m_nextCutStartIsValid(false),
26  m_nextCutStart(0), m_changed(true),
27  m_seekamountpos(4), m_seekamount(1.0),
28  m_ctx(nullptr), m_cachedTotalForOSD(0), m_undoStackPointer(0)
29  {
30  }
31 
32  void SetPlayerContext(PlayerContext *ctx) { m_ctx = ctx; }
33  bool HandleAction(QString &action, uint64_t frame);
34  float GetSeekAmount(void) const { return m_seekamount; }
35  void UpdateSeekAmount(int change);
36  void SetSeekAmount(float amount) { m_seekamount = amount; }
37 
38  void UpdateOSD(uint64_t frame, double frame_rate, OSD *osd);
39  void UpdateOSD(int64_t timecode, OSD *osd);
40 
41  bool IsEditing(void) const { return m_editing; }
42  void SetEditing(bool edit, OSD *osd = nullptr);
43  void SetFileEditing(bool edit);
44  bool IsFileEditing(void);
45  bool IsEmpty(void) const;
46  bool IsSaved(void) const;
47  bool IsChanged(void) const { return m_changed; }
48  void SetChanged(bool changed = true) { m_changed = changed; }
49 
50  void SetMap(const frm_dir_map_t &map);
51  void LoadCommBreakMap(frm_dir_map_t &map);
52  void SaveMap(bool isAutoSave = false);
53  void LoadMap(QString undoMessage = "");
54  bool LoadAutoSaveMap(void);
55  void CleanMap(void);
56 
57  void Clear(QString undoMessage = "");
58  void ReverseAll(void);
59  void NewCut(uint64_t frame);
60  void Delete(uint64_t frame, QString undoMessage);
61  void MoveRelative(uint64_t frame, bool right);
62  void Move(uint64_t frame, uint64_t to);
63 
64  bool IsInDelete(uint64_t frame) const;
65  uint64_t GetNearestMark(uint64_t frame, bool right,
66  bool *hasMark = nullptr) const;
67  bool IsTemporaryMark(uint64_t frame) const;
68  bool HasTemporaryMark(void) const;
69  uint64_t GetLastFrame(void) const;
70 
71  // Provide translations between frame numbers and millisecond
72  // durations, optionally taking the custlist into account.
73  uint64_t TranslatePositionFrameToMs(uint64_t position,
74  float fallback_framerate,
75  bool use_cutlist) const;
76  uint64_t TranslatePositionMsToFrame(uint64_t dur_ms,
77  float fallback_framerate,
78  bool use_cutlist) const;
79  uint64_t TranslatePositionAbsToRel(uint64_t position) const;
80  uint64_t TranslatePositionRelToAbs(uint64_t position) const;
81 
82  void TrackerReset(uint64_t frame);
83  bool TrackerWantsToJump(uint64_t frame, uint64_t &to);
84 
85  bool Undo(void);
86  bool Redo(void);
87  bool HasUndo(void) const { return m_undoStackPointer > 0; }
88  bool HasRedo(void) const
89  { return m_undoStackPointer < m_undoStack.size(); }
90  QString GetUndoMessage(void) const;
91  QString GetRedoMessage(void) const;
92 
93  private:
94  void AddMark(uint64_t frame, MarkTypes type);
95  void Add(uint64_t frame, MarkTypes type);
96  MarkTypes Delete(uint64_t frame);
97 
98  void Push(const QString &undoMessage);
99  void PushDeferred(const frm_dir_map_t &savedMap,
100  const QString &undoMessage);
101 
102  QString CreateTimeString(uint64_t frame, bool use_cutlist,
103  double frame_rate, bool full_resolution) const;
104 
105  bool m_editing;
107  uint64_t m_nextCutStart;
109  QString m_seekText;
110  bool m_changed;
115 
116  QVector<DeleteMapUndoEntry> m_undoStack;
118 };
119 
120 #endif // DELETEMAP_H
frm_dir_map_t deleteMap
Definition: deletemap.h:14
float m_seekamount
Definition: deletemap.h:112
bool IsEditing(void) const
Definition: deletemap.h:41
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
bool m_changed
Definition: deletemap.h:110
uint64_t m_cachedTotalForOSD
Definition: deletemap.h:114
bool HasUndo(void) const
Definition: deletemap.h:87
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
int m_undoStackPointer
Definition: deletemap.h:117
int m_seekamountpos
Definition: deletemap.h:111
void SetPlayerContext(PlayerContext *ctx)
Definition: deletemap.h:32
bool m_editing
Definition: deletemap.h:105
float GetSeekAmount(void) const
Definition: deletemap.h:34
MarkTypes
Definition: programtypes.h:48
uint64_t m_nextCutStart
Definition: deletemap.h:107
QVector< DeleteMapUndoEntry > m_undoStack
Definition: deletemap.h:116
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
#define MTV_PUBLIC
Definition: mythtvexp.h:15
bool HasRedo(void) const
Definition: deletemap.h:88
void SetChanged(bool changed=true)
Definition: deletemap.h:48
bool m_nextCutStartIsValid
Definition: deletemap.h:106
QString m_seekText
Definition: deletemap.h:109
struct DeleteMapUndoEntry DeleteMapUndoEntry
void SetSeekAmount(float amount)
Definition: deletemap.h:36
bool IsChanged(void) const
Definition: deletemap.h:47
PlayerContext * m_ctx
Definition: deletemap.h:113
DeleteMapUndoEntry(void)
Definition: deletemap.cpp:28
Definition: osd.h:132
DeleteMap()
Definition: deletemap.h:24
#define Clear(a)
frm_dir_map_t m_deleteMap
Definition: deletemap.h:108