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 "libmyth/remoteutil.h"
9 #include "libmythbase/mythdb.h"
11 #include "libmythbase/stringutil.h"
16 #include "libmythui/mythuihelper.h"
18 #include "libmythui/mythuitext.h"
19 
20 // MythFrontend
21 #include "proglist.h"
22 #include "programrecpriority.h"
23 #include "scheduleeditor.h"
24 
26  const ProgramRecPriorityInfo &other, bool ignore_non_serialized_data)
27 {
28  RecordingInfo::clone(other, ignore_non_serialized_data);
29 
30  if (!ignore_non_serialized_data)
31  {
32  m_recType = other.m_recType;
33  m_matchCount = other.m_matchCount;
34  m_recCount = other.m_recCount;
36  m_avg_delay = other.m_avg_delay;
37  m_profile = other.m_profile;
40  }
41 }
42 
44  const RecordingInfo &other, bool ignore_non_serialized_data)
45 {
46  RecordingInfo::clone(other, ignore_non_serialized_data);
47 
48  if (!ignore_non_serialized_data)
49  {
51  m_matchCount = 0;
52  m_recCount = 0;
53  m_last_record = QDateTime();
54  m_avg_delay = 0;
55  m_profile.clear();
56  m_storageGroup.clear();
57  m_recordingGroup.clear();
58  }
59 }
60 
62  const ProgramInfo &other, bool ignore_non_serialized_data)
63 {
64  RecordingInfo::clone(other, ignore_non_serialized_data);
65 
66  if (!ignore_non_serialized_data)
67  {
69  m_matchCount = 0;
70  m_recCount = 0;
71  m_last_record = QDateTime();
72  m_avg_delay = 0;
73  m_profile.clear();
74  m_storageGroup.clear();
75  m_recordingGroup.clear();
76  }
77 }
78 
80 {
82 
84  m_matchCount = 0;
85  m_recCount = 0;
86  m_last_record = QDateTime();
87  m_avg_delay = 0;
88  m_profile.clear();
89  m_storageGroup.clear();
90  m_recordingGroup.clear();
91 }
92 
94  bool showrerecord, uint star_range,
95  uint date_format) const
96 {
97  RecordingInfo::ToMap(progMap, showrerecord, star_range, date_format);
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  progMap["storagegroup"] = (m_storageGroup == "Default") ?
103  QObject::tr("Default") : m_storageGroup;
104  progMap["recordinggroup"] = (m_recordingGroup == "Default") ?
105  QObject::tr("Default") : m_recordingGroup;
106 }
107 
109 {
110  public:
111  explicit TitleSort(bool reverse) : m_reverse(reverse) {}
112 
114  const ProgramRecPriorityInfo *b) const
115  {
116  if (a->GetSortTitle() != b->GetSortTitle())
117  {
118  if (m_reverse)
121  }
122 
123  if (a->GetSortSubtitle() != b->GetSortSubtitle())
124  {
125  if (m_reverse)
128  }
129 
130  int finalA = a->GetRecordingPriority();
131  int finalB = b->GetRecordingPriority();
132 
133  if (finalA != finalB)
134  {
135  if (m_reverse)
136  return finalA < finalB;
137  return finalA > finalB;
138  }
139 
140  int typeA = RecTypePrecedence(a->m_recType);
141  int typeB = RecTypePrecedence(b->m_recType);
142 
143  if (typeA != typeB)
144  {
145  if (m_reverse)
146  return typeA > typeB;
147  return typeA < typeB;
148  }
149 
150  if (m_reverse)
151  return (a->GetRecordingRuleID() >
152  b->GetRecordingRuleID());
153  return (a->GetRecordingRuleID() <
154  b->GetRecordingRuleID());
155  }
156 
157  private:
158  bool m_reverse {false};
159 };
160 
162 {
163  public:
164  explicit ProgramRecPrioritySort(bool reverse) : m_reverse(reverse) {}
165 
167  const ProgramRecPriorityInfo *b) const
168  {
169  int finalA = a->GetRecordingPriority();
170  int finalB = b->GetRecordingPriority();
171 
172  if (finalA != finalB)
173  {
174  if (m_reverse)
175  return finalA < finalB;
176  return finalA > finalB;
177  }
178 
179  int typeA = RecTypePrecedence(a->m_recType);
180  int typeB = RecTypePrecedence(b->m_recType);
181 
182  if (typeA != typeB)
183  {
184  if (m_reverse)
185  return typeA > typeB;
186  return typeA < typeB;
187  }
188 
189  if (m_reverse)
190  return (a->GetRecordingRuleID() >
191  b->GetRecordingRuleID());
192  return (a->GetRecordingRuleID() <
193  b->GetRecordingRuleID());
194  }
195 
196  private:
197  bool m_reverse {false};
198 };
199 
201 {
202  public:
203  explicit ProgramRecTypeSort(bool reverse) : m_reverse(reverse) {}
204 
206  const ProgramRecPriorityInfo *b) const
207  {
208  int typeA = RecTypePrecedence(a->m_recType);
209  int typeB = RecTypePrecedence(b->m_recType);
210 
211  if (typeA != typeB)
212  {
213  if (m_reverse)
214  return (typeA > typeB);
215  return (typeA < typeB);
216  }
217 
218  int finalA = a->GetRecordingPriority();
219  int finalB = b->GetRecordingPriority();
220 
221  if (finalA != finalB)
222  {
223  if (m_reverse)
224  return finalA < finalB;
225  return finalA > finalB;
226  }
227 
228  if (m_reverse)
229  return (a->GetRecordingRuleID() >
230  b->GetRecordingRuleID());
231  return (a->GetRecordingRuleID() <
232  b->GetRecordingRuleID());
233  }
234 
235  private:
236  bool m_reverse {false};
237 };
238 
240 {
241  public:
242  explicit ProgramCountSort(bool reverse) : m_reverse(reverse) {}
243 
245  const ProgramRecPriorityInfo *b) const
246  {
247  int countA = a->m_matchCount;
248  int countB = b->m_matchCount;
249  int recCountA = a->m_recCount;
250  int recCountB = b->m_recCount;
251 
252  if (countA != countB)
253  {
254  if (m_reverse)
255  return countA < countB;
256  return countA > countB;
257  }
258 
259  if (recCountA != recCountB)
260  {
261  if (m_reverse)
262  return recCountA < recCountB;
263  return recCountA > recCountB;
264  }
265 
266  if (m_reverse)
267  {
268  if (a->GetSortTitle() != b->GetSortTitle())
271  }
272  if (a->GetSortTitle() != b->GetSortTitle())
275  }
276 
277  private:
278  bool m_reverse {false};
279 };
280 
282 {
283  public:
284  explicit ProgramRecCountSort(bool reverse) : m_reverse(reverse) {}
285 
287  const ProgramRecPriorityInfo *b) const
288  {
289  int countA = a->m_matchCount;
290  int countB = b->m_matchCount;
291  int recCountA = a->m_recCount;
292  int recCountB = b->m_recCount;
293 
294  if (recCountA != recCountB)
295  {
296  if (m_reverse)
297  return recCountA < recCountB;
298  return recCountA > recCountB;
299  }
300 
301  if (countA != countB)
302  {
303  if (m_reverse)
304  return countA < countB;
305  return countA > countB;
306  }
307 
308  if (m_reverse)
309  {
310  if (a->GetSortTitle() != b->GetSortTitle())
313  }
314  if (a->GetSortTitle() != b->GetSortTitle())
317  }
318 
319  private:
320  bool m_reverse {false};
321 };
322 
324 {
325  public:
326  explicit ProgramLastRecordSort(bool reverse) : m_reverse(reverse) {}
327 
329  const ProgramRecPriorityInfo *b) const
330  {
331  QDateTime lastRecA = a->m_last_record;
332  QDateTime lastRecB = b->m_last_record;
333 
334  if (lastRecA != lastRecB)
335  {
336  if (m_reverse)
337  return lastRecA < lastRecB;
338  return lastRecA > lastRecB;
339  }
340 
341  if (m_reverse)
342  {
343  if (a->GetSortTitle() != b->GetSortTitle())
346  }
347  if (a->GetSortTitle() != b->GetSortTitle())
350  }
351 
352  private:
353  bool m_reverse {false};
354 };
355 
357 {
358  public:
359  explicit ProgramAvgDelaySort(bool reverse) : m_reverse(reverse) {}
360 
362  const ProgramRecPriorityInfo *b) const
363  {
364  int avgA = a->m_avg_delay;
365  int avgB = b->m_avg_delay;
366 
367  if (avgA != avgB)
368  {
369  if (m_reverse)
370  return avgA > avgB;
371  return avgA < avgB;
372  }
373 
374  if (m_reverse)
375  {
376  if (a->GetSortTitle() != b->GetSortTitle())
379  }
380  if (a->GetSortTitle() != b->GetSortTitle())
383  }
384 
385  private:
386  bool m_reverse {false};
387 };
388 
390 
392  const QString &name)
393  : ScheduleCommon(parent, name)
394 {
395  m_sortType = (SortType)gCoreContext->GetNumSetting("ProgramRecPrioritySorting",
396  (int)byTitle);
397  m_reverseSort = gCoreContext->GetBoolSetting("ProgramRecPriorityReverse", false);
398 }
399 
401 {
402  if (!LoadWindowFromXML("schedule-ui.xml", "managerecrules", this))
403  return false;
404 
405  m_programList = dynamic_cast<MythUIButtonList *> (GetChild("programs"));
406 
407  m_schedInfoText = dynamic_cast<MythUIText *> (GetChild("scheduleinfo"));
408  m_recPriorityText = dynamic_cast<MythUIText *> (GetChild("recpriority"));
409  m_recPriorityBText = dynamic_cast<MythUIText *> (GetChild("recpriorityB"));
410  m_finalPriorityText = dynamic_cast<MythUIText *> (GetChild("finalpriority"));
411  m_lastRecordedText = dynamic_cast<MythUIText *> (GetChild("lastrecorded"));
412  m_lastRecordedDateText = dynamic_cast<MythUIText *> (GetChild("lastrecordeddate"));
413  m_lastRecordedTimeText = dynamic_cast<MythUIText *> (GetChild("lastrecordedtime"));
414  m_chanNameText = dynamic_cast<MythUIText *> (GetChild("channel"));
415  m_chanNumText = dynamic_cast<MythUIText *> (GetChild("channum"));
416  m_callSignText = dynamic_cast<MythUIText *> (GetChild("callsign"));
417  m_recProfileText = dynamic_cast<MythUIText *> (GetChild("recordingprofile"));
418 
419  if (!m_programList)
420  {
421  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
422  return false;
423  }
424 
428  this, &ProgramRecPriority::edit);
429 
430  m_programList->SetLCDTitles(tr("Schedule Priorities"),
431  "rec_type|titlesubtitle|progpriority");
432  m_programList->SetSearchFields("titlesubtitle");
433 
434  BuildFocusList();
436 
437  return true;
438 }
439 
441 {
442  FillList();
443 }
444 
446 {
447  SortList();
448 }
449 
450 bool ProgramRecPriority::keyPressEvent(QKeyEvent *event)
451 {
452  if (GetFocusWidget()->keyPressEvent(event))
453  return true;
454 
455  QStringList actions;
456  bool handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event, actions);
457 
458  for (int i = 0; i < actions.size() && !handled; i++)
459  {
460  QString action = actions[i];
461  handled = true;
462 
463  if (action == "RANKINC")
465  else if (action == "RANKDEC")
466  changeRecPriority(-1);
467  else if (action == "ESCAPE")
468  {
469  saveRecPriority();
470  gCoreContext->SaveSetting("ProgramRecPrioritySorting",
471  (int)m_sortType);
472  gCoreContext->SaveSetting("ProgramRecPriorityReverse",
473  (int)m_reverseSort);
474  Close();
475  }
476  else if (action == "1")
477  {
478  if (m_sortType != byTitle)
479  {
481  m_reverseSort = false;
482  }
483  else
485  SortList();
486  }
487  else if (action == "2")
488  {
489  if (m_sortType != byRecPriority)
490  {
492  m_reverseSort = false;
493  }
494  else
496  SortList();
497  }
498  else if (action == "4")
499  {
500  if (m_sortType != byRecType)
501  {
503  m_reverseSort = false;
504  }
505  else
507  SortList();
508  }
509  else if (action == "5")
510  {
511  if (m_sortType != byCount)
512  {
514  m_reverseSort = false;
515  }
516  else
517  {
519  }
520  SortList();
521  }
522  else if (action == "6")
523  {
524  if (m_sortType != byRecCount)
525  {
527  m_reverseSort = false;
528  }
529  else
531  SortList();
532  }
533  else if (action == "7")
534  {
535  if (m_sortType != byLastRecord)
536  {
538  m_reverseSort = false;
539  }
540  else
542  SortList();
543  }
544  else if (action == "8")
545  {
546  if (m_sortType != byAvgDelay)
547  {
549  m_reverseSort = false;
550  }
551  else
553  SortList();
554  }
555  else if (action == "PREVVIEW" || action == "NEXTVIEW")
556  {
557  m_reverseSort = false;
558  if (m_sortType == byTitle)
560  else if (m_sortType == byRecPriority)
562  else
564  SortList();
565  }
566  else if (action == "SELECT" || action == "EDIT")
567  {
568  saveRecPriority();
570  }
571  else if (action == "MENU")
572  {
573  showMenu();
574  }
575  else if (action == "CUSTOMEDIT")
576  {
577  saveRecPriority();
578  EditCustom();
579  }
580  else if (action == "DELETE")
581  {
582  saveRecPriority();
583  remove();
584  }
585  else if (action == "UPCOMING")
586  {
587  saveRecPriority();
588  ShowUpcoming();
589  }
590  else if (action == "INFO" || action == "DETAILS")
591  ShowDetails();
592  else
593  handled = false;
594  }
595 
596  if (!handled && MythScreenType::keyPressEvent(event))
597  handled = true;
598 
599  return handled;
600 }
601 
603 {
604  QString label = tr("Options");
605 
606  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
607  auto *menuPopup = new MythDialogBox(label, popupStack, "menuPopup");
608 
609  if (menuPopup->Create())
610  {
611  menuPopup->SetReturnEvent(this, "menu");
612 
613  menuPopup->AddButton(tr("Increase Priority"));
614  menuPopup->AddButton(tr("Decrease Priority"));
615  menuPopup->AddButton(tr("Sort"), nullptr, true);
616  menuPopup->AddButton(tr("Program Details"));
617  menuPopup->AddButton(tr("Upcoming"));
618  menuPopup->AddButton(tr("Custom Edit"));
619  menuPopup->AddButton(tr("Delete Rule"));
620  menuPopup->AddButton(tr("New Template"));
621 
622  popupStack->AddScreen(menuPopup);
623  }
624  else
625  {
626  delete menuPopup;
627  }
628 }
629 
631 {
632  QString label = tr("Sort Options");
633 
634  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
635  auto *menuPopup = new MythDialogBox(label, popupStack, "menuPopup");
636 
637  if (menuPopup->Create())
638  {
639  menuPopup->SetReturnEvent(this, "sortmenu");
640 
641  menuPopup->AddButton(tr("Reverse Sort Order"));
642  menuPopup->AddButton(tr("Sort By Title"));
643  menuPopup->AddButton(tr("Sort By Priority"));
644  menuPopup->AddButton(tr("Sort By Type"));
645  menuPopup->AddButton(tr("Sort By Count"));
646  menuPopup->AddButton(tr("Sort By Record Count"));
647  menuPopup->AddButton(tr("Sort By Last Recorded"));
648  menuPopup->AddButton(tr("Sort By Average Delay"));
649 
650  popupStack->AddScreen(menuPopup);
651  }
652  else
653  {
654  delete menuPopup;
655  }
656 }
657 
659 {
660  if (event->type() == DialogCompletionEvent::kEventType)
661  {
662  auto *dce = (DialogCompletionEvent*)(event);
663 
664  QString resultid = dce->GetId();
665  QString resulttext = dce->GetResultText();
666  int buttonnum = dce->GetResult();
667 
668  if (resultid == "menu")
669  {
670  if (resulttext == tr("Increase Priority"))
671  {
673  }
674  else if (resulttext == tr("Decrease Priority"))
675  {
676  changeRecPriority(-1);
677  }
678  else if (resulttext == tr("Sort"))
679  {
680  showSortMenu();
681  }
682  else if (resulttext == tr("Program Details"))
683  {
684  ShowDetails();
685  }
686  else if (resulttext == tr("Upcoming"))
687  {
688  saveRecPriority();
689  ShowUpcoming();
690  }
691  else if (resulttext == tr("Custom Edit"))
692  {
693  saveRecPriority();
694  EditCustom();
695  }
696  else if (resulttext == tr("Delete Rule"))
697  {
698  saveRecPriority();
699  remove();
700  }
701  else if (resulttext == tr("New Template"))
702  {
703  MythScreenStack *popupStack =
704  GetMythMainWindow()->GetStack("popup stack");
705  auto *textInput = new MythTextInputDialog(popupStack,
706  tr("Template Name"));
707  if (textInput->Create())
708  {
709  textInput->SetReturnEvent(this, "templatecat");
710  popupStack->AddScreen(textInput);
711  }
712  }
713  }
714  else if (resultid == "sortmenu")
715  {
716  if (resulttext == tr("Reverse Sort Order"))
717  {
719  SortList();
720  }
721  else if (resulttext == tr("Sort By Title"))
722  {
723  if (m_sortType != byTitle)
724  {
726  m_reverseSort = false;
727  }
728  else
730  SortList();
731  }
732  else if (resulttext == tr("Sort By Priority"))
733  {
734  if (m_sortType != byRecPriority)
735  {
737  m_reverseSort = false;
738  }
739  else
741  SortList();
742  }
743  else if (resulttext == tr("Sort By Type"))
744  {
745  if (m_sortType != byRecType)
746  {
748  m_reverseSort = false;
749  }
750  else
752  SortList();
753  }
754  else if (resulttext == tr("Sort By Count"))
755  {
756  if (m_sortType != byCount)
757  {
759  m_reverseSort = false;
760  }
761  else
762  {
764  }
765  SortList();
766  }
767  else if (resulttext == tr("Sort By Record Count"))
768  {
769  if (m_sortType != byRecCount)
770  {
772  m_reverseSort = false;
773  }
774  else
776  SortList();
777  }
778  else if (resulttext == tr("Sort By Last Recorded"))
779  {
780  if (m_sortType != byLastRecord)
781  {
783  m_reverseSort = false;
784  }
785  else
787  SortList();
788  }
789  else if (resulttext == tr("Sort By Average Delay"))
790  {
791  if (m_sortType != byAvgDelay)
792  {
794  m_reverseSort = false;
795  }
796  else
798  SortList();
799  }
800  }
801  else if (resultid == "deleterule")
802  {
803  auto *record = dce->GetData().value<RecordingRule *>();
804  if (record)
805  {
806  if (buttonnum > 0)
807  {
808  MythUIButtonListItem *item =
810 
811  if (record->Delete() && item)
812  RemoveItemFromList(item);
813  else
814  LOG(VB_GENERAL, LOG_ERR,
815  "Failed to delete recording rule");
816  }
817  delete record;
818  }
819  }
820  else if (resultid == "templatecat")
821  {
822  newTemplate(resulttext);
823  }
824  else
826  }
827 }
828 
830 {
831  if (!item)
832  return;
833 
834  auto *pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>();
835  if (!pgRecInfo)
836  return;
837 
838  auto *record = new RecordingRule();
839  record->m_recordID = pgRecInfo->GetRecordingRuleID();
840  if (record->m_searchType == kNoSearch)
841  record->LoadByProgram(pgRecInfo);
842 
844  auto *schededit = new ScheduleEditor(mainStack, record);
845  if (schededit->Create())
846  {
847  mainStack->AddScreen(schededit);
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(QVariant::fromValue(progInfo));
872  return;
873  }
874  }
875 
876  auto *record = new RecordingRule();
877  if (!record)
878  return;
879  record->MakeTemplate(category);
880 
882  auto *schededit = new ScheduleEditor(mainStack, record);
883  if (schededit->Create())
884  {
885  mainStack->AddScreen(schededit);
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  progInfo.m_storageGroup = record.m_storageGroup;
924 
925  m_programData[recid] = progInfo;
927  record.m_recPriority;
928  SortList(&m_programData[recid]);
929 
930  return;
931  }
932 
933  // We need to refetch the recording priority values since the Advanced
934  // Recording Options page could've been used to change them
935 
936  MSqlQuery query(MSqlQuery::InitCon());
937  query.prepare("SELECT recpriority, type, inactive "
938  "FROM record "
939  "WHERE recordid = :RECORDID");
940  query.bindValue(":RECORDID", recid);
941  if (!query.exec())
942  {
943  MythDB::DBError("Get new recording priority query", query);
944  }
945  else if (query.next())
946  {
947  int recPriority = query.value(0).toInt();
948  int rectype = query.value(1).toInt();
949  int inactive = query.value(2).toInt();
950 
951  // set the recording priorities of that program
952  pgRecInfo->SetRecordingPriority(recPriority);
953  pgRecInfo->m_recType = (RecordingType)rectype;
954  // also set the m_origRecPriorityData with new recording
955  // priority so we don't save to db again when we exit
957  pgRecInfo->GetRecordingPriority();
958  // also set the active/inactive state
959  pgRecInfo->m_recStatus = inactive ? RecStatus::Inactive : RecStatus::Unknown;
960 
961  SortList();
962  }
963  else
964  {
965  RemoveItemFromList(item);
966  }
967 
968  countMatches();
969 }
970 
972 {
974  if (!item)
975  return;
976 
977  auto *pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>();
978  if (!pgRecInfo ||
979  (pgRecInfo->m_recType == kTemplateRecord &&
980  pgRecInfo->GetCategory()
981  .compare("Default", Qt::CaseInsensitive) == 0))
982  {
983  return;
984  }
985 
986  auto *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?")
995  .arg(record->m_title, toString(pgRecInfo->GetRecordingRuleType()));
996 
997  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
998 
999  auto *okPopup = new MythConfirmationDialog(popupStack, message, true);
1000  okPopup->SetReturnEvent(this, "deleterule");
1001  okPopup->SetData(QVariant::fromValue(record));
1002 
1003  if (okPopup->Create())
1004  popupStack->AddScreen(okPopup);
1005  else
1006  delete okPopup;
1007 }
1008 
1010 {
1012  if (!item)
1013  return;
1014 
1015  auto *pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>();
1016  if (pgRecInfo)
1017  {
1018  MSqlQuery query(MSqlQuery::InitCon());
1019 
1020  query.prepare("SELECT inactive "
1021  "FROM record "
1022  "WHERE recordid = :RECID");
1023  query.bindValue(":RECID", pgRecInfo->GetRecordingRuleID());
1024 
1025 
1026  if (!query.exec())
1027  {
1028  MythDB::DBError("ProgramRecPriority::deactivate()", query);
1029  }
1030  else if (query.next())
1031  {
1032  int inactive = query.value(0).toInt();
1033  if (inactive)
1034  inactive = 0;
1035  else
1036  inactive = 1;
1037 
1038  query.prepare("UPDATE record "
1039  "SET inactive = :INACTIVE "
1040  "WHERE recordid = :RECID");
1041  query.bindValue(":INACTIVE", inactive);
1042  query.bindValue(":RECID", pgRecInfo->GetRecordingRuleID());
1043 
1044  if (!query.exec())
1045  {
1047  "Update recording schedule inactive query", query);
1048  }
1049  else
1050  {
1052  QString("DeactivateRule %1 %2")
1053  .arg(pgRecInfo->GetRecordingRuleID())
1054  .arg(pgRecInfo->GetTitle()));
1055  pgRecInfo->m_recStatus = inactive ? RecStatus::Inactive : RecStatus::Unknown;
1056  item->DisplayState("disabled", "status");
1057  }
1058  }
1059  }
1060 }
1061 
1063 {
1065  if (!item)
1066  return;
1067 
1068  auto *pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>();
1069  if (!pgRecInfo)
1070  return;
1071 
1072  // inc/dec recording priority
1073  int tempRecPriority = pgRecInfo->GetRecordingPriority() + howMuch;
1074  if (tempRecPriority > -100 && tempRecPriority < 100)
1075  {
1076  pgRecInfo->m_recPriority = tempRecPriority;
1077 
1078  // order may change if sorting by recording priority, so resort
1079  if (m_sortType == byRecPriority)
1080  SortList();
1081  else
1082  {
1083  // No need to re-fill the entire list, just update this entry
1084  int progRecPriority = pgRecInfo->GetRecordingPriority();
1085 
1086  item->SetText(QString::number(progRecPriority), "progpriority");
1087  item->SetText(QString::number(progRecPriority), "recpriority");
1088  if (m_recPriorityText)
1089  m_recPriorityText->SetText(QString::number(progRecPriority));
1090 
1091  item->SetText(QString::number(progRecPriority), "recpriorityB");
1092  if (m_recPriorityBText)
1093  m_recPriorityBText->SetText(QString::number(progRecPriority));
1094 
1095  item->SetText(QString::number(progRecPriority), "finalpriority");
1096  if (m_finalPriorityText)
1097  m_finalPriorityText->SetText(QString::number(progRecPriority));
1098  }
1099  }
1100 }
1101 
1103 {
1104  QMap<int, ProgramRecPriorityInfo>::Iterator it;
1105 
1106  for (it = m_programData.begin(); it != m_programData.end(); ++it)
1107  {
1108  ProgramRecPriorityInfo *progInfo = &(*it);
1109  int key = progInfo->GetRecordingRuleID();
1110 
1111  // if this program's recording priority changed from when we entered
1112  // save new value out to db
1113  if (progInfo->GetRecordingPriority() != m_origRecPriorityData[key])
1114  progInfo->ApplyRecordRecPriorityChange(
1115  progInfo->GetRecordingPriority());
1116  }
1117 }
1118 
1120 {
1121  std::vector<ProgramInfo *> recordinglist;
1122 
1123  m_programData.clear();
1124 
1125  RemoteGetAllScheduledRecordings(recordinglist);
1126 
1127  for (auto & pgiter : recordinglist)
1128  {
1129  ProgramInfo *progInfo = pgiter;
1130  m_programData[pgiter->GetRecordingRuleID()] =
1131  (*progInfo);
1132 
1133  // save recording priority value in map so we don't have to
1134  // save all program's recording priority values when we exit
1135  m_origRecPriorityData[pgiter->GetRecordingRuleID()] =
1136  pgiter->GetRecordingPriority();
1137 
1138  delete pgiter;
1139  }
1140 
1141  // get recording types associated with each program from db
1142  // (hope this is ok to do here, it's so much lighter doing
1143  // it all at once than once per program)
1144 
1145  MSqlQuery result(MSqlQuery::InitCon());
1146  result.prepare("SELECT recordid, title, chanid, starttime, startdate, "
1147  "type, inactive, last_record, avg_delay, profile, "
1148  "recgroup, storagegroup "
1149  "FROM record;");
1150 
1151  if (!result.exec())
1152  {
1153  MythDB::DBError("Get program recording priorities query", result);
1154  }
1155  else if (result.next())
1156  {
1157  countMatches();
1158  do {
1159  uint recordid = result.value(0).toUInt();
1160 // QString title = result.value(1).toString();
1161 // QString chanid = result.value(2).toString();
1162 // QString tempTime = result.value(3).toString();
1163 // QString tempDate = result.value(4).toString();
1164  RecordingType recType = (RecordingType)result.value(5).toInt();
1165  int inactive = result.value(6).toInt();
1166  QDateTime lastrec = MythDate::as_utc(result.value(7).toDateTime());
1167  int avgd = result.value(8).toInt();
1168  QString profile = result.value(9).toString();
1169  QString recordingGroup = result.value(10).toString();
1170  QString storageGroup = result.value(11).toString();
1171 
1172  // find matching program in m_programData and set
1173  // recType
1174  QMap<int, ProgramRecPriorityInfo>::Iterator it;
1175  it = m_programData.find(recordid);
1176  if (it != m_programData.end())
1177  {
1178  ProgramRecPriorityInfo *progInfo = &(*it);
1179 
1180  progInfo->m_recType = recType;
1181  progInfo->m_matchCount =
1182  m_listMatch[progInfo->GetRecordingRuleID()];
1183  progInfo->m_recCount =
1184  m_recMatch[progInfo->GetRecordingRuleID()];
1185  progInfo->m_last_record = lastrec;
1186  progInfo->m_avg_delay = avgd;
1187  progInfo->m_profile = profile;
1188  progInfo->m_recordingGroup = recordingGroup;
1189  progInfo->m_storageGroup = storageGroup;
1190 
1191  if (inactive)
1192  progInfo->m_recStatus = RecStatus::Inactive;
1193  else if (m_conMatch[progInfo->GetRecordingRuleID()] > 0)
1194  progInfo->m_recStatus = RecStatus::Conflict;
1195  else if (m_nowMatch[progInfo->GetRecordingRuleID()] > 0)
1196  progInfo->m_recStatus = RecStatus::Recording;
1197  else if (m_recMatch[progInfo->GetRecordingRuleID()] > 0)
1198  progInfo->m_recStatus = RecStatus::WillRecord;
1199  else
1200  progInfo->m_recStatus = RecStatus::Unknown;
1201  }
1202  } while (result.next());
1203  }
1204 }
1205 
1207 {
1208  m_listMatch.clear();
1209  m_conMatch.clear();
1210  m_nowMatch.clear();
1211  m_recMatch.clear();
1212  ProgramList schedList;
1213  LoadFromScheduler(schedList);
1214  QDateTime now = MythDate::current();
1215 
1216  for (auto *program : schedList)
1217  {
1218  const RecStatus::Type recstatus = (*program).GetRecordingStatus();
1219  const uint recordid = (*program).GetRecordingRuleID();
1220  if ((*program).GetRecordingEndTime() > now && recstatus != RecStatus::NotListed)
1221  {
1222  m_listMatch[recordid]++;
1223  if (recstatus == RecStatus::Conflict || recstatus == RecStatus::Offline)
1224  m_conMatch[recordid]++;
1225  else if (recstatus == RecStatus::WillRecord)
1226  m_recMatch[recordid]++;
1227  else if (recstatus == RecStatus::Recording)
1228  {
1229  m_nowMatch[recordid]++;
1230  m_recMatch[recordid]++;
1231  }
1232  }
1233  }
1234 }
1235 
1237 {
1238  if (newCurrentItem)
1239  m_currentItem = newCurrentItem;
1240  else
1241  {
1243  if (item)
1244  m_currentItem =
1245  item->GetData().value<ProgramRecPriorityInfo*>();
1246  }
1247 
1248  QMap<int, ProgramRecPriorityInfo>::Iterator pit;
1249 
1250  // copy m_programData into m_sortedProgram
1251  m_sortedProgram.clear();
1252  for (pit = m_programData.begin(); pit != m_programData.end(); ++pit)
1253  {
1254  ProgramRecPriorityInfo *progInfo = &(*pit);
1255  m_sortedProgram.push_back(progInfo);
1256  }
1257 
1258  // sort m_sortedProgram
1259  switch (m_sortType)
1260  {
1261  case byTitle :
1262  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1264  break;
1265  case byRecPriority :
1266  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1268  break;
1269  case byRecType :
1270  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1272  break;
1273  case byCount :
1274  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1276  break;
1277  case byRecCount :
1278  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1280  break;
1281  case byLastRecord :
1282  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1284  break;
1285  case byAvgDelay :
1286  sort(m_sortedProgram.begin(), m_sortedProgram.end(),
1288  break;
1289  }
1290 
1291  UpdateList();
1292 }
1293 
1295 {
1296  if (!m_currentItem && !m_programList->IsEmpty())
1298  .value<ProgramRecPriorityInfo*>();
1299 
1300  m_programList->Reset();
1301 
1302  std::vector<ProgramRecPriorityInfo*>::iterator it;
1303  for (it = m_sortedProgram.begin(); it != m_sortedProgram.end(); ++it)
1304  {
1305  ProgramRecPriorityInfo *progInfo = *it;
1306 
1307  auto *item = new MythUIButtonListItem(m_programList, "",
1308  QVariant::fromValue(progInfo));
1309 
1310  int progRecPriority = progInfo->GetRecordingPriority();
1311 
1312  if ((progInfo->m_recType == kSingleRecord ||
1313  progInfo->m_recType == kOverrideRecord ||
1314  progInfo->m_recType == kDontRecord) &&
1315  !(progInfo->GetSubtitle()).trimmed().isEmpty())
1316  {
1317  QString rating = QString::number(progInfo->GetStars(10));
1318 
1319  item->DisplayState(rating, "ratingstate");
1320  }
1321  else
1322  progInfo->m_subtitle.clear();
1323 
1324  QString state;
1325  if (progInfo->m_recType == kDontRecord ||
1326  (progInfo->m_recType != kTemplateRecord &&
1327  progInfo->m_recStatus == RecStatus::Inactive))
1328  state = "disabled";
1329  else if (m_conMatch[progInfo->GetRecordingRuleID()] > 0)
1330  state = "error";
1331  else if (m_recMatch[progInfo->GetRecordingRuleID()] > 0 ||
1332  progInfo->m_recType == kTemplateRecord)
1333  state = "normal";
1334  else if (m_nowMatch[progInfo->GetRecordingRuleID()] > 0)
1335  state = "running";
1336  else
1337  state = "warning";
1338 
1339  InfoMap infoMap;
1340  progInfo->ToMap(infoMap);
1341  item->SetTextFromMap(infoMap, state);
1342 
1343  QString subtitle;
1344  if (progInfo->m_subtitle != "(null)" &&
1345  (progInfo->m_recType == kSingleRecord ||
1346  progInfo->m_recType == kOverrideRecord ||
1347  progInfo->m_recType == kDontRecord))
1348  {
1349  subtitle = progInfo->m_subtitle;
1350  }
1351 
1352  QString matchInfo;
1353  if (progInfo->GetRecordingStatus() == RecStatus::Inactive)
1354  {
1355  matchInfo = QString("%1 %2")
1356  .arg(m_listMatch[progInfo->GetRecordingRuleID()])
1357  .arg(RecStatus::toString(progInfo->GetRecordingStatus(),
1358  progInfo->GetRecordingRuleType()));
1359  }
1360  else
1361  {
1362  matchInfo = tr("Recording %1 of %2")
1363  .arg(m_recMatch[progInfo->GetRecordingRuleID()])
1364  .arg(m_listMatch[progInfo->GetRecordingRuleID()]);
1365  }
1366 
1367  subtitle = QString("(%1) %2").arg(matchInfo, subtitle);
1368  item->SetText(subtitle, "scheduleinfo", state);
1369 
1370  item->SetText(QString::number(progRecPriority), "progpriority", state);
1371  item->SetText(QString::number(progRecPriority), "finalpriority", state);
1372 
1373  item->SetText(QString::number(progRecPriority), "recpriority", state);
1374  item->SetText(QString::number(progRecPriority), "recpriorityB", state);
1375 
1376  QString tempDateTime = MythDate::toString(progInfo->m_last_record,
1379  item->SetText(tempDateTime, "lastrecorded", state);
1380  QString tempDate = MythDate::toString(progInfo->m_last_record,
1383  item->SetText(tempDate, "lastrecordeddate", state);
1384  QString tempTime = MythDate::toString(
1385  progInfo->m_last_record, MythDate::kTime);
1386  item->SetText(tempTime, "lastrecordedtime", state);
1387 
1388  QString channame = progInfo->m_chanName;
1389  QString channum = progInfo->m_chanStr;
1390  QString callsign = progInfo->m_chanSign;
1391  if (progInfo->m_recType != kSingleRecord &&
1392  progInfo->m_recType != kOverrideRecord &&
1393  progInfo->m_recType != kDontRecord &&
1394  !(progInfo->GetRecordingRule()->m_filter & 1024) &&
1396  {
1397  channame = tr("Any");
1398  channum = tr("Any");
1399  callsign = tr("Any");
1400  }
1401  item->SetText(channame, "channel", state);
1402  item->SetText(channum, "channum", state);
1403  item->SetText(callsign, "callsign", state);
1404 
1405  QString profile = progInfo->m_profile;
1406  if ((profile == "Default") || (profile == "Live TV") ||
1407  (profile == "High Quality") || (profile == "Low Quality"))
1408  profile = tr(profile.toUtf8().constData());
1409  item->SetText(profile, "recordingprofile", state);
1410  item->SetText(progInfo->m_recordingGroup, "recordinggroup", state);
1411  item->SetText(progInfo->m_storageGroup, "storagegroup", state);
1412  item->DisplayState(state, "status");
1413 
1414  if (m_currentItem == progInfo)
1416  }
1417 
1418  m_currentItem = nullptr;
1419 
1420  MythUIText *norecordingText = dynamic_cast<MythUIText*>
1421  (GetChild("norecordings_info"));
1422 
1423  if (norecordingText)
1424  norecordingText->SetVisible(m_programData.isEmpty());
1425 }
1426 
1427 // Called whenever a new recording is selected from the list of
1428 // recordings. This function updates the screen with the information
1429 // on the newly selected recording.
1431 {
1432  if (!item)
1433  return;
1434 
1435  auto *pgRecInfo = item->GetData().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  {
1461  matchInfo = tr("Recording %1 of %2")
1462  .arg(m_recMatch[pgRecInfo->GetRecordingRuleID()])
1463  .arg(m_listMatch[pgRecInfo->GetRecordingRuleID()]);
1464  }
1465 
1466  subtitle = QString("(%1) %2").arg(matchInfo, subtitle);
1467 
1468  InfoMap infoMap;
1469  pgRecInfo->ToMap(infoMap);
1470  SetTextFromMap(infoMap);
1471 
1472  if (m_schedInfoText)
1473  m_schedInfoText->SetText(subtitle);
1474 
1475  if (m_recPriorityText)
1476  m_recPriorityText->SetText(QString::number(progRecPriority));
1477 
1478  if (m_recPriorityBText)
1479  m_recPriorityBText->SetText(QString::number(progRecPriority));
1480 
1481  if (m_finalPriorityText)
1482  m_finalPriorityText->SetText(QString::number(progRecPriority));
1483 
1484  if (m_lastRecordedText)
1485  {
1486  QString tempDateTime = MythDate::toString(pgRecInfo->m_last_record,
1489  m_lastRecordedText->SetText(tempDateTime);
1490  }
1491 
1493  {
1494  QString tempDate = MythDate::toString(pgRecInfo->m_last_record,
1497  m_lastRecordedDateText->SetText(tempDate);
1498  }
1499 
1501  {
1502  QString tempTime = MythDate::toString(
1503  pgRecInfo->m_last_record, MythDate::kTime);
1504  m_lastRecordedTimeText->SetText(tempTime);
1505  }
1506 
1508  {
1509  QString channame = pgRecInfo->m_chanName;
1510  QString channum = pgRecInfo->m_chanStr;
1511  QString callsign = pgRecInfo->m_chanSign;
1512  if (pgRecInfo->m_recType != kSingleRecord &&
1513  pgRecInfo->m_recType != kOverrideRecord &&
1514  pgRecInfo->m_recType != kDontRecord &&
1515  !(pgRecInfo->GetRecordingRule()->m_filter & 1024) &&
1516  pgRecInfo->GetRecordingRule()->m_searchType != kManualSearch)
1517  {
1518  channame = tr("Any");
1519  channum = tr("Any");
1520  callsign = tr("Any");
1521  }
1522  if (m_chanNameText)
1523  m_chanNameText->SetText(channame);
1524  if (m_chanNumText)
1525  m_chanNumText->SetText(channum);
1526  if (m_callSignText)
1527  m_callSignText->SetText(callsign);
1528  }
1529 
1530  if (m_recProfileText)
1531  {
1532  QString profile = pgRecInfo->m_profile;
1533  if ((profile == "Default") || (profile == "Live TV") ||
1534  (profile == "High Quality") || (profile == "Low Quality"))
1535  profile = tr(profile.toUtf8().constData());
1537  }
1538 }
1539 
1541 {
1542  if (!item)
1543  return;
1544 
1545  auto *pgRecInfo = item->GetData().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: */
scheduleeditor.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:807
RecStatus::Type
Type
Definition: recStatus.h:16
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:315
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:85
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:765
LoadFromScheduler
bool LoadFromScheduler(AutoDeleteDeque< TYPE * > &destination, bool &hasConflicts, const QString &altTable="", int recordid=-1)
Definition: programinfo.h:913
ProgramRecPriority::m_finalPriorityText
MythUIText * m_finalPriorityText
Definition: programrecpriority.h:126
ProgramRecPriorityInfo::clear
void clear(void) override
Definition: programrecpriority.cpp:79
mythdb.h
RecordingRule::m_category
QString m_category
Definition: recordingrule.h:80
MythUIButtonListItem::DisplayState
void DisplayState(const QString &state, const QString &name)
Definition: mythuibuttonlist.cpp:3563
ProgramRecPriority::Create
bool Create(void) override
Definition: programrecpriority.cpp:400
ProgramInfo::SetCategory
void SetCategory(const QString &cat)
Definition: programinfo.h:536
MythDate::as_utc
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:28
ProgramRecPriorityInfo::m_matchCount
int m_matchCount
Definition: programrecpriority.h:55
ProgramRecPriority::updateInfo
void updateInfo(MythUIButtonListItem *item)
Definition: programrecpriority.cpp:1430
ProgramRecPriority::UpdateList
void UpdateList()
Definition: programrecpriority.cpp:1294
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:386
ScheduleCommon::customEvent
void customEvent(QEvent *event) override
Definition: schedulecommon.cpp:480
ProgramRecPrioritySort::ProgramRecPrioritySort
ProgramRecPrioritySort(bool reverse)
Definition: programrecpriority.cpp:164
ProgramRecCountSort
Definition: programrecpriority.cpp:281
ProgramRecPriority::m_currentItem
ProgramRecPriorityInfo * m_currentItem
Definition: programrecpriority.h:135
ProgramRecPriority::GetCurrentProgram
ProgramInfo * GetCurrentProgram(void) const override
Definition: programrecpriority.cpp:1558
ProgramCountSort::operator()
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Definition: programrecpriority.cpp:244
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:135
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:1102
ProgramRecTypeSort::ProgramRecTypeSort
ProgramRecTypeSort(bool reverse)
Definition: programrecpriority.cpp:203
ProgramRecPriority::byRecType
@ byRecType
Definition: programrecpriority.h:79
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
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:75
RecordingRule::m_sortSubtitle
QString m_sortSubtitle
Definition: recordingrule.h:78
mythdialogbox.h
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:202
MythScreenStack
Definition: mythscreenstack.h:16
ProgramInfo::GetCategory
QString GetCategory(void) const
Definition: programinfo.h:369
ProgramRecPrioritySort
Definition: programrecpriority.cpp:161
RecStatus::Unknown
@ Unknown
Definition: recStatus.h:32
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:28
ProgramCountSort::ProgramCountSort
ProgramCountSort(bool reverse)
Definition: programrecpriority.cpp:242
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:608
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:440
ProgramRecPriority::changeRecPriority
void changeRecPriority(int howMuch)
Definition: programrecpriority.cpp:1062
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
mythuistatetype.h
ProgramRecPriority::showSortMenu
void showSortMenu(void)
Definition: programrecpriority.cpp:630
ProgramRecPriority::deactivate
void deactivate()
Definition: programrecpriority.cpp:1009
ProgramRecPriority::showMenu
void showMenu(void)
Definition: programrecpriority.cpp:602
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:72
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:888
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:15
TitleSort::operator()
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Definition: programrecpriority.cpp:113
proglist.h
ProgramRecPriority::SortType
SortType
Definition: programrecpriority.h:75
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:113
ProgramRecPrioritySort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:197
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: recStatus.h:31
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:1159
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:29
MythUIButtonList::IsEmpty
bool IsEmpty() const
Definition: mythuibuttonlist.cpp:1668
ProgramInfo::m_chanName
QString m_chanName
Definition: programinfo.h:782
ProgramRecCountSort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:320
ProgramRecPriority::newTemplate
void newTemplate(QString category)
Definition: programrecpriority.cpp:855
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:391
ProgramRecPriority::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: programrecpriority.cpp:450
ProgramRecTypeSort
Definition: programrecpriority.cpp:200
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:1104
ProgramInfo::m_category
QString m_category
Definition: programinfo.h:774
ProgramRecPriority::byRecPriority
@ byRecPriority
Definition: programrecpriority.h:78
ProgramRecPriority::byCount
@ byCount
Definition: programrecpriority.h:80
ProgramInfo::SetRecordingRuleType
void SetRecordingRuleType(RecordingType type)
Definition: programinfo.h:583
kTemplateRecord
@ kTemplateRecord
Definition: recordingtypes.h:32
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:1658
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:540
ScheduleEditor::ruleDeleted
void ruleDeleted(int ruleId)
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:227
ProgramRecPriority::m_listMatch
QMap< int, int > m_listMatch
Definition: programrecpriority.h:119
ProgramAvgDelaySort
Definition: programrecpriority.cpp:356
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:153
RecordingRule::m_lastRecorded
QDateTime m_lastRecorded
Definition: recordingrule.h:141
RecordingRule::m_recProfile
QString m_recProfile
Definition: recordingrule.h:118
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:93
TitleSort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:158
ProgramRecPriorityInfo::m_recType
RecordingType m_recType
Definition: programrecpriority.h:54
RecordingRule::m_searchType
RecSearchType m_searchType
Definition: recordingrule.h:110
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:109
RecStatus::Conflict
@ Conflict
Definition: recStatus.h:39
ProgramLastRecordSort::ProgramLastRecordSort
ProgramLastRecordSort(bool reverse)
Definition: programrecpriority.cpp:326
ProgramInfo::SetRecordingPriority
void SetRecordingPriority(int priority)
Definition: programinfo.h:538
RecordingRule::m_subtitle
QString m_subtitle
Definition: recordingrule.h:77
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:1556
scheduledrecording.h
ProgramAvgDelaySort::ProgramAvgDelaySort
ProgramAvgDelaySort(bool reverse)
Definition: programrecpriority.cpp:359
ProgramInfo::SetTitle
void SetTitle(const QString &t, const QString &st=nullptr)
Definition: programinfo.cpp:1152
ProgramLastRecordSort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:353
MythUIButtonList::SetLCDTitles
void SetLCDTitles(const QString &title, const QString &columnList="")
Definition: mythuibuttonlist.cpp:3034
kNoSearch
@ kNoSearch
Definition: recordingtypes.h:73
RecordingRule::m_filter
unsigned m_filter
Definition: recordingrule.h:113
ProgramRecPriority::m_callSignText
MythUIText * m_callSignText
Definition: programrecpriority.h:132
ProgramRecPriority::FillList
void FillList(void)
Definition: programrecpriority.cpp:1119
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3665
kManualSearch
@ kManualSearch
Definition: recordingtypes.h:78
uint
unsigned int uint
Definition: compat.h:79
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:61
ProgramRecPriority::customEvent
void customEvent(QEvent *event) override
Definition: programrecpriority.cpp:658
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:935
ProgramRecPriority::m_schedInfoText
MythUIText * m_schedInfoText
Definition: programrecpriority.h:123
TitleSort::TitleSort
TitleSort(bool reverse)
Definition: programrecpriority.cpp:111
ProgramInfo::m_recStatus
int8_t m_recStatus
Definition: programinfo.h:827
RecStatus::Offline
@ Offline
Definition: recStatus.h:44
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:1206
RecordingRule::m_sortTitle
QString m_sortTitle
Definition: recordingrule.h:76
ProgramRecPriority::m_sortedProgram
std::vector< ProgramRecPriorityInfo * > m_sortedProgram
Definition: programrecpriority.h:112
ProgramRecPriority::RemoveItemFromList
void RemoveItemFromList(MythUIButtonListItem *item)
Definition: programrecpriority.cpp:1540
RecordingRule::m_recGroupID
uint m_recGroupID
Definition: recordingrule.h:121
MythDate::kSimplify
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:26
ProgramRecPriority::scheduleChanged
void scheduleChanged(int recid)
Definition: programrecpriority.cpp:893
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:929
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:594
RecordingRule::m_storageGroup
QString m_storageGroup
Definition: recordingrule.h:119
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:68
RecStatus::Recording
@ Recording
Definition: recStatus.h:30
ProgramRecPriority::SortList
void SortList(ProgramRecPriorityInfo *newCurrentItem=nullptr)
Definition: programrecpriority.cpp:1236
ProgramInfo::m_subtitle
QString m_subtitle
Definition: programinfo.h:767
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: recStatus.h:42
ProgramAvgDelaySort::operator()
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Definition: programrecpriority.cpp:361
ProgramRecPriorityInfo::m_recordingGroup
QString m_recordingGroup
Definition: programrecpriority.h:60
ProgramRecTypeSort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:236
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:695
kOverrideRecord
@ kOverrideRecord
Definition: recordingtypes.h:28
RemoteGetAllScheduledRecordings
void RemoteGetAllScheduledRecordings(std::vector< ProgramInfo * > &scheduledlist)
Definition: remoteutil.cpp:163
kNotRecording
@ kNotRecording
Definition: recordingtypes.h:21
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:883
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:22
ProgramInfo::m_chanSign
QString m_chanSign
Definition: programinfo.h:781
RecStatus::NotListed
@ NotListed
Definition: recStatus.h:38
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:1110
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:166
ProgramInfo::m_chanStr
QString m_chanStr
Definition: programinfo.h:780
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:239
ProgramAvgDelaySort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:386
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:102
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:320
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:323
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:445
ProgramInfo::SetRecordingRuleID
void SetRecordingRuleID(uint id)
Definition: programinfo.h:540
MythDate::kDateTimeFull
@ kDateTimeFull
Default local time.
Definition: mythdate.h:23
RecStatus::toString
static QString toString(Type recstatus, uint id)
Converts "recstatus" into a short (unreadable) string.
Definition: recStatus.cpp:39
ProgramLastRecordSort::operator()
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Definition: programrecpriority.cpp:328
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:904
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:879
ProgramInfo::GetRecordingRuleID
uint GetRecordingRuleID(void) const
Definition: programinfo.h:449
ProgramRecPriority::edit
void edit(MythUIButtonListItem *item) const
Definition: programrecpriority.cpp:829
ProgramRecCountSort::ProgramRecCountSort
ProgramRecCountSort(bool reverse)
Definition: programrecpriority.cpp:284
TitleSort
Definition: programrecpriority.cpp:108
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:105
ProgramRecTypeSort::operator()
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Definition: programrecpriority.cpp:205
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:50
ScheduleEditor
Construct a recording schedule.
Definition: scheduleeditor.h:143
ProgramRecPriority::m_lastRecordedDateText
MythUIText * m_lastRecordedDateText
Definition: programrecpriority.h:128
RecordingType
RecordingType
Definition: recordingtypes.h:19
ProgramRecPriorityInfo::clone
virtual void clone(const ProgramRecPriorityInfo &other, bool ignore_non_serialized_data=false)
Definition: programrecpriority.cpp:25
ProgramRecPriority::remove
void remove()
Definition: programrecpriority.cpp:971
kDontRecord
@ kDontRecord
Definition: recordingtypes.h:29
ProgramRecCountSort::operator()
bool operator()(const ProgramRecPriorityInfo *a, const ProgramRecPriorityInfo *b) const
Definition: programrecpriority.cpp:286
ProgramRecPriority::m_nowMatch
QMap< int, int > m_nowMatch
Definition: programrecpriority.h:117
ProgramCountSort::m_reverse
bool m_reverse
Definition: programrecpriority.cpp:278
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:832
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