From 2fcbdbd22272aae4f30e0842a42e11e0ca1844a1 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Wed, 9 Jan 2008 22:37:59 +0100 Subject: - first try with favorites --- pages/whats_on.ecpp | 218 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 142 insertions(+), 76 deletions(-) (limited to 'pages/whats_on.ecpp') diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 7331adc..9944e21 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -8,6 +8,7 @@ #include "setup.h" #include "tools.h" #include "epg_events.h" +#include "epgsearch.h" using namespace std; using namespace vdrlive; @@ -69,6 +70,8 @@ if (type == "now") { if (seektime - time(0) + 3600 < 0) // if wanted time is past more then 1h, then use tomorrow seektime += SECSINDAY; head = tr("What's running at") + string(" ") + FormatDateTime(tr("%I:%M %p"), seektime) +string(" (") +FormatDateTime(tr("%a, %b %d"), seektime) + string(")"); +} else if (type == "favs") { + head = tr("Favorites"); } @@ -104,90 +107,151 @@ if (type == "now") { <%cpp> EpgEvents epgEvents; - ReadLock channelsLock( Channels ); - if (channelsLock) { - // int evntNr = 0; - for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) { - if (Channel->GroupSep()) { - continue; - } - const cSchedule *Schedule = Schedules->GetSchedule(Channel); - if (!Schedule) { - continue; - } - const cEvent *Event = NULL; - if (type == "now") - Event = Schedule->GetPresentEvent(); - else if (type == "next") - Event = Schedule->GetFollowingEvent(); - else if (type == "at") - Event = Schedule->GetEventAround(seektime); - if (!Event) { - continue; - } - - 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") { + if (type != "favs") + { + ReadLock channelsLock( Channels ); + if (channelsLock) { + // int evntNr = 0; + for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) { + if (Channel->GroupSep()) { + continue; + } + const cSchedule *Schedule = Schedules->GetSchedule(Channel); + if (!Schedule) { + continue; + } + const cEvent *Event = NULL; + if (type == "now") + Event = Schedule->GetPresentEvent(); + else if (type == "next") + Event = Schedule->GetFollowingEvent(); + else if (type == "at") + Event = Schedule->GetEventAround(seektime); + if (!Event) { + continue; + } + + 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()) &> +
+ +
+
+ <& 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) { + +% } +
-
-
<$ (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))); + } + 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()) &>
-% } -
- - "> - - - "> - -% } + + <& 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> - } + } + } } + else { + SearchResults results; + SearchTimers timers; + for (SearchTimers::iterator timer = timers.begin(); timer != timers.end(); ++timer) { + if (!timer->UseInFavorites()) continue; + SearchResults curresults; + curresults.GetByID(timer->Id()); + results.merge(curresults); + } + for (SearchResults::iterator result = results.begin(); result != results.end(); ++result) { + 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."); + + // last result? + bool bottom = false; + SearchResults::iterator nextres = result; + nextres++; + if (nextres == results.end()) bottom = true; + + time_t now = time(NULL); + long diff = result->StartTime() - now; + long absdiff = labs(diff); + if (absdiff >= 24*60*60) continue; // skip broadcasts more than a day away + string diffstring; + if (absdiff >= (60 * 60)) + diffstring = lexical_cast(long(absdiff / (60*60))) + " hours"; + else + diffstring = lexical_cast(long(absdiff / 60)) + " minutes"; + if (diff > 0) + diffstring = "in " + diffstring; + else + diffstring = "since " + diffstring; + + <& 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 $> minutes +
+ + "> + + + "> + +% } +<%cpp> + } + % if (mode == "list") { % } @@ -220,6 +284,8 @@ if (type == "now") { "><$ tr("at") $> " onchange="showspectime(this)"/> | +" href="whats_on.html?type=favs&mode=<$ current_mode $>"><$ tr("Favorites") $> +| % if ( current_mode == "list" ) { <$ tr("Details view") $> % } else { -- cgit v1.2.3