MythTV  master
programList.h
Go to the documentation of this file.
1 // Program Name: programs.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 LICENSE for details
8 //
10 
11 #ifndef PROGRAMS_H_
12 #define PROGRAMS_H_
13 
14 #include <QDateTime>
15 #include <QString>
16 #include <QVariantList>
17 
20 
21 #include "programAndChannel.h"
22 
23 namespace DTC
24 {
25 
26 class SERVICE_PUBLIC ProgramList : public QObject
27 {
28  Q_OBJECT
29  Q_CLASSINFO( "version", "1.0" );
30 
31  // Q_CLASSINFO Used to augment Metadata for properties.
32  // See datacontracthelper.h for details
33 
34  Q_CLASSINFO( "Programs", "type=DTC::Program");
35  Q_CLASSINFO( "AsOf" , "transient=true" );
36 
37  Q_PROPERTY( int StartIndex READ StartIndex WRITE setStartIndex )
38  Q_PROPERTY( int Count READ Count WRITE setCount )
39  Q_PROPERTY( int TotalAvailable READ TotalAvailable WRITE setTotalAvailable )
40  Q_PROPERTY( QDateTime AsOf READ AsOf WRITE setAsOf )
41  Q_PROPERTY( QString Version READ Version WRITE setVersion )
42  Q_PROPERTY( QString ProtoVer READ ProtoVer WRITE setProtoVer )
43 
44  Q_PROPERTY( QVariantList Programs READ Programs )
45 
46  PROPERTYIMP ( int , StartIndex )
47  PROPERTYIMP ( int , Count )
48  PROPERTYIMP ( int , TotalAvailable )
49  PROPERTYIMP_REF ( QDateTime , AsOf )
50  PROPERTYIMP_REF ( QString , Version )
51  PROPERTYIMP_REF ( QString , ProtoVer )
52 
53  PROPERTYIMP_RO_REF( QVariantList, Programs );
54 
55  public:
56 
57  static inline void InitializeCustomTypes();
58 
59  Q_INVOKABLE explicit ProgramList(QObject *parent = nullptr)
60  : QObject ( parent ),
61  m_StartIndex ( 0 ),
62  m_Count ( 0 ),
63  m_TotalAvailable( 0 )
64  {
65  }
66 
67  void Copy( const ProgramList *src )
68  {
69  m_StartIndex = src->m_StartIndex ;
70  m_Count = src->m_Count ;
71  m_TotalAvailable= src->m_TotalAvailable ;
72  m_AsOf = src->m_AsOf ;
73  m_Version = src->m_Version ;
74  m_ProtoVer = src->m_ProtoVer ;
75 
76  CopyListContents< Program >( this, m_Programs, src->m_Programs );
77  }
78 
80  {
81  // We must make sure the object added to the QVariantList has
82  // a parent of 'this'
83 
84  auto *pObject = new Program( this );
85  m_Programs.append( QVariant::fromValue<QObject *>( pObject ));
86 
87  return pObject;
88  }
89 
90  private:
91  Q_DISABLE_COPY(ProgramList);
92 };
93 
95 {
96  qRegisterMetaType< ProgramList* >();
97 
99 }
100 
101 } // namespace DTC
102 
103 #endif
DTC::Program
Definition: programAndChannel.h:145
DTC::ProgramList::Copy
void Copy(const ProgramList *src)
Definition: programList.h:67
DTC::ProgramList::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: programList.h:94
SERVICE_PUBLIC
#define SERVICE_PUBLIC
Definition: serviceexp.h:9
PROPERTYIMP_RO_REF
#define PROPERTYIMP_RO_REF(type, name)
Definition: datacontracthelper.h:114
datacontracthelper.h
DTC::ProgramList::AddNewProgram
Program * AddNewProgram()
Definition: programList.h:79
serviceexp.h
programAndChannel.h
PROPERTYIMP
#define PROPERTYIMP(type, name)
Definition: datacontracthelper.h:56
DTC
Definition: datacontracthelper.h:123
PROPERTYIMP_REF
#define PROPERTYIMP_REF(type, name)
Definition: datacontracthelper.h:70
DTC::ProgramList
Definition: programList.h:26
DTC::Program::InitializeCustomTypes
static void InitializeCustomTypes()
Definition: programAndChannel.h:335