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 {
34  Q_DECLARE_TR_FUNCTIONS(RecordingRule);
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);
67 
68  static QString SearchTypeToString(const 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  uint m_season {0};
85  uint m_episode {0};
86  QString m_category;
87 
88  QTime m_starttime;
89  QDate m_startdate;
90  QTime m_endtime;
91  QDate m_enddate;
92 
93  QString m_seriesid;
94  QString m_programid;
95  // String could be null when we trying to insert into DB
96  QString m_inetref;
97 
98  // Associated data for rule types
99  int m_channelid {0};
100  QString m_station;
101  int m_findday {0};
104  QTime m_findtime;
105  int m_findid;
106 
107  // Scheduling Options
109  RecSearchType m_searchType {kNoSearch};
110  int m_recPriority {0};
111  int m_prefInput {0};
112  int m_startOffset {0};
113  int m_endOffset {0};
116  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")};
122  QString m_storageGroup {tr("Default")};
123  QString m_playGroup {tr("Default")};
124 
125  bool m_autoExpire {false};
126  int m_maxEpisodes {0};
127  bool m_maxNewest {false};
128 
129  // Post Processing Options
130  bool m_autoCommFlag {true};
131  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  QDateTime m_nextRecording;
142  QDateTime m_lastRecorded;
143  QDateTime m_lastDeleted;
144  int m_averageDelay {100};
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
QString m_subtitle
Definition: recordingrule.h:81
QTime m_findtime
Time for timeslot rules.
RecordingDupInType
QString m_programid
Definition: recordingrule.h:94
AutoExpireType
Definition: programtypes.h:230
QString m_sortTitle
Definition: recordingrule.h:80
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
QString m_station
Q_DECLARE_METATYPE(GrabberScript *)
QDateTime m_nextRecording
RecordingDupMethodType
Holds information on recordings and videos.
Definition: programinfo.h:66
QDateTime m_lastRecorded
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QString m_description
Definition: recordingrule.h:83
QString m_template
RecSearchType
unsigned int uint
Definition: compat.h:140
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
QString m_seriesid
Definition: recordingrule.h:93
QString m_inetref
Definition: recordingrule.h:96
bool IsLoaded() const
Definition: recordingrule.h:57
QString m_title
Definition: recordingrule.h:79
QDateTime m_lastDeleted
QString m_sortSubtitle
Definition: recordingrule.h:82
QString m_category
Definition: recordingrule.h:86
AutoExpireType GetAutoExpire(void) const
Definition: recordingrule.h:63