MythTV  master
programAndChannel.h
Go to the documentation of this file.
1 // Program Name: program.h
3 // Created : Jan. 15, 2010
4 //
5 // Copyright (c) 2010 David Blain <dblain@mythtv.org>
6 //
7 // Licensed under the GPL v2 or later, see COPYING for details
8 //
10 
11 #ifndef PROGRAM_H_
12 #define PROGRAM_H_
13 
14 #include <QDateTime>
15 #include <QString>
16 
17 #include "serviceexp.h"
18 #include "datacontracthelper.h"
19 
20 #include "recording.h"
21 #include "artworkInfoList.h"
22 #include "castMemberList.h"
23 
24 namespace DTC
25 {
26 
27 class Program;
28 
29 
30 class SERVICE_PUBLIC ChannelInfo : public QObject
31 {
32  Q_OBJECT
33  Q_CLASSINFO( "version", "2.1" );
34 
35  // Q_CLASSINFO Used to augment Metadata for properties.
36  // See datacontracthelper.h for details
37 
38  Q_CLASSINFO( "Programs", "type=DTC::Program");
39 
40  Q_PROPERTY( uint ChanId READ ChanId WRITE setChanId )
41  Q_PROPERTY( QString ChanNum READ ChanNum WRITE setChanNum )
42  Q_PROPERTY( QString CallSign READ CallSign WRITE setCallSign )
43  Q_PROPERTY( QString IconURL READ IconURL WRITE setIconURL )
44  Q_PROPERTY( QString ChannelName READ ChannelName WRITE setChannelName )
45 
46  Q_PROPERTY( uint MplexId READ MplexId WRITE setMplexId DESIGNABLE SerializeDetails )
47  Q_PROPERTY( uint ServiceId READ ServiceId WRITE setServiceId DESIGNABLE SerializeDetails )
48  Q_PROPERTY( uint ATSCMajorChan READ ATSCMajorChan WRITE setATSCMajorChan DESIGNABLE SerializeDetails )
49  Q_PROPERTY( uint ATSCMinorChan READ ATSCMinorChan WRITE setATSCMinorChan DESIGNABLE SerializeDetails )
50  Q_PROPERTY( QString Format READ Format WRITE setFormat DESIGNABLE SerializeDetails )
51  Q_PROPERTY( QString FrequencyId READ FrequencyId WRITE setFrequencyId DESIGNABLE SerializeDetails )
52  Q_PROPERTY( int FineTune READ FineTune WRITE setFineTune DESIGNABLE SerializeDetails )
53  Q_PROPERTY( QString ChanFilters READ ChanFilters WRITE setChanFilters DESIGNABLE SerializeDetails )
54  Q_PROPERTY( int SourceId READ SourceId WRITE setSourceId DESIGNABLE SerializeDetails )
55  Q_PROPERTY( int InputId READ InputId WRITE setInputId DESIGNABLE SerializeDetails )
56  Q_PROPERTY( bool CommFree READ CommFree WRITE setCommFree DESIGNABLE SerializeDetails )
57  Q_PROPERTY( bool UseEIT READ UseEIT WRITE setUseEIT DESIGNABLE SerializeDetails )
58  Q_PROPERTY( bool Visible READ Visible WRITE setVisible DESIGNABLE SerializeDetails )
59  Q_PROPERTY( QString XMLTVID READ XMLTVID WRITE setXMLTVID DESIGNABLE SerializeDetails )
60  Q_PROPERTY( QString DefaultAuth READ DefaultAuth WRITE setDefaultAuth DESIGNABLE SerializeDetails )
61  Q_PROPERTY( QString ChannelGroups READ ChannelGroups WRITE setChannelGroups DESIGNABLE SerializeDetails )
62  Q_PROPERTY( QString Inputs READ Inputs WRITE setInputs DESIGNABLE SerializeDetails )
63 
64  Q_PROPERTY( QVariantList Programs READ Programs DESIGNABLE true )
65 
66  PROPERTYIMP ( uint , ChanId )
67  PROPERTYIMP ( QString , ChanNum )
68  PROPERTYIMP ( QString , CallSign )
69  PROPERTYIMP ( QString , IconURL )
70  PROPERTYIMP ( QString , ChannelName )
71  PROPERTYIMP ( uint , MplexId )
72  PROPERTYIMP ( uint , ServiceId )
73  PROPERTYIMP ( uint , ATSCMajorChan )
74  PROPERTYIMP ( uint , ATSCMinorChan )
75  PROPERTYIMP ( QString , Format )
76  PROPERTYIMP ( QString , FrequencyId )
77  PROPERTYIMP ( int , FineTune )
78  PROPERTYIMP ( QString , ChanFilters )
79  PROPERTYIMP ( int , SourceId )
80  PROPERTYIMP ( int , InputId )
81  PROPERTYIMP ( bool , CommFree )
82  PROPERTYIMP ( bool , UseEIT )
83  PROPERTYIMP ( bool , Visible )
84  PROPERTYIMP ( QString , XMLTVID )
85  PROPERTYIMP ( QString , DefaultAuth )
86  PROPERTYIMP ( QString , ChannelGroups )
87  PROPERTYIMP ( QString , Inputs )
88 
89  PROPERTYIMP_RO_REF( QVariantList, Programs )
90 
91  // Used only by Serializer
92  PROPERTYIMP( bool, SerializeDetails )
93 
94  public:
95 
96  static void InitializeCustomTypes();
97 
98  Q_INVOKABLE ChannelInfo(QObject *parent = nullptr)
99  : QObject ( parent ),
100  m_ChanId ( 0 ),
101  m_MplexId ( 0 ),
102  m_ServiceId ( 0 ),
103  m_ATSCMajorChan ( 0 ),
104  m_ATSCMinorChan ( 0 ),
105  m_FineTune ( 0 ),
106  m_SourceId ( 0 ),
107  m_InputId ( 0 ),
108  m_CommFree ( 0 ),
109  m_UseEIT ( false ),
110  m_Visible ( true ),
111  m_SerializeDetails( true )
112  {
113  }
114 
115  void Copy( const ChannelInfo *src )
116  {
117  m_ChanId = src->m_ChanId ;
118  m_ChanNum = src->m_ChanNum ;
119  m_CallSign = src->m_CallSign ;
120  m_IconURL = src->m_IconURL ;
121  m_ChannelName = src->m_ChannelName ;
122  m_ChanFilters = src->m_ChanFilters ;
123  m_SourceId = src->m_SourceId ;
124  m_InputId = src->m_InputId ;
125  m_CommFree = src->m_CommFree ;
126  m_UseEIT = src->m_UseEIT ;
127  m_Visible = src->m_Visible ;
128  m_ChannelGroups = src->m_ChannelGroups;
129  m_Inputs = src->m_Inputs;
130 
131  CopyListContents< Program >( this, m_Programs, src->m_Programs );
132  }
133 
134  Program *AddNewProgram();
135 
136  private:
137  Q_DISABLE_COPY(ChannelInfo);
138 };
139 
140 class SERVICE_PUBLIC Program : public QObject
141 {
142  Q_OBJECT
143  Q_CLASSINFO( "version" , "1.11" );
144  Q_CLASSINFO( "defaultProp", "Description" );
145  Q_CLASSINFO( "deprecated" , "FileSize,FileName,HostName");
146 
147  Q_PROPERTY( QDateTime StartTime READ StartTime WRITE setStartTime )
148  Q_PROPERTY( QDateTime EndTime READ EndTime WRITE setEndTime )
149  Q_PROPERTY( QString Title READ Title WRITE setTitle )
150  Q_PROPERTY( QString SubTitle READ SubTitle WRITE setSubTitle )
151  Q_PROPERTY( QString Category READ Category WRITE setCategory )
152  Q_PROPERTY( QString CatType READ CatType WRITE setCatType )
153  Q_PROPERTY( bool Repeat READ Repeat WRITE setRepeat )
154  Q_PROPERTY( int VideoProps READ VideoProps WRITE setVideoProps)
155  Q_PROPERTY( int AudioProps READ AudioProps WRITE setAudioProps)
156  Q_PROPERTY( int SubProps READ SubProps WRITE setSubProps )
157 
158  Q_PROPERTY( QString SeriesId READ SeriesId WRITE setSeriesId DESIGNABLE SerializeDetails )
159  Q_PROPERTY( QString ProgramId READ ProgramId WRITE setProgramId DESIGNABLE SerializeDetails )
160  Q_PROPERTY( double Stars READ Stars WRITE setStars DESIGNABLE SerializeDetails )
161  Q_PROPERTY( QDateTime LastModified READ LastModified WRITE setLastModified DESIGNABLE SerializeDetails )
162  Q_PROPERTY( int ProgramFlags READ ProgramFlags WRITE setProgramFlags DESIGNABLE SerializeDetails )
163  Q_PROPERTY( QDate Airdate READ Airdate WRITE setAirdate DESIGNABLE SerializeDetails )
164  Q_PROPERTY( QString Description READ Description WRITE setDescription DESIGNABLE SerializeDetails )
165  Q_PROPERTY( QString Inetref READ Inetref WRITE setInetref DESIGNABLE SerializeDetails )
166  Q_PROPERTY( int Season READ Season WRITE setSeason DESIGNABLE SerializeDetails )
167  Q_PROPERTY( int Episode READ Episode WRITE setEpisode DESIGNABLE SerializeDetails )
168  Q_PROPERTY( int TotalEpisodes READ TotalEpisodes WRITE setTotalEpisodes DESIGNABLE SerializeDetails )
169 
170  // ----
171  // DEPRECATED
172  // These don't belong here, they are Recording only metadata
173  Q_PROPERTY( qlonglong FileSize READ FileSize WRITE setFileSize DESIGNABLE SerializeDetails )
174  Q_PROPERTY( QString FileName READ FileName WRITE setFileName DESIGNABLE SerializeDetails )
175  Q_PROPERTY( QString HostName READ HostName WRITE setHostName DESIGNABLE SerializeDetails )
176  // ----
177 
178  Q_PROPERTY( QObject* Channel READ Channel DESIGNABLE SerializeChannel )
179  Q_PROPERTY( QObject* Recording READ Recording DESIGNABLE SerializeRecording )
180  Q_PROPERTY( QObject* Artwork READ Artwork DESIGNABLE SerializeArtwork )
181  Q_PROPERTY( QObject* Cast READ Cast DESIGNABLE SerializeCast )
182 
183  PROPERTYIMP ( QDateTime , StartTime )
184  PROPERTYIMP ( QDateTime , EndTime )
185  PROPERTYIMP ( QString , Title )
186  PROPERTYIMP ( QString , SubTitle )
187  PROPERTYIMP ( QString , Category )
188  PROPERTYIMP ( QString , CatType )
189  PROPERTYIMP ( bool , Repeat )
190 
191  PROPERTYIMP ( QString , SeriesId )
192  PROPERTYIMP ( QString , ProgramId )
193  PROPERTYIMP ( double , Stars )
194  PROPERTYIMP ( QDateTime , LastModified )
195  PROPERTYIMP ( int , ProgramFlags )
196  PROPERTYIMP ( int , VideoProps )
197  PROPERTYIMP ( int , AudioProps )
198  PROPERTYIMP ( int , SubProps )
199  PROPERTYIMP ( QDate , Airdate )
200  PROPERTYIMP ( QString , Description )
201  PROPERTYIMP ( QString , Inetref )
202  PROPERTYIMP ( int , Season )
203  PROPERTYIMP ( int , Episode )
204  PROPERTYIMP ( int , TotalEpisodes)
205 
206  // ----
207  // DEPRECATED
208  // These don't belong here, they are Recording only metadata
209  PROPERTYIMP ( qlonglong , FileSize )
210  PROPERTYIMP ( QString , FileName )
211  PROPERTYIMP ( QString , HostName )
212  // ----
213 
216  PROPERTYIMP_PTR( ArtworkInfoList, Artwork )
218 
219  // Used only by Serializer
220  PROPERTYIMP( bool, SerializeDetails )
221  PROPERTYIMP( bool, SerializeChannel )
222  PROPERTYIMP( bool, SerializeRecording )
223  PROPERTYIMP( bool, SerializeArtwork )
224  PROPERTYIMP( bool, SerializeCast );
225 
226  public:
227 
228  static inline void InitializeCustomTypes();
229 
230  Q_INVOKABLE Program(QObject *parent = nullptr)
231  : QObject ( parent ),
232  m_Repeat ( false ),
233  m_Stars ( 0 ),
234  m_ProgramFlags ( 0 ),
235  m_VideoProps ( 0 ),
236  m_AudioProps ( 0 ),
237  m_SubProps ( 0 ),
238  m_Season ( 0 ),
239  m_Episode ( 0 ),
240  m_TotalEpisodes ( 0 ),
241  m_FileSize ( 0 ), // DEPRECATED
242  m_Channel ( nullptr ),
243  m_Recording ( nullptr ),
244  m_Artwork ( nullptr ),
245  m_Cast ( nullptr ),
246  m_SerializeDetails ( true ),
247  m_SerializeChannel ( true ),
248  m_SerializeRecording ( true ),
249  m_SerializeArtwork ( true ),
250  m_SerializeCast ( true )
251  {
252  }
253 
254  void Copy( const Program *src )
255  {
256  m_StartTime = src->m_StartTime;
257  m_EndTime = src->m_EndTime;
258  m_Title = src->m_Title;
259  m_SubTitle = src->m_SubTitle;
260  m_Category = src->m_Category;
261  m_CatType = src->m_CatType;
262  m_Repeat = src->m_Repeat;
263  m_SeriesId = src->m_SeriesId;
264  m_ProgramId = src->m_ProgramId;
265  m_Stars = src->m_Stars;
266  m_LastModified = src->m_LastModified;
267  m_ProgramFlags = src->m_ProgramFlags;
268  m_VideoProps = src->m_VideoProps;
269  m_AudioProps = src->m_AudioProps;
270  m_SubProps = src->m_SubProps;
271  m_Airdate = src->m_Airdate;
272  m_Description = src->m_Description;
273  m_Inetref = src->m_Inetref;
274  m_Season = src->m_Season;
275  m_Episode = src->m_Episode;
276  m_TotalEpisodes = src->m_TotalEpisodes;
277  // DEPRECATED
278  m_FileSize = src->m_FileSize;
279  m_FileName = src->m_FileName;
280  m_HostName = src->m_HostName;
281  // ----
282  m_SerializeDetails = src->m_SerializeDetails;
283  m_SerializeChannel = src->m_SerializeChannel;
284  m_SerializeRecording= src->m_SerializeRecording;
285  m_SerializeArtwork = src->m_SerializeArtwork;
286  m_SerializeCast = src->m_SerializeCast;
287 
288  if ( src->m_Channel != nullptr)
289  Channel()->Copy( src->m_Channel );
290 
291  if ( src->m_Recording != nullptr)
292  Recording()->Copy( src->m_Recording );
293 
294  if ( src->m_Artwork != nullptr)
295  Artwork()->Copy( src->m_Artwork );
296 
297  if (src->m_Cast != nullptr)
298  Cast()->Copy( src->m_Cast );
299  }
300 
301 };
302 
304 {
305  // We must make sure the object added to the QVariantList has
306  // a parent of 'this'
307 
308  Program *pObject = new Program( this );
309  m_Programs.append( QVariant::fromValue<QObject *>( pObject ));
310 
311  return pObject;
312 }
313 
315 {
316  qRegisterMetaType< ChannelInfo* >();
317 
318  if (QMetaType::type( "DTC::Program*" ) == 0)
320 }
321 
323 {
324  qRegisterMetaType< Program* >();
325 
326  if (QMetaType::type( "DTC::ChannelInfo*" ) == 0)
328 
329  if (QMetaType::type( "DTC::RecordingInfo*" ) == 0)
331 
332  if (QMetaType::type( "DTC::ArtworkInfoList*" ) == 0)
334 
335  if (QMetaType::type( "DTC::CastMemberList*" ) == 0)
337 }
338 
339 } // namespace DTC
340 
341 #endif
AudioProps
if AudioProps changes, the audioprop column in program and recordedprogram has to changed accordingly
Definition: programtypes.h:168
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
static bool Recording(const RecordingInfo *p)
Definition: scheduler.cpp:221
void Copy(const Program *src)
unsigned int uint
Definition: compat.h:140
#define PROPERTYIMP(type, name)
static void InitializeCustomTypes()
#define SERVICE_PUBLIC
Definition: serviceexp.h:9
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
static void InitializeCustomTypes()
#define PROPERTYIMP_RO_REF(type, name)
#define Stars
Definition: synaesthesia.h:17
static void InitializeCustomTypes()
VideoProps
if VideoProps changes, the videoprop column in program and recordedprogram has to changed accordingly
Definition: programtypes.h:183
static void InitializeCustomTypes()
static void InitializeCustomTypes()
Definition: recording.h:124
#define PROPERTYIMP_PTR(type, name)
Program * AddNewProgram()
void Copy(const ChannelInfo *src)
enum MythDate::Formats Format