summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-01-15 13:09:16 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2006-01-15 13:09:16 +0100
commit197b8c27fa486577ea35e9e89d09abd877fd5c70 (patch)
tree10ac3ca3360465e6e4c3c4cc6c060f49d6124843 /menu.c
parent1de53359223140ccadd8a1a9a134f57e2f3c0468 (diff)
downloadvdr-197b8c27fa486577ea35e9e89d09abd877fd5c70.tar.gz
vdr-197b8c27fa486577ea35e9e89d09abd877fd5c70.tar.bz2
Implemented '0' key function in the "Schedule" menu
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c146
1 files changed, 130 insertions, 16 deletions
diff --git a/menu.c b/menu.c
index 8a1bab13..af9cebf8 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 1.393 2006/01/14 14:53:43 kls Exp $
+ * $Id: menu.c 1.394 2006/01/15 12:46:07 kls Exp $
*/
#include "menu.h"
@@ -323,10 +323,10 @@ public:
cMenuChannelItem(cChannel *Channel);
static void SetSortMode(eChannelSortMode SortMode) { sortMode = SortMode; }
static void IncSortMode(void) { sortMode = eChannelSortMode((sortMode == csmProvider) ? csmNumber : sortMode + 1); }
+ static eChannelSortMode SortMode(void) { return sortMode; }
virtual int Compare(const cListObject &ListObject) const;
virtual void Set(void);
cChannel *Channel(void) { return channel; }
- static eChannelSortMode SortMode(void) { return sortMode; }
};
cMenuChannelItem::eChannelSortMode cMenuChannelItem::sortMode = csmNumber;
@@ -962,21 +962,44 @@ eOSState cMenuEvent::ProcessKey(eKeys Key)
class cMenuScheduleItem : public cOsdItem {
public:
+ enum eScheduleSortMode { ssmAllThis, ssmThisThis, ssmThisAll, ssmAllAll }; // "which event(s) on which channel(s)"
+private:
+ static eScheduleSortMode sortMode;
+public:
const cEvent *event;
const cChannel *channel;
+ bool withDate;
int timerMatch;
- cMenuScheduleItem(const cEvent *Event, cChannel *Channel = NULL);
+ cMenuScheduleItem(const cEvent *Event, cChannel *Channel = NULL, bool WithDate = false);
+ static void SetSortMode(eScheduleSortMode SortMode) { sortMode = SortMode; }
+ static void IncSortMode(void) { sortMode = eScheduleSortMode((sortMode == ssmAllAll) ? ssmAllThis : sortMode + 1); }
+ static eScheduleSortMode SortMode(void) { return sortMode; }
+ virtual int Compare(const cListObject &ListObject) const;
bool Update(bool Force = false);
-};
+ };
-cMenuScheduleItem::cMenuScheduleItem(const cEvent *Event, cChannel *Channel)
+cMenuScheduleItem::eScheduleSortMode cMenuScheduleItem::sortMode = ssmAllThis;
+
+cMenuScheduleItem::cMenuScheduleItem(const cEvent *Event, cChannel *Channel, bool WithDate)
{
event = Event;
channel = Channel;
+ withDate = WithDate;
timerMatch = tmNone;
Update(true);
}
+int cMenuScheduleItem::Compare(const cListObject &ListObject) const
+{
+ cMenuScheduleItem *p = (cMenuScheduleItem *)&ListObject;
+ int r = -1;
+ if (sortMode != ssmAllThis)
+ r = strcoll(event->Title(), p->event->Title());
+ if (sortMode == ssmAllThis || r == 0)
+ r = event->StartTime() - p->event->StartTime();
+ return r;
+}
+
static char *TimerMatchChars = " tT";
bool cMenuScheduleItem::Update(bool Force)
@@ -989,7 +1012,9 @@ bool cMenuScheduleItem::Update(bool Force)
char t = TimerMatchChars[timerMatch];
char v = event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
char r = event->IsRunning() ? '*' : ' ';
- if (channel)
+ if (channel && withDate)
+ asprintf(&buffer, "%d\t%.*s\t%.*s\t%s\t%c%c%c\t%s", channel->Number(), 6, channel->ShortName(true), 6, *event->GetDateString(), *event->GetTimeString(), t, v, r, event->Title());
+ else 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());
@@ -1163,9 +1188,13 @@ private:
bool now, next;
int otherChannel;
int helpKeys;
+ eOSState Number(void);
eOSState Record(void);
eOSState Switch(void);
- void PrepareSchedule(cChannel *Channel);
+ void PrepareScheduleAllThis(const cEvent *Event, const cChannel *Channel);
+ void PrepareScheduleThisThis(const cEvent *Event, const cChannel *Channel);
+ void PrepareScheduleThisAll(const cEvent *Event, const cChannel *Channel);
+ void PrepareScheduleAllAll(const cEvent *Event, const cChannel *Channel);
bool Update(void);
void SetHelpKeys(void);
public:
@@ -1175,16 +1204,17 @@ public:
};
cMenuSchedule::cMenuSchedule(void)
-:cOsdMenu("", 7, 6, 4)
+:cOsdMenu("")
{
now = next = false;
otherChannel = 0;
helpKeys = -1;
+ cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
if (channel) {
cMenuWhatsOn::SetCurrentChannel(channel->Number());
schedules = cSchedules::Schedules(schedulesLock);
- PrepareSchedule(channel);
+ PrepareScheduleAllThis(NULL, channel);
SetHelpKeys();
}
}
@@ -1194,26 +1224,85 @@ cMenuSchedule::~cMenuSchedule()
cMenuWhatsOn::ScheduleEvent(); // makes sure any posted data is cleared
}
-void cMenuSchedule::PrepareSchedule(cChannel *Channel)
+void cMenuSchedule::PrepareScheduleAllThis(const cEvent *Event, const cChannel *Channel)
{
Clear();
+ SetCols(7, 6, 4);
char *buffer = NULL;
asprintf(&buffer, tr("Schedule - %s"), Channel->Name());
SetTitle(buffer);
free(buffer);
- if (schedules) {
+ if (schedules && Channel) {
+ const cSchedule *Schedule = schedules->GetSchedule(Channel);
+ if (Schedule) {
+ const cEvent *PresentEvent = Event ? Event : Schedule->GetPresentEvent(Channel->Number() == cDevice::CurrentChannel());
+ time_t now = time(NULL) - Setup.EPGLinger * 60;
+ for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
+ if (ev->EndTime() > now || ev == PresentEvent)
+ Add(new cMenuScheduleItem(ev), ev == PresentEvent);
+ }
+ }
+ }
+}
+
+void cMenuSchedule::PrepareScheduleThisThis(const cEvent *Event, const cChannel *Channel)
+{
+ Clear();
+ SetCols(7, 6, 4);
+ char *buffer = NULL;
+ asprintf(&buffer, tr("This event - %s"), Channel->Name());
+ SetTitle(buffer);
+ free(buffer);
+ if (schedules && Channel && Event) {
const cSchedule *Schedule = schedules->GetSchedule(Channel);
if (Schedule) {
- const cEvent *PresentEvent = Schedule->GetPresentEvent(Channel->Number() == cDevice::CurrentChannel());
time_t now = time(NULL) - Setup.EPGLinger * 60;
- for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
- if (Event->EndTime() > now || Event == PresentEvent)
- Add(new cMenuScheduleItem(Event), Event == PresentEvent);
+ for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
+ if ((ev->EndTime() > now || ev == Event) && !strcmp(ev->Title(), Event->Title()))
+ Add(new cMenuScheduleItem(ev), ev == Event);
}
}
}
}
+void cMenuSchedule::PrepareScheduleThisAll(const cEvent *Event, const cChannel *Channel)
+{
+ Clear();
+ SetCols(CHNUMWIDTH, 7, 7, 6, 4);
+ SetTitle(tr("This event - all channels"));
+ if (schedules && Event) {
+ for (cChannel *ch = Channels.First(); ch; ch = Channels.Next(ch)) {
+ const cSchedule *Schedule = schedules->GetSchedule(ch);
+ if (Schedule) {
+ time_t now = time(NULL) - Setup.EPGLinger * 60;
+ for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
+ if ((ev->EndTime() > now || ev == Event) && !strcmp(ev->Title(), Event->Title()))
+ Add(new cMenuScheduleItem(ev, ch, true), ev == Event && ch == Channel);
+ }
+ }
+ }
+ }
+}
+
+void cMenuSchedule::PrepareScheduleAllAll(const cEvent *Event, const cChannel *Channel)
+{
+ Clear();
+ SetCols(CHNUMWIDTH, 7, 7, 6, 4);
+ SetTitle(tr("All events - all channels"));
+ if (schedules) {
+ for (cChannel *ch = Channels.First(); ch; ch = Channels.Next(ch)) {
+ const cSchedule *Schedule = schedules->GetSchedule(ch);
+ if (Schedule) {
+ time_t now = time(NULL) - Setup.EPGLinger * 60;
+ for (const cEvent *ev = Schedule->Events()->First(); ev; ev = Schedule->Events()->Next(ev)) {
+ if (ev->EndTime() > now || ev == Event)
+ Add(new cMenuScheduleItem(ev, ch, true), ev == Event && ch == Channel);
+ }
+ }
+ }
+ }
+}
+
bool cMenuSchedule::Update(void)
{
bool result = false;
@@ -1241,6 +1330,29 @@ void cMenuSchedule::SetHelpKeys(void)
}
}
+eOSState cMenuSchedule::Number(void)
+{
+ cMenuScheduleItem::IncSortMode();
+ cMenuScheduleItem *CurrentItem = (cMenuScheduleItem *)Get(Current());
+ const cChannel *Channel = NULL;
+ const cEvent *Event = NULL;
+ if (CurrentItem) {
+ Event = CurrentItem->event;
+ Channel = Channels.GetByChannelID(Event->ChannelID(), true);
+ }
+ switch (cMenuScheduleItem::SortMode()) {
+ case cMenuScheduleItem::ssmAllThis: PrepareScheduleAllThis(Event, Channel); break;
+ case cMenuScheduleItem::ssmThisThis: PrepareScheduleThisThis(Event, Channel); break;
+ case cMenuScheduleItem::ssmThisAll: PrepareScheduleThisAll(Event, Channel); break;
+ case cMenuScheduleItem::ssmAllAll: PrepareScheduleAllAll(Event, Channel); break;
+ }
+ CurrentItem = (cMenuScheduleItem *)Get(Current());
+ Sort();
+ SetCurrent(CurrentItem);
+ Display();
+ return osContinue;
+}
+
eOSState cMenuSchedule::Record(void)
{
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
@@ -1290,6 +1402,7 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key)
if (state == osUnknown) {
switch (Key) {
+ case k0: return Number();
case kRecord:
case kRed: return Record();
case kGreen: if (schedules) {
@@ -1325,7 +1438,8 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key)
if (ei) {
cChannel *channel = Channels.GetByChannelID(ei->ChannelID(), true);
if (channel) {
- PrepareSchedule(channel);
+ cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
+ PrepareScheduleAllThis(NULL, channel);
if (channel->Number() != cDevice::CurrentChannel()) {
otherChannel = channel->Number();
SetHelp(Count() ? tr("Button$Record") : NULL, tr("Button$Now"), tr("Button$Next"), tr("Button$Switch"));