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#include <QVector>
9
10// MythTV headers
11#include "libmythbase/programtypes.h" // for frm_dir_map_t, MarkTypes
12#include "libmythtv/mythtvexp.h"
13
14class OSD;
15class PlayerContext;
16
18{
20 QString m_message; // how we got from previous map to this map
22 : m_deleteMap(std::move(dm)), m_message(std::move(msg)) { }
23 DeleteMapUndoEntry(void) = default;
24};
25
27{
28 Q_DECLARE_TR_FUNCTIONS(DeleteMap)
29 public:
30 DeleteMap() = default;
31
32 void SetPlayerContext(PlayerContext *ctx) { m_ctx = ctx; }
33 bool HandleAction(const 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 static void UpdateOSD(std::chrono::milliseconds 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(const QString& undoMessage = "");
54 bool LoadAutoSaveMap(void);
55 void CleanMap(void);
56
57 void Clear(const QString& undoMessage = "");
58 void ReverseAll(void);
59 void NewCut(uint64_t frame);
60 void Delete(uint64_t frame, const 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 std::chrono::milliseconds TranslatePositionFrameToMs(uint64_t position,
74 float fallback_framerate,
75 bool use_cutlist) const;
76 uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds 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) const;
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 {false};
106 bool m_nextCutStartIsValid {false};
107 uint64_t m_nextCutStart {0};
109 QString m_seekText;
110 bool m_changed {true};
111 int m_seekamountpos {4};
112 float m_seekamount {1.0F};
113 PlayerContext *m_ctx {nullptr};
114 uint64_t m_cachedTotalForOSD {0};
115
116 QVector<DeleteMapUndoEntry> m_undoStack;
117 int m_undoStackPointer {0};
118};
119
120#endif // DELETEMAP_H
#define Clear(a)
float GetSeekAmount(void) const
Definition: deletemap.h:34
void SetPlayerContext(PlayerContext *ctx)
Definition: deletemap.h:32
QString m_seekText
Definition: deletemap.h:109
frm_dir_map_t m_deleteMap
Definition: deletemap.h:108
void SetChanged(bool changed=true)
Definition: deletemap.h:48
QVector< DeleteMapUndoEntry > m_undoStack
Definition: deletemap.h:116
bool IsEditing(void) const
Definition: deletemap.h:41
DeleteMap()=default
void SetSeekAmount(float amount)
Definition: deletemap.h:36
bool HasUndo(void) const
Definition: deletemap.h:87
bool IsChanged(void) const
Definition: deletemap.h:47
bool HasRedo(void) const
Definition: deletemap.h:88
Definition: osd.h:94
#define MTV_PUBLIC
Definition: mythtvexp.h:15
STL namespace.
MarkTypes
Definition: programtypes.h:46
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:117
DeleteMapUndoEntry(void)=default
QString m_message
Definition: deletemap.h:20
frm_dir_map_t m_deleteMap
Definition: deletemap.h:19
DeleteMapUndoEntry(frm_dir_map_t dm, QString msg)
Definition: deletemap.h:21