The "Schedules" and "What's on now/next?" menus are now updated if a timer is set or modified

This commit is contained in:
Klaus Schmidinger 2005-12-27 11:27:38 +01:00
parent 2892300d94
commit 0b3d9a95fd
2 changed files with 67 additions and 38 deletions

View File

@ -3963,7 +3963,7 @@ Video Disk Recorder Revision History
commands may now be executed at any time, and the message will be displayed commands may now be executed at any time, and the message will be displayed
(no more "pending message"). (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 - Fixed handling second audio and Dolby Digital PIDs for encrypted channels
(was broken in version 1.3.37). (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(). - Removed an invalid access to Event->schedule in cSchedule::DelEvent().
- Modified cSchedule::Cleanup() (events are always sorted by time). - Modified cSchedule::Cleanup() (events are always sorted by time).
- Schedules are now cleaned up once every hour (not only at 05:00). - 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.

101
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "menu.h"
@ -940,26 +940,45 @@ eOSState cMenuEvent::ProcessKey(eKeys Key)
return state; return state;
} }
// --- cMenuWhatsOnItem ------------------------------------------------------ // --- cMenuScheduleItem -----------------------------------------------------
class cMenuWhatsOnItem : public cOsdItem { class cMenuScheduleItem : public cOsdItem {
public: public:
const cEvent *event; const cEvent *event;
const cChannel *channel; 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; event = Event;
channel = Channel; channel = Channel;
char *buffer = NULL; timerMatch = tmNone;
int TimerMatch; Update(true);
char t = Timers.GetMatch(Event, &TimerMatch) ? (TimerMatch == tmFull) ? 'T' : 't' : ' '; }
char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
char r = event->IsRunning() ? '*' : ' '; static char *TimerMatchChars = " tT";
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); 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 ---------------------------------------------------------- // --- cMenuWhatsOn ----------------------------------------------------------
@ -970,6 +989,7 @@ private:
eOSState Switch(void); eOSState Switch(void);
static int currentChannel; static int currentChannel;
static const cEvent *scheduleEvent; static const cEvent *scheduleEvent;
bool Update(void);
public: public:
cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr); cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr);
static int CurrentChannel(void) { return currentChannel; } static int CurrentChannel(void) { return currentChannel; }
@ -990,7 +1010,7 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha
if (Schedule) { if (Schedule) {
const cEvent *Event = Now ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent(); const cEvent *Event = Now ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent();
if (Event) 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")); 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 *cMenuWhatsOn::ScheduleEvent(void)
{ {
const cEvent *ei = scheduleEvent; const cEvent *ei = scheduleEvent;
@ -1007,7 +1037,7 @@ const cEvent *cMenuWhatsOn::ScheduleEvent(void)
eOSState cMenuWhatsOn::Switch(void) eOSState cMenuWhatsOn::Switch(void)
{ {
cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current()); cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
if (item) { if (item) {
cChannel *channel = Channels.GetByChannelID(item->event->ChannelID(), true); cChannel *channel = Channels.GetByChannelID(item->event->ChannelID(), true);
if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true)) if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
@ -1019,7 +1049,7 @@ eOSState cMenuWhatsOn::Switch(void)
eOSState cMenuWhatsOn::Record(void) eOSState cMenuWhatsOn::Record(void)
{ {
cMenuWhatsOnItem *item = (cMenuWhatsOnItem *)Get(Current()); cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
if (item) { if (item) {
cTimer *timer = new cTimer(item->event); cTimer *timer = new cTimer(item->event);
cTimer *t = Timers.GetTimer(timer); cTimer *t = Timers.GetTimer(timer);
@ -1034,6 +1064,7 @@ eOSState cMenuWhatsOn::Record(void)
eOSState cMenuWhatsOn::ProcessKey(eKeys Key) eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
{ {
bool HadSubMenu = HasSubMenu();
eOSState state = cOsdMenu::ProcessKey(Key); eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) { if (state == osUnknown) {
@ -1043,7 +1074,7 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
case kYellow: state = osBack; case kYellow: state = osBack;
// continue with kGreen // continue with kGreen
case kGreen: { case kGreen: {
cMenuWhatsOnItem *mi = (cMenuWhatsOnItem *)Get(Current()); cMenuScheduleItem *mi = (cMenuScheduleItem *)Get(Current());
if (mi) { if (mi) {
scheduleEvent = mi->event; scheduleEvent = mi->event;
currentChannel = mi->channel->Number(); currentChannel = mi->channel->Number();
@ -1052,34 +1083,16 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
break; break;
case kBlue: return Switch(); case kBlue: return Switch();
case kOk: if (Count()) case kOk: if (Count())
return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->event, true)); return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->event, true));
break; break;
default: break; default: break;
} }
} }
else if (HadSubMenu && !HasSubMenu() && Update())
Display();
return state; 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 --------------------------------------------------------- // --- cMenuSchedule ---------------------------------------------------------
class cMenuSchedule : public cOsdMenu { class cMenuSchedule : public cOsdMenu {
@ -1091,6 +1104,7 @@ private:
eOSState Record(void); eOSState Record(void);
eOSState Switch(void); eOSState Switch(void);
void PrepareSchedule(cChannel *Channel); void PrepareSchedule(cChannel *Channel);
bool Update(void);
public: public:
cMenuSchedule(void); cMenuSchedule(void);
virtual ~cMenuSchedule(); 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) eOSState cMenuSchedule::Record(void)
{ {
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current()); cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
@ -1163,6 +1187,7 @@ eOSState cMenuSchedule::Switch(void)
eOSState cMenuSchedule::ProcessKey(eKeys Key) eOSState cMenuSchedule::ProcessKey(eKeys Key)
{ {
bool HadSubMenu = HasSubMenu();
eOSState state = cOsdMenu::ProcessKey(Key); eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) { if (state == osUnknown) {
@ -1210,6 +1235,8 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key)
Display(); Display();
} }
} }
else if (HadSubMenu && Update())
Display();
} }
return state; return state;
} }