Patch #4: Day separator in Schedule
Commit Message
Hi list,
I'll be releasing this and a few other patches for VDR 1.3.33, which have
evolved during the last months while working on XeatreOS (a distribution
based on LinVDR 0.7, which is used for the Xeatre boxes,
http://www.xeatre.tv/). Some of their functionality may already be included
in plugins or other patches. Nevertheless, I'd like to release them now, and
let everybody decide whether they are useful or not.
This one adds a non-selectable item in schedules whenever a date change
occurs.
Greetings,
Sascha
Comments
2005/9/26, Sascha Volkenandt <lists@magoa.net>:
>
> This one adds a non-selectable item in schedules whenever a date change
> occurs.
>
This useful patch does not work properly with 1.3.38 (for example:
segmentation fault, when pressing the info key followed by ok). I have
attached an adapted version of it.
Joachim.
2006/1/14, Joachim Wilke <joachim.wilke@gmail.com>:
>
> 2005/9/26, Sascha Volkenandt <lists@magoa.net>:
> >
> > This one adds a non-selectable item in schedules whenever a date change
> > occurs.
> >
> This useful patch does not work properly with 1.3.38 (for example:
> segmentation fault, when pressing the info key followed by ok). I have
> attached an adapted version of it.
I adapted this patch again, now for vdr 1.3.39.
As 1.3.39 provides for different views in cMenuSchedule, i added the day
separator to the first three ones ("this channel", "this event on this
channel" and "this event on all channels").
Further I thought about translating the "New day" string which was part of
the separator but decided to drop it completely for cosmetic reasons
(personal opinion ;-), give it a try.
Joachim.
2006/1/15, Joachim Wilke <joachim.wilke@gmail.com>:
>
> 2006/1/14, Joachim Wilke <joachim.wilke@gmail.com>:
> >
> > 2005/9/26, Sascha Volkenandt <lists@magoa.net>:
> > >
> > > This one adds a non-selectable item in schedules whenever a date
> > > change
> > > occurs.
> > >
> > This useful patch does not work properly with 1.3.38 (for example:
> > segmentation fault, when pressing the info key followed by ok). I have
> > attached an adapted version of it.
>
>
> I adapted this patch again, now for vdr 1.3.39.
>
> As 1.3.39 provides for different views in cMenuSchedule, i added the day
> separator to the first three ones ("this channel", "this event on this
> channel" and "this event on all channels").
>
> Further I thought about translating the "New day" string which was part of
> the separator but decided to drop it completely for cosmetic reasons
> (personal opinion ;-), give it a try.
>
> Joachim.
>
> Also a very nice patch. It increases the usability of the Schedule menu
very much. Isn't this something that should go into core VDR?
Matthias
2006/1/15, Joachim Wilke <joachim.wilke@gmail.com>:
> I adapted this patch again, now for vdr 1.3.39.
I found a little but serious mistake in the patch, attached is the
fixed version.
Joachim.
@@ -230,6 +230,14 @@
return buf;
}
+cString cEvent::GetWeekdayString() const
+{
+ char buf[4];
+ struct tm tm_r;
+ strn0cpy(buf, WeekDayName(localtime_r(&startTime, &tm_r)->tm_wday), sizeof(buf));
+ return buf;
+}
+
void cEvent::Dump(FILE *f, const char *Prefix, bool InfoOnly) const
{
if (InfoOnly || startTime + duration + Setup.EPGLinger * 60 >= time(NULL)) {
@@ -87,6 +87,7 @@
cString GetTimeString(void) const;
cString GetEndTimeString(void) const;
cString GetVpsString(void) const;
+ cString GetWeekdayString(void) const;
void SetEventID(u_int16_t EventID);
void SetTableID(uchar TableID);
void SetVersion(uchar Version);
@@ -1078,6 +1078,23 @@
SetText(buffer, false);
}
+// --- cMenuScheduleSeparator ------------------------------------------------
+
+class cMenuScheduleSeparator : public cOsdItem {
+public:
+ const cEvent *event;
+ cMenuScheduleSeparator(const char *DateString);
+};
+
+cMenuScheduleSeparator::cMenuScheduleSeparator(const char *DateString)
+{
+ event = NULL;
+ char *buffer = NULL;
+ asprintf(&buffer, ">>> %s: %.*s", tr("New Day"), 10, DateString);
+ SetText(buffer, false);
+ SetSelectable(false);
+}
+
// --- cMenuSchedule ---------------------------------------------------------
class cMenuSchedule : public cOsdMenu {
@@ -1126,9 +1143,14 @@
if (Schedule) {
const cEvent *PresentEvent = Schedule->GetPresentEvent(Channel->Number() == cDevice::CurrentChannel());
time_t now = time(NULL) - Setup.EPGLinger * 60;
+ char curDate[10] = "";
for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
- if (Event->EndTime() > now || Event == PresentEvent)
+ if (Event->EndTime() > now || Event == PresentEvent) {
+ if (strlen(curDate) > 0 && strncmp(Event->GetWeekdayString(), curDate, 10) != 0)
+ Add(new cMenuScheduleSeparator(Event->GetDateString()));
Add(new cMenuScheduleItem(Event), Event == PresentEvent);
+ strncpy(curDate, Event->GetWeekdayString(), 10);
+ }
}
}
}