MythTV  master
channeleditor.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QCoreApplication>
3 
4 // MythTV
5 #include "mythcorecontext.h"
6 #include "mythprogressdialog.h"
7 #include "mythuibuttonlist.h"
8 #include "channelsettings.h"
9 #include "transporteditor.h"
10 #include "restoredata.h"
11 #include "mythuicheckbox.h"
12 #include "mythuitextedit.h"
13 #include "channeleditor.h"
14 #include "mythdialogbox.h"
15 #include "mythuibutton.h"
16 #include "channelutil.h"
17 #include "importicons.h"
18 #include "mythlogging.h"
19 #include "mythuiimage.h"
20 #include "mythuitext.h"
21 #include "scanwizard.h"
22 #include "sourceutil.h"
23 #include "cardutil.h"
24 #include "mythdirs.h"
25 #include "mythdb.h"
26 
27 #define LOC QString("ChannelEditor: ")
28 
29 ChannelWizard::ChannelWizard(int id, int default_sourceid)
30 {
31  setLabel(tr("Channel Options"));
32 
33  // Must be first.
34  addChild(m_cid = new ChannelID());
35  m_cid->setValue(id);
36 
37  QStringList cardtypes = ChannelUtil::GetInputTypes(m_cid->getValue().toUInt());
38 
39  // For a new channel the list will be empty so get it this way.
40  if (cardtypes.empty())
41  cardtypes = CardUtil::GetInputTypeNames(default_sourceid);
42 
43  bool all_v4l = !cardtypes.empty();
44  bool all_asi = !cardtypes.empty();
45  for (const QString& cardtype : qAsConst(cardtypes))
46  {
47  all_v4l &= CardUtil::IsV4L(cardtype);
48  all_asi &= cardtype == "ASI";
49  }
50 
51  auto *common = new ChannelOptionsCommon(*m_cid, default_sourceid,!all_v4l);
53 
54  auto *filters = new ChannelOptionsFilters(*m_cid);
55  addChild(filters);
56 
57  if (all_v4l)
59  else if (all_asi)
61 }
62 
64 
66  : MythScreenType(parent, "channeleditor"),
67  m_currentSortMode(QCoreApplication::translate("(Common)", "Channel Number"))
68 {
69 }
70 
72 {
73  // Load the theme for this screen
74  bool foundtheme = LoadWindowFromXML("config-ui.xml", "channeloverview", this);
75  if (!foundtheme)
76  return false;
77 
78  MythUIButtonList *sortList = dynamic_cast<MythUIButtonList *>(GetChild("sorting"));
79  m_sourceList = dynamic_cast<MythUIButtonList *>(GetChild("source"));
80  m_channelList = dynamic_cast<MythUIButtonList *>(GetChild("channels"));
81  m_preview = dynamic_cast<MythUIImage *>(GetChild("preview"));
82  m_channame = dynamic_cast<MythUIText *>(GetChild("name"));
83  m_channum = dynamic_cast<MythUIText *>(GetChild("channum"));
84  m_callsign = dynamic_cast<MythUIText *>(GetChild("callsign"));
85  m_chanid = dynamic_cast<MythUIText *>(GetChild("chanid"));
86  m_sourcename = dynamic_cast<MythUIText *>(GetChild("sourcename"));
87  m_frequency = dynamic_cast<MythUIText *>(GetChild("frequency"));
88  m_transportid = dynamic_cast<MythUIText *>(GetChild("transportid"));
89  m_compoundname = dynamic_cast<MythUIText *>(GetChild("compoundname"));
90 
91  MythUIButton *deleteButton = dynamic_cast<MythUIButton *>(GetChild("delete"));
92  MythUIButton *scanButton = dynamic_cast<MythUIButton *>(GetChild("scan"));
93  MythUIButton *restoreDataButton = dynamic_cast<MythUIButton *>(GetChild("restoredata"));
94  MythUIButton *importIconButton = dynamic_cast<MythUIButton *>(GetChild("importicons"));
95  MythUIButton *transportEditorButton = dynamic_cast<MythUIButton *>(GetChild("edittransport"));
96 
97  MythUICheckBox *hideCheck = dynamic_cast<MythUICheckBox *>(GetChild("nochannum"));
98 
99  if (!sortList || !m_sourceList || !m_channelList || !deleteButton ||
100  !scanButton || !importIconButton || !transportEditorButton ||
101  !hideCheck)
102  {
103  LOG(VB_GENERAL, LOG_ERR, LOC + "One or more buttons not found in theme.");
104  return false;
105  }
106 
107  // Delete button help text
108  deleteButton->SetHelpText(tr("Delete all channels on currently selected video source."));
109 
110  // Sort List
111  new MythUIButtonListItem(sortList, tr("Channel Number"));
112  new MythUIButtonListItem(sortList, tr("Channel Name"));
113  new MythUIButtonListItem(sortList, tr("Service ID"));
114  new MythUIButtonListItem(sortList, tr("Frequency"));
115  new MythUIButtonListItem(sortList, tr("Transport ID"));
116  new MythUIButtonListItem(sortList, tr("Video Source"));
119  sortList->SetValue(m_currentSortMode);
120 
121  // Source List
122  new MythUIButtonListItem(m_sourceList,tr("All"),
123  QVariant::fromValue((int)FILTER_ALL));
124  MSqlQuery query(MSqlQuery::InitCon());
125  query.prepare("SELECT name, sourceid FROM videosource");
126  if (query.exec())
127  {
128  while(query.next())
129  {
130  new MythUIButtonListItem(m_sourceList, query.value(0).toString(),
131  query.value(1).toInt());
132  }
133  }
134  new MythUIButtonListItem(m_sourceList,tr("(Unassigned)"),
135  QVariant::fromValue((int)FILTER_UNASSIGNED));
136  connect(sortList, &MythUIButtonList::itemSelected,
138 
139  // Hide/Show channels without channum checkbox
140  hideCheck->SetCheckState(m_currentHideMode);
141  connect(hideCheck, &MythUICheckBox::toggled,
143 
144  // Scan Button
145  scanButton->SetHelpText(tr("Starts the channel scanner."));
147 
148  // Restore Data button
149  if (restoreDataButton)
150  {
151  restoreDataButton->SetHelpText(tr("Restore Data from deleted channels."));
152  restoreDataButton->SetEnabled(true);
153  connect(restoreDataButton, &MythUIButton::Clicked, this, &ChannelEditor::restoreData);
154  }
155  else
156  {
157  LOG(VB_GENERAL, LOG_ERR, LOC + "Button \"Restore Data\" not found in theme.");
158  }
159 
160  // Import Icons Button
161  importIconButton->SetHelpText(tr("Starts the icon downloader"));
162  importIconButton->SetEnabled(true);
163  connect(importIconButton, &MythUIButton::Clicked, this, &ChannelEditor::channelIconImport);
164 
165  // Transport Editor Button
166  transportEditorButton->SetHelpText(
167  tr("Allows you to edit the transports directly. "
168  "This is rarely required unless you are using "
169  "a satellite dish and must enter an initial "
170  "frequency to for the channel scanner to try."));
171  connect(transportEditorButton, &MythUIButton::Clicked, this, &ChannelEditor::transportEditor);
172 
173  // Other signals
175  this, &ChannelEditor::edit);
178  connect(scanButton, &MythUIButton::Clicked, this, &ChannelEditor::scan);
179  connect(deleteButton, &MythUIButton::Clicked, this, &ChannelEditor::deleteChannels);
180 
181  fillList();
182 
183  BuildFocusList();
184 
185  return true;
186 }
187 
188 bool ChannelEditor::keyPressEvent(QKeyEvent *event)
189 {
190  if (GetFocusWidget()->keyPressEvent(event))
191  return true;
192 
193  QStringList actions;
194  bool handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);
195 
196  for (int i = 0; i < actions.size() && !handled; i++)
197  {
198  QString action = actions[i];
199  handled = true;
200 
201  if (action == "MENU")
202  menu();
203  else if (action == "DELETE")
204  del();
205  else if (action == "EDIT")
206  edit();
207  else
208  handled = false;
209  }
210 
211  if (!handled && MythScreenType::keyPressEvent(event))
212  handled = true;
213 
214  return handled;
215 }
216 
218 {
219  if (!item)
220  return;
221 
222  if (m_preview)
223  {
224  m_preview->Reset();
225  QString iconpath = item->GetImageFilename();
226  if (!iconpath.isEmpty())
227  {
228  // mythtv-setup needs direct access to channel icon dir to import. We
229  // also can't rely on the backend to be running, so access the file directly.
230  QString tmpIcon = GetConfDir() + "/channels/" + iconpath;
231  m_preview->SetFilename(tmpIcon);
232  m_preview->Load();
233  }
234  }
235 
236  if (m_channame)
237  m_channame->SetText(item->GetText("name"));
238 
239  if (m_channum)
240  m_channum->SetText(item->GetText("channum"));
241 
242  if (m_callsign)
243  m_callsign->SetText(item->GetText("callsign"));
244 
245  if (m_chanid)
246  m_chanid->SetText(item->GetText("chanid"));
247 
248  if (m_serviceid)
249  m_serviceid->SetText(item->GetText("serviceid"));
250 
251  if (m_frequency)
252  m_frequency->SetText(item->GetText("frequency"));
253 
254  if (m_transportid)
255  m_transportid->SetText(item->GetText("transportid"));
256 
257  if (m_sourcename)
258  m_sourcename->SetText(item->GetText("sourcename"));
259 
260  if (m_compoundname)
261  m_compoundname->SetText(item->GetText("compoundname"));
262 }
263 
265 {
266  QString currentValue = m_channelList->GetValue();
267  uint currentIndex = qMax(m_channelList->GetCurrentPos(), 0);
268  m_channelList->Reset();
269  QString newchanlabel = tr("(Add New Channel)");
270  auto *item = new MythUIButtonListItem(m_channelList, "");
271  item->SetText(newchanlabel, "compoundname");
272  item->SetText(newchanlabel, "name");
273 
274  bool fAllSources = true;
275 
276  QString querystr = "SELECT channel.name, channum, chanid, callsign, icon, "
277  "channel.visible, videosource.name, serviceid, "
278  "dtv_multiplex.frequency, dtv_multiplex.polarity, "
279  "dtv_multiplex.transportid, dtv_multiplex.mod_sys FROM channel "
280  "LEFT JOIN videosource ON "
281  "(channel.sourceid = videosource.sourceid) "
282  "LEFT JOIN dtv_multiplex ON "
283  "(channel.mplexid = dtv_multiplex.mplexid) "
284  "WHERE deleted IS NULL ";
285 
286  if (m_sourceFilter == FILTER_ALL)
287  {
288  fAllSources = true;
289  }
290  else
291  {
292  querystr += QString("AND channel.sourceid='%1' ")
293  .arg(m_sourceFilter);
294  fAllSources = false;
295  }
296 
297  if (m_currentSortMode == tr("Channel Name"))
298  {
299  querystr += " ORDER BY channel.name";
300  }
301  else if (m_currentSortMode == tr("Channel Number"))
302  {
303  querystr += " ORDER BY channum + 0, SUBSTRING_INDEX(channum, '_', -1) + 0";
304  }
305  else if (m_currentSortMode == tr("Service ID"))
306  {
307  querystr += " ORDER BY serviceid";
308  }
309  else if (m_currentSortMode == tr("Frequency"))
310  {
311  querystr += " ORDER BY dtv_multiplex.frequency, serviceid";
312  }
313  else if (m_currentSortMode == tr("Transport ID"))
314  {
315  querystr += " ORDER BY dtv_multiplex.transportid, serviceid";
316  }
317  else if (m_currentSortMode == tr("Video Source"))
318  {
319  querystr += " ORDER BY videosource.name, dtv_multiplex.transportid";
320  }
321 
322  MSqlQuery query(MSqlQuery::InitCon());
323  query.prepare(querystr);
324 
325  uint selidx = 0;
326  uint idx = 1;
327  if (query.exec() && query.size() > 0)
328  {
329  for (; query.next() ; idx++)
330  {
331  QString name = query.value(0).toString();
332  QString channum = query.value(1).toString();
333  QString chanid = query.value(2).toString();
334  QString callsign = query.value(3).toString();
335  QString icon = query.value(4).toString();
336  bool visible = query.value(5).toBool();
337  QString serviceid = query.value(7).toString();
338  QString frequency = query.value(8).toString();
339  QString polarity = query.value(9).toString().toUpper();
340  QString transportid = query.value(10).toString();
341  QString mod_sys = query.value(11).toString();
342  QString sourceid = "Unassigned";
343 
344  // Add polarity for satellite frequencies
345  if (mod_sys.startsWith("DVB-S"))
346  {
347  frequency += polarity;
348  }
349 
350  QString state = "normal";
351 
352  if (!visible)
353  state = "disabled";
354 
355  if (!query.value(6).toString().isEmpty())
356  {
357  sourceid = query.value(6).toString();
358  if (fAllSources && m_sourceFilter == FILTER_UNASSIGNED)
359  continue;
360  }
361  else
362  state = "warning";
363 
364  // Also hide channels that are not visible
365  if ((!visible || channum.isEmpty()) && m_currentHideMode)
366  continue;
367 
368  if (name.isEmpty())
369  name = "(Unnamed : " + chanid + ")";
370 
371  QString compoundname = name;
372 
373  if (m_currentSortMode == tr("Channel Name"))
374  {
375  if (!channum.isEmpty())
376  compoundname += " (" + channum + ")";
377  }
378  else if (m_currentSortMode == tr("Channel Number"))
379  {
380  if (!channum.isEmpty())
381  compoundname = channum + ". " + compoundname;
382  else
383  compoundname = "???. " + compoundname;
384  }
385 
386  if (m_sourceFilter == FILTER_ALL)
387  compoundname += " (" + sourceid + ")";
388 
389  bool sel = (chanid == currentValue);
390  selidx = (sel) ? idx : selidx;
391  item = new MythUIButtonListItem(m_channelList, "",
392  QVariant::fromValue(chanid));
393  item->SetText(compoundname, "compoundname");
394  item->SetText(chanid, "chanid");
395  item->SetText(channum, "channum");
396  item->SetText(name, "name");
397  item->SetText(callsign, "callsign");
398  item->SetText(serviceid, "serviceid");
399  item->SetText(frequency, "frequency");
400  item->SetText(transportid, "transportid");
401  item->SetText(sourceid, "sourcename");
402 
403  // mythtv-setup needs direct access to channel icon dir to import. We
404  // also can't rely on the backend to be running, so access the file directly.
405  QString tmpIcon = GetConfDir() + "/channels/" + icon;
406  item->SetImage(tmpIcon);
407  item->SetImage(tmpIcon, "icon");
408 
409  item->DisplayState(state, "status");
410  }
411  }
412 
413  // Make sure we select the current item, or the following one after
414  // deletion, with wrap around to "(New Channel)" after deleting last item.
415  m_channelList->SetItemCurrent((!selidx && currentIndex < idx) ? currentIndex : selidx);
416 }
417 
419 {
420  if (!item)
421  return;
422 
423  QString sortName = item->GetText();
424 
425  if (m_currentSortMode != sortName)
426  {
427  m_currentSortMode = sortName;
428  fillList();
429  }
430 }
431 
433 {
434  if (!item)
435  return;
436 
437  QString sourceName = item->GetText();
438  int sourceID = item->GetData().toInt();
439 
440  if (m_sourceFilter != sourceID)
441  {
442  m_sourceFilterName = sourceName;
443  m_sourceFilter = sourceID;
444  fillList();
445  }
446 }
447 
449 {
450  if (m_currentHideMode != hide)
451  {
452  m_currentHideMode = hide;
453  fillList();
454  }
455 }
456 
458 {
460 
461  if (!item)
462  return;
463 
464  QString message = tr("Delete channel '%1'?").arg(item->GetText("name"));
465 
466  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
467  auto *dialog = new MythConfirmationDialog(popupStack, message, true);
468 
469  if (dialog->Create())
470  {
471  dialog->SetData(QVariant::fromValue(item));
472  dialog->SetReturnEvent(this, "delsingle");
473  popupStack->AddScreen(dialog);
474  }
475  else
476  delete dialog;
477 
478 }
479 
481 {
482  const QString currentLabel = m_sourceList->GetValue();
483 
484  bool del_all = m_sourceFilter == FILTER_ALL;
485  bool del_nul = m_sourceFilter == FILTER_UNASSIGNED;
486 
487  QString message =
488  (del_all) ? tr("Delete ALL channels?") :
489  ((del_nul) ? tr("Delete all unassigned channels?") :
490  tr("Delete all channels on %1?").arg(currentLabel));
491 
492  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
493  auto *dialog = new MythConfirmationDialog(popupStack, message, true);
494 
495  if (dialog->Create())
496  {
497  dialog->SetReturnEvent(this, "delall");
498  popupStack->AddScreen(dialog);
499  }
500  else
501  delete dialog;
502 }
503 
505 {
506  if (!item)
507  item = m_channelList->GetItemCurrent();
508 
509  if (!item)
510  return;
511 
513 
514  int chanid = item->GetData().toInt();
515  auto *cw = new ChannelWizard(chanid, m_sourceFilter);
516  auto *ssd = new StandardSettingDialog(mainStack, "channelwizard", cw);
517  if (ssd->Create())
518  {
519  connect(ssd, &MythScreenType::Exiting, this, &ChannelEditor::fillList);
520  mainStack->AddScreen(ssd);
521  }
522  else
523  delete ssd;
524 }
525 
527 {
529 
530  if (!item)
531  return;
532 
533  int chanid = item->GetData().toInt();
534  if (chanid == 0)
535  edit(item);
536  else
537  {
538  QString label = tr("Channel Options");
539 
540  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
541 
542  auto *menu = new MythDialogBox(label, popupStack, "chanoptmenu");
543 
544  if (menu->Create())
545  {
546  menu->SetReturnEvent(this, "channelopts");
547 
548  menu->AddButton(tr("Edit"));
549 // if ()
550 // menu->AddButton(tr("Set Hidden"));
551 // else
552 // menu->AddButton(tr("Set Visible"));
553  menu->AddButton(tr("Delete"));
554 
555  popupStack->AddScreen(menu);
556  }
557  else
558  {
559  delete menu;
560  return;
561  }
562  }
563 }
564 
565 // Check that we have a video source and that at least one
566 // capture card is connected to the video source.
567 //
568 static bool check_cardsource(int sourceid, QString &sourcename)
569 {
570  // Check for videosource
571  if (sourceid < 1)
572  {
573  MythConfirmationDialog *md = ShowOkPopup(QObject::tr(
574  "Select a video source. 'All' cannot be used. "
575  "If there is no video source then create one in the "
576  "'Video sources' menu page and connect a capture card."));
577  WaitFor(md);
578  return false;
579  }
580 
581  // Check for a connected capture card
582  MSqlQuery query(MSqlQuery::InitCon());
583  query.prepare(
584  "SELECT capturecard.cardid "
585  "FROM capturecard "
586  "WHERE capturecard.sourceid = :SOURCEID AND "
587  " capturecard.hostname = :HOSTNAME");
588  query.bindValue(":SOURCEID", sourceid);
589  query.bindValue(":HOSTNAME", gCoreContext->GetHostName());
590 
591  if (!query.exec() || !query.isActive())
592  {
593  MythDB::DBError("check_capturecard()", query);
594  return false;
595  }
596  uint cardid = 0;
597  if (query.next())
598  cardid = query.value(0).toUInt();
599 
600  if (cardid < 1)
601  {
602  MythConfirmationDialog *md = ShowOkPopup(QObject::tr(
603  "No capture card!"
604  "\n"
605  "Connect video source '%1' to a capture card "
606  "in the 'Input Connections' menu page.")
607  .arg(sourcename));
608  WaitFor(md);
609  return false;
610  }
611 
612  // At least one capture card connected to the video source
613  // must be able to do channel scanning
614  if (SourceUtil::IsUnscanable(sourceid))
615  {
616  MythConfirmationDialog *md = ShowOkPopup(QObject::tr(
617  "The capture card(s) connected to video source '%1' "
618  "cannot be used for channel scanning.")
619  .arg(sourcename));
620  WaitFor(md);
621  return false;
622  }
623 
624  return true;
625 }
626 
628 {
629  // Check that we have a videosource and a connected capture card
631  return;
632 
633  // Create the dialog now that we have a video source and a capture card
635  auto *ssd = new StandardSettingDialog(mainStack, "scanwizard",
637  if (ssd->Create())
638  {
639  connect(ssd, &MythScreenType::Exiting, this, &ChannelEditor::fillList);
640  mainStack->AddScreen(ssd);
641  }
642  else
643  delete ssd;
644 }
645 
647 {
648  // Check that we have a videosource and a connected capture card
650  return;
651 
652  // Create the dialog now that we have a video source and a capture card
654 
655  auto *ssd = new StandardSettingDialog(mainStack, "restoredata",
657  if (ssd->Create())
658  {
659  // Reload channel list with fillList after Restore
660  connect(ssd, &MythScreenType::Exiting, this, &ChannelEditor::fillList);
661  mainStack->AddScreen(ssd);
662  }
663  else
664  delete ssd;
665 }
666 
668 {
669  // Check that we have a videosource and a connected capture card
671  return;
672 
673  // Create the dialog now that we have a video source and a capture card
675  auto *ssd = new StandardSettingDialog(mainStack, "transporteditor",
677  if (ssd->Create())
678  {
679  connect(ssd, &MythScreenType::Exiting, this, &ChannelEditor::fillList);
680  mainStack->AddScreen(ssd);
681  }
682  else
683  delete ssd;
684 }
685 
687 {
688  if (m_channelList->GetCount() == 0)
689  {
690  ShowOkPopup(tr("Add some channels first!"));
691  return;
692  }
693 
694  int channelID = 0;
696  if (item)
697  channelID = item->GetData().toInt();
698 
699  // Get selected channel name from database
700  QString querystr = QString("SELECT channel.name FROM channel "
701  "WHERE chanid='%1'").arg(channelID);
702  QString channelname;
703  MSqlQuery query(MSqlQuery::InitCon());
704  query.prepare(querystr);
705 
706  if (query.exec() && query.next())
707  {
708  channelname = query.value(0).toString();
709  }
710 
711  QString label = tr("Icon Import Options");
712 
713  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
714 
715  auto *menu = new MythDialogBox(label, popupStack, "iconoptmenu");
716 
717  if (menu->Create())
718  {
719  menu->SetReturnEvent(this, "iconimportopt");
720 
721  menu->AddButton(tr("Download all icons..."));
722  menu->AddButton(tr("Rescan for missing icons..."));
723  if (!channelname.isEmpty())
724  menu->AddButtonV(tr("Download icon for %1").arg(channelname),
725  channelname);
726 
727  popupStack->AddScreen(menu);
728  }
729  else
730  {
731  delete menu;
732  return;
733  }
734 }
735 
736 void ChannelEditor::customEvent(QEvent *event)
737 {
738  if (event->type() == DialogCompletionEvent::kEventType)
739  {
740  auto *dce = (DialogCompletionEvent*)(event);
741 
742  QString resultid= dce->GetId();
743  int buttonnum = dce->GetResult();
744 
745  if (resultid == "channelopts")
746  {
747  switch (buttonnum)
748  {
749  case 0 :
751  break;
752  case 1 :
753  del();
754  break;
755  }
756  }
757  else if (resultid == "delsingle" && buttonnum == 1)
758  {
759  auto *item = dce->GetData().value<MythUIButtonListItem *>();
760  if (!item)
761  return;
762  uint chanid = item->GetData().toUInt();
763  if (chanid && ChannelUtil::DeleteChannel(chanid))
764  m_channelList->RemoveItem(item);
765  }
766  else if (resultid == "delall" && buttonnum == 1)
767  {
768  bool del_all = m_sourceFilter == FILTER_ALL;
769  bool del_nul = m_sourceFilter == FILTER_UNASSIGNED;
770 
771  MSqlQuery query(MSqlQuery::InitCon());
772  if (del_all)
773  {
774  query.prepare("TRUNCATE TABLE channel");
775  }
776  else if (del_nul)
777  {
778  query.prepare("SELECT sourceid "
779  "FROM videosource "
780  "GROUP BY sourceid");
781 
782  if (!query.exec() || !query.isActive())
783  {
784  MythDB::DBError("ChannelEditor Delete Channels", query);
785  return;
786  }
787 
788  QString tmp = "";
789  while (query.next())
790  tmp += "'" + query.value(0).toString() + "',";
791 
792  if (tmp.isEmpty())
793  {
794  query.prepare("TRUNCATE TABLE channel");
795  }
796  else
797  {
798  tmp = tmp.left(tmp.length() - 1);
799  query.prepare(QString("UPDATE channel "
800  "SET deleted = NOW() "
801  "WHERE deleted IS NULL AND "
802  " sourceid NOT IN (%1)").arg(tmp));
803  }
804  }
805  else
806  {
807  query.prepare("UPDATE channel "
808  "SET deleted = NOW() "
809  "WHERE deleted IS NULL AND sourceid = :SOURCEID");
810  query.bindValue(":SOURCEID", m_sourceFilter);
811  }
812 
813  if (!query.exec())
814  MythDB::DBError("ChannelEditor Delete Channels", query);
815 
816  fillList();
817  }
818  else if (resultid == "iconimportopt")
819  {
821 
822  ImportIconsWizard *iconwizard = nullptr;
823 
824  QString channelname = dce->GetData().toString();
825 
826  switch (buttonnum)
827  {
828  case 0 : // Import all icons
829  iconwizard = new ImportIconsWizard(mainStack, false);
830  break;
831  case 1 : // Rescan for missing
832  iconwizard = new ImportIconsWizard(mainStack, true);
833  break;
834  case 2 : // Import a single channel icon
835  iconwizard = new ImportIconsWizard(mainStack, true,
836  channelname);
837  break;
838  default:
839  return;
840  }
841 
842  if (iconwizard->Create())
843  {
844  connect(iconwizard, &MythScreenType::Exiting, this, &ChannelEditor::fillList);
845  mainStack->AddScreen(iconwizard);
846  }
847  else
848  {
849  delete iconwizard;
850 
851  if (buttonnum == 2)
852  {
853  // Reload the list since ImportIconsWizard::Create() will return false
854  // if it automatically downloaded an icon for the selected channel
855  fillList();
856  }
857  }
858  }
859  }
860 }
MythUIButton::Clicked
void Clicked()
ChannelEditor::m_sourceFilterName
QString m_sourceFilterName
Definition: channeleditor.h:47
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:208
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
WaitFor
bool WaitFor(MythConfirmationDialog *dialog)
Blocks until confirmation dialog exits.
Definition: mythdialogbox.cpp:595
ChannelOptionsFilters
Definition: channelsettings.h:133
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:124
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:317
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:207
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1590
transporteditor.h
mythuitext.h
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
StandardSetting::setValue
virtual void setValue(const QString &newValue)
Definition: standardsettings.cpp:169
RestoreData
Definition: restoredata.h:81
LOC
#define LOC
Definition: channeleditor.cpp:27
mythdb.h
ChannelEditor::scan
void scan(void)
Definition: channeleditor.cpp:627
ChannelEditor::m_transportid
MythUIText * m_transportid
Definition: channeleditor.h:62
ChannelEditor::m_callsign
MythUIText * m_callsign
Definition: channeleditor.h:57
ChannelEditor::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: channeleditor.cpp:188
ChannelEditor::m_frequency
MythUIText * m_frequency
Definition: channeleditor.h:61
ChannelUtil::DeleteChannel
static bool DeleteChannel(uint channel_id)
Definition: channelutil.cpp:1765
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
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:968
DialogCompletionEvent::kEventType
static Type kEventType
Definition: mythdialogbox.h:57
ChannelEditor::menu
void menu(void)
Definition: channeleditor.cpp:526
MythUIButtonList::itemSelected
void itemSelected(MythUIButtonListItem *item)
ChannelWizard::m_cid
ChannelID * m_cid
Definition: channeleditor.h:75
mythdialogbox.h
ChannelEditor::m_currentHideMode
bool m_currentHideMode
Definition: channeleditor.h:49
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:197
MythScreenStack
Definition: mythscreenstack.h:16
ImportIconsWizard::Create
bool Create(void) override
Definition: importicons.cpp:59
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
ChannelOptionsCommon
Definition: channelsettings.h:113
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
check_cardsource
static bool check_cardsource(int sourceid, QString &sourcename)
Definition: channeleditor.cpp:568
mythdirs.h
MythUIImage::Reset
void Reset(void) override
Reset the image back to the default defined in the theme.
Definition: mythuiimage.cpp:645
mythuibuttonlist.h
ChannelEditor::edit
void edit(MythUIButtonListItem *item=nullptr)
Definition: channeleditor.cpp:504
ScanWizard
Definition: scanwizard.h:44
mythuiimage.h
MythUIButtonList::GetCount
int GetCount() const
Definition: mythuibuttonlist.cpp:1655
mythprogressdialog.h
scanwizard.h
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
MythUICheckBox::toggled
void toggled(bool)
SourceUtil::IsAnySourceScanable
static bool IsAnySourceScanable(void)
Definition: sourceutil.cpp:356
ChannelUtil::GetInputTypes
static QStringList GetInputTypes(uint chanid)
Definition: channelutil.cpp:822
ChannelID
Definition: channelsettings.h:20
MythUIButtonListItem
Definition: mythuibuttonlist.h:27
ImportIconsWizard
Definition: importicons.h:28
ChannelEditor::m_channame
MythUIText * m_channame
Definition: channeleditor.h:55
StandardSettingDialog
Definition: standardsettings.h:468
ChannelEditor::customEvent
void customEvent(QEvent *event) override
Definition: channeleditor.cpp:736
StandardSetting::addChild
virtual void addChild(StandardSetting *child)
Definition: standardsettings.cpp:70
sourceutil.h
ChannelEditor::m_sourceList
MythUIButtonList * m_sourceList
Definition: channeleditor.h:52
ChannelEditor::m_serviceid
MythUIText * m_serviceid
Definition: channeleditor.h:60
mythlogging.h
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
MythUIButtonList::itemClicked
void itemClicked(MythUIButtonListItem *item)
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1116
MythUIButtonList::GetCurrentPos
int GetCurrentPos() const
Definition: mythuibuttonlist.h:198
MythDialogBox
Basic menu dialog, message and a list of options.
Definition: mythdialogbox.h:166
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:200
restoredata.h
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:172
TransportListEditor
Definition: transporteditor.h:68
ChannelEditor::restoreData
void restoreData(void)
Definition: channeleditor.cpp:646
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:205
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
ChannelOptionsRawTS
Definition: channelsettings.h:145
ChannelEditor::m_channelList
MythUIButtonList * m_channelList
Definition: channeleditor.h:51
ChannelEditor::del
void del(void)
Definition: channeleditor.cpp:457
ChannelEditor::m_channum
MythUIText * m_channum
Definition: channeleditor.h:56
MythUIType::SetEnabled
void SetEnabled(bool enable)
Definition: mythuitype.cpp:1109
SourceUtil::IsUnscanable
static bool IsUnscanable(uint sourceid)
Definition: sourceutil.cpp:338
StandardSetting::getValue
virtual QString getValue(void) const
Definition: standardsettings.h:52
ChannelEditor::deleteChannels
void deleteChannels(void)
Definition: channeleditor.cpp:480
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3587
uint
unsigned int uint
Definition: compat.h:140
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:15
CardUtil::IsV4L
static bool IsV4L(const QString &rawtype)
Definition: cardutil.h:140
channeleditor.h
StandardSetting::setLabel
virtual void setLabel(QString str)
Definition: standardsettings.h:34
channelutil.h
MythUIButtonListItem::GetText
QString GetText(const QString &name="") const
Definition: mythuibuttonlist.cpp:3312
ChannelEditor::setSourceID
void setSourceID(MythUIButtonListItem *item)
Definition: channeleditor.cpp:432
ChannelEditor::channelIconImport
void channelIconImport(void)
Definition: channeleditor.cpp:686
ChannelEditor::m_compoundname
MythUIText * m_compoundname
Definition: channeleditor.h:63
ChannelEditor::m_chanid
MythUIText * m_chanid
Definition: channeleditor.h:58
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:30
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:397
ChannelEditor::m_sourcename
MythUIText * m_sourcename
Definition: channeleditor.h:59
MythConfirmationDialog
Dialog asking for user confirmation. Ok and optional Cancel button.
Definition: mythdialogbox.h:271
mythcorecontext.h
ChannelOptionsV4L
Definition: channelsettings.h:139
mythuitextedit.h
MythUICheckBox::SetCheckState
void SetCheckState(MythUIStateType::StateType state)
Definition: mythuicheckbox.cpp:66
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
cardutil.h
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:893
ChannelEditor::Create
bool Create(void) override
Definition: channeleditor.cpp:71
ChannelEditor::setHideMode
void setHideMode(bool hide)
Definition: channeleditor.cpp:448
ChannelEditor::fillList
void fillList()
Definition: channeleditor.cpp:264
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
ChannelEditor::FILTER_UNASSIGNED
@ FILTER_UNASSIGNED
Definition: channeleditor.h:43
MythUIButtonList::GetValue
virtual QString GetValue() const
Definition: mythuibuttonlist.cpp:1609
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:133
channelsettings.h
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
ChannelEditor::setSortMode
void setSortMode(MythUIButtonListItem *item)
Definition: channeleditor.cpp:418
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:104
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1557
ChannelEditor::m_preview
MythUIImage * m_preview
Definition: channeleditor.h:54
build_compdb.action
action
Definition: build_compdb.py:9
MythScreenType::Exiting
void Exiting()
mythuibutton.h
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &Stackname)
Definition: mythmainwindow.cpp:322
ChannelEditor::transportEditor
void transportEditor(void)
Definition: channeleditor.cpp:667
CardUtil::GetInputTypeNames
static QStringList GetInputTypeNames(uint sourceid)
Get a list of card input types for a source id.
Definition: cardutil.cpp:377
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:862
ChannelEditor::m_currentSortMode
QString m_currentSortMode
Definition: channeleditor.h:48
ChannelWizard
Definition: channeleditor.h:68
MythUIButtonListItem::GetImageFilename
QString GetImageFilename(const QString &name="") const
Definition: mythuibuttonlist.cpp:3493
ChannelEditor::m_sourceFilter
int m_sourceFilter
Definition: channeleditor.h:46
ChannelEditor::itemChanged
void itemChanged(MythUIButtonListItem *item)
Definition: channeleditor.cpp:217
mythuicheckbox.h
MythUIImage::SetFilename
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
Definition: mythuiimage.cpp:676
ChannelWizard::ChannelWizard
ChannelWizard(int id, int default_sourceid)
Definition: channeleditor.cpp:29
MythUIButtonList::SetValue
virtual void SetValue(int value)
Definition: mythuibuttonlist.h:174
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:151
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:50
ChannelEditor::ChannelEditor
ChannelEditor(MythScreenStack *parent)
Definition: channeleditor.cpp:65
ChannelEditor::FILTER_ALL
@ FILTER_ALL
Definition: channeleditor.h:42
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:558
importicons.h
common
Definition: mythtv/programs/scripts/metadata/Music/lyrics/common/__init__.py:1
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:837