MythTV  master
programrecpriority.cpp
Go to the documentation of this file.
1 
2 // own header
3 #include "programrecpriority.h"
4 
5 // C/C++ headers
6 #include <vector> // For std::vector
7 using namespace std;
8 
9 // QT headers
10 #include <QDateTime>
11 #include <QRegExp>
12 
13 // libmythtv headers
14 #include "recordingrule.h"
15 #include "scheduledrecording.h"
16 
17 // libmythbase
18 #include "mythdb.h"
19 #include "mythlogging.h"
20 #include "mythmiscutil.h"
21 #include "remoteutil.h"
22 
23 // libmythui
24 #include "mythuihelper.h"
25 #include "mythuibuttonlist.h"
26 #include "mythuitext.h"
27 #include "mythuistatetype.h"
28 #include "mythdialogbox.h"
29 
30 // mythfrontend
31 #include "proglist.h"
32 #include "scheduleeditor.h"
33 
35  const ProgramRecPriorityInfo &other, bool ignore_non_serialized_data)
36 {
37  RecordingInfo::clone(other, ignore_non_serialized_data);
38 
39  if (!ignore_non_serialized_data)
40  {
41  m_recType = other.m_recType;
42  m_matchCount = other.m_matchCount;
43  m_recCount = other.m_recCount;
44  m_last_record = other.m_last_record;
45  m_avg_delay = other.m_avg_delay;
46  m_profile = other.m_profile;
47  }
48 }
49 
51  const RecordingInfo &other, bool ignore_non_serialized_data)
52 {
53  RecordingInfo::clone(other, ignore_non_serialized_data);
54 
55  if (!ignore_non_serialized_data)
56  {
57  m_recType = kNotRecording;
58  m_matchCount = 0;
59  m_recCount = 0;
60  m_last_record = QDateTime();
61  m_avg_delay = 0;
62  m_profile.clear();
63  }
64 }
65 
67  const ProgramInfo &other, bool ignore_non_serialized_data)
68 {
69  RecordingInfo::clone(other, ignore_non_serialized_data);
70 
71  if (!ignore_non_serialized_data)
72  {
73  m_recType = kNotRecording;
74  m_matchCount = 0;
75  m_recCount = 0;
76  m_last_record = QDateTime();
77  m_avg_delay = 0;
78  m_profile.clear();
79  }
80 }
81 
83 {
85 
86  m_recType = kNotRecording;
87  m_matchCount = 0;
88  m_recCount = 0;
89  m_last_record = QDateTime();
90  m_avg_delay = 0;
91  m_profile.clear();
92 }
93 
95  bool showrerecord, uint star_range) const
96 {
97  RecordingInfo::ToMap(progMap, showrerecord, star_range);
98  progMap["title"] = (m_title == "Default (Template)") ?
99  QObject::tr("Default (Template)") : m_title;
100  progMap["category"] = (m_category == "Default") ?
101  QObject::tr("Default") : m_category;
102 }
103 
105 {
106  public:
107  explicit TitleSort(bool reverse) : m_reverse(reverse) {}
108 
110  const ProgramRecPriorityInfo *b) const
111  {
112  if (a->GetSortTitle() != b->GetSortTitle())
113  {
114  if (m_reverse)
115  return naturalCompare(b->GetSortTitle(), a->GetSortTitle()) < 0;
116  return naturalCompare(a->GetSortTitle(), b->GetSortTitle()) < 0;
117  }
118 
119  if (a->GetSortSubtitle() != b->GetSortSubtitle())
120  {
121  if (m_reverse)
122  return naturalCompare(b->GetSortSubtitle(), a->GetSortSubtitle()) < 0;
123  return naturalCompare(a->GetSortSubtitle(), b->GetSortSubtitle()) < 0;
124  }
125 
126  int finalA = a->GetRecordingPriority();
127  int finalB = b->GetRecordingPriority();
128 
129  if (finalA != finalB)
130  {
131  if (m_reverse)
132  return finalA < finalB;
133  return finalA > finalB;
134  }
135 
136  int typeA = RecTypePrecedence(a->m_recType);
137  int typeB = RecTypePrecedence(b->m_recType);
138 
139  if (typeA != typeB)
140  {
141  if (m_reverse)
142  return typeA > typeB;
143  return typeA < typeB;
144  }
145 
146  if (m_reverse)
147  return (a->GetRecordingRuleID() >
148  b->GetRecordingRuleID());
149  return (a->GetRecordingRuleID() <
150  b->GetRecordingRuleID());
151  }
152 
153  private:
154  bool m_reverse {false};
155 };
156 
158 {
159  public:
160  explicit ProgramRecPrioritySort(bool reverse) : m_reverse(reverse) {}
161 
163  const ProgramRecPriorityInfo *b) const
164  {
165  int finalA = a->GetRecordingPriority();
166  int finalB = b->GetRecordingPriority();
167 
168  if (finalA != finalB)
169  {
170  if (m_reverse)
171  return finalA < finalB;
172  return finalA > finalB;
173  }
174 
175  int typeA = RecTypePrecedence(a->m_recType);
176  int typeB = RecTypePrecedence(b->m_recType);
177 
178  if (typeA != typeB)
179  {
180  if (m_reverse)
181  return typeA > typeB;
182  return typeA < typeB;
183  }
184 
185  if (m_reverse)
186  return (a->GetRecordingRuleID() >
187  b->GetRecordingRuleID());
188  return (a->GetRecordingRuleID() <
189  b->GetRecordingRuleID());
190  }
191 
192  private:
193  bool m_reverse {false};
194 };
195 
197 {
198  public:
199  explicit ProgramRecTypeSort(bool reverse) : m_reverse(reverse) {}
200 
202  const ProgramRecPriorityInfo *b) const
203  {
204  int typeA = RecTypePrecedence(a->m_recType);
205  int typeB = RecTypePrecedence(b->m_recType);
206 
207  if (typeA != typeB)
208  {
209  if (m_reverse)
210  return (typeA > typeB);
211  return (typeA < typeB);
212  }
213 
214  int finalA = a->GetRecordingPriority();
215  int finalB = b->GetRecordingPriority();
216 
217  if (finalA != finalB)
218  {
219  if (m_reverse)
220  return finalA < finalB;
221  return finalA > finalB;
222  }
223 
224  if (m_reverse)
225  return (a->GetRecordingRuleID() >
226  b->GetRecordingRuleID());
227  return (a->GetRecordingRuleID() <
228  b->GetRecordingRuleID());
229  }
230 
231  private:
232  bool m_reverse {false};
233 };
234 
236 {
237  public:
238  explicit ProgramCountSort(bool reverse) : m_reverse(reverse) {}
239 
241  const ProgramRecPriorityInfo *b) const
242  {
243  int countA = a->m_matchCount;
244  int countB = b->m_matchCount;
245  int recCountA = a->m_recCount;
246  int recCountB = b->m_recCount;
247 
248  if (countA != countB)
249  {
250  if (m_reverse)
251  return countA < countB;
252  return countA > countB;
253  }
254 
255  if (recCountA != recCountB)
256  {
257  if (m_reverse)
258  return recCountA < recCountB;
259  return recCountA > recCountB;
260  }
261 
262  if (m_reverse)
263  {
264  if (a->GetSortTitle() != b->GetSortTitle())
265  return naturalCompare(b->GetSortTitle(), a->GetSortTitle()) < 0;
266  return naturalCompare(b->GetSortSubtitle(), a->GetSortSubtitle()) < 0;
267  }
268  if (a->GetSortTitle() != b->GetSortTitle())
269  return naturalCompare(a->GetSortTitle(), b->GetSortTitle()) < 0;
270  return naturalCompare(a->GetSortSubtitle(), b->GetSortSubtitle()) < 0;
271  }
272 
273  private:
274  bool m_reverse {false};
275 };
276 
278 {
279  public:
280  explicit ProgramRecCountSort(bool reverse) : m_reverse(reverse) {}
281 
283  const ProgramRecPriorityInfo *b) const
284  {
285  int countA = a->m_matchCount;
286  int countB = b->m_matchCount;
287  int recCountA = a->m_recCount;
288  int recCountB = b->m_recCount;
289 
290  if (recCountA != recCountB)
291  {
292  if (m_reverse)
293  return recCountA < recCountB;
294  return recCountA > recCountB;
295  }
296 
297  if (countA != countB)
298  {
299  if (m_reverse)
300  return countA < countB;
301  return countA > countB;
302  }
303 
304  if (m_reverse)
305  {
306  if (a->GetSortTitle() != b->GetSortTitle())
307  return naturalCompare(b->GetSortTitle(), a->GetSortTitle()) < 0;
308  return naturalCompare(b->GetSortSubtitle(), a->GetSortSubtitle()) < 0;
309  }
310  if (a->GetSortTitle() != b->GetSortTitle())
311  return naturalCompare(a->GetSortTitle(), b->GetSortTitle()) < 0;
312  return naturalCompare(a->GetSortSubtitle(), b->GetSortSubtitle()) < 0;
313  }
314 
315  private:
316  bool m_reverse {false};
317 };
318 
320 {
321  public:
322  explicit ProgramLastRecordSort(bool reverse) : m_reverse(reverse) {}
323 
325  const ProgramRecPriorityInfo *b) const
326  {
327  QDateTime lastRecA = a->m_last_record;
328  QDateTime lastRecB = b->m_last_record;
329 
330  if (lastRecA != lastRecB)
331  {
332  if (m_reverse)
333  return lastRecA < lastRecB;
334  return lastRecA > lastRecB;
335  }
336 
337  if (m_reverse)
338  {
339  if (a->GetSortTitle() != b->GetSortTitle())
340  return naturalCompare(b->GetSortTitle(), a->GetSortTitle()) < 0;
341  return naturalCompare(b->GetSortSubtitle(), a->GetSortSubtitle()) < 0;
342  }
343  if (a->GetSortTitle() != b->GetSortTitle())
344  return naturalCompare(a->GetSortTitle(), b->GetSortTitle()) < 0;
345  return naturalCompare(a->GetSortSubtitle(), b->GetSortSubtitle()) < 0;
346  }
347 
348  private:
349  bool m_reverse {false};
350 };
351 
353 {
354  public:
355  explicit ProgramAvgDelaySort(bool reverse) : m_reverse(reverse) {}
356 
358  const ProgramRecPriorityInfo *b) const
359  {
360  int avgA = a->m_avg_delay;
361  int avgB = b->m_avg_delay;
362 
363  if (avgA != avgB)
364  {
365  if (m_reverse)
366  return avgA > avgB;
367  return avgA < avgB;
368  }
369 
370  if (m_reverse)
371  {
372  if (a->GetSortTitle() != b->GetSortTitle())
373  return naturalCompare(b->GetSortTitle(), a->GetSortTitle()) < 0;
374  return naturalCompare(b->GetSortSubtitle(), a->GetSortSubtitle()) < 0;
375  }
376  if (a->GetSortTitle() != b->GetSortTitle())
377  return naturalCompare(a->GetSortTitle(), b->GetSortTitle()) < 0;
378  return naturalCompare(a->GetSortSubtitle(), b->GetSortSubtitle()) < 0;
379  }
380 
381  private:
382  bool m_reverse {false};
383 };
384 
386 
388  const QString &name)
389  : ScheduleCommon(parent, name)
390 {
391  m_sortType = (SortType)gCoreContext->GetNumSetting("ProgramRecPrioritySorting",
392  (int)byTitle);
393  m_reverseSort = gCoreContext->GetBoolSetting("ProgramRecPriorityReverse", false);
394 }
395 
397 {
398  if (!LoadWindowFromXML("schedule-ui.xml", "managerecrules", this))
399  return false;
400 
401  m_programList = dynamic_cast<MythUIButtonList *> (GetChild("programs"));
402 
403  m_schedInfoText = dynamic_cast<MythUIText *> (GetChild("scheduleinfo"));
404  m_recPriorityText = dynamic_cast<MythUIText *> (GetChild("recpriority"));
405  m_recPriorityBText = dynamic_cast<MythUIText *> (GetChild("recpriorityB"));
406  m_finalPriorityText = dynamic_cast<MythUIText *> (GetChild("finalpriority"));
407  m_lastRecordedText = dynamic_cast<MythUIText *> (GetChild("lastrecorded"));
408  m_lastRecordedDateText = dynamic_cast<MythUIText *> (GetChild("lastrecordeddate"));
409  m_lastRecordedTimeText = dynamic_cast<MythUIText *> (GetChild("lastrecordedtime"));
410  m_channameText = dynamic_cast<MythUIText *> (GetChild("channel"));
411  m_channumText = dynamic_cast<MythUIText *> (GetChild("channum"));
412  m_callsignText = dynamic_cast<MythUIText *> (GetChild("callsign"));
413  m_recProfileText = dynamic_cast<MythUIText *> (GetChild("recordingprofile"));
414 
415  if (!m_programList)
416  {
417  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
418  return false;
419  }
420 
421  connect(m_programList, SIGNAL(itemSelected(MythUIButtonListItem*)),
423  connect(m_programList, SIGNAL(itemClicked(MythUIButtonListItem*)),
424  SLOT(edit(MythUIButtonListItem*)));
425 
426  m_programList->SetLCDTitles(tr("Schedule Priorities"),
427  "rec_type|titlesubtitle|progpriority");
428  m_programList->SetSearchFields("titlesubtitle");
429 
430  BuildFocusList();
432 
433  return true;
434 }
435 
437 {
438  FillList();
439 }
440 
442 {
443  SortList();
444 }
445 
446 bool ProgramRecPriority::keyPressEvent(QKeyEvent *event)
447 {
448  if (GetFocusWidget()->keyPressEvent(event))
449  return true;
450 
451  QStringList actions;
452  bool handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event, actions);
453 
454  for (int i = 0; i < actions.size() && !handled; i++)
455  {
456  QString action = actions[i];
457  handled = true;
458 
459  if (action == "RANKINC")
461  else if (action == "RANKDEC")
462  changeRecPriority(-1);
463  else if (action == "ESCAPE")
464  {
465  saveRecPriority();
466  gCoreContext->SaveSetting("ProgramRecPrioritySorting",
467  (int)m_sortType);
468  gCoreContext->SaveSetting("ProgramRecPriorityReverse",
469  (int)m_reverseSort);
470  Close();
471  }
472  else if (action == "1")
473  {
474  if (m_sortType != byTitle)
475  {
477  m_reverseSort = false;
478  }
479  else
481  SortList();
482  }
483  else if (action == "2")
484  {
485  if (m_sortType != byRecPriority)
486  {
488  m_reverseSort = false;
489  }
490  else
492  SortList();
493  }
494  else if (action == "4")
495  {
496  if (m_sortType != byRecType)
497  {
499  m_reverseSort = false;
500  }
501  else
503  SortList();
504  }
505  else if (action == "5")
506  {
507  if (m_sortType != byCount)
508  {
510  m_reverseSort = false;
511  }
512  else
513  {
515  }
516  SortList();
517  }
518  else if (action == "6")
519  {
520  if (m_sortType != byRecCount)
521  {
523  m_reverseSort = false;
524  }
525  else
527  SortList();
528  }
529  else if (action == "7")
530  {
531  if (m_sortType != byLastRecord)
532  {
534  m_reverseSort = false;
535  }
536  else
538  SortList();
539  }
540  else if (action == "8")
541  {
542  if (m_sortType != byAvgDelay)
543  {
545  m_reverseSort = false;
546  }
547  else
549  SortList();
550  }
551  else if (action == "PREVVIEW" || action == "NEXTVIEW")
552  {
553  m_reverseSort = false;
554  if (m_sortType == byTitle)
556  else if (m_sortType == byRecPriority)
558  else
560  SortList();
561  }
562  else if (action == "SELECT" || action == "EDIT")
563  {
564  saveRecPriority();
566  }
567  else if (action == "MENU")
568  {
569  showMenu();
570  }
571  else if (action == "CUSTOMEDIT")
572  {
573  saveRecPriority();
574  EditCustom();
575  }
576  else if (action == "DELETE")
577  {
578  saveRecPriority();
579  remove();
580  }
581  else if (action == "UPCOMING")
582  {
583  saveRecPriority();
584  ShowUpcoming();
585  }
586  else if (action == "INFO" || action == "DETAILS")
587  ShowDetails();
588  else
589  handled = false;
590  }
591 
592  if (!handled && MythScreenType::keyPressEvent(event))
593  handled = true;
594 
595  return handled;
596 }
597 
599 {
600  QString label = tr("Options");
601 
602  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
603  MythDialogBox *menuPopup = new MythDialogBox(label, popupStack, "menuPopup");
604 
605  if (menuPopup->Create())
606  {
607  menuPopup->SetReturnEvent(this, "menu");
608 
609  menuPopup->AddButton(tr("Increase Priority"));
610  menuPopup->AddButton(tr("Decrease Priority"));
611  menuPopup->AddButton(tr("Sort"), nullptr, true);
612  menuPopup->AddButton(tr("Program Details"));
613  menuPopup->AddButton(tr("Upcoming"));
614  menuPopup->AddButton(tr("Custom Edit"));
615  menuPopup->AddButton(tr("Delete Rule"));
616  menuPopup->AddButton(tr("New Template"));
617 
618  popupStack->AddScreen(menuPopup);
619  }
620  else
621  {
622  delete menuPopup;
623  }
624 }
625 
627 {
628  QString label = tr("Sort Options");
629 
630  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
631  MythDialogBox *menuPopup = new MythDialogBox(label, popupStack, "menuPopup");
632 
633  if (menuPopup->Create())
634  {
635  menuPopup->SetReturnEvent(this, "sortmenu");
636 
637  menuPopup->AddButton(tr("Reverse Sort Order"));
638  menuPopup->AddButton(tr("Sort By Title"));
639  menuPopup->AddButton(tr("Sort By Priority"));
640  menuPopup->AddButton(tr("Sort By Type"));
641  menuPopup->AddButton(tr("Sort By Count"));
642  menuPopup->AddButton(tr("Sort By Record Count"));
643  menuPopup->AddButton(tr("Sort By Last Recorded"));
644  menuPopup->AddButton(tr("Sort By Average Delay"));
645 
646  popupStack->AddScreen(menuPopup);
647  }
648  else
649  {
650  delete menuPopup;
651  }
652 }
653 
655 {
656  if (event->type() == DialogCompletionEvent::kEventType)
657  {
659 
660  QString resultid = dce->GetId();
661  QString resulttext = dce->GetResultText();
662  int buttonnum = dce->GetResult();
663 
664  if (resultid == "menu")
665  {
666  if (resulttext == tr("Increase Priority"))
667  {
669  }
670  else if (resulttext == tr("Decrease Priority"))
671  {
672  changeRecPriority(-1);
673  }
674  else if (resulttext == tr("Sort"))
675  {
676  showSortMenu();
677  }
678  else if (resulttext == tr("Program Details"))
679  {
680  ShowDetails();
681  }
682  else if (resulttext == tr("Upcoming"))
683  {
684  saveRecPriority();
685  ShowUpcoming();
686  }
687  else if (resulttext == tr("Custom Edit"))
688  {
689  saveRecPriority();
690  EditCustom();
691  }
692  else if (resulttext == tr("Delete Rule"))
693  {
694  saveRecPriority();
695  remove();
696  }
697  else if (resulttext == tr("New Template"))
698  {
699  MythScreenStack *popupStack =
700  GetMythMainWindow()->GetStack("popup stack");
701  MythTextInputDialog *textInput =
702  new MythTextInputDialog(popupStack,
703  tr("Template Name"));
704  if (textInput->Create())
705  {
706  textInput->SetReturnEvent(this, "templatecat");
707  popupStack->AddScreen(textInput);
708  }
709  }
710  }
711  else if (resultid == "sortmenu")
712  {
713  if (resulttext == tr("Reverse Sort Order"))
714  {
716  SortList();
717  }
718  else if (resulttext == tr("Sort By Title"))
719  {
720  if (m_sortType != byTitle)
721  {
723  m_reverseSort = false;
724  }
725  else
727  SortList();
728  }
729  else if (resulttext == tr("Sort By Priority"))
730  {
731  if (m_sortType != byRecPriority)
732  {
734  m_reverseSort = false;
735  }
736  else
738  SortList();
739  }
740  else if (resulttext == tr("Sort By Type"))
741  {
742  if (m_sortType != byRecType)
743  {
745  m_reverseSort = false;
746  }
747  else
749  SortList();
750  }
751  else if (resulttext == tr("Sort By Count"))
752  {
753  if (m_sortType != byCount)
754  {
756  m_reverseSort = false;
757  }
758  else
759  {
761  }
762  SortList();
763  }
764  else if (resulttext == tr("Sort By Record Count"))
765  {
766  if (m_sortType != byRecCount)
767  {
769  m_reverseSort = false;
770  }
771  else
773  SortList();
774  }
775  else if (resulttext == tr("Sort By Last Recorded"))
776  {
777  if (m_sortType != byLastRecord)
778  {
780  m_reverseSort = false;
781  }
782  else
784  SortList();
785  }
786  else if (resulttext == tr("Sort By Average Delay"))
787  {
788  if (m_sortType != byAvgDelay)
789  {
791  m_reverseSort = false;
792  }
793  else
795  SortList();
796  }
797  }
798  else if (resultid == "deleterule")
799  {
800  RecordingRule *record =
801  dce->GetData().value<RecordingRule *>();
802  if (record)
803  {
804  if (buttonnum > 0)
805  {
806  MythUIButtonListItem *item =
808 
809  if (record->Delete() && item)
810  RemoveItemFromList(item);
811  else
812  LOG(VB_GENERAL, LOG_ERR,
813  "Failed to delete recording rule");
814  }
815  delete record;
816  }
817  }
818  else if (resultid == "templatecat")
819  {
820  newTemplate(resulttext);
821  }
822  else
824  }
825 }
826 
828 {
829  if (!item)
830  return;
831 
832  ProgramRecPriorityInfo *pgRecInfo =
833  item->GetData().value<ProgramRecPriorityInfo*>();
834 
835  if (!pgRecInfo)
836  return;
837 
838  RecordingRule *record = new RecordingRule();
839  record->m_recordID = pgRecInfo->GetRecordingRuleID();
840  if (record->m_searchType == kNoSearch)
841  record->LoadByProgram(pgRecInfo);
842 
844  ScheduleEditor *schededit = new ScheduleEditor(mainStack, record);
845  if (schededit->Create())
846  {
847  mainStack->AddScreen(schededit);
848  connect(schededit, SIGNAL(ruleSaved(int)), SLOT(scheduleChanged(int)));
849  connect(schededit, SIGNAL(ruleDeleted(int)), SLOT(scheduleChanged(int)));
850  }
851  else
852  delete schededit;
853 }
854 
855 void ProgramRecPriority::newTemplate(QString category)
856 {
857  category = category.trimmed();
858  if (category.isEmpty())
859  return;
860 
861  // Try to find an existing template and use it.
862  QMap<int, ProgramRecPriorityInfo>::Iterator it;
863  for (it = m_programData.begin(); it != m_programData.end(); ++it)
864  {
865  ProgramRecPriorityInfo *progInfo = &(*it);
866  if (progInfo->GetRecordingRuleType() == kTemplateRecord &&
867  category.compare(progInfo->GetCategory(),
868  Qt::CaseInsensitive) == 0)
869  {
870  m_programList->SetValueByData(qVariantFromValue(progInfo));
872  return;
873  }
874  }
875 
876  RecordingRule *record = new RecordingRule();
877  if (!record)
878  return;
879  record->MakeTemplate(category);
880 
882  ScheduleEditor *schededit = new ScheduleEditor(mainStack, record);
883  if (schededit->Create())
884  {
885  mainStack->AddScreen(schededit);
886  connect(schededit, SIGNAL(ruleSaved(int)), SLOT(scheduleChanged(int)));
887  connect(schededit, SIGNAL(ruleDeleted(int)), SLOT(scheduleChanged(int)));
888  }
889  else
890  delete schededit;
891 }
892 
894 {
895  // Assumes that the current item didn't change, which isn't guaranteed
897  ProgramRecPriorityInfo *pgRecInfo = nullptr;
898  if (item)
899  pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>();
900 
901  // If the recording id doesn't match, the user created a new
902  // template.
903  if (!pgRecInfo || recid != pgRecInfo->getRecordID())
904  {
905  RecordingRule record;
906  record.m_recordID = recid;
907  if (!record.Load() || record.m_type == kNotRecording)
908  return;
909 
910  ProgramRecPriorityInfo progInfo;
911  progInfo.SetRecordingRuleID(record.m_recordID);
912  progInfo.SetRecordingRuleType(record.m_type);
913  progInfo.SetTitle(record.m_title, record.m_sortTitle);
914  progInfo.SetSubtitle(record.m_subtitle, record.m_sortSubtitle);
915  progInfo.SetCategory(record.m_category);
916  progInfo.SetRecordingPriority(record.m_recPriority);
917  progInfo.m_recType = record.m_type;
918  progInfo.m_recstatus = record.m_isInactive ?
920  progInfo.m_profile = record.m_recProfile;
921  progInfo.m_last_record = record.m_lastRecorded;
922 
923  m_programData[recid] = progInfo;
925  record.m_recPriority;
926  SortList(&m_programData[recid]);
927 
928  return;
929  }
930 
931  // We need to refetch the recording priority values since the Advanced
932  // Recording Options page could've been used to change them
933 
934  MSqlQuery query(MSqlQuery::InitCon());
935  query.prepare("SELECT recpriority, type, inactive "
936  "FROM record "
937  "WHERE recordid = :RECORDID");
938  query.bindValue(":RECORDID", recid);
939  if (!query.exec())
940  {
941  MythDB::DBError("Get new recording priority query", query);
942  }
943  else if (query.next())
944  {
945  int recPriority = query.value(0).toInt();
946  int rectype = query.value(1).toInt();
947  int inactive = query.value(2).toInt();
948 
949  // set the recording priorities of that program
950  pgRecInfo->SetRecordingPriority(recPriority);
951  pgRecInfo->m_recType = (RecordingType)rectype;
952  // also set the m_origRecPriorityData with new recording
953  // priority so we don't save to db again when we exit
955  pgRecInfo->GetRecordingPriority();
956  // also set the active/inactive state
957  pgRecInfo->m_recstatus = inactive ? RecStatus::Inactive : RecStatus::Unknown;
958 
959  SortList();
960  }
961  else
962  {
963  RemoveItemFromList(item);
964  }
965 
966  countMatches();
967 }
968 
970 {
972  if (!item)
973  return;
974 
975  ProgramRecPriorityInfo *pgRecInfo =
976  item->GetData().value<ProgramRecPriorityInfo*>();
977 
978  if (!pgRecInfo ||
979  (pgRecInfo->m_recType == kTemplateRecord &&
980  pgRecInfo->GetCategory()
981  .compare("Default", Qt::CaseInsensitive) == 0))
982  {
983  return;
984  }
985 
986  RecordingRule *record = new RecordingRule();
987  record->m_recordID = pgRecInfo->GetRecordingRuleID();
988  if (!record->Load())
989  {
990  delete record;
991  return;
992  }
993 
994  QString message = tr("Delete '%1' %2 rule?").arg(record->m_title)
995  .arg(toString(pgRecInfo->GetRecordingRuleType()));
996 
997  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
998 
999  MythConfirmationDialog *okPopup = new MythConfirmationDialog(popupStack,
1000  message, true);
1001 
1002  okPopup->SetReturnEvent(this, "deleterule");
1003  okPopup->SetData(qVariantFromValue(record));
1004 
1005  if (okPopup->Create())
1006  popupStack->AddScreen(okPopup);
1007  else
1008  delete okPopup;
1009 }
1010 
1012 {
1014  if (!item)
1015  return;
1016 
1017  ProgramRecPriorityInfo *pgRecInfo =
1018  item->GetData().value<ProgramRecPriorityInfo*>();
1019 
1020  if (pgRecInfo)
1021  {
1022  MSqlQuery query(MSqlQuery::InitCon());
1023 
1024  query.prepare("SELECT inactive "
1025  "FROM record "
1026  "WHERE recordid = :RECID");
1027  query.bindValue(":RECID", pgRecInfo->GetRecordingRuleID());
1028 
1029 
1030  if (!query.exec())
1031  {
1032  MythDB::DBError("ProgramRecPriority::deactivate()", query);
1033  }
1034  else if (query.next())
1035  {
1036  int inactive = query.value(0).toInt();
1037  if (inactive)
1038  inactive = 0;
1039  else
1040  inactive = 1;
1041 
1042  query.prepare("UPDATE record "
1043  "SET inactive = :INACTIVE "
1044  "WHERE recordid = :RECID");
1045  query.bindValue(":INACTIVE", inactive);
1046  query.bindValue(":RECID", pgRecInfo->GetRecordingRuleID());
1047 
1048  if (!query.exec())
1049  {
1051  "Update recording schedule inactive query", query);
1052  }
1053  else
1054  {
1056  QString("DeactivateRule %1 %2")
1057  .arg(pgRecInfo->GetRecordingRuleID())
1058  .arg(pgRecInfo->GetTitle()));
1059  pgRecInfo->m_recstatus = inactive ? RecStatus::Inactive : RecStatus::Unknown;
1060  item->DisplayState("disabled", "status");
1061  }
1062  }
1063  }
1064 }
1065 
1067 {
1069  if (!item)
1070  return;
1071 
1072  ProgramRecPriorityInfo *pgRecInfo =
1073  item->GetData().value<ProgramRecPriorityInfo*>();
1074 
1075  if (!pgRecInfo)
1076  return;
1077 
1078  int tempRecPriority;
1079  // inc/dec recording priority
1080  tempRecPriority = pgRecInfo->GetRecordingPriority() + howMuch;
1081  if (tempRecPriority > -100 && tempRecPriority < 100)
1082  {
1083  pgRecInfo->m_recpriority = tempRecPriority;
1084 
1085  // order may change if sorting by recording priority, so resort
1086  if (m_sortType == byRecPriority)
1087  SortList();
1088  else
1089  {
1090  // No need to re-fill the entire list, just update this entry
1091  int progRecPriority = pgRecInfo->GetRecordingPriority();
1092 
1093  item->SetText(QString::number(progRecPriority), "progpriority");
1094  item->SetText(QString::number(progRecPriority), "recpriority");
1095  if (m_recPriorityText)
1096  m_recPriorityText->SetText(QString::number(progRecPriority));
1097 
1098  item->SetText(QString::number(progRecPriority), "recpriorityB");
1099  if (m_recPriorityBText)
1100  m_recPriorityBText->SetText(QString::number(progRecPriority));
1101 
1102  item->SetText(QString::number(progRecPriority), "finalpriority");
1103  if (m_finalPriorityText)
1104  m_finalPriorityText->SetText(QString::number(progRecPriority));
1105  }
1106  }
1107 }
1108 
1110 {
1111  QMap<int, ProgramRecPriorityInfo>::Iterator it;
1112 
1113  for (it = m_programData.begin(); it != m_programData.end(); ++it)
1114  {
1115  ProgramRecPriorityInfo *progInfo = &(*it);
1116  int key = progInfo->GetRecordingRuleID();
1117 
1118  // if this program's recording priority changed from when we entered
1119  // save new value out to db
1120  if (progInfo->GetRecordingPriority() != m_origRecPriorityData[key])
1121  progInfo->ApplyRecordRecPriorityChange(
1122  progInfo->GetRecordingPriority());
1123  }
1124 }
1125 
1127 {
1128  vector<ProgramInfo *> recordinglist;
1129 
1130  m_programData.clear();
1131 
1132  RemoteGetAllScheduledRecordings(recordinglist);
1133 
1134  vector<ProgramInfo *>::iterator pgiter = recordinglist.begin();
1135 
1136  for (; pgiter != recordinglist.end(); ++pgiter)
1137  {
1138  ProgramInfo *progInfo = *pgiter;
1139  m_programData[(*pgiter)->GetRecordingRuleID()] =
1140  (*progInfo);
1141 
1142  // save recording priority value in map so we don't have to
1143  // save all program's recording priority values when we exit
1144  m_origRecPriorityData[(*pgiter)->GetRecordingRuleID()] =
1145  (*pgiter)->GetRecordingPriority();
1146 
1147  delete (*pgiter);
1148  }
1149 
1150  // get recording types associated with each program from db
1151  // (hope this is ok to do here, it's so much lighter doing
1152  // it all at once than once per program)
1153 
1154  MSqlQuery result(MSqlQuery::InitCon());
1155  result.prepare("SELECT recordid, title, chanid, starttime, startdate, "
1156  "type, inactive, last_record, avg_delay, profile "
1157  "FROM record;");
1158 
1159  if (!result.exec())
1160  {
1161  MythDB::DBError("Get program recording priorities query", result);
1162  }
1163  else if (result.next())
1164  {
1165  countMatches();
1166  do {
1167  uint recordid = result.value(0).toUInt();
1168  QString title = result.value(1).toString();
1169  QString chanid = result.value(2).toString();
1170  QString tempTime = result.value(3).toString();
1171  QString tempDate = result.value(4).toString();
1172  RecordingType recType = (RecordingType)result.value(5).toInt();
1173  int inactive = result.value(6).toInt();
1174  QDateTime lastrec = MythDate::as_utc(result.value(7).toDateTime());
1175  int avgd = result.value(8).toInt();
1176  QString profile = result.value(9).toString();
1177 
1178  // find matching program in m_programData and set
1179  // recType
1180  QMap<int, ProgramRecPriorityInfo>::Iterator it;
1181  it = m_programData.find(recordid);
1182  if (it != m_programData.end())
1183  {
1184  ProgramRecPriorityInfo *progInfo = &(*it);
1185 
1186  progInfo->m_recType = recType;
1187  progInfo->m_matchCount =
1188  m_listMatch[progInfo->GetRecordingRuleID()];
1189  progInfo->m_recCount =
1190  m_recMatch[progInfo->GetRecordingRuleID()];
1191  progInfo->m_last_record = lastrec;
1192  progInfo->m_avg_delay = avgd;
1193  progInfo->m_profile = profile;
1194 
1195  if (inactive)
1196  progInfo->m_recstatus = RecStatus::Inactive;
1197  else if (m_conMatch[progInfo->GetRecordingRuleID()] > 0)
1198  progInfo->m_recstatus = RecStatus::Conflict;
1199  else if (m_nowMatch[progInfo->GetRecordingRuleID()] > 0)
1200  progInfo->m_recstatus = RecStatus::Recording;
1201  else if (m_recMatch[progInfo->GetRecordingRuleID()] > 0)
1202  progInfo->m_recstatus = RecStatus::WillRecord;
1203  else
1204  progInfo->m_recstatus = RecStatus::Unknown;
1205  }
1206  } while (result.next());
1207  }
1208 }
1209 
1211 {
1212  m_listMatch.clear();
1213  m_conMatch.clear();
1214  m_nowMatch.clear();
1215  m_recMatch.clear();
1216  ProgramList schedList;
1217  LoadFromScheduler(schedList);
1218  QDateTime now = MythDate::current();
1219 
1220  ProgramList::const_iterator it = schedList.begin();
1221  for (; it != schedList.end(); ++it)
1222  {
1223  const RecStatus::Type recstatus = (**it).GetRecordingStatus();
1224  const uint recordid = (**it).GetRecordingRuleID();
1225  if ((**it).GetRecordingEndTime() > now && recstatus != RecStatus::NotListed)
1226  {
1227  m_listMatch[recordid]++;
1228  if (recstatus == RecStatus::Conflict || recstatus == RecStatus::Offline)
1229  m_conMatch[recordid]++;
1230  else if (recstatus == RecStatus::WillRecord)
1231  m_recMatch[recordid]++;
1232  else if (recstatus == RecStatus::Recording)
1233  {
1234  m_nowMatch[recordid]++;
1235  m_recMatch[recordid]++;
1236  }
1237  }
1238  }
1239 }
1240 
1242 {
1243  if (newCurrentItem)
1244  m_currentItem = newCurrentItem;
1245  else
1246  {
1248  if (item)
1249  m_currentItem =
1250  item->GetData().value<ProgramRecPriorityInfo*>();
1251  }
1252 
1253  QMap<int, ProgramRecPriorityInfo>::Iterator pit;
1254 
1255  // copy m_programData into m_sortedProgram
1256  m_sortedProgram.clear();
1257  for (pit = m_programData.begin(); pit != m_programData.end(); ++pit)
1258  {
1259  ProgramRecPriorityInfo *progInfo = &(*pit);
1260  m_sortedProgram.push_back(progInfo);
1261  }
1262 
1263  // sort m_sortedProgram
1264  switch (m_sortType)
1265  {
1266  case byTitle :
1267  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1269  break;
1270  case byRecPriority :
1271  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1273  break;
1274  case byRecType :
1275  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1277  break;
1278  case byCount :
1279  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1281  break;
1282  case byRecCount :
1283  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1285  break;
1286  case byLastRecord :
1287  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1289  break;
1290  case byAvgDelay :
1291  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1293  break;
1294  }
1295 
1296  UpdateList();
1297 }
1298 
1300 {
1301  if (!m_currentItem && !m_programList->IsEmpty())
1303  .value<ProgramRecPriorityInfo*>();
1304 
1305  m_programList->Reset();
1306 
1307  vector<ProgramRecPriorityInfo*>::iterator it;
1308  for (it = m_sortedProgram.begin(); it != m_sortedProgram.end(); ++it)
1309  {
1310  ProgramRecPriorityInfo *progInfo = *it;
1311 
1312  MythUIButtonListItem *item =
1314  qVariantFromValue(progInfo));
1315 
1316  int progRecPriority = progInfo->GetRecordingPriority();
1317 
1318  if ((progInfo->m_rectype == kSingleRecord ||
1319  progInfo->m_rectype == kOverrideRecord ||
1320  progInfo->m_rectype == kDontRecord) &&
1321  !(progInfo->GetSubtitle()).trimmed().isEmpty())
1322  {
1323  QString rating = QString::number(progInfo->GetStars(10));
1324 
1325  item->DisplayState(rating, "ratingstate");
1326  }
1327  else
1328  progInfo->m_subtitle.clear();
1329 
1330  QString state;
1331  if (progInfo->m_recType == kDontRecord ||
1332  (progInfo->m_recType != kTemplateRecord &&
1333  progInfo->m_recstatus == RecStatus::Inactive))
1334  state = "disabled";
1335  else if (m_conMatch[progInfo->GetRecordingRuleID()] > 0)
1336  state = "error";
1337  else if (m_recMatch[progInfo->GetRecordingRuleID()] > 0 ||
1338  progInfo->m_recType == kTemplateRecord)
1339  state = "normal";
1340  else if (m_nowMatch[progInfo->GetRecordingRuleID()] > 0)
1341  state = "running";
1342  else
1343  state = "warning";
1344 
1345  InfoMap infoMap;
1346  progInfo->ToMap(infoMap);
1347  item->SetTextFromMap(infoMap, state);
1348 
1349  QString subtitle;
1350  if (progInfo->m_subtitle != "(null)" &&
1351  (progInfo->m_rectype == kSingleRecord ||
1352  progInfo->m_rectype == kOverrideRecord ||
1353  progInfo->m_rectype == kDontRecord))
1354  {
1355  subtitle = progInfo->m_subtitle;
1356  }
1357 
1358  QString matchInfo;
1359  if (progInfo->GetRecordingStatus() == RecStatus::Inactive)
1360  {
1361  matchInfo = QString("%1 %2")
1362  .arg(m_listMatch[progInfo->GetRecordingRuleID()])
1363  .arg(RecStatus::toString(progInfo->GetRecordingStatus(),
1364  progInfo->GetRecordingRuleType()));
1365  }
1366  else
1367  matchInfo = tr("Recording %1 of %2")
1368  .arg(m_recMatch[progInfo->GetRecordingRuleID()])
1369  .arg(m_listMatch[progInfo->GetRecordingRuleID()]);
1370 
1371  subtitle = QString("(%1) %2").arg(matchInfo).arg(subtitle);
1372  item->SetText(subtitle, "scheduleinfo", state);
1373 
1374  item->SetText(QString::number(progRecPriority), "progpriority", state);
1375  item->SetText(QString::number(progRecPriority), "finalpriority", state);
1376 
1377  item->SetText(QString::number(progRecPriority), "recpriority", state);
1378  item->SetText(QString::number(progRecPriority), "recpriorityB", state);
1379 
1380  QString tempDateTime = MythDate::toString(progInfo->m_last_record,
1383  item->SetText(tempDateTime, "lastrecorded", state);
1384  QString tempDate = MythDate::toString(progInfo->m_last_record,
1387  item->SetText(tempDate, "lastrecordeddate", state);
1388  QString tempTime = MythDate::toString(
1389  progInfo->m_last_record, MythDate::kTime);
1390  item->SetText(tempTime, "lastrecordedtime", state);
1391 
1392  QString channame = progInfo->m_channame;
1393  QString channum = progInfo->m_chanstr;
1394  QString callsign = progInfo->m_chansign;
1395  if (progInfo->m_recType != kSingleRecord &&
1396  progInfo->m_recType != kOverrideRecord &&
1397  progInfo->m_recType != kDontRecord &&
1398  !(progInfo->GetRecordingRule()->m_filter & 1024) &&
1400  {
1401  channame = tr("Any");
1402  channum = tr("Any");
1403  callsign = tr("Any");
1404  }
1405  item->SetText(channame, "channel", state);
1406  item->SetText(channum, "channum", state);
1407  item->SetText(callsign, "callsign", state);
1408 
1409  QString profile = progInfo->m_profile;
1410  if ((profile == "Default") || (profile == "Live TV") ||
1411  (profile == "High Quality") || (profile == "Low Quality"))
1412  profile = tr(profile.toUtf8().constData());
1413  item->SetText(profile, "recordingprofile", state);
1414  item->DisplayState(state, "status");
1415 
1416  if (m_currentItem == progInfo)
1418  }
1419 
1420  m_currentItem = nullptr;
1421 
1422  MythUIText *norecordingText = dynamic_cast<MythUIText*>
1423  (GetChild("norecordings_info"));
1424 
1425  if (norecordingText)
1426  norecordingText->SetVisible(m_programData.isEmpty());
1427 }
1428 
1430 {
1431  if (!item)
1432  return;
1433 
1434  ProgramRecPriorityInfo *pgRecInfo = item->GetData()
1435  .value<ProgramRecPriorityInfo *>();
1436 
1437  if (!pgRecInfo)
1438  return;
1439 
1440  int progRecPriority = pgRecInfo->GetRecordingPriority();
1441 
1442  QString subtitle;
1443  if (pgRecInfo->m_subtitle != "(null)" &&
1444  (pgRecInfo->m_rectype == kSingleRecord ||
1445  pgRecInfo->m_rectype == kOverrideRecord ||
1446  pgRecInfo->m_rectype == kDontRecord))
1447  {
1448  subtitle = pgRecInfo->m_subtitle;
1449  }
1450 
1451  QString matchInfo;
1452  if (pgRecInfo->GetRecordingStatus() == RecStatus::Inactive)
1453  {
1454  matchInfo = QString("%1 %2")
1455  .arg(m_listMatch[pgRecInfo->GetRecordingRuleID()])
1456  .arg(RecStatus::toString(pgRecInfo->GetRecordingStatus(),
1457  pgRecInfo->GetRecordingRuleType()));
1458  }
1459  else
1460  matchInfo = tr("Recording %1 of %2")
1461  .arg(m_recMatch[pgRecInfo->GetRecordingRuleID()])
1462  .arg(m_listMatch[pgRecInfo->GetRecordingRuleID()]);
1463 
1464  subtitle = QString("(%1) %2").arg(matchInfo).arg(subtitle);
1465 
1466  InfoMap infoMap;
1467  pgRecInfo->ToMap(infoMap);
1468  SetTextFromMap(infoMap);
1469 
1470  if (m_schedInfoText)
1471  m_schedInfoText->SetText(subtitle);
1472 
1473  if (m_recPriorityText)
1474  m_recPriorityText->SetText(QString::number(progRecPriority));
1475 
1476  if (m_recPriorityBText)
1477  m_recPriorityBText->SetText(QString::number(progRecPriority));
1478 
1479  if (m_finalPriorityText)
1480  m_finalPriorityText->SetText(QString::number(progRecPriority));
1481 
1482  if (m_lastRecordedText)
1483  {
1484  QString tempDateTime = MythDate::toString(pgRecInfo->m_last_record,
1487  m_lastRecordedText->SetText(tempDateTime);
1488  }
1489 
1491  {
1492  QString tempDate = MythDate::toString(pgRecInfo->m_last_record,
1495  m_lastRecordedDateText->SetText(tempDate);
1496  }
1497 
1499  {
1500  QString tempTime = MythDate::toString(
1501  pgRecInfo->m_last_record, MythDate::kTime);
1502  m_lastRecordedTimeText->SetText(tempTime);
1503  }
1504 
1506  {
1507  QString channame = pgRecInfo->m_channame;
1508  QString channum = pgRecInfo->m_chanstr;
1509  QString callsign = pgRecInfo->m_chansign;
1510  if (pgRecInfo->m_recType != kSingleRecord &&
1511  pgRecInfo->m_recType != kOverrideRecord &&
1512  pgRecInfo->m_recType != kDontRecord &&
1513  !(pgRecInfo->GetRecordingRule()->m_filter & 1024) &&
1514  pgRecInfo->GetRecordingRule()->m_searchType != kManualSearch)
1515  {
1516  channame = tr("Any");
1517  channum = tr("Any");
1518  callsign = tr("Any");
1519  }
1520  if (m_channameText)
1521  m_channameText->SetText(channame);
1522  if (m_channumText)
1523  m_channumText->SetText(channum);
1524  if (m_callsignText)
1525  m_callsignText->SetText(callsign);
1526  }
1527 
1528  if (m_recProfileText)
1529  {
1530  QString profile = pgRecInfo->m_profile;
1531  if ((profile == "Default") || (profile == "Live TV") ||
1532  (profile == "High Quality") || (profile == "Low Quality"))
1533  profile = tr(profile.toUtf8().constData());
1535  }
1536 
1537 }
1538 
1540 {
1541  if (!item)
1542  return;
1543 
1544  ProgramRecPriorityInfo *pgRecInfo = item->GetData()
1545  .value<ProgramRecPriorityInfo *>();
1546 
1547  if (!pgRecInfo)
1548  return;
1549 
1550  QMap<int, ProgramRecPriorityInfo>::iterator it;
1551  it = m_programData.find(pgRecInfo->GetRecordingRuleID());
1552  if (it != m_programData.end())
1553  m_programData.erase(it);
1554 
1555  m_programList->RemoveItem(item);
1556 }
1557 
1559 {
1561  return item ? item->GetData().value<ProgramRecPriorityInfo*>() : nullptr;
1562 }
1563 
1564 /* vim: set expandtab tabstop=4 shiftwidth=4: */
QString m_subtitle
Definition: recordingrule.h:81
TitleSort(bool reverse)
ProgramRecTypeSort(bool reverse)
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:782
bool m_isInactive
Recording rule is enabled?
Definition: recordingrule.h:76
float GetStars(void) const
Definition: programinfo.h:434
QString m_channame
Definition: programinfo.h:753
MythUIText * m_lastRecordedDateText
ProgramRecPriority(MythScreenStack *parent, const QString &name)
MythUIText * m_lastRecordedTimeText
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:863
std::vector< ProgramRecPriorityInfo * > m_sortedProgram
virtual void ToMap(InfoMap &progMap, bool showrerecord=false, uint star_range=10) const
Converts ProgramInfo into QString QHash containing each field in ProgramInfo converted into localized...
bool LoadByProgram(const ProgramInfo *proginfo)
Dialog asking for user confirmation.
void newTemplate(QString category)
QString m_sortTitle
Definition: recordingrule.h:80
bool Create(void) override
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
bool Delete(bool sendSig=true)
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
QString toString(MarkTypes type)
QString m_chansign
Definition: programinfo.h:752
virtual void ShowUpcoming(void) const
Show the upcoming recordings for this title.
void SaveSetting(const QString &key, int newValue)
MythUIText * m_finalPriorityText
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
Basic menu dialog, message and a list of options.
RecordingRule * GetRecordingRule(void)
Returns the "record" field, creating it if necessary.
QString GetTitle(void) const
Definition: programinfo.h:353
void SetRecordingRuleID(uint id)
Definition: programinfo.h:523
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:136
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:34
MythScreenStack * GetStack(const QString &stackname)
QMap< int, int > m_listMatch
QMap< int, int > m_origRecPriorityData
void customEvent(QEvent *event) override
int m_recordID
Unique Recording Rule ID.
Definition: recordingrule.h:72
unsigned int uint
Definition: compat.h:140
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void ToMap(InfoMap &progMap, bool showrerecord=false, uint star_range=10) const override
Converts ProgramInfo into QString QHash containing each field in ProgramInfo converted into localized...
RecordingType m_type
MythScreenStack * GetMainStack()
virtual void ShowDetails(void) const
Show the Program Details screen.
MythUIText * m_lastRecordedText
int32_t m_recpriority
Definition: programinfo.h:748
int GetRecordingPriority(void) const
Definition: programinfo.h:432
int RecTypePrecedence(RecordingType rectype)
Converts a RecordingType to a simple integer so it's specificity can be compared to another.
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
iterator begin(void)
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:23
void RemoveItem(MythUIButtonListItem *item)
void BuildFocusList(void)
static Type kEventType
Definition: mythdialogbox.h:50
enum RecordingTypes RecordingType
QString m_chanstr
Definition: programinfo.h:751
MythUIText * m_recPriorityText
unsigned char b
Definition: ParseText.cpp:329
int8_t m_recstatus
Definition: programinfo.h:797
QVariant value(int i) const
Definition: mythdbcon.h:198
virtual void Close()
void AddButton(const QString &title, QVariant data=0, bool newMenu=false, bool setCurrent=false)
virtual void clone(const RecordingInfo &other, bool ignore_non_serialized_data=false)
Copies important fields from other RecordingInfo.
void changeRecPriority(int howMuch)
Holds information on recordings and videos.
Definition: programinfo.h:66
bool Create(void) override
virtual void SetVisible(bool visible)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
QDateTime m_lastRecorded
def rating(profile, smoonURL, gate)
Definition: scan.py:25
ProgramInfo * GetCurrentProgram(void) const override
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
MythUIButtonList * m_programList
Default local time.
Definition: mythdate.h:19
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
void clear(void) override
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Construct a recording schedule.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
void RemoteGetAllScheduledRecordings(vector< ProgramInfo * > &scheduledlist)
Definition: remoteutil.cpp:163
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
void SetReturnEvent(QObject *retobject, const QString &resultid)
ProgramRecPriorityInfo * m_currentItem
QString GetSortSubtitle(void) const
Definition: programinfo.h:356
static QString toString(Type, uint id)
Converts "recstatus" into a short (unreadable) string.
Definition: recStatus.cpp:39
void RemoveItemFromList(MythUIButtonListItem *item)
QString GetSubtitle(void) const
Definition: programinfo.h:355
Default local time.
Definition: mythdate.h:16
void SetReturnEvent(QObject *retobject, const QString &resultid)
QMap< int, ProgramRecPriorityInfo > m_programData
virtual void SetTextFromMap(const InfoMap &infoMap)
static void ReschedulePlace(const QString &why)
bool Create(void) override
void scheduleChanged(int recid)
QMap< int, int > m_conMatch
void SetText(const QString &text, const QString &name="", const QString &state="")
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:23
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
MythUIText * m_callsignText
const char * name
Definition: ParseText.cpp:328
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
virtual void EditCustom(void)
Creates a dialog for creating a custom recording rule.
MythUIText * m_channameText
virtual void clone(const ProgramRecPriorityInfo &other, bool ignore_non_serialized_data=false)
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:101
void customEvent(QEvent *) override
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythUIType * GetFocusWidget(void) const
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
void clear(void) override
MythMainWindow * GetMythMainWindow(void)
bool keyPressEvent(QKeyEvent *) override
Key event handler.
bool MakeTemplate(QString category)
void SetCategory(const QString &cat)
Definition: programinfo.h:519
void SetTitle(const QString &t, const QString &st=nullptr)
ProgramAvgDelaySort(bool reverse)
int GetNumSetting(const QString &key, int defaultval=0)
void SortList(ProgramRecPriorityInfo *newCurrentItem=nullptr)
Dialog prompting the user to enter a text string.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:807
bool keyPressEvent(QKeyEvent *) override
Key event handler.
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
MythUIText * m_recProfileText
QString m_title
Definition: recordingrule.h:79
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:439
ProgramRecCountSort(bool reverse)
void SetLCDTitles(const QString &title, const QString &columnList="")
bool GetBoolSetting(const QString &key, bool defaultval=false)
QString GetSortTitle(void) const
Definition: programinfo.h:354
MythUIText * m_channumText
bool Create(void) override
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:443
QMap< int, int > m_recMatch
void SetReturnEvent(QObject *retobject, const QString &resultid)
QString m_sortSubtitle
Definition: recordingrule.h:82
iterator end(void)
MythUIText * m_schedInfoText
void SetRecordingRuleType(RecordingType type)
Definition: programinfo.h:566
QString m_recProfile
uint GetRecordingRuleID(void) const
Definition: programinfo.h:441
bool LoadFromScheduler(AutoDeleteDeque< TYPE * > &destination, bool &hasConflicts, QString altTable="", int recordid=-1)
Definition: programinfo.h:876
Default local time.
Definition: mythdate.h:20
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
ProgramRecPrioritySort(bool reverse)
QMap< int, int > m_nowMatch
MythUIText * m_recPriorityBText
int getRecordID(void)
Returns a record id, creating "record" it if necessary.
bool Load(bool asTemplate=false)
Load a single rule from the recorded table.
unsigned m_filter
QString m_category
Definition: recordingrule.h:86
void SetItemCurrent(MythUIButtonListItem *item)
QString m_subtitle
Definition: programinfo.h:738
Add year to string if not included.
Definition: mythdate.h:22
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
QString GetCategory(void) const
Definition: programinfo.h:361
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
void ApplyRecordRecPriorityChange(int)
Sets recording priority of "record", creating "record" if it does not exist.
void updateInfo(MythUIButtonListItem *item)
uint8_t m_rectype
Definition: programinfo.h:798
List::const_iterator const_iterator
void SetRecordingPriority(int priority)
Definition: programinfo.h:521
int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity)
void SetSearchFields(const QString &fields)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:37
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:132
void DisplayState(const QString &state, const QString &name)
void SetTextFromMap(const InfoMap &infoMap, const QString &state="")
void edit(MythUIButtonListItem *item)
ProgramCountSort(bool reverse)
void SetData(QVariant data)
ProgramLastRecordSort(bool reverse)
RecSearchType m_searchType
void SetSubtitle(const QString &st, const QString &sst=nullptr)
void SetValueByData(const QVariant &data)
MythUIButtonListItem * GetItemCurrent() const
void LoadInBackground(QString message="")
bool Create(void) override