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