MythTV master
v2grabber.h
Go to the documentation of this file.
1
2// Program Name: v2grabber.h
3// Created : Sep 22, 2022
4//
5// Copyright (c) 2022 Peter Bennett <pbennett@mythtv.org>
6//
7// Licensed under the GPL v2 or later, see COPYING for details
8//
10
11#ifndef V2GRABBER_H_
12#define V2GRABBER_H_
13
14#include <QString>
15
17
19
20class V2Grabber : public QObject
21{
22 Q_OBJECT
23 Q_CLASSINFO( "Version" , "1.0" );
24
25 SERVICE_PROPERTY2( QString , Program )
26 SERVICE_PROPERTY2( QString , DisplayName )
27
28 public:
29
30 Q_INVOKABLE V2Grabber(QObject *parent = nullptr)
31 : QObject( parent )
32 {
33 }
34
35 void Copy( const V2Grabber *src )
36 {
37 m_Program = src->m_Program;
38 m_DisplayName = src->m_DisplayName;
39 }
40
41 private:
43};
44
46
47
48class V2GrabberList : public QObject
49{
50 Q_OBJECT
51 Q_CLASSINFO( "Version", "1.0" );
52 Q_CLASSINFO( "Grabbers", "type=V2Grabber");
53
54 SERVICE_PROPERTY2( QVariantList, Grabbers );
55
56 public:
57
58 Q_INVOKABLE V2GrabberList(QObject *parent = nullptr)
59 : QObject( parent )
60 {
61 }
62
63 // Copy not needed
64 // void Copy( const V2GrabberList *src )
65 // {
66 // CopyListContents< V2Grabber >( this, m_Grabbers, src->m_Grabbers );
67 // }
68
70 {
71 // We must make sure the object added to the QVariantList has
72 // a parent of 'this'
73
74 auto *pObject = new V2Grabber( this );
75 m_Grabbers.append( QVariant::fromValue<QObject *>( pObject ));
76
77 return pObject;
78 }
79
80 bool containsProgram(QString &program)
81 {
82 auto matchProgram = [&program](const QVariant& entry)
83 {
84 auto *grabber = entry.value<V2Grabber*>();
85 return (grabber->GetProgram() == program);
86 };
87 return std::any_of(m_Grabbers.cbegin(), m_Grabbers.cend(), matchProgram);
88 }
89
90 private:
92};
93
95
96
97#endif
V2Grabber * AddNewGrabber()
Definition: v2grabber.h:69
Q_INVOKABLE V2GrabberList(QObject *parent=nullptr)
Definition: v2grabber.h:58
Q_DISABLE_COPY(V2GrabberList)
SERVICE_PROPERTY2(QVariantList, Grabbers)
Q_CLASSINFO("Grabbers", "type=V2Grabber")
Q_CLASSINFO("Version", "1.0")
bool containsProgram(QString &program)
Definition: v2grabber.h:80
Q_DISABLE_COPY(V2Grabber)
Q_INVOKABLE V2Grabber(QObject *parent=nullptr)
Definition: v2grabber.h:30
void Copy(const V2Grabber *src)
Definition: v2grabber.h:35
Q_CLASSINFO("Version", "1.0")
Q_DECLARE_METATYPE(std::chrono::seconds)
#define SERVICE_PROPERTY2(Type, Name)