diff options
-rw-r--r-- | menu_main.c | 7 | ||||
-rw-r--r-- | menu_whatson.c | 49 | ||||
-rw-r--r-- | menu_whatson.h | 15 |
3 files changed, 57 insertions, 14 deletions
diff --git a/menu_main.c b/menu_main.c index 8dc1c56..8567dc7 100644 --- a/menu_main.c +++ b/menu_main.c @@ -143,12 +143,7 @@ void cMenuSearchMain::PrepareSchedule(cChannel *Channel) struct tm *t_event = localtime_r(&EventDate, &tm_rEvent); struct tm *t_lastevent = localtime_r(&lastEventDate, &tm_rLastEvent); if (t_event->tm_mday != t_lastevent->tm_mday) - { - cString szSep = cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, GETDATESTRING(Event), MENU_SEPARATOR_ITEMS); - cOsdItem* pSepItem = new cOsdItem(szSep); - pSepItem->SetSelectable(false); - Add(pSepItem); - } + Add(new cMenuMyScheduleSepItem(Event)); lastEventDate = EventDate; } Add(new cMenuMyScheduleItem(Event, NULL, showNow, ScheduleTemplate), Event == PresentEvent); diff --git a/menu_whatson.c b/menu_whatson.c index 96dcd16..94c14b5 100644 --- a/menu_whatson.c +++ b/menu_whatson.c @@ -201,8 +201,9 @@ bool cMenuMyScheduleItem::Update(bool Force) char* title = NULL; title = strdup(event?event->Title():tr(">>> no info! <<<")); + title = strreplacei(title, ":", "%colon%"); // assume a title has the form "a?b:c", - // we need to replace the colon to avoid misinterpretation the expression as a condition + // we need to replace the colon to avoid misinterpretation of the expression as a condition buffer = strreplacei(buffer, "%title%", title); free(title); @@ -255,6 +256,45 @@ void cMenuMyScheduleItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, #endif } +// --- cMenuMyScheduleSepItem ------------------------------------------------------ +cMenuMyScheduleSepItem::cMenuMyScheduleSepItem(const cEvent *Event, cChannel *Channel) + : cMenuMyScheduleItem(Event, Channel, showNow, NULL) +{ + event = Event; + channel = Channel; + dummyEvent = NULL; + SetSelectable(false); + Update(true); +} + +cMenuMyScheduleSepItem::~cMenuMyScheduleSepItem() +{ + if (dummyEvent) + delete dummyEvent; +} + +bool cMenuMyScheduleSepItem::Update(bool Force) +{ + if (channel) + SetText(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, channel->Name(), MENU_SEPARATOR_ITEMS)); + else if (event) + { + dummyEvent = new cEvent(0); + dummyEvent->SetTitle(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, GETDATESTRING(event), MENU_SEPARATOR_ITEMS)); + SetText(dummyEvent->Title()); + } + return true; +} + +void cMenuMyScheduleSepItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) +{ +#if APIVERSNUM >= 10733 + bool withDate = (channel == NULL); // search for a better way to determine this + if (!DisplayMenu->SetItemEvent(dummyEvent, Index, Current, Selectable, channel, withDate, timerMatch)) + DisplayMenu->SetItem(Text(), Index, Current, Selectable); +#endif +} + // --- cMenuWhatsOnSearch ---------------------------------------------------------- @@ -432,12 +472,7 @@ void cMenuWhatsOnSearch::LoadSchedules() else { if (EPGSearchConfig.showChannelGroups && strlen(Channel->Name())) - { - cString szGroup = cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, Channel->Name(), MENU_SEPARATOR_ITEMS); - cOsdItem* pGroupItem = new cOsdItem(szGroup); - pGroupItem->SetSelectable(false); - Add(pGroupItem); - } + Add(new cMenuMyScheduleSepItem(NULL, Channel)); } } } diff --git a/menu_whatson.h b/menu_whatson.h index a30a5ab..75595e8 100644 --- a/menu_whatson.h +++ b/menu_whatson.h @@ -40,11 +40,24 @@ public: cMenuTemplate* menuTemplate; cMenuMyScheduleItem(const cEvent *Event, cChannel *Channel = NULL, showMode ShowMode = showNow, cMenuTemplate* menuTemplate = NULL); - bool Update(bool Force = false); + virtual bool Update(bool Force = false); virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); }; +// --- cMenuMyScheduleSepItem ------------------------------------------------------ +class cMenuMyScheduleSepItem : public cMenuMyScheduleItem { + cEvent *dummyEvent; // this event is used to store the text of the separator in its title + // to pass it in SetMenuItem via the event argument. Would be nice + // if VDR had a SetItemSeparator function for this +public: + + cMenuMyScheduleSepItem(const cEvent *Event, cChannel *Channel = NULL); + ~cMenuMyScheduleSepItem(); + virtual bool Update(bool Force = false); + virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); +}; + // --- cMenuWhatsOnSearch ---------------------------------------------------------- class cMenuWhatsOnSearch : public cOsdMenu { private: |