diff options
author | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2007-01-21 16:54:56 +0000 |
---|---|---|
committer | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2007-01-21 16:54:56 +0000 |
commit | 903e6b746db36238b48741bafcbfeb60e1a718c9 (patch) | |
tree | 1507ec5c79ab612b2808d61d3467953121177e74 | |
parent | 6514a4d1e37954506168f5c9a7ea41580cdba95e (diff) | |
download | vdr-plugin-live-903e6b746db36238b48741bafcbfeb60e1a718c9.tar.gz vdr-plugin-live-903e6b746db36238b48741bafcbfeb60e1a718c9.tar.bz2 |
- use epg_events in recordings too. This simplifies the overall
recordings code.
-rw-r--r-- | epg_events.cpp | 35 | ||||
-rw-r--r-- | epg_events.h | 36 | ||||
-rw-r--r-- | pages/.cvsignore | 2 | ||||
-rw-r--r-- | pages/pageelems.ecpp | 2 | ||||
-rw-r--r-- | pages/recordings.ecpp | 102 | ||||
-rw-r--r-- | pages/whats_on.ecpp | 5 |
6 files changed, 102 insertions, 80 deletions
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<EpgEvent> 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; </div> <div class="epg_content"> <div class="epg_tools"> - <& (tools_comp) &> + <& (tools_comp) id=(boxId) &> </div> <div> <div class="info"><$ (time) $></div> 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 <vdr/plugin.h> #include <vdr/config.h> + #include "exception.h" #include "tools.h" +#include "epg_events.h" + #include "recordings.h" using namespace vdrlive; +using namespace std; </%pre> <%args> </%args> <%request scope="page"> RecordingsTree recordingsTree(LiveRecordingsManager()); -RecordingsTree::RecordingsItemPtr currRecItem; +EpgEvents epgEvents; </%request> <%include>page_init.eh</%include> <%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("<div class=\"recording_item\" onclick=\"Toggle(this)\">\n") - + std::string("\t\t\t<div class=\"recording_imgs\">") + reply.out() << string("\t\t\t") + + string("<div class=\"recording_item\" onclick=\"Toggle(this)\">\n") + + string("\t\t\t<div class=\"recording_imgs\">") + StringRepeat(level, "<img src=\"transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />") - + std::string("<img class=\"recording_expander\" src=\"") + collapseimg + std::string("\" alt=\"\" />") - + std::string("<img class=\"recording_folder\" src=\"") + folderimg + std::string("\" alt=\"\" />") - + std::string("</div>"); + + string("<img class=\"recording_expander\" src=\"") + collapseimg + string("\" alt=\"\" />") + + string("<img class=\"recording_folder\" src=\"") + folderimg + string("\" alt=\"\" />") + + string("</div>"); }> <div class="recording_name"><$ recItem->Name() $></div> <div class="recording_actions"> </div> @@ -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<std::string, int>(level + 1)); + recItemParams.add("level", lexical_cast<string, int>(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<std::string, int>(day.length() - 1) + ".25em;"); - reply.out() << std::string("\t\t\t") - + std::string("<div class=\"recording_item\">\n") - + std::string("\t\t\t<div class=\"recording_imgs\">") + 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<string, int>(day.length() - 1) + ".25em;"); + reply.out() << string("\t\t\t") + + string("<div class=\"recording_item\">\n") + + string("\t\t\t<div class=\"recording_imgs\">") + StringRepeat(level, "<img src=\"transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />") - + std::string("<img src=\"transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />") - + std::string("<img src=\"movie.png\" alt=\"movie\" />") - + std::string("</div>"); + + string("<img src=\"transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />") + + string("<img src=\"movie.png\" alt=\"movie\" />") + + string("</div>"); - const cRecordingInfo* info = recItem->RecInfo(); - std::string shortDescr(tr("Click to view details.")); if (info && info->ShortText()) shortDescr = (std::string("") + info->ShortText() + std::string("<br />") + shortDescr); + string shortDescr(tr("Click to view details.")); if (info && info->ShortText()) shortDescr = (string("") + info->ShortText() + string("<br />") + shortDescr); }> <div class="recording_day" style="width: <$ dayLen $>"><$ day $></div> <div class="recording_date"><$ FormatDateTime(tr("%b %d %y"), recItem->StartTime()) $></div> @@ -130,45 +143,26 @@ for (iter = recordingsTree.begin(path); iter != end; ++iter) { </ul> </%def> + <%def recordings_data> -<%args> -path[]; -int level = 0; -</%args> <{ -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<std::string, int>(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<EpgEventPtr>::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> <%def rec_tools> -<& pageelems.ajax_action_href action="play_recording" param=(currRecItem->Id()) image="play.png" alt="" &> +<%args> + string id; +</%args> +<& pageelems.ajax_action_href action="play_recording" param=(id) image="play.png" alt="" &> </%def> 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") { }> <div class="event"> <div class="station"> - <div><div><div><$ (epgEvent->ChannelName()) $></div></div></div> + <div><div><div><$ (epgEvent->Caption()) $></div></div></div> </div> <div class="content"> <div class="tools"> @@ -93,14 +93,13 @@ if (type == "now") { } }> </div> - <div class="epg_data" style="display: none;"> <{ // create hidden div for the tooltip hints. for (vector<EpgEventPtr>::iterator i = epgEvents.begin(); i != epgEvents.end(); ++i) { EpgEventPtr epg = *i; }> - <& pageelems.epg_tt_box boxId=(epg->Id()) caption=(epg->ChannelName()) time=(epg->StartTime(tr("%I:%M %p")) + string(" - ") + epg->EndTime(tr("%I:%M %p"))) title=(epg->Title()) short_descr=(epg->ShortDescr()) long_descr=(epg->LongDescr()) &> + <& pageelems.epg_tt_box boxId=(epg->Id()) caption=(epg->Caption()) time=(epg->StartTime(tr("%I:%M %p")) + string(" - ") + epg->EndTime(tr("%I:%M %p"))) title=(epg->Title()) short_descr=(epg->ShortDescr()) long_descr=(epg->LongDescr()) &> <{ } }> |