diff options
-rw-r--r-- | pages/multischedule.ecpp | 99 | ||||
-rw-r--r-- | pages/setup.ecpp | 8 | ||||
-rw-r--r-- | setup.cpp | 2 | ||||
-rw-r--r-- | setup.h | 3 |
4 files changed, 88 insertions, 24 deletions
diff --git a/pages/multischedule.ecpp b/pages/multischedule.ecpp index bf05fa6..f3188f0 100644 --- a/pages/multischedule.ecpp +++ b/pages/multischedule.ecpp @@ -32,6 +32,7 @@ struct SchedEntry { }; std::vector<std::string> channel_groups_names; + std::vector< std::vector<int> > channel_groups_numbers; std::vector<std::string> times_names; std::vector<time_t> times_start; </%pre> @@ -55,39 +56,89 @@ pageTitle = trVDR("Schedule"); if ( !channelsLock ) throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") ); -#define MAX_CHANNELS 5 +#define MAX_CHANNELS 10 #define MAX_DAYS 3 #define MAX_HOURS 8 #define MINUTES_PER_ROW 5 #define CHARACTERS_PER_ROW 30 + if ( channel_groups_numbers.size() == 0 ) + { // build the groups of channels to display - std::vector< std::vector<int> > channel_groups_numbers; - channel_groups_names.clear(); - int cur_group_count=0; - for ( cChannel *listChannel = Channels.First(); listChannel; listChannel = Channels.Next( listChannel ) ) + std::string channelGroups=LiveSetup().GetChannelGroups(); + if ( channelGroups.empty() ) { - if ( listChannel->GroupSep() || *listChannel->Name() == '\0' ) - continue; + // setup default channel groups + int lastChannel = LiveSetup().GetLastChannel(); + if ( lastChannel == 0 ) + lastChannel = Channels.MaxNumber(); + std::stringstream groups; + for ( int i = 1; i<= lastChannel; i++) + { + groups << i; + if ( (i % 5) == 0 ) + groups << ";"; + else + groups << ","; + } + channelGroups = groups.str(); + LiveSetup().SetChannelGroups( channelGroups ); + } + size_t groupSep; + std::string thisGroup = ""; + while ( ! channelGroups.empty() ) + { + groupSep = channelGroups.find(';'); + thisGroup = channelGroups.substr(0, groupSep ); + if ( groupSep != channelGroups.npos ) + channelGroups.erase(0, groupSep+1 ); + else + channelGroups=""; - if ( cur_group_count==0 ) + int cur_group_count=0; + channel_groups_names.push_back( std::string() ); + channel_groups_numbers.push_back( std::vector<int>() ); + while ( !thisGroup.empty() ) + { + std::string thisChannel; + try { + if ( cur_group_count != 0 ) + channel_groups_names.back() += std::string( " - " ); + size_t channelSep = thisGroup.find(','); + thisChannel = thisGroup.substr(0, channelSep ); + if ( channelSep != thisGroup.npos ) + thisGroup.erase( 0, channelSep+1 ); + else + thisGroup = ""; + int channel_no = lexical_cast< int > (thisChannel); + cChannel* Channel = Channels.GetByNumber( channel_no ); + if ( !Channel ) + { + esyslog("Live: could not find channel no '%s'.", thisChannel.c_str() ); + continue; + } + channel_groups_names.back() += std::string( Channel->Name() ); + channel_groups_numbers.back().push_back( Channel->Number() ); + cur_group_count++; + if ( cur_group_count>=MAX_CHANNELS ) + { + // start new group if group gets too large + cur_group_count=0; + channel_groups_names.push_back( std::string() ); + channel_groups_numbers.push_back( std::vector<int>() ); + } + } + catch ( const bad_lexical_cast & ) { - // first entry in this group - channel_groups_names.push_back( std::string() ); - channel_groups_numbers.push_back( std::vector<int>( MAX_CHANNELS) ); + esyslog("Live: could not convert '%s' into a channel number", thisChannel.c_str()); + continue; } - else channel_groups_names.back() += " - "; - - channel_groups_names.back() += std::string( listChannel->Name() ); - channel_groups_numbers.back()[ cur_group_count ] = listChannel->Number(); + } + } + } - cur_group_count++; - if ( cur_group_count >= MAX_CHANNELS ) - // we need a new group next round - cur_group_count = 0; - } if ( channel >= channel_groups_numbers.size() ) - channel = channel_groups_numbers.size()-1; + channel = 0; channel_group = channel; { // build time list @@ -151,11 +202,11 @@ pageTitle = trVDR("Schedule"); time_t sched_end = sched_start + 60 * 60 * MAX_HOURS; int sched_end_row = ( sched_end - sched_start ) / 60 / MINUTES_PER_ROW; std::list<SchedEntry> table[MAX_CHANNELS]; - string channel_names[ MAX_CHANNELS]; + std::vector<std::string> channel_names(channel_groups_numbers[ channel ].size() ); if ( channel >= channel_groups_numbers.size() ) channel = channel_groups_numbers.size()-1; //for ( int chan = 0; chan<MAX_CHANNELS; chan++) - for ( int j = 0; j<MAX_CHANNELS; j++) + for ( unsigned int j = 0; j<channel_groups_numbers[ channel ].size(); j++) { int prev_row = -1; @@ -245,7 +296,7 @@ pageTitle = trVDR("Schedule"); <td > <div class="boxheader"> <div><div><$ tr("Time") $></div></div> </div></td> <td class="time spacer"> </td> <%cpp> - for ( int channel = 0; channel< MAX_CHANNELS ; channel++) + for ( unsigned int channel = 0; channel< channel_names.size() ; channel++) { </%cpp> <td> <div class="boxheader"> <div> <div><$ StringEscapeAndBreak(channel_names[channel]) $> </div></div> </div></td> diff --git a/pages/setup.ecpp b/pages/setup.ecpp index 98bf1eb..c1d328f 100644 --- a/pages/setup.ecpp +++ b/pages/setup.ecpp @@ -16,6 +16,7 @@ using namespace std; string login; string pass; string times; + string channelGroups; string startscreen; string theme; string localnetmask; @@ -58,6 +59,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) LiveSetup().CheckLocalNet(request.getPeerIp()); } LiveSetup().SetTimes(times); + LiveSetup().SetChannelGroups(channelGroups); LiveSetup().SetStartScreen(startscreen); LiveSetup().SetTheme(theme); LiveSetup().SetShowLogo(!showLogo.empty()); @@ -85,6 +87,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) login = LiveSetup().GetAdminLogin(); useauth = LiveSetup().GetUseAuth(); times = LiveSetup().GetTimes(); + channelGroups = LiveSetup().GetChannelGroups(); startscreen = LiveSetup().GetStartScreen(); theme = LiveSetup().GetTheme(); localnetmask = LiveSetup().GetLocalNetMask(); @@ -227,6 +230,11 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) <& tooltip.help text=(tr("Format is HH:MM. Separate multiple times with a semicolon")) &></td> </tr> <tr> + <td class="label leftcol"><div class="withmargin"><$ tr("Channel groups for MultiSchedule") $>:</div></td> + <td class="rightcol"><input type="text" name="channelGroups" value="<$ channelGroups $>" id="channelGroups" /> + <& tooltip.help text=(tr("Separate channels with a comma ',', separate groups with a semi-colon ';'")) &></td> + </tr> + <tr> <td class="label leftcol"><div class="withmargin"><$ tr("Show channels without EPG") $>:</div></td> <td class="rightcol"> <input type="checkbox" name="showChannelsWithoutEPG" id="showChannelsWithoutEPG" value="1" <%cpp> CHECKIF(!showChannelsWithoutEPG.empty()); </%cpp>/> @@ -120,6 +120,7 @@ bool Setup::ParseSetupEntry( char const* name, char const* value ) else if ( strcmp( name, "AdminLogin" ) == 0 ) m_adminLogin = value; else if ( strcmp( name, "AdminPasswordMD5" ) == 0 ) m_adminPasswordMD5 = value; else if ( strcmp( name, "UserdefTimes" ) == 0 ) m_times = value; + else if ( strcmp( name, "ChannelGroups" ) == 0 ) m_channelGroups = value; else if ( strcmp( name, "StartPage" ) == 0 ) m_startscreen = value; else if ( strcmp( name, "Theme" ) == 0 ) m_theme = value; else if ( strcmp( name, "LocalNetMask" ) == 0 ) { m_localnetmask = value; } @@ -284,6 +285,7 @@ bool Setup::SaveSetup() liveplugin->SetupStore("LocalNetMask", m_localnetmask.c_str()); } liveplugin->SetupStore("UserdefTimes", m_times.c_str()); + liveplugin->SetupStore("ChannelGroups", m_channelGroups.c_str()); liveplugin->SetupStore("StartPage", m_startscreen.c_str()); liveplugin->SetupStore("Theme", m_theme.c_str()); liveplugin->SetupStore("LastWhatsOnListMode", m_lastwhatsonlistmode.c_str()); @@ -44,6 +44,7 @@ class Setup bool GetUseAuth() const { return m_useAuth; } bool UseAuth() const; std::string const GetTimes() const { return m_times; } + std::string const GetChannelGroups() const { return m_channelGroups; } std::string const GetStartScreen() const { return m_startscreen; } std::string const GetStartScreenLink() const; std::string const GetTheme() const { return m_theme; } @@ -68,6 +69,7 @@ class Setup void SetUseAuth(int auth) { m_useAuth = auth; } void SetScreenshotInterval(int interval) { m_screenshotInterval = interval; } void SetTimes(std::string const & times) { m_times = times; } + void SetChannelGroups(std::string const & channelGroups) { m_channelGroups = channelGroups; } void SetStartScreen(std::string const & startscreen) { m_startscreen = startscreen; } void SetTheme(std::string const & theme) { m_theme = theme; } void SetLocalNetMask(std::string const & localnetmask) { m_localnetmask = localnetmask; } @@ -119,6 +121,7 @@ class Setup std::string m_adminLogin; std::string m_adminPasswordMD5; std::string m_times; + std::string m_channelGroups; std::string m_startscreen; std::string m_theme; std::string m_localnetmask; |