diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-12-27 11:27:38 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-12-27 11:27:38 +0100 |
commit | 0b3d9a95fdeb4141fa223a221f7120a44e3c7057 (patch) | |
tree | 69cfbf690b2e3fb72b575791000ff90c9ab79247 | |
parent | 2892300d94f4255f33ebf26866d28e1696658c86 (diff) | |
download | vdr-0b3d9a95fdeb4141fa223a221f7120a44e3c7057.tar.gz vdr-0b3d9a95fdeb4141fa223a221f7120a44e3c7057.tar.bz2 |
The "Schedules" and "What's on now/next?" menus are now updated if a timer is set or modified
-rw-r--r-- | HISTORY | 4 | ||||
-rw-r--r-- | menu.c | 101 |
2 files changed, 67 insertions, 38 deletions
@@ -3963,7 +3963,7 @@ Video Disk Recorder Revision History commands may now be executed at any time, and the message will be displayed (no more "pending message"). -2005-12-26: Version 1.3.38 +2005-12-27: Version 1.3.38 - Fixed handling second audio and Dolby Digital PIDs for encrypted channels (was broken in version 1.3.37). @@ -3998,3 +3998,5 @@ Video Disk Recorder Revision History - Removed an invalid access to Event->schedule in cSchedule::DelEvent(). - Modified cSchedule::Cleanup() (events are always sorted by time). - Schedules are now cleaned up once every hour (not only at 05:00). +- The "Schedules" and "What's on now/next?" menus are now updated if a timer + is set or modified. @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.378 2005/12/26 15:44:27 kls Exp $ + * $Id: menu.c 1.379 2005/12/27 11:23:30 kls Exp $ */ #include "menu.h" @@ -940,26 +940,45 @@ eOSState cMenuEvent::ProcessKey(eKeys Key) return state; } -// --- cMenuWhatsOnItem ------------------------------------------------------ +// --- cMenuScheduleItem ----------------------------------------------------- -class cMenuWhatsOnItem : public cOsdItem { +class cMenuScheduleItem : public cOsdItem { public: const cEvent *event; const cChannel *channel; - cMenuWhatsOnItem(const cEvent *Event, cChannel *Channel); + int timerMatch; + cMenuScheduleItem(const cEvent *Event, cChannel *Channel = NULL); + bool Update(bool Force = false); }; -cMenuWhatsOnItem::cMenuWhatsOnItem(const cEvent *Event, cChannel *Channel) +cMenuScheduleItem::cMenuScheduleItem(const cEvent *Event, cChannel *Channel) { event = Event; channel = Channel; - char *buffer = NULL; - int TimerMatch; - char t = Timers.GetMatch(Event, &TimerMatch) ? (TimerMatch == tmFull) ? 'T' : 't' : ' '; - char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' '; - char r = event->IsRunning() ? '*' : ' '; - asprintf(&buffer, "%d\t%.*s\t%s\t%c%c%c\t%s", channel->Number(), 6, channel->ShortName(true), *event->GetTimeString(), t, v, r, event->Title()); - SetText(buffer, false); + timerMatch = tmNone; + Update(true); +} + +static char *TimerMatchChars = " tT"; + +bool cMenuScheduleItem::Update(bool Force) +{ + bool result = false; + int OldTimerMatch = timerMatch; + Timers.GetMatch(event, &timerMatch); + if (Force || timerMatch != OldTimerMatch) { + char *buffer = NULL; + char t = TimerMatchChars[timerMatch]; + char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' '; + char r = event->IsRunning() ? '*' : ' '; + if (channel) + asprintf(&buffer, "%d\t%.*s\t%s\t%c%c%c\t%s", channel->Number(), 6, channel->ShortName(true), *event->GetTimeString(), t, v, r, event->Title()); + else + asprintf(&buffer, "%.*s\t%s\t%c%c%c\t%s", 6, *event->GetDateString(), *event->GetTimeString(), t, v, r, event->Title()); + SetText(buffer, false); + result = true; + } + return result; } // --- cMenuWhatsOn ---------------------------------------------------------- @@ -970,6 +989,7 @@ private: eOSState Switch(void); static int currentChannel; static const cEvent *scheduleEvent; + bool Update(void); public: cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr); static int CurrentChannel(void) { return currentChannel; } @@ -990,7 +1010,7 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha if (Schedule) { const cEvent *Event = Now ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent(); if (Event) - Add(new cMenuWhatsOnItem(Event, Channel), Channel->Number() == CurrentChannelNr); + Add(new cMenuScheduleItem(Event, Channel), Channel->Number() == CurrentChannelNr); } } } @@ -998,6 +1018,16 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha SetHelp(Count() ? tr("Record") : NULL, Now ? tr("Next") : tr("Now"), tr("Button$Schedule"), tr("Switch")); } +bool cMenuWhatsOn::Update(void) +{ + bool result = false; + for (cOsdItem *item = First(); item; item = Next(item)) { + if (((cMenuScheduleItem *)item)->Update()) + result = true; + } + return result; +} + const cEvent *cMenuWhatsOn::ScheduleEvent(void) { const cEvent *ei = scheduleEvent; @@ -1007,7 +1037,7 @@ const cEvent *cMenuWhatsOn::ScheduleEvent(void) eOSState cMenuWhatsOn::Switch(void) { - cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current()); + cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current()); if (item) { cChannel *channel = Channels.GetByChannelID(item->event->ChannelID(), true); if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true)) @@ -1019,7 +1049,7 @@ eOSState cMenuWhatsOn::Switch(void) eOSState cMenuWhatsOn::Record(void) { - cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current()); + cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current()); if (item) { cTimer *timer = new cTimer(item->event); cTimer *t = Timers.GetTimer(timer); @@ -1034,6 +1064,7 @@ eOSState cMenuWhatsOn::Record(void) eOSState cMenuWhatsOn::ProcessKey(eKeys Key) { + bool HadSubMenu = HasSubMenu(); eOSState state = cOsdMenu::ProcessKey(Key); if (state == osUnknown) { @@ -1043,7 +1074,7 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key) case kYellow: state = osBack; // continue with kGreen case kGreen: { - cMenuWhatsOnItem *mi = (cMenuWhatsOnItem *)Get(Current()); + cMenuScheduleItem *mi = (cMenuScheduleItem *)Get(Current()); if (mi) { scheduleEvent = mi->event; currentChannel = mi->channel->Number(); @@ -1052,34 +1083,16 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key) break; case kBlue: return Switch(); case kOk: if (Count()) - return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->event, true)); + return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->event, true)); break; default: break; } } + else if (HadSubMenu && !HasSubMenu() && Update()) + Display(); return state; } -// --- cMenuScheduleItem ----------------------------------------------------- - -class cMenuScheduleItem : public cOsdItem { -public: - const cEvent *event; - cMenuScheduleItem(const cEvent *Event); -}; - -cMenuScheduleItem::cMenuScheduleItem(const cEvent *Event) -{ - event = Event; - char *buffer = NULL; - int TimerMatch; - char t = Timers.GetMatch(Event, &TimerMatch) ? (TimerMatch == tmFull) ? 'T' : 't' : ' '; - char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' '; - char r = event->IsRunning() ? '*' : ' '; - asprintf(&buffer, "%.*s\t%s\t%c%c%c\t%s", 6, *event->GetDateString(), *event->GetTimeString(), t, v, r, event->Title()); - SetText(buffer, false); -} - // --- cMenuSchedule --------------------------------------------------------- class cMenuSchedule : public cOsdMenu { @@ -1091,6 +1104,7 @@ private: eOSState Record(void); eOSState Switch(void); void PrepareSchedule(cChannel *Channel); + bool Update(void); public: cMenuSchedule(void); virtual ~cMenuSchedule(); @@ -1136,6 +1150,16 @@ void cMenuSchedule::PrepareSchedule(cChannel *Channel) } } +bool cMenuSchedule::Update(void) +{ + bool result = false; + for (cOsdItem *item = First(); item; item = Next(item)) { + if (((cMenuScheduleItem *)item)->Update()) + result = true; + } + return result; +} + eOSState cMenuSchedule::Record(void) { cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current()); @@ -1163,6 +1187,7 @@ eOSState cMenuSchedule::Switch(void) eOSState cMenuSchedule::ProcessKey(eKeys Key) { + bool HadSubMenu = HasSubMenu(); eOSState state = cOsdMenu::ProcessKey(Key); if (state == osUnknown) { @@ -1210,6 +1235,8 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key) Display(); } } + else if (HadSubMenu && Update()) + Display(); } return state; } |