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