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') 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 From 1f4a4cfc016c562eb7c8e2b3d99fa53dea036ece Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Thu, 10 Jan 2008 13:36:07 +0100 Subject: - translation fixes --- pages/whats_on.ecpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'pages') diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 9944e21..e2f1a0f 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -202,7 +202,18 @@ if (type == "now") { curresults.GetByID(timer->Id()); results.merge(curresults); } + 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 + + 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"); + string epgId = EpgEvents::EncodeDomId(result->Channel(), result->EventId()); string channelname = Channels.GetByChannelID(result->Channel())->Name(); int channelnr = Channels.GetByChannelID(result->Channel())->Number(); @@ -212,31 +223,15 @@ if (type == "now") { + "

" + 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; + bool bottom = (++nextres == results.end()); <& 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 + <$ diffstring $>
"> -- cgit v1.2.3 From 513a4f2a4d63e5e3221891b9f1cef42dd58ad45c Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Thu, 10 Jan 2008 13:40:39 +0100 Subject: - presence of favorites now depends on existence of epgsearch --- pages/whats_on.ecpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pages') diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index e2f1a0f..9a60e7f 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -279,8 +279,10 @@ if (type == "now") { "><$ tr("at") $> " onchange="showspectime(this)"/> | +% if ( LiveFeatures< features::epgsearch >().Recent() ) { " href="whats_on.html?type=favs&mode=<$ current_mode $>"><$ tr("Favorites") $> | +% } % if ( current_mode == "list" ) { <$ tr("Details view") $> % } else { -- cgit v1.2.3 From e3f72a5ad92ce4c75f8d91f1925491f53fbdbe52 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Thu, 10 Jan 2008 19:23:57 +0100 Subject: - favorites in 'detailed mode' --- pages/whats_on.ecpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'pages') diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 9a60e7f..a902ae6 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -225,6 +225,7 @@ if (type == "now") { // last result? SearchResults::iterator nextres = result; bool bottom = (++nextres == results.end()); + if (mode == "list") { <& pageelems.epg_tool_box detail=(0) epgid=(epgId) title=(result->Title()) startTime=(result->StartTime()) endTime=(result->StopTime()) lastCurrentChanel=(bottom ? 1 : 0) &> @@ -239,14 +240,35 @@ if (type == "now") { % if (!longDescription.empty()) { <& tooltip.hint text=(longDescription) &><& tooltip.display domId=(epgId) &> % } - ><$ (result->Title()) $>
<$ (result->ShortText()) $>
- + ><$ (result->Title()) $>
<$ (result->ShortText()) $>
+ ">
><$ (channelname) $>
- -% } -<%cpp> + +% } else { +
+ +
+
+ <& pageelems.epg_tool_box detail=(1) epgid=(epgId) title=(result->Title()) startTime=(result->StartTime()) endTime=(result->StopTime()) &> +
+
+
<$ (FormatDateTime(tr("%I:%M %p"), result->StartTime())) $> - <$ (FormatDateTime(tr("%I:%M %p"), result->StopTime())) $>
+
<$ diffstring $>
+
<$ (result->Title()) $>
+
<$ (result->ShortText()) $>
+
<$ truncDescription $>
+% if (truncated) { + +% } +
+
+
+<%cpp> } + } } - + % if (mode == "list") { % } -- cgit v1.2.3 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 From c1b029ee77466aab34207d06dd2e7a475bbbb053 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sun, 13 Jan 2008 23:25:40 +0100 Subject: A little bit of cleanup in epg_events.[h|cpp] after the last changes. --- pages/whats_on.ecpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pages') diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 4a7948f..7744b4d 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -132,13 +132,13 @@ if (type == "now") { if (!Event) { continue; } - + EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event); eventList.push_back(epgEvent); } } - } - else // get favorite broadcasts from epgsearch + } + else // get favorite broadcasts from epgsearch { SearchResults results; SearchTimers timers; -- cgit v1.2.3