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