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 
34  m_transportStart->setLabel(tr("First Channel"));
35  m_transportStart->setHelpText(tr("Start scanning at this channel."));
36 
38  m_transportEnd->setLabel(tr("Last Channel"));
39  m_transportEnd->setHelpText(tr("Stop scanning after this channel."));
40 
42  m_transportCount->setLabel(tr("Channel Count"));
43  m_transportCount->setHelpText(tr("Total number of channels to scan."));
45 
46  auto *range = new GroupSetting();
47  range->setLabel(tr("Scanning Range"));
48  range->addChild(m_transportStart);
49  range->addChild(m_transportEnd);
50  range->addChild(m_transportCount);
51 
52  setting->addTargetedChildren(target,
53  {this, m_atscTable, m_atscModulation, range});
54 
55  connect(m_transportStart, qOverload<const QString&>(&StandardSetting::valueChanged),
57  connect(m_transportEnd, qOverload<const QString&>(&StandardSetting::valueChanged),
59 
61  }
62 
63  ~PaneATSC() override
64  {
65  while (!m_tables.empty())
66  {
67  delete m_tables.back();
68  m_tables.pop_back();
69  }
70  }
71 
72  void SetFrequencyTable(const QString &atsc_table)
73  { m_atscTable->setValue(atsc_table); }
74 
75  QString GetFrequencyTable(void) const
76  { return m_atscTable->getValue(); }
77  QString GetModulation(void) const
78  { return m_atscModulation->getValue(); }
80  QString &start, QString &end) const
81  {
83  return false;
84 
85  start = m_transportStart->getValue();
86  end = m_transportEnd->getValue();
87 
88  return !start.isEmpty() && !end.isEmpty();
89  }
90 
91  protected slots:
92  void FreqTableChanged(const QString &freqtbl)
93  {
94  if (freqtbl == "us")
96  else if (m_atscModulation->getValue() == "vsb8")
98 
100  }
101 
102  void ModulationChanged(const QString &/*modulation*/)
103  {
105  }
106 
107  void TransportRangeChanged(const QString &/*range*/)
108  {
111  if (b < a)
112  {
114  b = a;
115  }
116 
117  int diff = std::max(b + 1 - a, 0);
118  m_transportCount->setValue(QString::number(diff));
119  }
120 
121  protected:
123  {
126  m_transportCount->setValue(QString::number(0));
127 
129 
130  bool first = true;
131  for (auto it = m_tables.begin(); it != m_tables.end(); ++it)
132  {
133  auto next = it;
134  ++next;
135 
136  const FrequencyTable &ft = **it;
137  int name_num = ft.m_nameOffset;
138  QString strNameFormat = ft.m_nameFormat;
140  while (freq <= ft.m_frequencyEnd)
141  {
142  QString name = strNameFormat;
143  if (strNameFormat.indexOf("%") >= 0)
144  name = strNameFormat.arg(name_num);
145 
146  m_transportStart->addSelection(name, name, first);
147  first = false;
148 
149  bool last = (next == m_tables.end()) &&
150  ((freq + ft.m_frequencyStep) >= ft.m_frequencyEnd);
151  m_transportEnd->addSelection(name, name, last);
152 
153  name_num++;
154  freq += ft.m_frequencyStep;
155  }
156  }
157  }
158 
160  {
161  QString format = "atsc";
162  QString modulation = GetModulation();
163  QString country = GetFrequencyTable();
164 
165  const QString new_tables_sig =
166  QString("%1_%2_%3").arg(format, modulation, country);
167 
168  if (new_tables_sig != m_tablesSig)
169  {
170  while (!m_tables.empty())
171  {
172  delete m_tables.back();
173  m_tables.pop_back();
174  }
175 
176  m_tablesSig = new_tables_sig;
177 
179  format, modulation, country);
180  }
181  }
182 
183  protected:
189  QString m_tablesSig;
191 };
192 
193 #endif // PANE_ATSC_H
PaneATSC::SetFrequencyTable
void SetFrequencyTable(const QString &atsc_table)
Definition: paneatsc.h:72
PaneATSC::FreqTableChanged
void FreqTableChanged(const QString &freqtbl)
Definition: paneatsc.h:92
MythUIComboBoxSetting::clearSelections
void clearSelections()
Definition: standardsettings.cpp:514
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:170
ScanATSCModulation
Definition: modulationsetting.h:39
PaneATSC::ResetTransportRange
void ResetTransportRange(void)
Definition: paneatsc.h:122
freq_table_list_t
std::vector< const FrequencyTable * > freq_table_list_t
Definition: frequencytables.h:25
TransMythUIComboBoxSetting
Definition: standardsettings.h:272
PaneATSC::ModulationChanged
void ModulationChanged(const QString &)
Definition: paneatsc.h:102
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:185
PaneATSC::GetFrequencyTable
QString GetFrequencyTable(void) const
Definition: paneatsc.h:75
PaneATSC
Definition: paneatsc.h:16
PaneATSC::m_transportStart
TransMythUIComboBoxSetting * m_transportStart
Definition: paneatsc.h:186
PaneATSC::m_tables
freq_table_list_t m_tables
Definition: paneatsc.h:190
frequencytablesetting.h
modulationsetting.h
StandardSetting::setHelpText
virtual void setHelpText(const QString &str)
Definition: standardsettings.h:37
FrequencyTable::m_frequencyStep
uint64_t m_frequencyStep
Definition: frequencytables.h:102
MythUIComboBoxSetting::getValueIndex
int getValueIndex(const QString &value) const
Definition: standardsettings.cpp:488
StandardSetting::setReadOnly
virtual void setReadOnly(bool readonly)
Definition: standardsettings.cpp:54
StandardSetting::getValue
virtual QString getValue(void) const
Definition: standardsettings.h:52
uint
unsigned int uint
Definition: compat.h:79
PaneATSC::~PaneATSC
~PaneATSC() override
Definition: paneatsc.h:63
PaneATSC::m_transportEnd
TransMythUIComboBoxSetting * m_transportEnd
Definition: paneatsc.h:187
PaneATSC::m_tablesSig
QString m_tablesSig
Definition: paneatsc.h:189
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:79
StandardSetting::setLabel
virtual void setLabel(QString str)
Definition: standardsettings.h:34
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:499
frequencytables.h
ScanFrequencyTable
Definition: frequencytablesetting.h:10
PaneATSC::TransportRangeChanged
void TransportRangeChanged(const QString &)
Definition: paneatsc.h:107
FrequencyTable::m_nameOffset
int m_nameOffset
Definition: frequencytables.h:99
StandardSetting::setVisible
void setVisible(bool visible)
Definition: standardsettings.cpp:60
StandardSetting
Definition: standardsettings.h:29
PaneATSC::m_transportCount
GroupSetting * m_transportCount
Definition: paneatsc.h:188
PaneATSC::GetModulation
QString GetModulation(void) const
Definition: paneatsc.h:77
StandardSetting::addTargetedChildren
void addTargetedChildren(const QString &value, std::initializer_list< StandardSetting * > settings)
Definition: standardsettings.cpp:107
PaneATSC::m_atscTable
ScanFrequencyTable * m_atscTable
Definition: paneatsc.h:184
FrequencyTable::m_frequencyStart
uint64_t m_frequencyStart
Definition: frequencytables.h:100
PaneATSC::FetchFrequencyTables
void FetchFrequencyTables(void)
Definition: paneatsc.h:159
MythUIComboBoxSetting::setValue
void setValue(int value) override
Definition: standardsettings.cpp:479
MythUIComboBoxSetting::size
virtual int size(void) const
Definition: standardsettings.cpp:621
GroupSetting
Definition: standardsettings.h:435