Go to the documentation of this file.
17 #define LOC QString("DelMap: ")
18 #define EDIT_CHECK do { \
20 LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot edit outside edit mode."); \
37 const QString &undoMessage)
77 tr(
"(Nothing to undo)"));
83 tr(
"(Nothing to redo)"));
94 Clear(tr(
"Clear Cuts"));
97 else if (
action ==
"MOVEPREV")
99 else if (
action ==
"MOVENEXT")
101 else if (
action ==
"CUTTOBEGINNING")
103 Push(tr(
"Cut to Beginning"));
106 else if (
action ==
"CUTTOEND")
108 Push(tr(
"Cut to End"));
115 else if (
action ==
"NEWCUT")
117 else if (
action ==
"DELETE")
120 Delete(frame, tr(
"Delete"));
122 else if (
action ==
"UNDO")
126 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);
310 long long lastframe = -1;
311 long long remove = -1;
312 QMutableMapIterator<uint64_t, MarkTypes> it(
m_deleteMap);
320 if (it.key() > frame)
326 lasttype = it.value();
327 lastframe = it.key();
330 (lastframe > -1) && (lastframe < (int64_t)frame))
337 while (it.hasPrevious())
340 if (it.key() <= frame)
346 lasttype = it.value();
347 lastframe = it.key();
350 (lastframe > -1) && (lastframe > (int64_t)frame))
367 if (!undoMessage.isEmpty())
375 frm_dir_map_t::Iterator it =
m_deleteMap.find(frame);
378 int type = it.value();
403 int64_t existing = -1;
416 auto otherframe =
static_cast<uint64_t
>(existing);
417 if (otherframe == frame)
421 uint64_t startframe = 0;
422 uint64_t endframe = 0;
423 int64_t cut_start = -1;
424 int64_t cut_end = -1;
430 frm_dir_map_t::Iterator it2 =
m_deleteMap.find(frame);
443 if (otherframe < frame)
445 startframe = otherframe;
446 endframe = cut_end != -1 ?
static_cast<uint64_t
>(cut_end)
451 startframe = cut_start != -1 ?
static_cast<uint64_t
>(cut_start)
453 endframe = otherframe;
460 if (endframe >= total - 1)
464 if ((startframe == 0) && (endframe == total))
466 LOG(VB_GENERAL, LOG_CRIT,
LOC +
467 "Refusing to cut entire recording.");
476 frm_dir_map_t::Iterator it =
m_deleteMap.find(startframe);
477 for ( ; it !=
m_deleteMap.end() && otherframe < endframe; ++it)
479 otherframe = it.key();
480 if ((startframe < otherframe) && (endframe > otherframe))
482 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
483 QString(
"Deleting bounded marker: %1").arg(otherframe));
500 frm_dir_map_t::Iterator it =
m_deleteMap.find(frame);
503 int type = it.value();
517 Delete(frame, tr(
"Delete"));
536 Push(tr(
"Move Mark"));
575 frm_dir_map_t::const_iterator it =
m_deleteMap.find(frame);
580 uint64_t lastframe = UINT64_MAX;
583 if (it.key() > frame)
585 lasttype = it.value();
586 lastframe = it.key();
600 frm_dir_map_t::const_iterator it =
m_deleteMap.find(frame);
616 frm_dir_map_t::const_iterator it =
m_deleteMap.begin();
621 if (it.key() > frame)
631 if (it.key() >= frame)
673 int64_t lastframe = -1;
674 int64_t tempframe = -1;
675 QList<int64_t> deleteList;
678 int thistype = it.value();
679 uint64_t thisframe = it.key();
680 if (thisframe >= total)
682 deleteList.append(thisframe);
684 else if (lasttype == thistype)
686 deleteList.append(thistype ==
MARK_CUT_END ? thisframe :
687 (uint64_t)lastframe);
694 deleteList.append(tempframe);
695 tempframe = thisframe;
700 lastframe = thisframe;
706 for (
const int64_t & dit : qAsConst(deleteList))
728 Push(tr(
"Load Detected Commercials"));
730 for (
auto it = map.begin(); it != map.end(); ++it)
742 if (!undoMessage.isEmpty())
781 QMutableMapIterator<uint64_t, MarkTypes> it(
m_deleteMap);
813 frm_dir_map_t::iterator cutpoint =
m_deleteMap.find(frame);
832 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Tracker next CUT_START: %1")
846 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
847 QString(
"Tracker wants to jump to: %1").arg(to));
861 frm_dir_map_t::const_iterator it =
m_deleteMap.end();
884 QMutableMapIterator<uint64_t, MarkTypes> it(currentMap);
892 return currentMap == savedMap;
896 float fallback_framerate,
897 bool use_cutlist)
const
905 float fallback_framerate,
906 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.
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