Browse files

Services: Allow filtering by Channel Group in GetProgramGuide

  • Loading branch information...
1 parent 23d1a06 commit 67cf9c538ed5410694b1b4ff52c2e65b934ebd74 @stuartm stuartm committed Nov 15, 2013
View
7 mythtv/libs/libmythservicecontracts/services/guideServices.h
@@ -39,7 +39,7 @@
class SERVICE_PUBLIC GuideServices : public Service //, public QScriptable ???
{
Q_OBJECT
- Q_CLASSINFO( "version" , "2.0" );
+ Q_CLASSINFO( "version" , "2.1" );
public:
@@ -60,15 +60,16 @@ class SERVICE_PUBLIC GuideServices : public Service //, public QScriptable ???
const QDateTime &EndTime ,
int StartChanId,
int NumChannels,
- bool Details ) = 0;
+ bool Details,
+ int ChannelGroupId ) = 0;
virtual DTC::Program* GetProgramDetails ( int ChanId,
const QDateTime &StartTime ) = 0;
virtual QFileInfo GetChannelIcon ( int ChanId,
int Width ,
int Height ) = 0;
- virtual DTC::ChannelGroupList* GetChannelGroupList ( bool IncludeEmpty ) = 0;
+ virtual DTC::ChannelGroupList* GetChannelGroupList ( bool IncludeEmpty ) = 0;
};
#endif
View
32 mythtv/programs/mythbackend/services/guide.cpp
@@ -48,7 +48,8 @@ DTC::ProgramGuide *Guide::GetProgramGuide( const QDateTime &rawStartTime ,
const QDateTime &rawEndTime ,
int nStartChanId,
int nNumChannels,
- bool bDetails )
+ bool bDetails,
+ int nChannelGroupId )
{
if (!rawStartTime.isValid())
throw( "StartTime is invalid" );
@@ -94,15 +95,26 @@ DTC::ProgramGuide *Guide::GetProgramGuide( const QDateTime &rawStartTime ,
MSqlBindings bindings;
// lpad is to allow natural sorting of numbers
- QString sSQL = "WHERE program.chanid >= :StartChanId "
- "AND program.chanid <= :EndChanId "
- "AND program.endtime >= :StartDate "
- "AND program.starttime <= :EndDate "
- "GROUP BY program.starttime, channel.chanid "
- "ORDER BY lpad(channel.channum, 10, 0), "
- " callsign, "
- " lpad(program.chanid, 10, 0), "
- " program.starttime ";
+ QString sSQL;
+
+ if (nChannelGroupId > 0)
+ {
+ sSQL = "LEFT JOIN channelgroup ON program.chanid = channelgroup.chanid "
+ "WHERE channelgroup.grpid = :CHANGRPID AND ";
+ bindings[":CHANGRPID" ] = nChannelGroupId;
+ }
+ else
+ sSQL = "WHERE ";
+
+ sSQL += "program.chanid >= :StartChanId "
+ "AND program.chanid <= :EndChanId "
+ "AND program.endtime >= :StartDate "
+ "AND program.starttime <= :EndDate "
+ "GROUP BY program.starttime, channel.chanid "
+ "ORDER BY lpad(channel.channum, 10, 0), "
+ " callsign, "
+ " lpad(program.chanid, 10, 0), "
+ " program.starttime ";
bindings[":StartChanId"] = nStartChanId;
bindings[":EndChanId" ] = nEndChanId;
View
8 mythtv/programs/mythbackend/services/guide.h
@@ -51,7 +51,8 @@ class Guide : public GuideServices
const QDateTime &EndTime ,
int StartChanId,
int NumChannels,
- bool Details );
+ bool Details,
+ int ChannelGroupId );
DTC::Program* GetProgramDetails ( int ChanId,
const QDateTime &StartTime );
@@ -96,9 +97,10 @@ class ScriptableGuide : public QObject
const QDateTime &EndTime ,
int StartChanId,
int NumChannels,
- bool Details )
+ bool Details,
+ int ChannelGroupId )
{
- return m_obj.GetProgramGuide( StartTime, EndTime, StartChanId, NumChannels, Details );
+ return m_obj.GetProgramGuide( StartTime, EndTime, StartChanId, NumChannels, Details, ChannelGroupId );
}
QObject* GetProgramDetails( int ChanId, const QDateTime &StartTime )

0 comments on commit 67cf9c5

Please sign in to comment.