MythTV  master
multiplexsetting.cpp
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * vim: set expandtab tabstop=4 shiftwidth=4:
3  *
4  * Original Project
5  * MythTV http://www.mythtv.org
6  *
7  * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
8  * Copyright (c) 2005 - 2007 Daniel Kristjansson
9  *
10  * Description:
11  * Collection of classes to provide channel scanning functionallity
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27  *
28  */
29 
30 #include "multiplexsetting.h"
31 #include "frequencies.h"
32 
34 {
36 
37  if (!m_sourceid)
38  return;
39 
41 
42  query.prepare(
43  "SELECT mplexid, networkid, transportid, "
44  " frequency, symbolrate, modulation "
45  "FROM dtv_multiplex "
46  "WHERE sourceid = :SOURCEID "
47  "ORDER by frequency, networkid, transportid");
48  query.bindValue(":SOURCEID", m_sourceid);
49 
50  if (!query.exec() || !query.isActive() || query.size() <= 0)
51  return;
52 
53  while (query.next())
54  {
55  QString DisplayText;
56  if (query.value(5).toString() == "8vsb")
57  {
58  QString ChannelNumber =
59  QString("Freq %1").arg(query.value(3).toInt());
60  int findFrequency = (query.value(3).toInt() / 1000) - 1750;
61  for (const auto & list : gChanLists[0].list)
62  {
63  if ((list.freq <= findFrequency + 200) &&
64  (list.freq >= findFrequency - 200))
65  {
66  ChannelNumber = QString("%1").arg(list.name);
67  }
68  }
69 
70  //: %1 is the channel number
71  DisplayText = tr("ATSC Channel %1").arg(ChannelNumber);
72  }
73  else
74  {
75  DisplayText = QString("%1 Hz (%2) (%3) (%4)")
76  .arg(query.value(3).toString())
77  .arg(query.value(4).toString())
78  .arg(query.value(1).toInt())
79  .arg(query.value(2).toInt());
80  }
81  addSelection(DisplayText, query.value(0).toString());
82  }
83 }
84 
86 {
87  m_sourceid = sourceid;
88  Load();
89 }
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:204
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
MythUIComboBoxSetting::clearSelections
void clearSelections()
Definition: standardsettings.cpp:494
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:203
multiplexsetting.h
MultiplexSetting::Load
void Load(void) override
Definition: multiplexsetting.cpp:33
frequencies.h
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:198
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
MultiplexSetting::SetSourceID
void SetSourceID(uint sourceid)
Definition: multiplexsetting.cpp:85
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
MultiplexSetting::m_sourceid
uint m_sourceid
Definition: multiplexsetting.h:23
uint
unsigned int uint
Definition: compat.h:140
gChanLists
const CHANLISTS_vec gChanLists
Definition: frequencies.cpp:2230
MythUIComboBoxSetting::addSelection
void addSelection(const QString &label, QString value=QString(), bool select=false)
Definition: standardsettings.cpp:479
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
query
MSqlQuery query(MSqlQuery::InitCon())
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808