MythTV  master
paneatsc.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * vim: set expandtab tabstop=4 shiftwidth=4:
3  */
4 
5 #ifndef PANE_ATSC_H
6 #define PANE_ATSC_H
7 
8 #include <algorithm>
9 
10 // MythTV headers
12 #include "frequencytablesetting.h"
13 #include "modulationsetting.h"
14 #include "frequencytables.h"
15 
16 class PaneATSC : public GroupSetting
17 {
18  Q_OBJECT
19 
20  public:
21  PaneATSC(const QString &target, StandardSetting *setting) :
24  {
25  setVisible(false);
26 
27  connect(m_atscTable, qOverload<const QString&>(&StandardSetting::valueChanged),
29 
30  connect(m_atscModulation, qOverload<const QString&>(&StandardSetting::valueChanged),
32 
33  auto *range = new GroupSetting();
37  range->setLabel(tr("Scanning Range"));
38  range->addChild(m_transportStart);
39  range->addChild(m_transportEnd);
40  range->addChild(m_transportCount);
41 
42  setting->addTargetedChildren(target,
43  {this, m_atscTable, m_atscModulation, range});
44 
45  connect(m_transportStart, qOverload<const QString&>(&StandardSetting::valueChanged),
47  connect(m_transportEnd, qOverload<const QString&>(&StandardSetting::valueChanged),
49 
51  }
52 
53  ~PaneATSC() override
54  {
55  while (!m_tables.empty())
56  {
57  delete m_tables.back();
58  m_tables.pop_back();
59  }
60  }
61 
62  void SetFrequencyTable(const QString &atsc_table)
63  { m_atscTable->setValue(atsc_table); }
64 
65  QString GetFrequencyTable(void) const
66  { return m_atscTable->getValue(); }
67  QString GetModulation(void) const
68  { return m_atscModulation->getValue(); }
70  QString &start, QString &end) const
71  {
73  return false;
74 
75  start = m_transportStart->getValue();
76  end = m_transportEnd->getValue();
77 
78  return !start.isEmpty() && !end.isEmpty();
79  }
80 
81  protected slots:
82  void FreqTableChanged(const QString &freqtbl)
83  {
84  if (freqtbl == "us")
86  else if (m_atscModulation->getValue() == "vsb8")
88 
90  }
91 
92  void ModulationChanged(const QString &/*modulation*/)
93  {
95  }
96 
97  void TransportRangeChanged(const QString &/*range*/)
98  {
101  if (b < a)
102  {
104  b = a;
105  }
106 
107  int diff = std::max(b + 1 - a, 0);
108  m_transportCount->setValue(QString::number(diff));
109  }
110 
111  protected:
113  {
116  m_transportCount->setValue(QString::number(0));
117 
119 
120  bool first = true;
121  for (auto it = m_tables.begin(); it != m_tables.end(); ++it)
122  {
123  auto next = it;
124  ++next;
125 
126  const FrequencyTable &ft = **it;
127  int name_num = ft.m_nameOffset;
128  QString strNameFormat = ft.m_nameFormat;
130  while (freq <= ft.m_frequencyEnd)
131  {
132  QString name = strNameFormat;
133  if (strNameFormat.indexOf("%") >= 0)
134  name = strNameFormat.arg(name_num);
135 
136  m_transportStart->addSelection(name, name, first);
137  first = false;
138 
139  bool last = (next == m_tables.end()) &&
140  ((freq + ft.m_frequencyStep) >= ft.m_frequencyEnd);
141  m_transportEnd->addSelection(name, name, last);
142 
143  name_num++;
144  freq += ft.m_frequencyStep;
145  }
146  }
147  }
148 
150  {
151  QString format = "atsc";
152  QString modulation = GetModulation();
153  QString country = GetFrequencyTable();
154 
155  const QString new_tables_sig =
156  QString("%1_%2_%3").arg(format, modulation, country);
157 
158  if (new_tables_sig != m_tablesSig)
159  {
160  while (!m_tables.empty())
161  {
162  delete m_tables.back();
163  m_tables.pop_back();
164  }
165 
166  m_tablesSig = new_tables_sig;
167 
169  format, modulation, country);
170  }
171  }
172 
173  protected:
179  QString m_tablesSig;
181 };
182 
183 #endif // PANE_ATSC_H
PaneATSC::SetFrequencyTable
void SetFrequencyTable(const QString &atsc_table)
Definition: paneatsc.h:62
PaneATSC::FreqTableChanged
void FreqTableChanged(const QString &freqtbl)
Definition: paneatsc.h:82
MythUIComboBoxSetting::clearSelections
void clearSelections()
Definition: standardsettings.cpp:513
PaneATSC::PaneATSC
PaneATSC(const QString &target, StandardSetting *setting)
Definition: paneatsc.h:21
FrequencyTable
Definition: frequencytables.h:38
StandardSetting::setValue
virtual void setValue(const QString &newValue)
Definition: standardsettings.cpp:169
ScanATSCModulation
Definition: modulationsetting.h:39
PaneATSC::ResetTransportRange
void ResetTransportRange(void)
Definition: paneatsc.h:112
freq_table_list_t
std::vector< const FrequencyTable * > freq_table_list_t
Definition: frequencytables.h:25
TransMythUIComboBoxSetting
Definition: standardsettings.h:272
TransTextEditSetting
Definition: standardsettings.h:161
PaneATSC::ModulationChanged
void ModulationChanged(const QString &)
Definition: paneatsc.h:92
FrequencyTable::m_nameFormat
QString m_nameFormat
Definition: frequencytables.h:98
freq
static const std::array< const uint32_t, 4 > freq
Definition: element.cpp:45
GroupSetting::GroupSetting
GroupSetting()=default
PaneATSC::m_atscModulation
ScanATSCModulation * m_atscModulation
Definition: paneatsc.h:175
PaneATSC::GetFrequencyTable
QString GetFrequencyTable(void) const
Definition: paneatsc.h:65
PaneATSC
Definition: paneatsc.h:16
PaneATSC::m_transportCount
TransTextEditSetting * m_transportCount
Definition: paneatsc.h:178
FrequencyTable::m_frequencyStep
uint m_frequencyStep
Definition: frequencytables.h:102
PaneATSC::m_transportStart
TransMythUIComboBoxSetting * m_transportStart
Definition: paneatsc.h:176
PaneATSC::m_tables
freq_table_list_t m_tables
Definition: paneatsc.h:180
frequencytablesetting.h
modulationsetting.h
MythUIComboBoxSetting::getValueIndex
int getValueIndex(const QString &value) const
Definition: standardsettings.cpp:487
StandardSetting::getValue
virtual QString getValue(void) const
Definition: standardsettings.h:52
uint
unsigned int uint
Definition: compat.h:140
PaneATSC::~PaneATSC
~PaneATSC() override
Definition: paneatsc.h:53
PaneATSC::m_transportEnd
TransMythUIComboBoxSetting * m_transportEnd
Definition: paneatsc.h:177
PaneATSC::m_tablesSig
QString m_tablesSig
Definition: paneatsc.h:179
channelscanmiscsettings.h
get_matching_freq_tables
freq_table_list_t get_matching_freq_tables(const QString &format, const QString &modulation, const QString &country)
Definition: frequencytables.cpp:246
PaneATSC::GetFrequencyTableRange
bool GetFrequencyTableRange(QString &start, QString &end) const
Definition: paneatsc.h:69
FrequencyTable::m_frequencyEnd
uint64_t m_frequencyEnd
Definition: frequencytables.h:101
StandardSetting::valueChanged
void valueChanged(const QString &newValue)
MythUIComboBoxSetting::addSelection
void addSelection(const QString &label, QString value=QString(), bool select=false)
Definition: standardsettings.cpp:498
frequencytables.h
ScanFrequencyTable
Definition: frequencytablesetting.h:10
PaneATSC::TransportRangeChanged
void TransportRangeChanged(const QString &)
Definition: paneatsc.h:97
FrequencyTable::m_nameOffset
int m_nameOffset
Definition: frequencytables.h:99
StandardSetting::setVisible
void setVisible(bool visible)
Definition: standardsettings.cpp:59
StandardSetting
Definition: standardsettings.h:29
PaneATSC::GetModulation
QString GetModulation(void) const
Definition: paneatsc.h:67
StandardSetting::addTargetedChildren
void addTargetedChildren(const QString &value, std::initializer_list< StandardSetting * > settings)
Definition: standardsettings.cpp:106
PaneATSC::m_atscTable
ScanFrequencyTable * m_atscTable
Definition: paneatsc.h:174
FrequencyTable::m_frequencyStart
uint64_t m_frequencyStart
Definition: frequencytables.h:100
PaneATSC::FetchFrequencyTables
void FetchFrequencyTables(void)
Definition: paneatsc.h:149
MythUIComboBoxSetting::setValue
void setValue(int value) override
Definition: standardsettings.cpp:478
MythUIComboBoxSetting::size
virtual int size(void) const
Definition: standardsettings.cpp:620
GroupSetting
Definition: standardsettings.h:435