MythTV  0.26-pre
multiplexsetting.cpp
Go to the documentation of this file.
00001 /* -*- Mode: c++ -*-
00002  * vim: set expandtab tabstop=4 shiftwidth=4:
00003  *
00004  * Original Project
00005  *      MythTV      http://www.mythtv.org
00006  *
00007  * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
00008  * Copyright (c) 2005 - 2007 Daniel Kristjansson
00009  *
00010  * Description:
00011  *     Collection of classes to provide channel scanning functionallity
00012  *
00013  * This program is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU General Public License
00015  * as published by the Free Software Foundation; either version 2
00016  * of the License, or (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00026  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
00027  *
00028  */
00029 
00030 #include "multiplexsetting.h"
00031 #include "frequencies.h"
00032 
00033 void MultiplexSetting::Load(void)
00034 {
00035     clearSelections();
00036 
00037     if (!sourceid)
00038         return;
00039 
00040     MSqlQuery query(MSqlQuery::InitCon());
00041 
00042     query.prepare(
00043         "SELECT mplexid,   networkid,  transportid, "
00044         "       frequency, symbolrate, modulation "
00045         "FROM dtv_multiplex "
00046         "WHERE sourceid = :SOURCEID "
00047         "ORDER by frequency, networkid, transportid");
00048     query.bindValue(":SOURCEID", sourceid);
00049 
00050     if (!query.exec() || !query.isActive() || query.size() <= 0)
00051         return;
00052 
00053     while (query.next())
00054     {
00055         QString DisplayText;
00056         if (query.value(5).toString() == "8vsb")
00057         {
00058             QString ChannelNumber =
00059                 QString("Freq %1").arg(query.value(3).toInt());
00060             struct CHANLIST* curList = chanlists[0].list;
00061             int totalChannels = chanlists[0].count;
00062             int findFrequency = (query.value(3).toInt() / 1000) - 1750;
00063             for (int x = 0 ; x < totalChannels ; x++)
00064             {
00065                 if ((curList[x].freq <= findFrequency + 200) &&
00066                     (curList[x].freq >= findFrequency - 200))
00067                 {
00068                     ChannelNumber = QString("%1").arg(curList[x].name);
00069                 }
00070             }
00071             DisplayText = QObject::tr("ATSC Channel %1").arg(ChannelNumber);
00072         }
00073         else
00074         {
00075             DisplayText = QString("%1 Hz (%2) (%3) (%4)")
00076                 .arg(query.value(3).toString())
00077                 .arg(query.value(4).toString())
00078                 .arg(query.value(1).toInt())
00079                 .arg(query.value(2).toInt());
00080         }
00081         addSelection(DisplayText, query.value(0).toString());
00082     }
00083 }
00084 
00085 void MultiplexSetting::SetSourceID(uint _sourceid)
00086 {
00087     sourceid = _sourceid;
00088     Load();
00089 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends