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