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