MythTV  master
enum.h
Go to the documentation of this file.
1 // Program Name: enum.h
3 // Created : July 25, 2014
4 //
5 // Copyright (c) 2014 David Blain <dblain@mythtv.org>
6 //
7 // Licensed under the GPL v2 or later, see COPYING for details
8 //
10 
11 #ifndef ENUMLIST_H_
12 #define ENUMLIST_H_
13 
14 #include <QVariantList>
15 
16 #include "serviceexp.h"
17 #include "datacontracthelper.h"
18 
19 #include "enumItem.h"
20 
21 namespace DTC
22 {
23 
24 class SERVICE_PUBLIC Enum : public QObject
25 {
26  Q_OBJECT
27  Q_CLASSINFO( "version", "1.0" );
28 
29  // Q_CLASSINFO Used to augment Metadata for properties.
30  // See datacontracthelper.h for details
31 
32  Q_CLASSINFO( "EnumItems", "type=DTC::Enum");
33 
34  Q_PROPERTY( QString Type READ Type WRITE setType )
35  Q_PROPERTY( QVariantList EnumItems READ EnumItems DESIGNABLE true )
36 
37 
38  PROPERTYIMP ( QString , Type )
39  PROPERTYIMP_RO_REF( QVariantList, EnumItems )
40 
41  public:
42 
43  static inline void InitializeCustomTypes();
44 
45  Q_INVOKABLE explicit Enum(QObject *parent = nullptr)
46  : QObject( parent )
47  {
48  }
49 
50  void Copy( const Enum *src )
51  {
52  m_Type = src->m_Type;
53 
54  CopyListContents< EnumItem >( this, m_EnumItems, src->m_EnumItems );
55  }
56 
58  {
59  // We must make sure the object added to the QVariantList has
60  // a parent of 'this'
61 
62  EnumItem *pObject = new EnumItem( this );
63  m_EnumItems.append( QVariant::fromValue<QObject *>( pObject ));
64 
65  return pObject;
66  }
67 
68  private:
69  Q_DISABLE_COPY(Enum);
70 };
71 
73 {
74  qRegisterMetaType< Enum* >();
75 
77 }
78 
79 } // namespace DTC
80 
81 #endif
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
EnumItem * AddNewEnum()
Definition: enum.h:57
#define PROPERTYIMP(type, name)
static void InitializeCustomTypes()
Definition: enumItem.h:54
static void InitializeCustomTypes()
Definition: enum.h:72
#define SERVICE_PUBLIC
Definition: serviceexp.h:9
#define PROPERTYIMP_RO_REF(type, name)
Definition: enum.h:24
void Copy(const Enum *src)
Definition: enum.h:50