From 4ff3d113a7d0824d6ba1660f3e649dbfc941d179 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 3 Mar 2025 11:05:23 +0100 Subject: [PATCH] The new virtual function cSkinDisplayMenu::SetItemEvent(..., const cTimer *Timer) can be used to get full access to the timer (if any) defined for this event --- HISTORY | 2 ++ menu.c | 13 ++++++++----- skins.h | 6 +++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/HISTORY b/HISTORY index 8ef5dcd5..766fea0e 100644 --- a/HISTORY +++ b/HISTORY @@ -10098,3 +10098,5 @@ Video Disk Recorder Revision History Plugins may want to do the same, but don't have to. - Renamed cStatus::Osd*2() to cStatus::Osd*(). Plugins that use these recently introduced functions need to remove the '2' from the name. +- The new virtual function cSkinDisplayMenu::SetItemEvent(..., const cTimer *Timer) can be + used to get full access to the timer (if any) defined for this event. diff --git a/menu.c b/menu.c index d9c23d45..591ce4ab 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 5.24 2025/03/02 11:03:35 kls Exp $ + * $Id: menu.c 5.25 2025/03/03 11:05:23 kls Exp $ */ #include "menu.h" @@ -1569,6 +1569,7 @@ private: public: const cEvent *event; const cChannel *channel; + const cTimer *timer; bool withDate; eTimerMatch timerMatch; bool timerActive; @@ -1587,6 +1588,7 @@ cMenuScheduleItem::cMenuScheduleItem(const cTimers *Timers, const cEvent *Event, { event = Event; channel = Channel; + timer = NULL; withDate = WithDate; timerMatch = tmNone; timerActive = false; @@ -1612,10 +1614,10 @@ bool cMenuScheduleItem::Update(const cTimers *Timers, bool Force) LOCK_SCHEDULES_READ; eTimerMatch OldTimerMatch = timerMatch; bool OldTimerActive = timerActive; - const cTimer *Timer = Timers->GetMatch(event, &timerMatch); - if (event->EndTime() < time(NULL) && !event->IsRunning() && (!Timer || !Timer->Recording())) + timer = Timers->GetMatch(event, &timerMatch); + if (event->EndTime() < time(NULL) && !event->IsRunning() && (!timer || !timer->Recording())) timerMatch = tmNone; - timerActive = Timer && Timer->HasFlags(tfActive); + timerActive = timer && timer->HasFlags(tfActive); if (Force || timerMatch != OldTimerMatch || timerActive != OldTimerActive) { cString buffer; char t = TimerMatchChars[timerMatch + (timerActive ? 0 : 3)]; @@ -1637,9 +1639,10 @@ bool cMenuScheduleItem::Update(const cTimers *Timers, bool Force) void cMenuScheduleItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) { + LOCK_TIMERS_READ; LOCK_CHANNELS_READ; LOCK_SCHEDULES_READ; - if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, withDate, timerMatch, timerActive)) + if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, withDate, timerMatch, timer)) DisplayMenu->SetItem(Text(), Index, Current, Selectable); } diff --git a/skins.h b/skins.h index 43f56e9f..2bda50c0 100644 --- a/skins.h +++ b/skins.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: skins.h 5.7 2025/03/02 11:03:35 kls Exp $ + * $Id: skins.h 5.8 2025/03/03 11:05:23 kls Exp $ */ #ifndef __SKINS_H @@ -244,6 +244,10 @@ public: ///< If the skin displays the Event item in its own way, it shall return true. ///< The default implementation does nothing and returns false, which results in ///< a call to SetItem() with a proper text. + virtual bool SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch, const cTimer *Timer) { + return SetItemEvent(Event, Index, Current, Selectable, Channel, WithDate, TimerMatch, Timer && Timer->HasFlags(tfActive)); } + ///< Like SetItemEvent(..., bool TimerActive), but with full access to the Timer. + ///< If Timer is NULL, no timer is defined for this event. virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable) { return false; } ///< Sets the item at the given Index to Timer. See SetItem() for more information. ///< If a derived skin class implements this function, it can display a Timer item