00001 #ifndef DELETEMAP_H
00002 #define DELETEMAP_H
00003
00004 #include "osd.h"
00005 #include "programinfo.h"
00006 #include "playercontext.h"
00007 #include "mythtvexp.h"
00008
00009 class DeleteMap;
00010
00011 typedef struct DeleteMapUndoEntry
00012 {
00013 frm_dir_map_t deleteMap;
00014 QString message;
00015 DeleteMapUndoEntry(frm_dir_map_t dm, QString msg);
00016 DeleteMapUndoEntry(void);
00017 } DeleteMapUndoEntry;
00018
00019 class MTV_PUBLIC DeleteMap
00020 {
00021 public:
00022 DeleteMap(): m_editing(false),
00023 m_nextCutStartIsValid(false),
00024 m_nextCutStart(0), m_changed(true),
00025 m_seekamountpos(4), m_seekamount(30),
00026 m_ctx(0), m_cachedTotalForOSD(0), m_undoStackPointer(-1)
00027 {
00028 Push("");
00029 }
00030
00031 void SetPlayerContext(PlayerContext *ctx) { m_ctx = ctx; }
00032 bool HandleAction(QString &action, uint64_t frame, uint64_t played,
00033 uint64_t total, double rate);
00034 int GetSeekAmount(void) const { return m_seekamount; }
00035 void UpdateSeekAmount(int change, double framerate);
00036 void SetSeekAmount(int amount) { m_seekamount = amount; }
00037
00038 void UpdateOSD(uint64_t frame, uint64_t total, double frame_rate, OSD *osd);
00039
00040 bool IsEditing(void) const { return m_editing; }
00041 void SetEditing(bool edit, OSD *osd = NULL);
00042 void SetFileEditing(bool edit);
00043 bool IsFileEditing(void);
00044 bool IsEmpty(void) const;
00045 bool IsSaved(void) const;
00046
00047 void SetMap(const frm_dir_map_t &map);
00048 void LoadCommBreakMap(uint64_t total, frm_dir_map_t &map);
00049 void SaveMap(uint64_t total, bool isAutoSave = false);
00050 void LoadMap(uint64_t total, QString undoMessage = "");
00051 bool LoadAutoSaveMap(uint64_t total);
00052 void CleanMap(uint64_t total);
00053
00054 void Clear(QString undoMessage = "");
00055 void ReverseAll(uint64_t total);
00056 void Add(uint64_t frame, uint64_t total, MarkTypes type,
00057 QString undoMessage);
00058 void NewCut(uint64_t frame, uint64_t total);
00059 void Delete(uint64_t frame, uint64_t total, QString undoMessage = "");
00060 void MoveRelative(uint64_t frame, uint64_t total, bool right);
00061 void Move(uint64_t frame, uint64_t to, uint64_t total);
00062
00063 bool IsInDelete(uint64_t frame) const;
00064 uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right,
00065 bool *hasMark = 0) const;
00066 bool IsTemporaryMark(uint64_t frame) const;
00067 bool HasTemporaryMark(void) const;
00068 uint64_t GetLastFrame(uint64_t total) const;
00069 uint64_t TranslatePositionAbsToRel(uint64_t absPosition) const {
00070 return TranslatePositionAbsToRel(m_deleteMap, absPosition);
00071 }
00072 uint64_t TranslatePositionRelToAbs(uint64_t relPosition) const {
00073 return TranslatePositionRelToAbs(m_deleteMap, relPosition);
00074 }
00075 static uint64_t TranslatePositionAbsToRel(const frm_dir_map_t &deleteMap,
00076 uint64_t absPosition);
00077 static uint64_t TranslatePositionRelToAbs(const frm_dir_map_t &deleteMap,
00078 uint64_t relPosition);
00079
00080 void TrackerReset(uint64_t frame, uint64_t total);
00081 bool TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to);
00082
00083 bool Undo(void);
00084 bool Redo(void);
00085 bool HasUndo(void) const { return m_undoStackPointer > 0; }
00086 bool HasRedo(void) const
00087 { return m_undoStackPointer < m_undoStack.size() - 1; }
00088 QString GetUndoMessage(void) const;
00089 QString GetRedoMessage(void) const;
00090
00091 private:
00092 void Add(uint64_t frame, MarkTypes type);
00093 MarkTypes Delete(uint64_t frame);
00094
00095 void Push(QString undoMessage);
00096
00097 bool m_editing;
00098 bool m_nextCutStartIsValid;
00099 uint64_t m_nextCutStart;
00100 frm_dir_map_t m_deleteMap;
00101 QString m_seekText;
00102 bool m_changed;
00103 int m_seekamountpos;
00104 int m_seekamount;
00105 PlayerContext *m_ctx;
00106 uint64_t m_cachedTotalForOSD;
00107
00108
00109 QVector<DeleteMapUndoEntry> m_undoStack;
00110 int m_undoStackPointer;
00111 };
00112
00113 #endif // DELETEMAP_H