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