From 903e6b746db36238b48741bafcbfeb60e1a718c9 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sun, 21 Jan 2007 16:54:56 +0000 Subject: - use epg_events in recordings too. This simplifies the overall recordings code. --- epg_events.cpp | 35 ++++++++++++----- epg_events.h | 36 +++++++++++------- pages/.cvsignore | 2 + pages/pageelems.ecpp | 2 +- pages/recordings.ecpp | 102 ++++++++++++++++++++++++-------------------------- pages/whats_on.ecpp | 5 +-- 6 files changed, 102 insertions(+), 80 deletions(-) create mode 100644 pages/.cvsignore diff --git a/epg_events.cpp b/epg_events.cpp index f2f7fc2..3940a57 100644 --- a/epg_events.cpp +++ b/epg_events.cpp @@ -4,14 +4,31 @@ namespace vdrlive { + EpgEvent::EpgEvent(const std::string& id, + const std::string& caption, + const std::string& title, + const std::string& short_descr, + const std::string& long_descr, + time_t start_time, + time_t end_time) : + m_eventId(id), + m_caption(caption), + m_title(title), + m_short_descr(short_descr), + m_long_descr(long_descr), + m_start_time(start_time), + m_end_time(end_time) + { + } + EpgEvent::EpgEvent(const std::string& id, const cEvent* event, const char* channelName) : - eventId(id), - title(event->Title() ? event->Title() : ""), - channel_name(channelName), - short_descr(event->ShortText() ? event->ShortText() : ""), - long_descr(event->Description() ? event->Description() : ""), - start_time(event->StartTime()), - end_time(event->EndTime()) + m_eventId(id), + m_caption(channelName), + m_title(event->Title() ? event->Title() : ""), + m_short_descr(event->ShortText() ? event->ShortText() : ""), + m_long_descr(event->Description() ? event->Description() : ""), + m_start_time(event->StartTime()), + m_end_time(event->EndTime()) { } @@ -21,12 +38,12 @@ namespace vdrlive const std::string EpgEvent::StartTime(const char* format) const { - return FormatDateTime(format, start_time); + return FormatDateTime(format, m_start_time); } const std::string EpgEvent::EndTime(const char* format) const { - return FormatDateTime(format, end_time); + return FormatDateTime(format, m_end_time); } EpgEvents::EpgEvents() : diff --git a/epg_events.h b/epg_events.h index 61ba3ff..d70ad26 100644 --- a/epg_events.h +++ b/epg_events.h @@ -19,32 +19,42 @@ namespace vdrlive class EpgEvent { public: - EpgEvent(const std::string& id, const cEvent* event, const char* channelName = ""); + EpgEvent(const std::string& id, + const std::string& caption, + const std::string& title, + const std::string& short_descr, + const std::string& long_descr, + time_t start_time, + time_t end_time); + + EpgEvent(const std::string& id, + const cEvent* event, + const char* channelName = ""); virtual ~EpgEvent(); - const std::string& Id() const { return eventId; } + const std::string& Id() const { return m_eventId; } - const std::string& Title() const { return title; } + const std::string& Title() const { return m_title; } - const std::string& ChannelName() const { return channel_name; } + const std::string& Caption() const { return m_caption; } - const std::string& ShortDescr() const { return short_descr; } + const std::string& ShortDescr() const { return m_short_descr; } - const std::string& LongDescr() const { return long_descr; } + const std::string& LongDescr() const { return m_long_descr; } const std::string StartTime(const char* format) const; const std::string EndTime(const char* format) const; private: - std::string eventId; - std::string title; - std::string channel_name; - std::string short_descr; - std::string long_descr; - time_t start_time; - time_t end_time; + std::string m_eventId; + std::string m_caption; + std::string m_title; + std::string m_short_descr; + std::string m_long_descr; + time_t m_start_time; + time_t m_end_time; }; typedef boost::shared_ptr EpgEventPtr; diff --git a/pages/.cvsignore b/pages/.cvsignore new file mode 100644 index 0000000..1ae0abb --- /dev/null +++ b/pages/.cvsignore @@ -0,0 +1,2 @@ +*.cpp +.dependencies diff --git a/pages/pageelems.ecpp b/pages/pageelems.ecpp index 61089b1..8cc94fd 100644 --- a/pages/pageelems.ecpp +++ b/pages/pageelems.ecpp @@ -67,7 +67,7 @@ using namespace vdrlive;
- <& (tools_comp) &> + <& (tools_comp) id=(boxId) &>
<$ (time) $>
diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp index a97dd17..2459944 100644 --- a/pages/recordings.ecpp +++ b/pages/recordings.ecpp @@ -1,18 +1,22 @@ <%pre> #include #include + #include "exception.h" #include "tools.h" +#include "epg_events.h" + #include "recordings.h" using namespace vdrlive; +using namespace std; <%args> <%request scope="page"> RecordingsTree recordingsTree(LiveRecordingsManager()); -RecordingsTree::RecordingsItemPtr currRecItem; +EpgEvents epgEvents; <%include>page_init.eh <%cpp> @@ -69,16 +73,16 @@ RecordingsTree::Map::iterator end = recordingsTree.end(path); <{ for (iter = recordingsTree.begin(path); iter != end; ++iter) { RecordingsTree::RecordingsItemPtr recItem = iter->second; - std::string folderimg("folder_closed.png"); - std::string collapseimg("plus.png"); + string folderimg("folder_closed.png"); + string collapseimg("plus.png"); if (recItem->IsDir()) { - reply.out() << std::string("\t\t\t") - + std::string("
\n") - + std::string("\t\t\t
") + reply.out() << string("\t\t\t") + + string("
\n") + + string("\t\t\t
") + StringRepeat(level, "\"\"") - + std::string("\"\"") - + std::string("\"\"") - + std::string("
"); + + string("\"\"") + + string("\"\"") + + string("
"); }>
<$ recItem->Name() $>
 
@@ -89,28 +93,37 @@ for (iter = recordingsTree.begin(path); iter != end; ++iter) { recItemParams.add("path", *i); } recItemParams.add("path", recItem->Name()); - recItemParams.add("level", lexical_cast(level + 1)); + recItemParams.add("level", lexical_cast(level + 1)); callComp("recordings.recordings_item", request, reply, recItemParams); } } for (iter = recordingsTree.begin(path); iter != end; ++iter) { RecordingsTree::RecordingsItemPtr recItem = iter->second; - std::string folderimg("folder_closed.png"); - std::string collapseimg("plus.png"); + string folderimg("folder_closed.png"); + string collapseimg("plus.png"); if (!recItem->IsDir()) { - currRecItem = recItem; - std::string day(FormatDateTime("%a,", recItem->StartTime())); - std::string dayLen(lexical_cast(day.length() - 1) + ".25em;"); - reply.out() << std::string("\t\t\t") - + std::string("
\n") - + std::string("\t\t\t
") + const cRecordingInfo* info = recItem->RecInfo(); + if (info) { + EpgEventPtr epgEvent(new EpgEvent(recItem->Id(), + recItem->Name(), + info->Title() ? info->Title() : recItem->Name(), + info->ShortText() ? info->ShortText() : "", + info->Description() ? info->Description() : "", + recItem->StartTime(), + recItem->StartTime())); + epgEvents.push_back(epgEvent); + } + string day(FormatDateTime("%a,", recItem->StartTime())); + string dayLen(lexical_cast(day.length() - 1) + ".25em;"); + reply.out() << string("\t\t\t") + + string("
\n") + + string("\t\t\t
") + StringRepeat(level, "\"\"") - + std::string("\"\"") - + std::string("\"movie\"") - + std::string("
"); + + string("\"\"") + + string("\"movie\"") + + string("
"); - const cRecordingInfo* info = recItem->RecInfo(); - std::string shortDescr(tr("Click to view details.")); if (info && info->ShortText()) shortDescr = (std::string("") + info->ShortText() + std::string("
") + shortDescr); + string shortDescr(tr("Click to view details.")); if (info && info->ShortText()) shortDescr = (string("") + info->ShortText() + string("
") + shortDescr); }>
<$ day $>
<$ FormatDateTime(tr("%b %d %y"), recItem->StartTime()) $>
@@ -130,45 +143,26 @@ for (iter = recordingsTree.begin(path); iter != end; ++iter) { + <%def recordings_data> -<%args> -path[]; -int level = 0; - <{ -RecordingsTree::Map::iterator iter; -RecordingsTree::Map::iterator end = recordingsTree.end(path); -for (iter = recordingsTree.begin(path); iter != end; ++iter) { - RecordingsTree::RecordingsItemPtr recItem = iter->second; - if (recItem->IsDir()) { - cxxtools::QueryParams recItemParams(qparam, false); - for (path_type::const_iterator i = path.begin(); i != path.end(); ++i) { - recItemParams.add("path", *i); - } - recItemParams.add("path", recItem->Name()); - recItemParams.add("level", lexical_cast(level + 1)); - callComp("recordings.recordings_data", request, reply, recItemParams); - } - else { - currRecItem = recItem; - const cRecordingInfo* info = recItem->RecInfo(); - if (info) { - std::string start(FormatDateTime("%a,", recItem->StartTime()) + std::string(" ") - + FormatDateTime(tr("%b %d %y"), recItem->StartTime()) + std::string(" ") - + FormatDateTime(tr("%I:%M %p"), recItem->StartTime())); - std::string title(recItem->Name()); if (info->Title()) title = info->Title(); - std::string shortDescr; if (info->ShortText()) shortDescr = info->ShortText(); - std::string longDescr; if (info->Description()) longDescr = info->Description(); + // create hidden div for the tooltip hints. + for (vector::iterator i = epgEvents.begin(); i != epgEvents.end(); ++i) { + EpgEventPtr epg = *i; + string start(epg->StartTime("%a,") + string(" ") + + epg->StartTime(tr("%b %d %y")) + string(" ") + + epg->StartTime(tr("%I:%M %p"))); }> - <& pageelems.epg_tt_box boxId=(recItem->Id()) caption=(recItem->Name()) tools_comp=("recordings.rec_tools") time=(start) title=(title) short_descr=(shortDescr) long_descr=(longDescr) &> + <& pageelems.epg_tt_box boxId=(epg->Id()) caption=(epg->Caption()) tools_comp=("recordings.rec_tools") time=(start) title=(epg->Title()) short_descr=(epg->ShortDescr()) long_descr=(epg->LongDescr()) &> <{ - } } -} }> <%def rec_tools> -<& pageelems.ajax_action_href action="play_recording" param=(currRecItem->Id()) image="play.png" alt="" &> +<%args> + string id; + +<& pageelems.ajax_action_href action="play_recording" param=(id) image="play.png" alt="" &> diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 49ec9f3..bf5a639 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -66,7 +66,7 @@ if (type == "now") { }>
-
<$ (epgEvent->ChannelName()) $>
+
<$ (epgEvent->Caption()) $>
@@ -93,14 +93,13 @@ if (type == "now") { } }>
-