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