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