From 015380b9fd9f4e3b34edc83d2ee57db1aa809c34 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 15 Jan 2011 16:59:59 +0100 Subject: - make MultiSchedule duration configurable - by default show the channel group containing the current channel - show "switch to this channel"-buttons --- pages/multischedule.ecpp | 47 +++++++++++++++++++++++++++++++++++++++++++---- pages/setup.ecpp | 9 +++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) (limited to 'pages') diff --git a/pages/multischedule.ecpp b/pages/multischedule.ecpp index f3188f0..4ae0c7e 100644 --- a/pages/multischedule.ecpp +++ b/pages/multischedule.ecpp @@ -37,7 +37,7 @@ struct SchedEntry { std::vector times_start; <%args> - unsigned int channel = 0; + int channel = -1; unsigned int time_para = 0; <%session scope="global"> @@ -136,6 +136,29 @@ pageTitle = trVDR("Schedule"); } } } + if ( channel < 0 ) { + if (cDevice::CurrentChannel()) { + // find group corresponding to current channel + int curGroup =0; + int curChannel = cDevice::CurrentChannel(); + for ( std::vector< std::vector >::iterator grIt = channel_groups_numbers.begin(); + grIt != channel_groups_numbers.end() && channel < 0; ++grIt, ++curGroup ) + { + for ( std::vector::iterator chIt = (*grIt).begin(); + chIt != (*grIt).end() && channel < 0; ++ chIt ) + { + if ( *chIt == curChannel ) + channel_group = channel = curGroup; + } + } + // if nothing is found, fall back to group 0 + if ( channel < 0 ) + channel = 0; + } + else { + channel_group = channel; + } + } if ( channel >= channel_groups_numbers.size() ) channel = 0; @@ -172,7 +195,6 @@ pageTitle = trVDR("Schedule"); { times_names.push_back(FormatDateTime( tr("%A, %x"), midnight + MAX_HOURS*3600*i) +std::string(" ")+ FormatDateTime( tr("%I:%M %p"), midnight + MAX_HOURS*3600*i) ); - //times_names.push_back("today 0:00"); times_start.push_back( midnight + MAX_HOURS*3600*i ); } if ( time_para >= times_names.size() ) @@ -199,10 +221,23 @@ pageTitle = trVDR("Schedule"); if ( time_para >= times_start.size() ) time_para = times_start.size()-1; time_t sched_start = times_start[ time_para ]; - time_t sched_end = sched_start + 60 * 60 * MAX_HOURS; + time_t max_hours; + try { + max_hours = lexical_cast( LiveSetup().GetScheduleDuration() ); + } + catch ( const bad_lexical_cast & ) + { + esyslog("Live: could not convert '%s' into a schedule duration", LiveSetup().GetScheduleDuration().c_str()); + max_hours = 8; + }; + if (max_hours > 48) + max_hours = 48; + + time_t sched_end = sched_start + 60 * 60 * max_hours; int sched_end_row = ( sched_end - sched_start ) / 60 / MINUTES_PER_ROW; std::list table[MAX_CHANNELS]; std::vector channel_names(channel_groups_numbers[ channel ].size() ); + std::vector channel_IDs(channel_groups_numbers[ channel ].size() ); if ( channel >= channel_groups_numbers.size() ) channel = channel_groups_numbers.size()-1; //for ( int chan = 0; chanGroupSep() || Channel->Name() == '\0' ) continue; channel_names[ j ] = Channel->Name(); + channel_IDs[ j ] = Channel->GetChannelID(); cSchedule const* Schedule = schedules->GetSchedule( Channel ); if ( ! Schedule ) @@ -299,7 +335,10 @@ pageTitle = trVDR("Schedule"); for ( unsigned int channel = 0; channel< channel_names.size() ; channel++) { -
<$ StringEscapeAndBreak(channel_names[channel]) $>
+
<$ StringEscapeAndBreak(channel_names[channel]) $> + <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(channel_IDs[channel]) image="zap.png" alt="" &> + <& pageelems.vlc_stream_channel channelId=(channel_IDs[channel]) &> +
  <%cpp> } diff --git a/pages/setup.ecpp b/pages/setup.ecpp index c1d328f..d5d4f2a 100644 --- a/pages/setup.ecpp +++ b/pages/setup.ecpp @@ -17,6 +17,7 @@ using namespace std; string pass; string times; string channelGroups; + string scheduleDuration; string startscreen; string theme; string localnetmask; @@ -60,6 +61,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) } LiveSetup().SetTimes(times); LiveSetup().SetChannelGroups(channelGroups); + LiveSetup().SetScheduleDuration(scheduleDuration); LiveSetup().SetStartScreen(startscreen); LiveSetup().SetTheme(theme); LiveSetup().SetShowLogo(!showLogo.empty()); @@ -88,6 +90,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) useauth = LiveSetup().GetUseAuth(); times = LiveSetup().GetTimes(); channelGroups = LiveSetup().GetChannelGroups(); + scheduleDuration = LiveSetup().GetScheduleDuration(); startscreen = LiveSetup().GetStartScreen(); theme = LiveSetup().GetTheme(); localnetmask = LiveSetup().GetLocalNetMask(); @@ -234,6 +237,11 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) <& tooltip.help text=(tr("Separate channels with a comma ',', separate groups with a semi-colon ';'")) &> + +
<$ tr("Duration of MultiSchedule in hours") $>:
+ + +
<$ tr("Show channels without EPG") $>:
@@ -247,6 +255,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) + -- cgit v1.2.3