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