MythTV  master
recordingrule.h
Go to the documentation of this file.
1 #ifndef RECORDING_RULE_H
2 #define RECORDING_RULE_H
3 
4 // QT
5 #include <QDateTime>
6 #include <QDate>
7 #include <QTime>
8 #include <QStringList>
9 #include <QCoreApplication>
10 
11 // libmythbase
12 #include "mythtvexp.h"
13 
14 // libmyth
15 #include "programinfo.h"
16 
17 // libmythtv
18 #include "programtypes.h"
19 #include "recordinginfo.h"
20 #include "recordingtypes.h"
21 
33 {
35 
36  public:
37  static const int kNumFilters = 16;
38 
39  RecordingRule();
40  ~RecordingRule() = default;
41 
42  void ensureSortFields(void);
43  bool Load(bool asTemplate = false);
44  bool LoadByProgram(const ProgramInfo* proginfo);
45  bool LoadBySearch(RecSearchType lsearch, const QString& textname, const QString& forwhat,
46  QString joininfo = "", ProgramInfo *pginfo = nullptr);
47  bool LoadTemplate(const QString& category, const QString& categoryType = "Default");
48 
49  bool ModifyPowerSearchByID(int rid, const QString& textname, QString forwhat,
50  QString joininfo = "");
51  bool MakeOverride(void);
52  bool MakeTemplate(QString category);
53 
54  bool Save(bool sendSig = true);
55  bool Delete(bool sendSig = true);
56 
57  bool IsLoaded() const { return m_loaded; }
58  void UseTempTable(bool usetemp, const QString& table = "record_tmp");
59  static unsigned GetDefaultFilter(void);
60 
61  void ToMap(InfoMap &infoMap) const;
62 
64  { return m_autoExpire ? kNormalAutoExpire : kDisableAutoExpire; }
65 
66  bool IsValid(QString &msg) const;
67 
68  static QString SearchTypeToString(RecSearchType searchType);
69  static QStringList GetTemplateNames(void);
70 
72  int m_recordID {-1};
73  int m_parentRecID {0};
74 
76  bool m_isInactive {false};
77 
78  // Recording metadata
79  QString m_title;
80  QString m_sortTitle;
81  QString m_subtitle;
82  QString m_sortSubtitle;
83  QString m_description;
84  QString m_category;
85 
86  QString m_seriesid;
87  QString m_programid;
88  // String could be null when we trying to insert into DB
89  QString m_inetref;
90 
91  QDate m_startdate;
92  QDate m_enddate;
93  QTime m_starttime;
94  QTime m_endtime;
95 
96  uint m_season {0};
97  uint m_episode {0};
98 
99  // Associated data for rule types
100  int m_channelid {0};
101  QString m_station;
102  QTime m_findtime;
104  int m_findid;
106  int m_findday {0};
107 
108  // Scheduling Options
109  int m_recPriority {0};
110  int m_prefInput {0};
111  int m_startOffset {0};
112  int m_endOffset {0};
114  RecSearchType m_searchType {kNoSearch};
117  unsigned m_filter {0};
118 
119  // Storage Options
120  // TODO: These should all be converted to integer IDs instead
121  QString m_recProfile {tr("Default")};
122  QString m_storageGroup {tr("Default")};
123  QString m_playGroup {tr("Default")};
125 
126  int m_maxEpisodes {0};
127  bool m_autoExpire {false};
128  bool m_maxNewest {false};
129 
130  // Post Processing Options
132  bool m_autoCommFlag {true};
133  bool m_autoTranscode {false};
134  bool m_autoUserJob1 {false};
135  bool m_autoUserJob2 {false};
136  bool m_autoUserJob3 {false};
137  bool m_autoUserJob4 {false};
138  bool m_autoMetadataLookup {true};
139 
140  // Statistic fields - Used to generate statistics about particular rules
141  // and influence watch list weighting
142  int m_averageDelay {100};
143  QDateTime m_nextRecording;
144  QDateTime m_lastRecorded;
145  QDateTime m_lastDeleted;
146 
147  // Temporary table related - Used for schedule previews
148  QString m_recordTable {"record"};
149  int m_tempID {0};
150 
151  // Is this an override rule? Purely for the benefit of the UI, we display
152  // different options for override rules
153  bool m_isOverride {false};
154 
155  // Is this a template rule? Purely for the benefit of the UI, we
156  // display all options for template rules
157  bool m_isTemplate {false};
158 
159  private:
160  // Populate variables from a ProgramInfo object
161  void AssignProgramInfo();
162 
163  // Name of template used for new rule.
164  QString m_template;
165 
166  // Pointer for ProgramInfo, exists only if we loaded from ProgramInfo in
167  // the first place
168  const ProgramInfo *m_progInfo {nullptr};
169 
170  // Indicate that a rule has been loaded, for new rules this is still true
171  // after any of the Load* methods is called
172  bool m_loaded {false};
173 };
174 
176 
177 #endif
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
RecordingRule::m_enddate
QDate m_enddate
Definition: recordingrule.h:92
RecordingInfo::kDefaultRecGroup
@ kDefaultRecGroup
Definition: recordinginfo.h:190
RecordingRule::m_seriesid
QString m_seriesid
Definition: recordingrule.h:86
RecordingRule::m_description
QString m_description
Definition: recordingrule.h:83
RecordingRule::m_template
QString m_template
Definition: recordingrule.h:164
RecordingRule::m_inetref
QString m_inetref
Definition: recordingrule.h:89
RecordingRule::m_category
QString m_category
Definition: recordingrule.h:84
RecordingRule::m_nextRecording
QDateTime m_nextRecording
Definition: recordingrule.h:143
RecordingRule::m_starttime
QTime m_starttime
Definition: recordingrule.h:93
kDupCheckSubThenDesc
@ kDupCheckSubThenDesc
Definition: recordingtypes.h:62
mythtvexp.h
RecordingRule::m_title
QString m_title
Definition: recordingrule.h:79
RecordingRule::m_sortSubtitle
QString m_sortSubtitle
Definition: recordingrule.h:82
RecordingRule::m_lastDeleted
QDateTime m_lastDeleted
Definition: recordingrule.h:145
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:33
RecordingDupMethodType
RecordingDupMethodType
Definition: recordingtypes.h:56
category
QString category
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1419
RecordingRule::IsLoaded
bool IsLoaded() const
Definition: recordingrule.h:57
recordingtypes.h
kDupsInAll
@ kDupsInAll
Definition: recordingtypes.h:47
programtypes.h
RecordingRule::m_findid
int m_findid
Definition: recordingrule.h:104
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
RecordingRule::~RecordingRule
~RecordingRule()=default
kDisableAutoExpire
@ kDisableAutoExpire
Definition: programtypes.h:236
RecordingDupInType
RecordingDupInType
Definition: recordingtypes.h:43
programinfo.h
kNormalAutoExpire
@ kNormalAutoExpire
Definition: programtypes.h:237
RecordingRule::m_lastRecorded
QDateTime m_lastRecorded
Definition: recordingrule.h:144
RecSearchType
RecSearchType
Definition: recordingtypes.h:70
RecordingRule::m_subtitle
QString m_subtitle
Definition: recordingrule.h:81
RecordingRule::GetAutoExpire
AutoExpireType GetAutoExpire(void) const
Definition: recordingrule.h:63
kNoSearch
@ kNoSearch
Definition: recordingtypes.h:71
uint
unsigned int uint
Definition: compat.h:140
RecordingRule::m_programid
QString m_programid
Definition: recordingrule.h:87
RecordingRule::m_sortTitle
QString m_sortTitle
Definition: recordingrule.h:80
RecordingRule::m_endtime
QTime m_endtime
Definition: recordingrule.h:94
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
recordinginfo.h
RecordingRule::m_transcoder
int m_transcoder
Definition: recordingrule.h:131
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:68
kNotRecording
@ kNotRecording
Definition: recordingtypes.h:21
AutoExpireType
AutoExpireType
Definition: programtypes.h:235
RecordingRule::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(RecordingRule)
RecordingRule::m_station
QString m_station
Definition: recordingrule.h:101
RecordingRule::m_startdate
QDate m_startdate
Definition: recordingrule.h:91
RecordingType
Definition: recordingprofile.cpp:1225