MythTV  master
transporteditor.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  * vim: set expandtab tabstop=4 shiftwidth=4:
4  *
5  * Original Project
6  * MythTV http://www.mythtv.org
7  *
8  * Author(s):
9  * John Pullan <john@pullan.org>
10  * Taylor Jacob <rtjacob@earthlink.net>
11  * Daniel Kristjansson <danielk@cuymedia.net>
12  *
13  * Description:
14  * Collection of classes to provide dvb a transport editor
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
29  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
30  *
31  */
32 
33 #include <vector>
34 using namespace std;
35 
36 #include "transporteditor.h"
37 #include "videosource.h"
38 #include "sourceutil.h"
39 #include "mythcorecontext.h"
40 #include "mythdb.h"
41 
42 #define LOC QString("DTVMux: ")
43 
45 {
46  public:
47  MultiplexID() : AutoIncrementSetting("dtv_multiplex", "mplexid")
48  {
49  setVisible(false);
50  setName("MPLEXID");
51  }
52 
53  public:
54  QString GetColumnName(void) const { return m_column; }
55 };
56 
57 static QString pp_modulation(const QString& mod)
58 {
59  if (mod.endsWith("vsb"))
60  return mod.left(mod.length() - 3) + "-VSB";
61 
62  if (mod.startsWith("qam_"))
63  return "QAM-" + mod.mid(4, mod.length());
64 
65  if (mod == "analog")
66  return QObject::tr("Analog");
67 
68  return mod.toUpper();
69 }
70 
72 {
73  vector<uint> cardids;
74 
75  // Work out what card we have.. (doesn't always work well)
77  query.prepare(
78  "SELECT capturecard.cardid "
79  "FROM capturecard "
80  "WHERE capturecard.sourceid = :SOURCEID AND "
81  " capturecard.parentid = 0 AND "
82  " capturecard.hostname = :HOSTNAME");
83  query.bindValue(":SOURCEID", sourceid);
84  query.bindValue(":HOSTNAME", gCoreContext->GetHostName());
85 
86  if (!query.exec() || !query.isActive())
87  {
88  MythDB::DBError("TransportWizard()", query);
89  return CardUtil::ERROR_PROBE;
90  }
91  while (query.next())
92  cardids.push_back(query.value(0).toUInt());
93 
94  if (cardids.empty())
95  {
96  ShowOkPopup(QObject::tr(
97  "Sorry, the Transport Editor can only edit transports "
98  "of a video source that is connected to a capture card."));
99 
100  return CardUtil::ERROR_PROBE;
101  }
102 
103  vector<CardUtil::INPUT_TYPES> cardtypes;
104 
105  for (uint cardid : cardids)
106  {
108  QString cardtype = CardUtil::GetRawInputType(cardid);
109  if (cardtype == "DVB")
110  cardtype = CardUtil::ProbeSubTypeName(cardid);
111  nType = CardUtil::toInputType(cardtype);
112 
113  if (nType == CardUtil::HDHOMERUN)
114  {
116  nType = CardUtil::DVBC;
118  nType = CardUtil::DVBT2;
119  }
120 
121  if ((CardUtil::ERROR_OPEN == nType) ||
122  (CardUtil::ERROR_UNKNOWN == nType) ||
123  (CardUtil::ERROR_PROBE == nType))
124  {
125  ShowOkPopup(
126  QObject::tr(
127  "Failed to probe a capture card connected to this "
128  "transport's video source. Please make sure the "
129  "backend is not running."));
130 
131  return CardUtil::ERROR_PROBE;
132  }
133 
134  cardtypes.push_back(nType);
135  }
136 
137  // This should never happen... (unless DB has changed under us)
138  if (cardtypes.empty())
139  return CardUtil::ERROR_PROBE;
140 
141  // If there are multiple cards connected to this video source
142  // check if they are the same type or compatible.
143  for (size_t i = 1; i < cardtypes.size(); i++)
144  {
145  CardUtil::INPUT_TYPES typeA = cardtypes[i - 1];
146  CardUtil::INPUT_TYPES typeB = cardtypes[i + 0];
147 
148  // MPEG devices are seen as V4L (historical)
149  typeA = (CardUtil::MPEG == typeA) ? CardUtil::V4L : typeA;
150  typeB = (CardUtil::MPEG == typeB) ? CardUtil::V4L : typeB;
151 
152  // HDHOMERUN devices can be DVBC, DVBT/T2, ATSC or a combination of those.
153  // If there are other non-HDHR devices connected to this videosource that
154  // have an explicit type then assume that the HDHOMERUN is also of that type.
155  typeA = (CardUtil::HDHOMERUN == typeA) ? typeB : typeA;
156  typeB = (CardUtil::HDHOMERUN == typeB) ? typeA : typeB;
157 
158  if (typeA == typeB)
159  continue;
160 
161  ShowOkPopup(
162  QObject::tr(
163  "The capture cards connected to this transport's video source "
164  "are incompatible. Please create separate video sources "
165  "per capture card type."));
166 
167  return CardUtil::ERROR_PROBE;
168  }
169 
170  // Look for tuner type to decide on transport editor list format
171  CardUtil::INPUT_TYPES retval = cardtypes[0];
172  for (size_t i = 1; i < cardtypes.size(); i++)
173  {
174  if ((cardtypes[i] == CardUtil::DVBS ) ||
175  (cardtypes[i] == CardUtil::DVBC ) ||
176  (cardtypes[i] == CardUtil::DVBT ) ||
177  (cardtypes[i] == CardUtil::ATSC ) ||
178  (cardtypes[i] == CardUtil::DVBS2) ||
179  (cardtypes[i] == CardUtil::DVBT2) )
180  {
181  retval = cardtypes[i];
182  }
183  }
184 
185  return retval;
186 }
187 
189 {
190  for (auto *setting : m_list)
191  removeChild(setting);
192  m_list.clear();
193 
194  if (!sourceid)
195  {
196  m_sourceid = 0;
197  }
198  else
199  {
200  m_cardtype = get_cardtype(sourceid);
201  m_sourceid = ((CardUtil::ERROR_OPEN == m_cardtype) ||
202  (CardUtil::ERROR_UNKNOWN == m_cardtype) ||
203  (CardUtil::ERROR_PROBE == m_cardtype)) ? 0 : sourceid;
204  }
205 }
206 
208  m_videosource(new VideoSourceShow(sourceid))
209 {
210  setLabel(tr("Transport Editor"));
211 
213 
214  auto *newTransport =
215  new ButtonStandardSetting("(" + tr("New Transport") + ")");
216  connect(newTransport, SIGNAL(clicked()), SLOT(NewTransport(void)));
217 
218  addChild(newTransport);
219 
220  connect(m_videosource, SIGNAL(valueChanged(const QString&)),
221  this, SLOT(SetSourceID(const QString&)));
222 
223  SetSourceID(sourceid);
224 }
225 
226 void TransportListEditor::SetSourceID(const QString& name)
227 {
228  if (m_isLoading)
229  return;
230 
231  uint sourceid = SourceUtil::GetSourceID(name);
232 
233  SetSourceID(sourceid);
234  Load();
235 }
236 
238 {
239  if (m_isLoading)
240  return;
241  m_isLoading = true;
242  if (m_sourceid)
243  {
245  query.prepare(
246  "SELECT mplexid, modulation, frequency, "
247  " symbolrate, networkid, transportid, "
248  " constellation, mod_sys "
249  "FROM dtv_multiplex, videosource "
250  "WHERE dtv_multiplex.sourceid = :SOURCEID AND "
251  " dtv_multiplex.sourceid = videosource.sourceid "
252  "ORDER by networkid, transportid, frequency, mplexid");
253  query.bindValue(":SOURCEID", m_sourceid);
254 
255  if (!query.exec() || !query.isActive())
256  {
257  MythDB::DBError("TransportList::fillSelections", query);
258  m_isLoading = false;
259  return;
260  }
261 
262  while (query.next())
263  {
264  QString rawmod = ((CardUtil::OFDM == m_cardtype) ||
266  query.value(6).toString() : query.value(1).toString();
267 
268  QString mod = pp_modulation(rawmod);
269  while (mod.length() < 7)
270  mod += " ";
271 
272  QString rate = query.value(3).toString();
273  rate = (rate == "0") ? "" : QString("rate %1").arg(rate);
274 
275  QString netid = query.value(4).toUInt() ?
276  QString("netid %1").arg(query.value(4).toUInt(), 5) : "";
277 
278  QString tid = query.value(5).toUInt() ?
279  QString("tid %1").arg(query.value(5).toUInt(), 5) : "";
280 
281  QString hz = "Hz";
282  if (CardUtil::QPSK == m_cardtype ||
284  hz = "kHz";
285 
286  QString type = "";
287  if (CardUtil::OFDM == m_cardtype)
288  type = "(DVB-T)";
290  type = QString("(%1)").arg(query.value(7).toString());
291  if (CardUtil::QPSK == m_cardtype)
292  type = "(DVB-S)";
293  if (CardUtil::QAM == m_cardtype)
294  type = "(DVB-C)";
296  type = "(DVB-S2)";
297 
298  QString txt = QString("%1 %2 %3 %4 %5 %6 %7")
299  .arg(mod).arg(query.value(2).toString())
300  .arg(hz).arg(rate).arg(netid).arg(tid).arg(type);
301 
302  auto *transport = new TransportSetting(txt, query.value(0).toUInt(),
304  connect(transport, &TransportSetting::deletePressed,
305  this, [transport, this] () { Delete(transport); });
306  connect(transport, &TransportSetting::openMenu,
307  this, [transport, this] () { Menu(transport); });
308  addChild(transport);
309  m_list.push_back(transport);
310  }
311  }
312 
314  m_isLoading = false;
315 }
316 
318 {
319  auto *transport = new TransportSetting(QString("New Transport"), 0,
321  addChild(transport);
322  m_list.push_back(transport);
323  emit settingsChanged(this);
324 }
325 
326 
328 {
329  if (m_isLoading)
330  return;
331 
332  ShowOkPopup(
333  tr("Are you sure you would like to delete this transport?"),
334  this,
335  [transport, this](bool result)
336  {
337  if (!result)
338  return;
339 
340  uint mplexid = transport->getMplexId();
341 
343  query.prepare("DELETE FROM dtv_multiplex WHERE mplexid = :MPLEXID");
344  query.bindValue(":MPLEXID", mplexid);
345 
346  if (!query.exec() || !query.isActive())
347  MythDB::DBError("TransportEditor -- delete multiplex", query);
348 
349  query.prepare("UPDATE channel SET deleted = NOW() "
350  "WHERE deleted IS NULL AND mplexid = :MPLEXID");
351  query.bindValue(":MPLEXID", mplexid);
352 
353  if (!query.exec() || !query.isActive())
354  MythDB::DBError("TransportEditor -- delete channels", query);
355 
356  removeChild(transport);
357  m_list.removeAll(transport);
358  },
359  true);
360 }
361 
363 {
364  if (m_isLoading)
365  return;
366 
367  auto *menu = new MythMenu(tr("Transport Menu"), this, "transportmenu");
368  menu->AddItem(tr("Delete..."), [transport, this] () { Delete(transport); });
369 
370  MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
371 
372  auto *menuPopup = new MythDialogBox(menu, popupStack, "menudialog");
373  menuPopup->SetReturnEvent(this, "transportmenu");
374 
375  if (menuPopup->Create())
376  popupStack->AddScreen(menuPopup);
377  else
378  delete menuPopup;
379 }
380 
382 {
383  protected:
384  MuxDBStorage(StorageUser *_setting, const MultiplexID *_id, const QString& _name) :
385  SimpleDBStorage(_setting, "dtv_multiplex", _name), m_mplexId(_id)
386  {
387  }
388 
389  QString GetSetClause(MSqlBindings &bindings) const override; // SimpleDBStorage
390  QString GetWhereClause(MSqlBindings &bindings) const override; // SimpleDBStorage
391 
393 };
394 
396 {
397  QString muxTag = ":WHERE" + m_mplexId->GetColumnName().toUpper();
398 
399  bindings.insert(muxTag, m_mplexId->getValue());
400 
401  // return query
402  return m_mplexId->GetColumnName() + " = " + muxTag;
403 }
404 
405 QString MuxDBStorage::GetSetClause(MSqlBindings &bindings) const
406 {
407  QString muxTag = ":SET" + m_mplexId->GetColumnName().toUpper();
408  QString nameTag = ":SET" + GetColumnName().toUpper();
409 
410  bindings.insert(muxTag, m_mplexId->getValue());
411  bindings.insert(nameTag, m_user->GetDBValue());
412 
413  // return query
414  return (m_mplexId->GetColumnName() + " = " + muxTag + ", " +
415  GetColumnName() + " = " + nameTag);
416 }
417 
419 {
420  public:
421  VideoSourceID(const MultiplexID *id, uint _sourceid) :
422  StandardSetting(this),
423  MuxDBStorage(this, id, "sourceid")
424  {
425  setVisible(false);
426  setValue(_sourceid);
427  }
428  void edit(MythScreenType * /*screen*/) override { } // StandardSetting
429  void resultEdit(DialogCompletionEvent * /*dce*/) override { } // StandardSetting
430 };
431 
433 {
434  public:
436  bool is_dvb_country,
437  bool is_atsc_country) :
438  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "sistandard")
439  {
440  setLabel(QObject::tr("Digital TV Standard"));
441  setHelpText(QObject::tr(
442  "Guiding standard to use for making sense of the "
443  "data streams after they have been demodulated, "
444  "error corrected and demultiplexed."));
445  if (is_dvb_country)
446  addSelection(QObject::tr("DVB"), "dvb");
447 
448  if (is_atsc_country)
449  {
450  addSelection(QObject::tr("ATSC"), "atsc");
451  addSelection(QObject::tr("OpenCable"), "opencable");
452  }
453 
454  addSelection(QObject::tr("MPEG"), "mpeg");
455  };
456 };
457 
459 {
460  public:
461  explicit Frequency(const MultiplexID *id, bool in_kHz = false) :
462  MythUITextEditSetting(this), MuxDBStorage(this, id, "frequency")
463  {
464  QString hz = (in_kHz) ? "kHz" : "Hz";
465  setLabel(QObject::tr("Frequency") + " (" + hz + ")");
466  setHelpText(QObject::tr(
467  "Frequency (Option has no default).\n"
468  "The frequency for this transport (multiplex) in") + " " + hz + ".");
469  };
470 };
471 
473 {
474  public:
475  explicit DVBSSymbolRate(const MultiplexID *id) :
476  MythUIComboBoxSetting(this, true), MuxDBStorage(this, id, "symbolrate")
477  {
478  setLabel(QObject::tr("Symbol Rate"));
479  setHelpText(
480  QObject::tr(
481  "Symbol Rate (symbols/sec).\n"
482  "Most DVB-S transponders transmit at 27.5 "
483  "million symbols per second."));
484  addSelection("3333000");
485  addSelection("22000000");
486  addSelection("22500000");
487  addSelection("23000000");
488  addSelection("27500000", "27500000", true);
489  addSelection("28000000");
490  addSelection("28500000");
491  addSelection("29500000");
492  addSelection("29700000");
493  addSelection("29900000");
494  };
495 };
496 
498 {
499  public:
500  explicit DVBCSymbolRate(const MultiplexID *id) :
501  MythUIComboBoxSetting(this, true), MuxDBStorage(this, id, "symbolrate")
502  {
503  setLabel(QObject::tr("Symbol Rate"));
504  setHelpText(
505  QObject::tr(
506  "Symbol Rate (symbols/second).\n"
507  "Most DVB-C transports transmit at 6.9 or 6.875 "
508  "million symbols per second."));
509  addSelection("3450000");
510  addSelection("5000000");
511  addSelection("5900000");
512  addSelection("6875000");
513  addSelection("6900000", "6900000", true);
514  addSelection("6950000");
515  };
516 };
517 
519 {
520  public:
521  explicit SignalPolarity(const MultiplexID *id) :
522  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "polarity")
523  {
524  setLabel(QObject::tr("Polarity"));
525  setHelpText(QObject::tr("Polarity (Option has no default)"));
526  addSelection(QObject::tr("Horizontal"), "h");
527  addSelection(QObject::tr("Vertical"), "v");
528  addSelection(QObject::tr("Right Circular"), "r");
529  addSelection(QObject::tr("Left Circular"), "l");
530  };
531 };
532 
534 {
535  public:
536  Modulation(const MultiplexID *id, uint nType);
537 };
538 
540  MythUIComboBoxSetting(this),
541  MuxDBStorage(this, id, ((CardUtil::OFDM == nType) ||
542  (CardUtil::DVBT2 == nType)) ?
543  "constellation" : "modulation")
544 {
545  setLabel(QObject::tr("Modulation"));
546  setHelpText(QObject::tr("Modulation, aka Constellation"));
547 
548  if (CardUtil::QPSK == nType)
549  {
550  // no modulation options
551  setVisible(false);
552  }
553  else if (CardUtil::DVBS2 == nType)
554  {
555  addSelection("QPSK", "qpsk");
556  addSelection("8PSK", "8psk");
557  addSelection("16APSK", "16apsk");
558  addSelection("32APSK", "32apsk");
559  }
560  else if ((CardUtil::QAM == nType) || (CardUtil::OFDM == nType) ||
561  (CardUtil::DVBT2 == nType))
562  {
563  addSelection(QObject::tr("QAM Auto"), "auto");
564  addSelection("QAM-16", "qam_16");
565  addSelection("QAM-32", "qam_32");
566  addSelection("QAM-64", "qam_64");
567  addSelection("QAM-128", "qam_128");
568  addSelection("QAM-256", "qam_256");
569 
570  if ((CardUtil::OFDM == nType) || (CardUtil::DVBT2 == nType))
571  {
572  addSelection("QPSK", "qpsk");
573  }
574  }
575  else if ((CardUtil::ATSC == nType) ||
576  (CardUtil::HDHOMERUN == nType))
577  {
578  addSelection("8-VSB", "8vsb");
579  addSelection("QAM-64", "qam_64");
580  addSelection("QAM-256", "qam_256");
581  }
582  else
583  {
584  addSelection(QObject::tr("Analog"), "analog");
585  setVisible(false);
586  }
587 };
588 
590 {
591  public:
592  explicit DVBInversion(const MultiplexID *id) :
593  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "inversion")
594  {
595  setLabel(QObject::tr("Inversion"));
596  setHelpText(QObject::tr("Inversion (Default: Auto):\n"
597  "Most cards can autodetect this now, so leave it at Auto"
598  " unless it won't work."));
599  addSelection(QObject::tr("Auto"), "a");
600  addSelection(QObject::tr("On"), "1");
601  addSelection(QObject::tr("Off"), "0");
602  };
603 };
604 
606 {
607  public:
608  explicit DVBTBandwidth(const MultiplexID *id) :
609  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "bandwidth")
610  {
611  setLabel(QObject::tr("Bandwidth"));
612  setHelpText(QObject::tr("Bandwidth (Default: Auto)"));
613  addSelection(QObject::tr("Auto"), "a");
614  addSelection(QObject::tr("6 MHz"), "6");
615  addSelection(QObject::tr("7 MHz"), "7");
616  addSelection(QObject::tr("8 MHz"), "8");
617  };
618 };
619 
621 {
622  public:
623  explicit DVBT2Bandwidth(const MultiplexID *id) :
624  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "bandwidth")
625  {
626  setLabel(QObject::tr("Bandwidth"));
627  setHelpText(QObject::tr("Bandwidth for DVB-T2 (Default: Auto)"));
628  addSelection(QObject::tr("Auto"), "a");
629  addSelection(QObject::tr("5 MHz"), "5");
630  addSelection(QObject::tr("6 MHz"), "6");
631  addSelection(QObject::tr("7 MHz"), "7");
632  addSelection(QObject::tr("8 MHz"), "8");
633  // addSelection(QObject::tr("10 MHz"), "10");
634  // addSelection(QObject::tr("1.712 MHz"), "1712");
635  };
636 };
637 
639 {
640  public:
642  MythUIComboBoxSetting(_storage)
643  {
644  addSelection(QObject::tr("Auto"), "auto");
645  addSelection(QObject::tr("None"), "none");
646  addSelection("1/2");
647  addSelection("2/3");
648  addSelection("3/4");
649  addSelection("3/5");
650  addSelection("4/5");
651  addSelection("5/6");
652  addSelection("6/7");
653  addSelection("7/8");
654  addSelection("8/9");
655  addSelection("9/10");
656  };
657 };
658 
661 {
662  public:
665  MuxDBStorage(this, id, "fec")
666  {
667  setLabel(QObject::tr("FEC"));
668  setHelpText(QObject::tr("Forward Error Correction (Default: Auto)"));
669  };
670 };
671 
674 {
675  public:
676  explicit DVBTCoderateLP(const MultiplexID *id) :
678  MuxDBStorage(this, id, "lp_code_rate")
679  {
680  setLabel(QObject::tr("LP Coderate"));
681  setHelpText(QObject::tr("Low Priority Code Rate (Default: Auto)"));
682  };
683 };
684 
687 {
688  public:
689  explicit DVBTCoderateHP(const MultiplexID *id) :
691  MuxDBStorage(this, id, "hp_code_rate")
692  {
693  setLabel(QObject::tr("HP Coderate"));
694  setHelpText(QObject::tr("High Priority Code Rate (Default: Auto)"));
695  };
696 };
697 
699 {
700  public:
701  explicit DVBTGuardInterval(const MultiplexID *id) :
702  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "guard_interval")
703  {
704  setLabel(QObject::tr("Guard Interval"));
705  setHelpText(QObject::tr("Guard Interval for DVB-T (Default: Auto)"));
706  addSelection(QObject::tr("Auto"), "auto");
707  addSelection("1/4");
708  addSelection("1/8");
709  addSelection("1/16");
710  addSelection("1/32");
711  };
712 };
713 
715 {
716  public:
717  explicit DVBT2GuardInterval(const MultiplexID *id) :
718  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "guard_interval")
719  {
720  setLabel(QObject::tr("Guard Interval"));
721  setHelpText(QObject::tr("Guard Interval for DVB-T2 (Default: Auto)"));
722  addSelection(QObject::tr("Auto"), "auto");
723  addSelection("1/4");
724  addSelection("1/8");
725  addSelection("1/16");
726  addSelection("1/32");
727  addSelection("1/128");
728  addSelection("19/128");
729  addSelection("19/256");
730  };
731 };
732 
734 {
735  public:
736  explicit DVBTTransmissionMode(const MultiplexID *id) :
737  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "transmission_mode")
738  {
739  setLabel(QObject::tr("Transmission Mode"));
740  setHelpText(QObject::tr("Transmission Mode for DVB-T (Default: Auto)"));
741  addSelection(QObject::tr("Auto"), "a");
742  addSelection("2K", "2");
743  addSelection("8K", "8");
744  };
745 };
746 
747 // The 16k and 32k modes do require a database schema update because
748 // field dtv_multiplex:transmission_mode is now only one character.
749 //
751 {
752  public:
753  explicit DVBT2TransmissionMode(const MultiplexID *id) :
754  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "transmission_mode")
755  {
756  setLabel(QObject::tr("Transmission Mode"));
757  setHelpText(QObject::tr("Transmission Mode for DVB-T2 (Default: Auto)"));
758  addSelection(QObject::tr("Auto"), "a");
759  addSelection("1K", "1");
760  addSelection("2K", "2");
761  addSelection("4K", "4");
762  addSelection("8K", "8");
763  // addSelection("16K", "16");
764  // addSelection("32K", "32");
765  };
766 };
767 
769 {
770  public:
771  explicit DVBTHierarchy(const MultiplexID *id) :
772  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "hierarchy")
773  {
774  setLabel(QObject::tr("Hierarchy"));
775  setHelpText(QObject::tr("Hierarchy (Default: Auto)"));
776  addSelection(QObject::tr("Auto"), "a");
777  addSelection(QObject::tr("None"), "n");
778  addSelection("1");
779  addSelection("2");
780  addSelection("4");
781  }
782 };
783 
785 {
786  public:
787  explicit DVBTModulationSystem(const MultiplexID *id) :
788  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "mod_sys")
789  {
790  setLabel(QObject::tr("Modulation System"));
791  setHelpText(QObject::tr("Modulation System (Default: DVB-T2)"));
792  addSelection("DVB-T", "DVB-T");
793  addSelection("DVB-T2", "DVB-T2", true);
794  };
795 };
796 
798 {
799  public:
800  explicit DVBSModulationSystem(const MultiplexID *id) :
801  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "mod_sys")
802  {
803  setLabel(QObject::tr("Modulation System"));
804  setHelpText(QObject::tr("Modulation System (Default: DVB-S2)"));
805  addSelection("DVB-S", "DVB-S");
806  addSelection("DVB-S2", "DVB-S2", true);
807  }
808 };
809 
811 {
812  public:
813  explicit DVBCModulationSystem(const MultiplexID *id) :
814  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "mod_sys")
815  {
816  setLabel(QObject::tr("Modulation System"));
817  setHelpText(QObject::tr("Modulation System (Default: DVB-C/A)"));
818  addSelection("DVB-C/A", "DVB-C/A", true);
819  addSelection("DVB-C/B", "DVB-C/B");
820  addSelection("DVB-C/C", "DVB-C/C");
821  }
822 };
823 
825 {
826  public:
827  explicit RollOff(const MultiplexID *id) :
828  MythUIComboBoxSetting(this), MuxDBStorage(this, id, "rolloff")
829  {
830  setLabel(QObject::tr("Roll-off"));
831  setHelpText(QObject::tr("Roll-off factor (Default: 0.35)"));
832  addSelection("0.35");
833  addSelection("0.20");
834  addSelection("0.25");
835  addSelection(QObject::tr("Auto"), "auto");
836  }
837 };
838 
839 TransportSetting::TransportSetting(const QString &label, uint mplexid,
840  uint sourceid, uint cardtype)
841  : m_mplexid(new MultiplexID())
842 {
843  setLabel(label);
844 
845  // Must be first.
846  m_mplexid->setValue(mplexid);
848  addChild(new VideoSourceID(m_mplexid, sourceid));
849 
850  if (CardUtil::OFDM == cardtype)
851  {
852  addChild(new DTVStandard(m_mplexid, true, false));
856  addChild(new Modulation(m_mplexid, cardtype));
857 
863  }
864  else if (CardUtil::DVBT2 == cardtype)
865  {
866  addChild(new DTVStandard(m_mplexid, true, false));
870  addChild(new Modulation(m_mplexid, cardtype));
872 
878  }
879  else if (CardUtil::QPSK == cardtype ||
880  CardUtil::DVBS2 == cardtype)
881  {
882  addChild(new DTVStandard(m_mplexid, true, false));
883  addChild(new Frequency(m_mplexid, true));
886  addChild(new Modulation(m_mplexid, cardtype));
890 
891  if (CardUtil::DVBS2 == cardtype)
892  addChild(new RollOff(m_mplexid));
893  }
894  else if (CardUtil::QAM == cardtype)
895  {
896  addChild(new DTVStandard(m_mplexid, true, false));
899  addChild(new Modulation(m_mplexid, cardtype));
903  }
904  else if (CardUtil::ATSC == cardtype ||
905  CardUtil::HDHOMERUN == cardtype)
906  {
907  addChild(new DTVStandard(m_mplexid, false, true));
909  addChild(new Modulation(m_mplexid, cardtype));
910  }
911  else if ((CardUtil::FIREWIRE == cardtype) ||
912  (CardUtil::FREEBOX == cardtype))
913  {
914  addChild(new DTVStandard(m_mplexid, true, true));
915  }
916  else if ((CardUtil::V4L == cardtype) ||
917  (CardUtil::MPEG == cardtype))
918  {
920  addChild(new Modulation(m_mplexid, cardtype));
921  }
922 }
923 
924 bool TransportSetting::keyPressEvent(QKeyEvent *event)
925 {
926  QStringList actions;
927  bool handled =
928  GetMythMainWindow()->TranslateKeyPress("Global", event, actions);
929 
930  for (int i = 0; i < actions.size() && !handled; i++)
931  {
932  QString action = actions[i];
933 
934  if (action == "DELETE")
935  {
936  handled = true;
937  emit deletePressed();
938  }
939  else if (action == "MENU")
940  {
941  handled = true;
942  emit openMenu();
943  }
944  }
945 
946  return handled;
947 }
948 
950 {
951  return m_mplexid->getValue().toUInt();
952 }
Collection of helper utilities for input DB use.
Definition: cardutil.h:40
void Delete(TransportSetting *transport)
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
static uint GetSourceID(const QString &name)
Definition: sourceutil.cpp:69
static bool HDHRdoesDVBC(const QString &device)
uint getMplexId() const
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
QString GetColumnName(void) const
Definition: mythstorage.h:47
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
MuxDBStorage(StorageUser *_setting, const MultiplexID *_id, const QString &_name)
DVBForwardErrorCorrectionSelector(Storage *_storage)
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
static QString ProbeSubTypeName(uint inputid)
Definition: cardutil.cpp:929
static QString pp_modulation(const QString &mod)
static enum INPUT_TYPES toInputType(const QString &name)
Definition: cardutil.h:72
void settingsChanged(StandardSetting *selectedSetting=nullptr)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
TransportListEditor(uint initial_sourceid)
virtual void Load(void)
Basic menu dialog, message and a list of options.
void addSelection(const QString &label, QString value=QString(), bool select=false)
virtual void setHelpText(const QString &str)
DVBTHierarchy(const MultiplexID *id)
VideoSourceShow * m_videosource
DVBForwardErrorCorrection(const MultiplexID *id)
MythScreenStack * GetStack(const QString &stackname)
bool keyPressEvent(QKeyEvent *event) override
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
virtual QString GetDBValue(void) const =0
static MythThemedMenu * menu
void edit(MythScreenType *) override
QString GetWhereClause(MSqlBindings &bindings) const override
QString GetColumnName(void) const
virtual QString getValue(void) const
DVBT2Bandwidth(const MultiplexID *id)
void Menu(TransportSetting *transport)
void SetSourceID(uint _sourceid)
DVBSModulationSystem(const MultiplexID *id)
QVariant value(int i) const
Definition: mythdbcon.h:198
DVBTBandwidth(const MultiplexID *id)
void resultEdit(DialogCompletionEvent *) override
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
SignalPolarity(const MultiplexID *id)
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:98
VideoSourceID(const MultiplexID *id, uint _sourceid)
MSqlQuery query(MSqlQuery::InitCon())
DVBT2GuardInterval(const MultiplexID *id)
static bool HDHRdoesDVB(const QString &device)
DVBCModulationSystem(const MultiplexID *id)
virtual void setLabel(QString str)
DVBTTransmissionMode(const MultiplexID *id)
DVBInversion(const MultiplexID *id)
StorageUser * m_user
Definition: mythstorage.h:50
void valueChanged(const QString &newValue)
bool isActive(void) const
Definition: mythdbcon.h:204
DVBT2TransmissionMode(const MultiplexID *id)
DVBTModulationSystem(const MultiplexID *id)
unsigned int uint
Definition: compat.h:140
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
QString GetSetClause(MSqlBindings &bindings) const override
virtual void addChild(StandardSetting *child)
DVBTCoderateHP(const MultiplexID *id)
DVBTGuardInterval(const MultiplexID *id)
MythMainWindow * GetMythMainWindow(void)
DTVStandard(const MultiplexID *id, bool is_dvb_country, bool is_atsc_country)
static QString GetVideoDevice(uint inputid)
Definition: cardutil.h:279
void setVisible(bool visible)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808
QVector< StandardSetting * > m_list
Modulation(const MultiplexID *id, uint nType)
Frequency(const MultiplexID *id, bool in_kHz=false)
DVBCSymbolRate(const MultiplexID *id)
TransportSetting(const QString &label, uint mplexid, uint sourceid, uint cardtype)
static QString GetRawInputType(uint inputid)
Definition: cardutil.h:277
RollOff(const MultiplexID *id)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
MultiplexID * m_mplexid
const MultiplexID * m_mplexId
static CardUtil::INPUT_TYPES get_cardtype(uint sourceid)
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
Screen in which all other widgets are contained and rendered.
QString GetHostName(void)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
INPUT_TYPES
all the different inputs
Definition: cardutil.h:46
virtual void setValue(const QString &newValue)
DVBSSymbolRate(const MultiplexID *id)
virtual void removeChild(StandardSetting *child)
void Load(void) override
DVBTCoderateLP(const MultiplexID *id)