MythTV  0.28pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
scanwizardconfig.cpp
Go to the documentation of this file.
1 #include "scanwizardconfig.h"
2 
3 #include "videosource.h"
4 #include "cardutil.h"
6 
8 #include "inputselectorsetting.h"
9 #include "scanwizard.h"
10 
11 #include "panedvbs.h"
12 #include "panedvbs2.h"
13 #include "panedvbc.h"
14 #include "panedvbt.h"
15 #include "paneatsc.h"
16 #include "paneanalog.h"
17 #include "panesingle.h"
18 #include "paneall.h"
19 #include "panedvbutilsimport.h"
20 #include "paneexistingscanimport.h"
21 
23  ScanWizard *_parent,
24  uint default_sourceid, uint default_cardid,
25  QString default_inputname) :
27  videoSource(new VideoSourceSelector(
28  default_sourceid, CardUtil::GetScanableCardTypes(), false)),
29  input(new InputSelector(default_cardid, default_inputname)),
30  scanType(new ScanTypeSetting()),
31  scanConfig(new ScanOptionalConfig(scanType)),
32  services(new DesiredServices()),
33  ftaOnly(new FreeToAirOnly()),
34  trustEncSI(new TrustEncSISetting())
35 {
36  setLabel(tr("Scan Configuration"));
37 
38  ConfigurationGroup *cfg =
39  new HorizontalConfigurationGroup(false, false, true, true);
40  cfg->addChild(services);
41  cfg->addChild(ftaOnly);
42  cfg->addChild(trustEncSI);
43 
45  addChild(input);
46  addChild(cfg);
49 
50  connect(videoSource, SIGNAL(valueChanged(const QString&)),
51  scanConfig, SLOT( SetSourceID( const QString&)));
52 
53  connect(videoSource, SIGNAL(valueChanged(const QString&)),
54  input, SLOT( SetSourceID( const QString&)));
55 
56  connect(input, SIGNAL(valueChanged(const QString&)),
57  scanType, SLOT( SetInput( const QString&)));
58 
59  connect(input, SIGNAL(valueChanged(const QString&)),
60  _parent, SLOT( SetInput( const QString&)));
61 }
62 
64 {
65  return videoSource->getValue().toUInt();
66 }
67 
69 {
71 }
72 
74 {
75  return ftaOnly->getValue().toInt();
76 }
77 
79 {
80  return trustEncSI->getValue().toInt();
81 }
82 
85 
86 void ScanTypeSetting::SetInput(const QString &cardids_inputname)
87 {
88  uint cardid = 0;
89  QString inputname = QString::null;
90  if (!InputSelector::Parse(cardids_inputname, cardid, inputname))
91  return;
92 
93  // Only refresh if we really have to. If we do it too often
94  // Then we end up fighting the scan routine when we want to
95  // check the type of dvb card :/
96  if (cardid == hw_cardid)
97  return;
98 
99  hw_cardid = cardid;
100  QString subtype = CardUtil::ProbeSubTypeName(hw_cardid);
101  int nCardType = CardUtil::toCardType(subtype);
102  clearSelections();
103 
104  switch (nCardType)
105  {
106  case CardUtil::V4L:
107  case CardUtil::MPEG:
108  addSelection(tr("Full Scan"),
109  QString::number(FullScan_Analog), true);
110  addSelection(tr("Import existing scan"),
111  QString::number(ExistingScanImport));
112  return;
113  case CardUtil::DVBT:
114  addSelection(tr("Full Scan"),
115  QString::number(FullScan_DVBT), true);
116  addSelection(tr("Full Scan (Tuned)"),
117  QString::number(NITAddScan_DVBT));
118 // addSelection(tr("Import channels.conf"),
119 // QString::number(DVBUtilsImport));
120  addSelection(tr("Import existing scan"),
121  QString::number(ExistingScanImport));
122  break;
123  case CardUtil::DVBS:
124  addSelection(tr("Full Scan (Tuned)"),
125  QString::number(NITAddScan_DVBS));
126 // addSelection(tr("Import channels.conf"),
127 // QString::number(DVBUtilsImport));
128  addSelection(tr("Import existing scan"),
129  QString::number(ExistingScanImport));
130  break;
131  case CardUtil::DVBS2:
132  addSelection(tr("Full Scan (Tuned)"),
133  QString::number(NITAddScan_DVBS2));
134 // addSelection(tr("Import channels.conf"),
135 // QString::number(DVBUtilsImport));
136  addSelection(tr("Import existing scan"),
137  QString::number(ExistingScanImport));
138  break;
139  case CardUtil::QAM:
140  addSelection(tr("Full Scan (Tuned)"),
141  QString::number(NITAddScan_DVBC));
142  addSelection(tr("Full Scan"),
143  QString::number(FullScan_DVBC));
144 // addSelection(tr("Import channels.conf"),
145 // QString::number(DVBUtilsImport));
146  addSelection(tr("Import existing scan"),
147  QString::number(ExistingScanImport));
148  break;
149  case CardUtil::ATSC:
150  addSelection(tr("Full Scan"),
151  QString::number(FullScan_ATSC), true);
152 // addSelection(tr("Import channels.conf"),
153 // QString::number(DVBUtilsImport));
154  addSelection(tr("Import existing scan"),
155  QString::number(ExistingScanImport));
156  break;
157  case CardUtil::HDHOMERUN:
159  {
160  addSelection(tr("Full Scan"),
161  QString::number(FullScan_DVBT), true);
162  addSelection(tr("Full Scan (Tuned)"),
163  QString::number(NITAddScan_DVBT));
164  }
165  else
166  addSelection(tr("Full Scan"),
167  QString::number(FullScan_ATSC), true);
168 // addSelection(tr("Import channels.conf"),
169 // QString::number(DVBUtilsImport));
170  addSelection(tr("Import existing scan"),
171  QString::number(ExistingScanImport));
172  break;
173  case CardUtil::FREEBOX:
174  addSelection(tr("M3U Import with MPTS"),
175  QString::number(IPTVImportMPTS), true);
176  addSelection(tr("M3U Import"),
177  QString::number(IPTVImport), true);
178  return;
179  case CardUtil::ASI:
180  addSelection(tr("ASI Scan"),
181  QString::number(CurrentTransportScan), true);
182  return;
184  addSelection(tr("Failed to probe the card"),
185  QString::number(Error_Probe), true);
186  return;
187  default:
188  addSelection(tr("Failed to open the card"),
189  QString::number(Error_Open), true);
190  return;
191  }
192 
193  addSelection(tr("Scan of all existing transports"),
194  QString::number(FullTransportScan));
195  addSelection(tr("Scan of single existing transport"),
196  QString::number(TransportScan));
197 }
198 
201 
204  false, false, true, true),
205  scanType(_scan_type),
206  country(new ScanCountry()),
207  network(new ScanNetwork()),
208  paneDVBT(new PaneDVBT()), paneDVBS(new PaneDVBS()),
209  paneDVBS2(new PaneDVBS2()), paneATSC(new PaneATSC()),
210  paneDVBC(new PaneDVBC()), paneAnalog(new PaneAnalog()),
211  paneSingle(new PaneSingle()), paneAll(new PaneAll()),
212  paneDVBUtilsImport(new PaneDVBUtilsImport()),
213  paneExistingScanImport(new PaneExistingScanImport())
214 {
216 
217  // only save settings for the selected pane
218  setSaveAll(false);
219 
220  addTarget(QString::number(ScanTypeSetting::Error_Open),
221  new PaneError(tr("Failed to open the card")));
222  addTarget(QString::number(ScanTypeSetting::Error_Probe),
223  new PaneError(tr("Failed to probe the card")));
225  paneDVBC);
227  paneDVBS);
229  paneDVBS2);
231  paneDVBT);
232  addTarget(QString::number(ScanTypeSetting::FullScan_ATSC),
233  paneATSC);
234  addTarget(QString::number(ScanTypeSetting::FullScan_DVBC),
235  network);
236  addTarget(QString::number(ScanTypeSetting::FullScan_DVBT),
237  country);
239  paneAnalog);
240  addTarget(QString::number(ScanTypeSetting::TransportScan),
241  paneSingle);
243  paneAll);
245  new BlankSetting());
246  addTarget(QString::number(ScanTypeSetting::IPTVImport),
247  new BlankSetting());
248 // addTarget(QString::number(ScanTypeSetting::DVBUtilsImport),
249 // paneDVBUtilsImport);
252 }
253 
254 void ScanOptionalConfig::triggerChanged(const QString& value)
255 {
257 }
258 
259 void ScanOptionalConfig::SetSourceID(const QString &sourceid)
260 {
261  paneAnalog->SetSourceID(sourceid.toUInt());
262  paneSingle->SetSourceID(sourceid.toUInt());
263  paneExistingScanImport->SetSourceID(sourceid.toUInt());
264 }
265 
267 {
268  int st = scanType->getValue().toInt();
269 
270  switch (st)
271  {
273  return "atsc";
275  return "dvbc";
277  return "dvbt";
279  return "analog";
280  default:
281  return "unknown";
282  }
283 }
284 
286 {
287  int st = scanType->getValue().toInt();
288 
289  switch (st)
290  {
292  return paneATSC->GetModulation();
294  return "qam";
296  return "ofdm";
298  return "analog";
299  default:
300  return "unknown";
301  }
302 }
303 
305 {
306  int st = scanType->getValue().toInt();
307 
308  switch (st)
309  {
311  return paneATSC->GetFrequencyTable();
313  return network->getValue();
315  return country->getValue();
317  return paneAnalog->GetFrequencyTable();
318  default:
319  return "unknown";
320  }
321 }
322 
324  QString &start, QString &end) const
325 {
326  start = end = QString::null;
327 
328  int st = scanType->getValue().toInt();
330  return paneATSC->GetFrequencyTableRange(start, end);
331 
332  return false;
333 }
334 
336 {
337  int st = scanType->getValue().toInt();
338 
339  switch (st)
340  {
344  return paneAll->ignoreSignalTimeout();
347  default:
348  return false;
349  }
350 }
351 
353 {
354  int st = scanType->getValue().toInt();
355  switch (st)
356  {
358  return paneSingle->GetFollowNIT();
360  return paneAll->GetFollowNIT();
361  default:
362  return false;
363  }
364 }
365 
367 {
369 }
370 
372 {
373  int mplexid = paneSingle->GetMultiplex();
374  return (mplexid <= 0) ? 0 : mplexid;
375 }
376 
378 {
380 }
381 
382 QMap<QString,QString> ScanOptionalConfig::GetStartChan(void) const
383 {
384  QMap<QString,QString> startChan;
385 
386  int st = scanType->getValue().toInt();
388  {
389  const PaneDVBT *pane = paneDVBT;
390 
391  startChan["std"] = "dvb";
392  startChan["type"] = "OFDM";
393  startChan["frequency"] = pane->frequency();
394  startChan["inversion"] = pane->inversion();
395  startChan["bandwidth"] = pane->bandwidth();
396  startChan["coderate_hp"] = pane->coderate_hp();
397  startChan["coderate_lp"] = pane->coderate_lp();
398  startChan["constellation"] = pane->constellation();
399  startChan["trans_mode"] = pane->trans_mode();
400  startChan["guard_interval"] = pane->guard_interval();
401  startChan["hierarchy"] = pane->hierarchy();
402  }
403  else if (ScanTypeSetting::NITAddScan_DVBS == st)
404  {
405  const PaneDVBS *pane = paneDVBS;
406 
407  startChan["std"] = "dvb";
408  startChan["type"] = "QPSK";
409  startChan["modulation"] = "qpsk";
410  startChan["frequency"] = pane->frequency();
411  startChan["inversion"] = pane->inversion();
412  startChan["symbolrate"] = pane->symbolrate();
413  startChan["fec"] = pane->fec();
414  startChan["polarity"] = pane->polarity();
415  }
416  else if (ScanTypeSetting::NITAddScan_DVBC == st)
417  {
418  const PaneDVBC *pane = paneDVBC;
419 
420  startChan["std"] = "dvb";
421  startChan["type"] = "QAM";
422  startChan["frequency"] = pane->frequency();
423  startChan["inversion"] = pane->inversion();
424  startChan["symbolrate"] = pane->symbolrate();
425  startChan["fec"] = pane->fec();
426  startChan["modulation"] = pane->modulation();
427  }
428  else if (ScanTypeSetting::NITAddScan_DVBS2 == st)
429  {
430  const PaneDVBS2 *pane = paneDVBS2;
431 
432  startChan["std"] = "dvb";
433  startChan["type"] = "DVB_S2";
434  startChan["frequency"] = pane->frequency();
435  startChan["inversion"] = pane->inversion();
436  startChan["symbolrate"] = pane->symbolrate();
437  startChan["fec"] = pane->fec();
438  startChan["modulation"] = pane->modulation();
439  startChan["polarity"] = pane->polarity();
440  startChan["mod_sys"] = pane->mod_sys();
441  startChan["rolloff"] = pane->rolloff();
442  }
443 
444  return startChan;
445 }