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  struct CHANLIST* curList = chanlists[0].list;
61  int totalChannels = chanlists[0].count;
62  int findFrequency = (query.value(3).toInt() / 1000) - 1750;
63  for (int x = 0 ; x < totalChannels ; ++x)
64  {
65  if ((curList[x].freq <= findFrequency + 200) &&
66  (curList[x].freq >= findFrequency - 200))
67  {
68  ChannelNumber = QString("%1").arg(curList[x].name);
69  }
70  }
71 
72  //: %1 is the channel number
73  DisplayText = tr("ATSC Channel %1").arg(ChannelNumber);
74  }
75  else
76  {
77  DisplayText = QString("%1 Hz (%2) (%3) (%4)")
78  .arg(query.value(3).toString())
79  .arg(query.value(4).toString())
80  .arg(query.value(1).toInt())
81  .arg(query.value(2).toInt());
82  }
83  addSelection(DisplayText, query.value(0).toString());
84  }
85 }
86 
88 {
89  m_sourceid = sourceid;
90  Load();
91 }
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:782
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:863
int freq
Definition: frequencies.h:98
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
void addSelection(const QString &label, QString value=QString(), bool select=false)
int size(void) const
Definition: mythdbcon.h:203
struct CHANLIST * list
Definition: frequencies.h:103
unsigned int uint
Definition: compat.h:140
uint32_t freq[4]
Definition: element.c:44
QVariant value(int i) const
Definition: mythdbcon.h:198
struct CHANLISTS chanlists[]
bool isActive(void) const
Definition: mythdbcon.h:204
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
const char * name
Definition: ParseText.cpp:328
void Load(void) override
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:807
void SetSourceID(uint sourceid)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603