From 3be2cb060c30581bd1c59c72a90b0d0c3f79bd45 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Sun, 13 Jan 2008 13:46:22 +0100 Subject: - code for collecting and displaying EPG events in 'What's on' is now separated --- pages/whats_on.ecpp | 172 +++++++++++++++++++--------------------------------- 1 file changed, 63 insertions(+), 109 deletions(-) (limited to 'pages') diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index a902ae6..4a7948f 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -106,7 +106,9 @@ if (type == "now") { % } <%cpp> EpgEvents epgEvents; + std::list eventList; + // collect the broadcasts if (type != "favs") { ReadLock channelsLock( Channels ); @@ -132,68 +134,12 @@ if (type == "now") { } EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event); - - bool truncated = false; - string truncDescription = StringWordTruncate(epgEvent->LongDescr(), maximumTooltipHintLength, truncated); - string longDescription = StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), maximumDescriptionLength)) - + "

" + tr("Click to view details."); - bool lastCurrentChanel = true; - - if (mode == "detail") { - -
- -
-
- <& pageelems.epg_tool_box detail=(1) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &> -
-
-
<$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $>
-% if (epgEvent->Elapsed() >= 0) { -
<& pageelems.progressbar progress=(epgEvent->Elapsed()) &>
-% } -
<$ (epgEvent->Title()) $>
-
<$ (epgEvent->ShortDescr()) $>
-
<$ truncDescription $>
-% if (truncated) { - -% } -
-
-
-<%cpp> - } - else { // mode == "list" - lastCurrentChanel = ((Channel->Number() == LiveSetup().GetLastChannel()) - || (!Channels.Next(Channel))); - - - <& pageelems.epg_tool_box detail=(0) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) lastCurrentChanel=(lastCurrentChanel ? 1 : 0) &> - "> -
-
<$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $>
-% if (epgEvent->Elapsed() >= 0) { -
<& pageelems.progressbar progress=(epgEvent->Elapsed()) &>
-% } -
- - "> - - - "> - -% } -<%cpp> - } + eventList.push_back(epgEvent); + } } - } - else { + } + else // get favorite broadcasts from epgsearch + { SearchResults results; SearchTimers timers; for (SearchTimers::iterator timer = timers.begin(); timer != timers.end(); ++timer) { @@ -205,68 +151,76 @@ if (type == "now") { time_t now = time(NULL); for (SearchResults::iterator result = results.begin(); result != results.end(); ++result) { long diff = result->StartTime() - now; - long absdiff = labs(diff); - if (absdiff >= 24*60*60) continue; // skip broadcasts more than a day away + if (labs(diff) >= 24*60*60) continue; // skip broadcasts more than a day away + EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(result->GetChannel(), result->GetEvent()); + eventList.push_back(epgEvent); + } + } - string diffstring = string((diff > 0) ? tr("in") : tr("since")) + " "; - if (absdiff >= (60 * 60)) - diffstring += lexical_cast(long(absdiff / (60*60))) + " " + tr("hours"); - else - diffstring += lexical_cast(long(absdiff / 60)) + " " + tr("minutes"); + // display broadcasts + for(std::list::iterator i = eventList.begin(); i != eventList.end(); ++i ) { + EpgInfoPtr epgEvent = *i; - string epgId = EpgEvents::EncodeDomId(result->Channel(), result->EventId()); - string channelname = Channels.GetByChannelID(result->Channel())->Name(); - int channelnr = Channels.GetByChannelID(result->Channel())->Number(); - bool truncated = false; - string truncDescription = StringWordTruncate(result->Description(), maximumTooltipHintLength, truncated); - string longDescription = StringEscapeAndBreak(StringWordTruncate(result->Description(), maximumDescriptionLength)) - + "

" + tr("Click to view details."); + bool truncated = false; + string truncDescription = StringWordTruncate(epgEvent->LongDescr(), maximumTooltipHintLength, truncated); + string longDescription = StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), maximumDescriptionLength)) + + "

" + tr("Click to view details."); + bool lastCurrentChanel = true; + const cChannel* Channel = epgEvent->Channel(); + if (!Channel) continue; + int chNumber = Channel->Number(); - // last result? - SearchResults::iterator nextres = result; - bool bottom = (++nextres == results.end()); - if (mode == "list") { + if (mode == "detail") { - - <& pageelems.epg_tool_box detail=(0) epgid=(epgId) title=(result->Title()) startTime=(result->StartTime()) endTime=(result->StopTime()) lastCurrentChanel=(bottom ? 1 : 0) &> - "> -
-
<$ (FormatDateTime(tr("%I:%M %p"), result->StartTime())) $> - <$ (FormatDateTime(tr("%I:%M %p"), result->StopTime())) $>
- <$ diffstring $> -
- - "> - - - "> - -% } else {
- <& pageelems.epg_tool_box detail=(1) epgid=(epgId) title=(result->Title()) startTime=(result->StartTime()) endTime=(result->StopTime()) &> + <& pageelems.epg_tool_box detail=(1) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) &>
-
<$ (FormatDateTime(tr("%I:%M %p"), result->StartTime())) $> - <$ (FormatDateTime(tr("%I:%M %p"), result->StopTime())) $>
-
<$ diffstring $>
-
<$ (result->Title()) $>
-
<$ (result->ShortText()) $>
+
<$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $>
+% if (epgEvent->Elapsed() >= 0) { +
<& pageelems.progressbar progress=(epgEvent->Elapsed()) &>
+% } +
<$ (epgEvent->Title()) $>
+
<$ (epgEvent->ShortDescr()) $>
<$ truncDescription $>
-% if (truncated) { - -% } +% if (truncated) { + +% }
-
-<%cpp> } - } + +<%cpp> + } else { // mode == "list" + lastCurrentChanel = ((chNumber == LiveSetup().GetLastChannel()) || (!Channels.Next(Channel))); + + + <& pageelems.epg_tool_box detail=(0) epgid=(epgEvent->Id()) title=(epgEvent->Title()) startTime=(epgEvent->GetStartTime()) endTime=(epgEvent->GetEndTime()) lastCurrentChanel=(lastCurrentChanel ? 1 : 0) &> + "> +
+
<$ (epgEvent->StartTime(tr("%I:%M %p"))) $> - <$ (epgEvent->EndTime(tr("%I:%M %p"))) $>
+% if (epgEvent->Elapsed() >= 0) { +
<& pageelems.progressbar progress=(epgEvent->Elapsed()) &>
+% } +
+ + "> + + + "> + + +% } +<%cpp> } % if (mode == "list") { -- cgit v1.2.3