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.2" );
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 )
47  Q_PROPERTY( uint ServiceId READ ServiceId WRITE setServiceId )
48  Q_PROPERTY( uint ATSCMajorChan READ ATSCMajorChan WRITE setATSCMajorChan )
49  Q_PROPERTY( uint ATSCMinorChan READ ATSCMinorChan WRITE setATSCMinorChan )
50  Q_PROPERTY( QString Format READ Format WRITE setFormat )
51  Q_PROPERTY( QString FrequencyId READ FrequencyId WRITE setFrequencyId )
52  Q_PROPERTY( int FineTune READ FineTune WRITE setFineTune )
53  Q_PROPERTY( QString ChanFilters READ ChanFilters WRITE setChanFilters )
54  Q_PROPERTY( int SourceId READ SourceId WRITE setSourceId )
55  Q_PROPERTY( int InputId READ InputId WRITE setInputId )
56  Q_PROPERTY( bool CommFree READ CommFree WRITE setCommFree )
57  Q_PROPERTY( bool UseEIT READ UseEIT WRITE setUseEIT )
58  Q_PROPERTY( bool Visible READ Visible WRITE setVisible )
59  Q_PROPERTY( QString ExtendedVisible READ ExtendedVisible WRITE setExtendedVisible )
60  Q_PROPERTY( QString XMLTVID READ XMLTVID WRITE setXMLTVID )
61  Q_PROPERTY( QString DefaultAuth READ DefaultAuth WRITE setDefaultAuth )
62  Q_PROPERTY( QString ChannelGroups READ ChannelGroups WRITE setChannelGroups )
63  Q_PROPERTY( QString Inputs READ Inputs WRITE setInputs )
64  Q_PROPERTY( uint ServiceType READ ServiceType WRITE setServiceType )
65 
66  Q_PROPERTY( QVariantList Programs READ Programs )
67 
68  PROPERTYIMP ( uint , ChanId )
69  PROPERTYIMP_REF ( QString , ChanNum )
70  PROPERTYIMP_REF ( QString , CallSign )
71  PROPERTYIMP_REF ( QString , IconURL )
72  PROPERTYIMP_REF ( QString , ChannelName )
73  PROPERTYIMP ( uint , MplexId )
74  PROPERTYIMP ( uint , ServiceId )
75  PROPERTYIMP ( uint , ATSCMajorChan )
76  PROPERTYIMP ( uint , ATSCMinorChan )
77  PROPERTYIMP_REF ( QString , Format )
78  PROPERTYIMP_REF ( QString , FrequencyId )
79  PROPERTYIMP ( int , FineTune )
80  PROPERTYIMP_REF ( QString , ChanFilters )
81  PROPERTYIMP ( int , SourceId )
82  PROPERTYIMP ( int , InputId )
83  PROPERTYIMP ( bool , CommFree )
84  PROPERTYIMP ( bool , UseEIT )
85  PROPERTYIMP ( bool , Visible )
86  PROPERTYIMP_REF ( QString , ExtendedVisible )
87  PROPERTYIMP_REF ( QString , XMLTVID )
88  PROPERTYIMP_REF ( QString , DefaultAuth )
89  PROPERTYIMP_REF ( QString , ChannelGroups )
90  PROPERTYIMP_REF ( QString , Inputs )
91  PROPERTYIMP ( uint , ServiceType )
92 
93  PROPERTYIMP_RO_REF( QVariantList, Programs )
94 
95  // Used only by Serializer
96  PROPERTYIMP( bool, SerializeDetails )
97 
98  public:
99 
100  static void InitializeCustomTypes();
101 
102  Q_INVOKABLE explicit ChannelInfo(QObject *parent = nullptr)
103  : QObject ( parent ),
104  m_ChanId ( 0 ),
105  m_MplexId ( 0 ),
106  m_ServiceId ( 0 ),
107  m_ATSCMajorChan ( 0 ),
108  m_ATSCMinorChan ( 0 ),
109  m_FineTune ( 0 ),
110  m_SourceId ( 0 ),
111  m_InputId ( 0 ),
112  m_CommFree ( false ),
113  m_UseEIT ( false ),
114  m_Visible ( true ),
115  m_ServiceType ( 0 ),
116  m_SerializeDetails( true )
117  {
118  }
119 
120  void Copy( const ChannelInfo *src )
121  {
122  m_ChanId = src->m_ChanId ;
123  m_ChanNum = src->m_ChanNum ;
124  m_CallSign = src->m_CallSign ;
125  m_IconURL = src->m_IconURL ;
126  m_ChannelName = src->m_ChannelName ;
127  m_ChanFilters = src->m_ChanFilters ;
128  m_SourceId = src->m_SourceId ;
129  m_InputId = src->m_InputId ;
130  m_CommFree = src->m_CommFree ;
131  m_UseEIT = src->m_UseEIT ;
132  m_Visible = src->m_Visible ;
133  m_ChannelGroups = src->m_ChannelGroups;
134  m_Inputs = src->m_Inputs;
135 
136  CopyListContents< Program >( this, m_Programs, src->m_Programs );
137  }
138 
139  Program *AddNewProgram();
140 
141  private:
142  Q_DISABLE_COPY(ChannelInfo);
143 };
144 
145 class SERVICE_PUBLIC Program : public QObject
146 {
147  Q_OBJECT
148  Q_CLASSINFO( "version" , "1.12" );
149  Q_CLASSINFO( "defaultProp", "Description" );
150  Q_CLASSINFO( "deprecated" , "FileSize,FileName,HostName");
151 
152  Q_PROPERTY( QDateTime StartTime READ StartTime WRITE setStartTime )
153  Q_PROPERTY( QDateTime EndTime READ EndTime WRITE setEndTime )
154  Q_PROPERTY( QString Title READ Title WRITE setTitle )
155  Q_PROPERTY( QString SubTitle READ SubTitle WRITE setSubTitle )
156  Q_PROPERTY( QString Category READ Category WRITE setCategory )
157  Q_PROPERTY( QString CatType READ CatType WRITE setCatType )
158  Q_PROPERTY( bool Repeat READ Repeat WRITE setRepeat )
159  Q_PROPERTY( int VideoProps READ VideoProps WRITE setVideoProps)
160  Q_PROPERTY( QString VideoPropNames READ VideoPropNames WRITE setVideoPropNames )
161  Q_PROPERTY( int AudioProps READ AudioProps WRITE setAudioProps)
162  Q_PROPERTY( QString AudioPropNames READ AudioPropNames WRITE setAudioPropNames )
163  Q_PROPERTY( int SubProps READ SubProps WRITE setSubProps )
164  Q_PROPERTY( QString SubPropNames READ SubPropNames WRITE setSubPropNames )
165 
166  Q_PROPERTY( QString SeriesId READ SeriesId WRITE setSeriesId )
167  Q_PROPERTY( QString ProgramId READ ProgramId WRITE setProgramId )
168  Q_PROPERTY( double Stars READ Stars WRITE setStars )
169  Q_PROPERTY( QDateTime LastModified READ LastModified WRITE setLastModified )
170  Q_PROPERTY( int ProgramFlags READ ProgramFlags WRITE setProgramFlags )
171  Q_PROPERTY( QString ProgramFlagNames READ ProgramFlagNames WRITE setProgramFlagNames )
172  Q_PROPERTY( QDate Airdate READ Airdate WRITE setAirdate )
173  Q_PROPERTY( QString Description READ Description WRITE setDescription )
174  Q_PROPERTY( QString Inetref READ Inetref WRITE setInetref )
175  Q_PROPERTY( int Season READ Season WRITE setSeason )
176  Q_PROPERTY( int Episode READ Episode WRITE setEpisode )
177  Q_PROPERTY( int TotalEpisodes READ TotalEpisodes WRITE setTotalEpisodes )
178 
179  // ----
180  // DEPRECATED
181  // These don't belong here, they are Recording only metadata
182  Q_PROPERTY( qlonglong FileSize READ FileSize WRITE setFileSize )
183  Q_PROPERTY( QString FileName READ FileName WRITE setFileName )
184  Q_PROPERTY( QString HostName READ HostName WRITE setHostName )
185  // ----
186 
187  Q_PROPERTY( QObject* Channel READ Channel )
188  Q_PROPERTY( QObject* Recording READ Recording )
189  Q_PROPERTY( QObject* Artwork READ Artwork )
190  Q_PROPERTY( QObject* Cast READ Cast )
191 
192  PROPERTYIMP_REF( QDateTime , StartTime )
193  PROPERTYIMP_REF( QDateTime , EndTime )
194  PROPERTYIMP_REF( QString , Title )
195  PROPERTYIMP_REF( QString , SubTitle )
196  PROPERTYIMP_REF( QString , Category )
197  PROPERTYIMP_REF( QString , CatType )
198  PROPERTYIMP ( bool , Repeat )
199 
200  PROPERTYIMP_REF( QString , SeriesId )
201  PROPERTYIMP_REF( QString , ProgramId )
202  PROPERTYIMP ( double , Stars )
203  PROPERTYIMP_REF( QDateTime , LastModified )
204  PROPERTYIMP ( int , ProgramFlags )
205  PROPERTYIMP_REF( QString , ProgramFlagNames )
206  PROPERTYIMP ( int , VideoProps )
207  PROPERTYIMP_REF( QString , VideoPropNames )
208  PROPERTYIMP ( int , AudioProps )
209  PROPERTYIMP_REF( QString , AudioPropNames )
210  PROPERTYIMP ( int , SubProps )
211  PROPERTYIMP_REF( QString , SubPropNames )
212  PROPERTYIMP ( QDate , Airdate )
213  PROPERTYIMP_REF( QString , Description )
214  PROPERTYIMP_REF( QString , Inetref )
215  PROPERTYIMP ( int , Season )
216  PROPERTYIMP ( int , Episode )
217  PROPERTYIMP ( int , TotalEpisodes)
218 
219  // ----
220  // DEPRECATED
221  // These don't belong here, they are Recording only metadata
222  PROPERTYIMP ( qlonglong , FileSize )
223  PROPERTYIMP_REF( QString , FileName )
224  PROPERTYIMP_REF( QString , HostName )
225  // ----
226 
229  PROPERTYIMP_PTR( ArtworkInfoList, Artwork )
231 
232  // Used only by Serializer
233  PROPERTYIMP( bool, SerializeDetails )
234  PROPERTYIMP( bool, SerializeChannel )
235  PROPERTYIMP( bool, SerializeRecording )
236  PROPERTYIMP( bool, SerializeArtwork )
237  PROPERTYIMP( bool, SerializeCast );
238 
239  public:
240 
241  static inline void InitializeCustomTypes();
242 
243  Q_INVOKABLE explicit Program(QObject *parent = nullptr)
244  : QObject ( parent ),
245  m_Repeat ( false ),
246  m_Stars ( 0 ),
247  m_ProgramFlags ( 0 ),
248  m_VideoProps ( 0 ),
249  m_AudioProps ( 0 ),
250  m_SubProps ( 0 ),
251  m_Season ( 0 ),
252  m_Episode ( 0 ),
253  m_TotalEpisodes ( 0 ),
254  m_FileSize ( 0 ), // DEPRECATED
255  m_Channel ( nullptr ),
256  m_Recording ( nullptr ),
257  m_Artwork ( nullptr ),
258  m_Cast ( nullptr ),
259  m_SerializeDetails ( true ),
260  m_SerializeChannel ( true ),
261  m_SerializeRecording ( true ),
262  m_SerializeArtwork ( true ),
263  m_SerializeCast ( true )
264  {
265  }
266 
267  void Copy( const Program *src )
268  {
269  m_StartTime = src->m_StartTime;
270  m_EndTime = src->m_EndTime;
271  m_Title = src->m_Title;
272  m_SubTitle = src->m_SubTitle;
273  m_Category = src->m_Category;
274  m_CatType = src->m_CatType;
275  m_Repeat = src->m_Repeat;
276  m_SeriesId = src->m_SeriesId;
277  m_ProgramId = src->m_ProgramId;
278  m_Stars = src->m_Stars;
279  m_LastModified = src->m_LastModified;
280  m_ProgramFlags = src->m_ProgramFlags;
281  m_VideoProps = src->m_VideoProps;
282  m_AudioProps = src->m_AudioProps;
283  m_SubProps = src->m_SubProps;
284  m_Airdate = src->m_Airdate;
285  m_Description = src->m_Description;
286  m_Inetref = src->m_Inetref;
287  m_Season = src->m_Season;
288  m_Episode = src->m_Episode;
289  m_TotalEpisodes = src->m_TotalEpisodes;
290  // DEPRECATED
291  m_FileSize = src->m_FileSize;
292  m_FileName = src->m_FileName;
293  m_HostName = src->m_HostName;
294  // ----
295  m_SerializeDetails = src->m_SerializeDetails;
296  m_SerializeChannel = src->m_SerializeChannel;
297  m_SerializeRecording= src->m_SerializeRecording;
298  m_SerializeArtwork = src->m_SerializeArtwork;
299  m_SerializeCast = src->m_SerializeCast;
300 
301  if ( src->m_Channel != nullptr)
302  Channel()->Copy( src->m_Channel );
303 
304  if ( src->m_Recording != nullptr)
305  Recording()->Copy( src->m_Recording );
306 
307  if ( src->m_Artwork != nullptr)
308  Artwork()->Copy( src->m_Artwork );
309 
310  if (src->m_Cast != nullptr)
311  Cast()->Copy( src->m_Cast );
312  }
313 
314 };
315 
317 {
318  // We must make sure the object added to the QVariantList has
319  // a parent of 'this'
320 
321  auto *pObject = new Program( this );
322  m_Programs.append( QVariant::fromValue<QObject *>( pObject ));
323 
324  return pObject;
325 }
326 
328 {
329  qRegisterMetaType< ChannelInfo* >();
330 
331  if (qMetaTypeId<DTC::Program*>() == 0)
333 }
334 
336 {
337  qRegisterMetaType< Program* >();
338 
339  if (qMetaTypeId<DTC::ChannelInfo*>() == QMetaType::UnknownType)
341 
342  if (qMetaTypeId<DTC::RecordingInfo*>() == QMetaType::UnknownType)
344 
345  if (qMetaTypeId<DTC::ArtworkInfoList*>() == QMetaType::UnknownType)
347 
348  if (qMetaTypeId<DTC::CastMemberList*>() == QMetaType::UnknownType)
350 }
351 
352 } // namespace DTC
353 
354 #endif
DTC::ChannelInfo::AddNewProgram
Program * AddNewProgram()
Definition: programAndChannel.h:316
Channel
Definition: channel.h:33
DTC::ArtworkInfoList::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: artworkInfoList.h:68
recording.h
DTC::ChannelInfo::Copy
void Copy(const ChannelInfo *src)
Definition: programAndChannel.h:120
false
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
DTC::Program
Definition: programAndChannel.h:145
UseEIT
Definition: videosource.cpp:598
DTC::CastMemberList::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: castMemberList.h:59
MythDate::Format
Format
Definition: mythdate.h:15
Stars
#define Stars
Definition: synaesthesia.h:21
SERVICE_PUBLIC
#define SERVICE_PUBLIC
Definition: serviceexp.h:9
Visible
Definition: channelsettings.cpp:391
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
PROPERTYIMP_RO_REF
#define PROPERTYIMP_RO_REF(type, name)
Definition: datacontracthelper.h:114
DTC::CastMemberList
Definition: castMemberList.h:16
datacontracthelper.h
serviceexp.h
DTC::RecordingInfo
Definition: recording.h:25
uint
unsigned int uint
Definition: compat.h:144
PROPERTYIMP_PTR
#define PROPERTYIMP_PTR(type, name)
Definition: datacontracthelper.h:102
DTC::RecordingInfo::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: recording.h:124
Recording
static bool Recording(const RecordingInfo *p)
Definition: scheduler.cpp:215
PROPERTYIMP
#define PROPERTYIMP(type, name)
Definition: datacontracthelper.h:56
DTC
Definition: datacontracthelper.h:123
DTC::ChannelInfo::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: programAndChannel.h:327
DTC::Program::Copy
void Copy(const Program *src)
Definition: programAndChannel.h:267
PROPERTYIMP_REF
#define PROPERTYIMP_REF(type, name)
Definition: datacontracthelper.h:70
DTC::ChannelInfo
Definition: programAndChannel.h:30
DTC::Program::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: programAndChannel.h:335
artworkInfoList.h
DTC::ArtworkInfoList
Definition: artworkInfoList.h:25
castMemberList.h