Go to the documentation of this file.
18 #define LOC QString("DelMap: ")
19 #define EDIT_CHECK do { \
21 LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot edit outside edit mode."); \
38 const QString &undoMessage)
78 tr(
"(Nothing to undo)"));
84 tr(
"(Nothing to redo)"));
95 Clear(tr(
"Clear Cuts"));
98 else if (
action ==
"MOVEPREV")
100 else if (
action ==
"MOVENEXT")
102 else if (
action ==
"CUTTOBEGINNING")
104 Push(tr(
"Cut to Beginning"));
107 else if (
action ==
"CUTTOEND")
109 Push(tr(
"Cut to End"));
116 else if (
action ==
"NEWCUT")
120 else if (
action ==
"DELETE")
123 Delete(frame, tr(
"Delete"));
125 else if (
action ==
"UNDO")
129 else if (
action ==
"REDO")
163 double frame_rate,
bool full_resolution)
167 QString fmt = (ms >= 1h) ?
"H:mm:ss" :
"mm:ss";
189 QString cutmarker =
" ";
191 cutmarker = tr(
"cut");
195 QString relTimeDisplay;
197 QString relLengthDisplay;
199 infoMap[
"timedisplay"] = timestr;
200 infoMap[
"framedisplay"] = QString::number(frame);
201 infoMap[
"cutindicator"] = cutmarker;
202 infoMap[
"title"] = tr(
"Edit");
204 infoMap[
"reltimedisplay"] = relTimeDisplay;
205 infoMap[
"rellengthdisplay"] = relLengthDisplay;
207 infoMap[
"fulltimedisplay"] = tr(
"%3 (%1 of %2)")
208 .arg(relTimeDisplay, relLengthDisplay, timestr);
210 QHash<QString,float> posMap;
211 posMap.insert(
"position", (
float)((
double)frame/(
double)total));
267 if (!undoMessage.isEmpty())
277 Push(tr(
"Reverse Cuts"));
296 frm_dir_map_t::Iterator find_temporary =
m_deleteMap.find(frame);
313 long long lastframe = -1;
314 long long remove = -1;
315 QMutableMapIterator<uint64_t, MarkTypes> it(
m_deleteMap);
323 if (it.key() > frame)
329 lasttype = it.value();
330 lastframe = it.key();
333 (lastframe > -1) && (lastframe < (int64_t)frame))
340 while (it.hasPrevious())
343 if (it.key() <= frame)
349 lasttype = it.value();
350 lastframe = it.key();
353 (lastframe > -1) && (lastframe > (int64_t)frame))
370 if (!undoMessage.isEmpty())
378 frm_dir_map_t::Iterator it =
m_deleteMap.find(frame);
381 int type = it.value();
406 int64_t existing = -1;
419 auto otherframe =
static_cast<uint64_t
>(existing);
420 if (otherframe == frame)
424 uint64_t startframe = 0;
425 uint64_t endframe = 0;
426 int64_t cut_start = -1;
427 int64_t cut_end = -1;
433 frm_dir_map_t::Iterator it2 =
m_deleteMap.find(frame);
446 if (otherframe < frame)
448 startframe = otherframe;
449 endframe = cut_end != -1 ?
static_cast<uint64_t
>(cut_end)
454 startframe = cut_start != -1 ?
static_cast<uint64_t
>(cut_start)
456 endframe = otherframe;
463 if (endframe >= total - 1)
467 if ((startframe == 0) && (endframe == total))
469 LOG(VB_GENERAL, LOG_CRIT,
LOC +
470 "Refusing to cut entire recording.");
479 frm_dir_map_t::Iterator it =
m_deleteMap.find(startframe);
480 for ( ; it !=
m_deleteMap.end() && otherframe < endframe; ++it)
482 otherframe = it.key();
483 if ((startframe < otherframe) && (endframe > otherframe))
485 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
486 QString(
"Deleting bounded marker: %1").arg(otherframe));
505 frm_dir_map_t::Iterator it =
m_deleteMap.find(frame);
508 int type = it.value();
522 Delete(frame, tr(
"Delete"));
541 Push(tr(
"Move Mark"));
580 frm_dir_map_t::const_iterator it =
m_deleteMap.find(frame);
585 uint64_t lastframe = UINT64_MAX;
588 if (it.key() > frame)
590 lasttype = it.value();
591 lastframe = it.key();
605 frm_dir_map_t::const_iterator it =
m_deleteMap.find(frame);
621 frm_dir_map_t::const_iterator it =
m_deleteMap.begin();
626 if (it.key() > frame)
636 if (it.key() >= frame)
678 int64_t lastframe = -1;
679 int64_t tempframe = -1;
680 QList<int64_t> deleteList;
683 int thistype = it.value();
684 uint64_t thisframe = it.key();
685 if (thisframe >= total)
687 deleteList.append(thisframe);
689 else if (lasttype == thistype)
691 deleteList.append(thistype ==
MARK_CUT_END ? thisframe :
692 (uint64_t)lastframe);
699 deleteList.append(tempframe);
700 tempframe = thisframe;
705 lastframe = thisframe;
711 for (
const int64_t & dit : std::as_const(deleteList))
733 Push(tr(
"Load Detected Commercials"));
735 for (
auto it = map.begin(); it != map.end(); ++it)
747 if (!undoMessage.isEmpty())
786 QMutableMapIterator<uint64_t, MarkTypes> it(
m_deleteMap);
818 frm_dir_map_t::iterator cutpoint =
m_deleteMap.find(frame);
839 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Tracker next CUT_START: %1")
853 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
854 QString(
"Tracker wants to jump to: %1").arg(to));
868 frm_dir_map_t::const_iterator it =
m_deleteMap.end();
891 QMutableMapIterator<uint64_t, MarkTypes> it(currentMap);
899 return currentMap == savedMap;
903 float fallback_framerate,
904 bool use_cutlist)
const
912 float fallback_framerate,
913 bool use_cutlist)
const
void SaveMap(bool isAutoSave=false)
Saves the delete map to the database.
static constexpr const char * ACTION_DOWN
void UnlockPlayingInfo(const char *file, int line) const
void Add(uint64_t frame, MarkTypes type)
Private addition to the deleteMap.
uint64_t GetTotalFrameCount(void) const
void ReverseAll(void)
Reverses the direction of each mark in the map.
uint64_t TranslatePositionRelToAbs(uint64_t position) const
void TrackerReset(uint64_t frame)
Resets the internal state tracker.
QVector< DeleteMapUndoEntry > m_undoStack
bool LoadAutoSaveMap(void)
Returns true if an auto-save map was loaded.
uint64_t GetNearestMark(uint64_t frame, bool right, bool *hasMark=nullptr) const
Returns the next or previous mark.
std::chrono::milliseconds TranslatePositionFrameToMs(uint64_t position, float fallback_framerate, bool use_cutlist) const
void SetMap(const frm_dir_map_t &map)
Use the given map.
void SetGraph(const QString &Window, const QString &Graph, std::chrono::milliseconds Timecode)
bool IsDatabaseIgnored(void) const
/brief Returns true if database is being ignored.
void SetFileEditing(bool edit)
Update the editing status in the file's ProgramInfo.
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
QString formatTime(std::chrono::milliseconds msecs, QString fmt)
Format a milliseconds time value.
void SetEditing(bool editing)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
uint64_t GetCurrentFrameCount(void) const
void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total)
static constexpr const char * OSD_WIN_PROGEDIT
void SetEditing(bool edit, OSD *osd=nullptr)
Set the edit mode and optionally hide the edit mode OSD.
void Push(const QString &undoMessage)
QString GetUndoMessage(void) const
bool TrackerWantsToJump(uint64_t frame, uint64_t &to) const
Returns true if the given frame has passed the last cut point start and provides the frame number of ...
uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds dur_ms, float fallback_framerate, const frm_dir_map_t &cutlist)
void CleanMap(void)
Removes redundant marks and ensures the markup sequence is valid.
QHash< QString, QString > InfoMap
static uint64_t TranslatePositionAbsToRel(const frm_dir_map_t &deleteMap, uint64_t absPosition, const frm_pos_map_t &map=frm_pos_map_t(), float fallback_ratio=1.0)
ProgramInfo * m_playingInfo
Currently playing info.
void NewCut(uint64_t frame)
Add a new cut marker (to start or end a cut region)
void LockPlayingInfo(const char *file, int line) const
static uint64_t TranslatePositionRelToAbs(const frm_dir_map_t &deleteMap, uint64_t relPosition, const frm_pos_map_t &map=frm_pos_map_t(), float fallback_ratio=1.0)
bool IsInDelete(uint64_t frame) const
Returns true if the given frame is deemed to be within a region that should be cut.
bool QueryCutList(frm_dir_map_t &delMap, bool loadAutosave=false) const
frm_dir_map_t m_deleteMap
std::chrono::milliseconds TranslatePositionFrameToMs(long long position, float fallback_framerate, const frm_dir_map_t &cutlist)
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
void LoadMap(const QString &undoMessage="")
Loads the delete map from the database.
virtual void ToMap(InfoMap &progMap, bool showrerecord=false, uint star_range=10, uint date_format=0) const
Converts ProgramInfo into QString QHash containing each field in ProgramInfo converted into localized...
uint64_t TranslatePositionAbsToRel(uint64_t position) const
void Clear(const QString &undoMessage="")
Clears the deleteMap.
bool IsFileEditing(void)
Determines whether the file is currently in edit mode.
void LoadCommBreakMap(frm_dir_map_t &map)
Loads the given commercial break map into the deleteMap.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static eu8 clamp(eu8 value, eu8 low, eu8 high)
uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds dur_ms, float fallback_framerate, bool use_cutlist) const
void AddMark(uint64_t frame, MarkTypes type)
Add a new mark of the given type.
bool m_nextCutStartIsValid
DecoderBase * GetDecoder(void)
Returns the stream decoder currently in use.
QString CreateTimeString(uint64_t frame, bool use_cutlist, double frame_rate, bool full_resolution) const
static constexpr const char * ACTION_UP
bool IsSaved(void) const
Compares the current cut list with the saved cut list.
uint64_t m_cachedTotalForOSD
bool IsWatchingInprogress(void) const
void Delete(uint64_t frame, const QString &undoMessage)
Remove the mark at the given frame.
void Move(uint64_t frame, uint64_t to)
Move an existing mark to a new frame.
bool QueryIsEditing(void) const
Queries "recorded" table for its "editing" field and returns true if it is set to true.
void MoveRelative(uint64_t frame, bool right)
Move the previous (!right) or next (right) cut to frame.
void PushDeferred(const frm_dir_map_t &savedMap, const QString &undoMessage)
void SaveCutList(frm_dir_map_t &delMap, bool isAutoSave=false) const
void HideWindow(const QString &Window) override
bool HasTemporaryMark(void) const
Returns true if a temporary placeholder mark is defined.
void SetValues(const QString &Window, const QHash< QString, int > &Map, OSDTimeout Timeout)
void SaveMarkupFlag(MarkTypes type) const
Clears the specified flag, then if sets it.
bool IsTemporaryMark(uint64_t frame) const
Returns true if the given frame is a temporary/placeholder mark.
uint64_t GetLastFrame(void) const
Returns the number of the last frame in the video that is not in a cut sequence.
bool HandleAction(const QString &action, uint64_t frame)
void UpdateOSD(uint64_t frame, double frame_rate, OSD *osd)
Show and update the edit mode On Screen Display.
void UpdateSeekAmount(int change)
QString GetRedoMessage(void) const