MythTV  master
recordingtypes.cpp
Go to the documentation of this file.
1 #include <QObject>
2 
3 #include "recordingtypes.h"
4 
8 {
9  switch (rectype)
10  {
11  case kNotRecording: return 0; break;
12  case kDontRecord: return 1; break;
13  case kOverrideRecord: return 2; break;
14  case kSingleRecord: return 3; break;
15  case kOneRecord: return 4; break;
16  case kWeeklyRecord: return 6; break;
17  case kDailyRecord: return 8; break;
18  case kAllRecord: return 9; break;
19  case kTemplateRecord: return 0; break;
20  default: return 11;
21  }
22 }
23 
25 QString toString(RecordingType rectype)
26 {
27  switch (rectype)
28  {
29  case kSingleRecord:
30  return QObject::tr("Single Record");
31  case kAllRecord:
32  return QObject::tr("Record All");
33  case kOneRecord:
34  return QObject::tr("Record One");
35  case kDailyRecord:
36  return QObject::tr("Record Daily");
37  case kWeeklyRecord:
38  return QObject::tr("Record Weekly");
39  case kOverrideRecord:
40  case kDontRecord:
41  return QObject::tr("Override Recording");
42  case kTemplateRecord:
43  return QObject::tr("Recording Template");
44  default:
45  return QObject::tr("Not Recording");
46  }
47 }
48 
50 QString toDescription(RecordingType rectype)
51 {
52  switch (rectype)
53  {
54  case kSingleRecord:
55  return QObject::tr("Record only this showing");
56  case kAllRecord:
57  return QObject::tr("Record all showings");
58  case kOneRecord:
59  return QObject::tr("Record only one showing");
60  case kDailyRecord:
61  return QObject::tr("Record one showing every day");
62  case kWeeklyRecord:
63  return QObject::tr("Record one showing every week");
64  case kOverrideRecord:
65  return QObject::tr("Record this showing with override options");
66  case kDontRecord:
67  return QObject::tr("Do not record this showing");
68  case kTemplateRecord:
69  return QObject::tr("Modify this recording rule template");
70  default:
71  return QObject::tr("Do not record this program");
72  }
73 }
74 
76 QString toRawString(RecordingType rectype)
77 {
78  switch (rectype)
79  {
80  case kSingleRecord:
81  return QString("Single Record");
82  case kAllRecord:
83  return QString("Record All");
84  case kOneRecord:
85  return QString("Record One");
86  case kDailyRecord:
87  return QString("Record Daily");
88  case kWeeklyRecord:
89  return QString("Record Weekly");
90  case kOverrideRecord:
91  return QString("Override Recording");
92  case kDontRecord:
93  return QString("Do not Record");
94  case kTemplateRecord:
95  return QString("Recording Template");
96  default:
97  return QString("Not Recording");
98  }
99 }
100 
102 {
103  if (type.toLower() == "not recording" || type.toLower() == "not")
104  return kNotRecording;
105  if (type.toLower() == "single record" || type.toLower() == "single")
106  return kSingleRecord;
107  if (type.toLower() == "record all" || type.toLower() == "all")
108  return kAllRecord;
109  if (type.toLower() == "record one" || type.toLower() == "one" ||
110  type.toLower() == "find one" || type.toLower() == "findone")
111  return kOneRecord;
112  if (type.toLower() == "record daily" || type.toLower() == "daily" ||
113  type.toLower() == "find daily" || type.toLower() == "finddaily")
114  return kDailyRecord;
115  if (type.toLower() == "record weekly" || type.toLower() == "weekly" ||
116  type.toLower() == "find weekly" || type.toLower() == "findweekly")
117  return kWeeklyRecord;
118  if (type.toLower() == "recording template" || type.toLower() == "template")
119  return kTemplateRecord;
120  if (type.toLower() == "override recording" || type.toLower() == "override")
121  return kOverrideRecord;
122  return kDontRecord;
123 }
124 
126 QChar toQChar(RecordingType rectype)
127 {
128  QString ret;
129  switch (rectype)
130  {
131  case kSingleRecord:
132  ret = QObject::tr("S", "RecTypeChar kSingleRecord"); break;
133  case kAllRecord:
134  ret = QObject::tr("A", "RecTypeChar kAllRecord"); break;
135  case kOneRecord:
136  ret = QObject::tr("1", "RecTypeChar kOneRecord"); break;
137  case kDailyRecord:
138  ret = QObject::tr("D", "RecTypeChar kDailyRecord"); break;
139  case kWeeklyRecord:
140  ret = QObject::tr("W", "RecTypeChar kWeeklyRecord"); break;
141  case kOverrideRecord:
142  case kDontRecord:
143  ret = QObject::tr("O", "RecTypeChar kOverrideRecord/kDontRecord");
144  break;
145  case kTemplateRecord:
146  ret = QObject::tr("T", "RecTypeChar kTemplateRecord"); break;
147  case kNotRecording:
148  default:
149  ret = " ";
150  }
151  return (ret.isEmpty()) ? QChar(' ') : ret[0];
152 }
153 
154 QString toString(RecordingDupInType recdupin)
155 {
156  switch (recdupin)
157  {
158  case kDupsInRecorded:
159  return QObject::tr("Current Recordings");
160  case kDupsInOldRecorded:
161  return QObject::tr("Previous Recordings");
162  case kDupsInAll:
163  return QObject::tr("All Recordings");
164  // TODO: This is wrong, kDupsNewEpi is returned in conjunction with
165  // one of the other values.
166  case kDupsNewEpi:
167  return QObject::tr("New Episodes Only");
168  default:
169  return QString();
170  }
171 }
172 
174 {
175  switch (recdupin)
176  {
177  case kDupsInRecorded:
178  return QObject::tr("Look for duplicates in current recordings only");
179  case kDupsInOldRecorded:
180  return QObject::tr("Look for duplicates in previous recordings only");
181  case kDupsInAll:
182  return QObject::tr("Look for duplicates in current and previous "
183  "recordings");
184  // TODO: This is wrong, kDupsNewEpi is returned in conjunction with
185  // one of the other values.
186  case kDupsNewEpi:
187  return QObject::tr("Record new episodes only");
188  default:
189  return QString();
190  }
191 }
192 
194 {
195  // Remove "New Episodes" flag
196  recdupin = (RecordingDupInType) (recdupin & (-1 - kDupsNewEpi));
197  switch (recdupin)
198  {
199  case kDupsInRecorded:
200  return QString("Current Recordings");
201  case kDupsInOldRecorded:
202  return QString("Previous Recordings");
203  case kDupsInAll:
204  return QString("All Recordings");
205  default:
206  return QString("Unknown");
207  }
208 }
209 
210 // New Episodes Only is a flag added to DupIn
212 {
213  return (recdupin & kDupsNewEpi);
214 }
215 
217 {
218  if (type.toLower() == "current recordings" || type.toLower() == "current")
219  return kDupsInRecorded;
220  if (type.toLower() == "previous recordings" || type.toLower() == "previous")
221  return kDupsInOldRecorded;
222  if (type.toLower() == "all recordings" || type.toLower() == "all")
223  return kDupsInAll;
224  if (type.toLower() == "new episodes only" || type.toLower() == "new")
225  return static_cast<RecordingDupInType> (kDupsInAll | kDupsNewEpi);
226  return kDupsInAll;
227 }
228 
229 RecordingDupInType dupInFromStringAndBool(const QString& type, bool newEpisodesOnly) {
231  if (newEpisodesOnly)
232  result = static_cast<RecordingDupInType> (result | kDupsNewEpi);
233  return result;
234 }
235 
237 {
238  switch (duptype)
239  {
240  case kDupCheckNone:
241  return QObject::tr("None");
242  case kDupCheckSub:
243  return QObject::tr("Subtitle");
244  case kDupCheckDesc:
245  return QObject::tr("Description");
246  case kDupCheckSubDesc:
247  return QObject::tr("Subtitle and Description");
249  return QObject::tr("Subtitle then Description");
250  default:
251  return QString();
252  }
253 }
254 
256 {
257  switch (duptype)
258  {
259  case kDupCheckNone:
260  return QObject::tr("Don't match duplicates");
261  case kDupCheckSub:
262  return QObject::tr("Match duplicates using subtitle");
263  case kDupCheckDesc:
264  return QObject::tr("Match duplicates using description");
265  case kDupCheckSubDesc:
266  return QObject::tr("Match duplicates using subtitle & description");
268  return QObject::tr("Match duplicates using subtitle then description");
269  default:
270  return QString();
271  }
272 }
273 
275 {
276  switch (duptype)
277  {
278  case kDupCheckNone:
279  return QString("None");
280  case kDupCheckSub:
281  return QString("Subtitle");
282  case kDupCheckDesc:
283  return QString("Description");
284  case kDupCheckSubDesc:
285  return QString("Subtitle and Description");
287  return QString("Subtitle then Description");
288  default:
289  return QString("Unknown");
290  }
291 }
292 
294 {
295  if (type.toLower() == "none")
296  return kDupCheckNone;
297  if (type.toLower() == "subtitle")
298  return kDupCheckSub;
299  if (type.toLower() == "description")
300  return kDupCheckDesc;
301  if (type.toLower() == "subtitle and description" || type.toLower() == "subtitleanddescription")
302  return kDupCheckSubDesc;
303  if (type.toLower() == "subtitle then description" || type.toLower() == "subtitlethendescription")
304  return kDupCheckSubThenDesc;
305  return kDupCheckSubDesc;
306 }
307 
308 QString toRawString(RecSearchType searchtype)
309 {
310  switch (searchtype)
311  {
312  case kNoSearch:
313  return QString("None");
314  case kPowerSearch:
315  return QString("Power Search");
316  case kTitleSearch:
317  return QString("Title Search");
318  case kKeywordSearch:
319  return QString("Keyword Search");
320  case kPeopleSearch:
321  return QString("People Search");
322  case kManualSearch:
323  return QString("Manual Search");
324  default:
325  return QString("Unknown");
326  }
327 }
328 
330 {
331  if (type.toLower() == "none")
332  return kNoSearch;
333  if (type.toLower() == "power search" || type.toLower() == "power")
334  return kPowerSearch;
335  if (type.toLower() == "title search" || type.toLower() == "title")
336  return kTitleSearch;
337  if (type.toLower() == "keyword search" || type.toLower() == "keyword")
338  return kKeywordSearch;
339  if (type.toLower() == "people search" || type.toLower() == "people")
340  return kPeopleSearch;
341  if (type.toLower() == "manual search" || type.toLower() == "manual")
342  return kManualSearch;
343  return kNoSearch;
344 }
kDupCheckDesc
@ kDupCheckDesc
Definition: recordingtypes.h:62
toRawString
QString toRawString(RecordingType rectype)
Converts "rectype" into an untranslated string.
Definition: recordingtypes.cpp:76
searchTypeFromString
RecSearchType searchTypeFromString(const QString &type)
Definition: recordingtypes.cpp:329
kDailyRecord
@ kDailyRecord
Definition: recordingtypes.h:23
kDupCheckSubThenDesc
@ kDupCheckSubThenDesc
Definition: recordingtypes.h:64
dupInFromString
RecordingDupInType dupInFromString(const QString &type)
Definition: recordingtypes.cpp:216
newEpifromDupIn
bool newEpifromDupIn(RecordingDupInType recdupin)
Definition: recordingtypes.cpp:211
kDupCheckSub
@ kDupCheckSub
Definition: recordingtypes.h:61
RecordingDupMethodType
RecordingDupMethodType
Definition: recordingtypes.h:58
kKeywordSearch
@ kKeywordSearch
Definition: recordingtypes.h:76
recordingtypes.h
kDupsInAll
@ kDupsInAll
Definition: recordingtypes.h:47
kDupsInRecorded
@ kDupsInRecorded
Definition: recordingtypes.h:45
RecordingDupInType
RecordingDupInType
Definition: recordingtypes.h:43
kPowerSearch
@ kPowerSearch
Definition: recordingtypes.h:74
kTemplateRecord
@ kTemplateRecord
Definition: recordingtypes.h:32
dupMethodFromString
RecordingDupMethodType dupMethodFromString(const QString &type)
Definition: recordingtypes.cpp:293
kDupsInOldRecorded
@ kDupsInOldRecorded
Definition: recordingtypes.h:46
recTypeFromString
RecordingType recTypeFromString(const QString &type)
Definition: recordingtypes.cpp:101
RecSearchType
RecSearchType
Definition: recordingtypes.h:72
dupInFromStringAndBool
RecordingDupInType dupInFromStringAndBool(const QString &type, bool newEpisodesOnly)
Definition: recordingtypes.cpp:229
kNoSearch
@ kNoSearch
Definition: recordingtypes.h:73
kManualSearch
@ kManualSearch
Definition: recordingtypes.h:78
toDescription
QString toDescription(RecordingType rectype)
Converts "rectype" into a human readable description.
Definition: recordingtypes.cpp:50
kTitleSearch
@ kTitleSearch
Definition: recordingtypes.h:75
kOneRecord
@ kOneRecord
Definition: recordingtypes.h:27
kWeeklyRecord
@ kWeeklyRecord
Definition: recordingtypes.h:26
kOverrideRecord
@ kOverrideRecord
Definition: recordingtypes.h:28
kNotRecording
@ kNotRecording
Definition: recordingtypes.h:21
kDupCheckNone
@ kDupCheckNone
Definition: recordingtypes.h:60
kSingleRecord
@ kSingleRecord
Definition: recordingtypes.h:22
toQChar
QChar toQChar(RecordingType rectype)
Converts "rectype" into a human readable character.
Definition: recordingtypes.cpp:126
RecTypePrecedence
int RecTypePrecedence(RecordingType rectype)
Converts a RecordingType to a simple integer so it's specificity can be compared to another.
Definition: recordingtypes.cpp:7
kAllRecord
@ kAllRecord
Definition: recordingtypes.h:25
kDupsNewEpi
@ kDupsNewEpi
Definition: recordingtypes.h:48
toString
QString toString(RecordingType rectype)
Converts "rectype" into a human readable string.
Definition: recordingtypes.cpp:25
RecordingType
RecordingType
Definition: recordingtypes.h:20
kDupCheckSubDesc
@ kDupCheckSubDesc
Definition: recordingtypes.h:63
kPeopleSearch
@ kPeopleSearch
Definition: recordingtypes.h:77
kDontRecord
@ kDontRecord
Definition: recordingtypes.h:29