[mythtv] [PATCH] Updated version of presetpatch
Bjorn Hijmans
bjorn at hijmans.nl
Mon Apr 28 09:22:40 EDT 2003
On Mon, 28 Apr 2003, Bjorn Hijmans wrote:
> > Still not quite correct =) Tuner cards can have multiple inputs attached to
> > different sources, and this would only catch one of them. Might make more
> > sense to just get the lowest chanid whenever the TV object starts up or the
> > user changes the input of the card.
>
> Next try :) This one figures out the lowest chanid using the
> CurrentInputName (when starting livetv and when switching inputs) and
> stores it in a member variable.
And the attachment.
Bjorn
-------------- next part --------------
diff -ur MC/libs/libmythtv/programinfo.cpp MC.clean.patched/libs/libmythtv/programinfo.cpp
--- MC/libs/libmythtv/programinfo.cpp Wed Apr 23 23:15:18 2003
+++ MC.clean.patched/libs/libmythtv/programinfo.cpp Sun Apr 27 22:34:44 2003
@@ -349,6 +349,25 @@
return GetProgramAtDateTime(channel, sqltime);
}
+QString ProgramInfo::GetChanNumFromChanid(QString channel)
+{
+ QSqlQuery query;
+ QString thequery;
+ QString channum;
+
+ thequery = QString("SELECT channum FROM channel WHERE chanid=%1;") . arg(channel);
+ query.exec(thequery);
+
+ if(query.isActive() && query.numRowsAffected() > 0)
+ {
+ query.next();
+
+ channum = query.value(0).toString();
+ }
+
+ return channum;
+}
+
ProgramInfo *ProgramInfo::GetProgramFromRecorded(QString channel, QString starttime)
{
QSqlQuery query;
diff -ur MC/libs/libmythtv/programinfo.h MC.clean.patched/libs/libmythtv/programinfo.h
--- MC/libs/libmythtv/programinfo.h Wed Apr 23 23:15:18 2003
+++ MC.clean.patched/libs/libmythtv/programinfo.h Sun Apr 27 22:34:46 2003
@@ -66,6 +66,8 @@
static ProgramInfo *GetProgramAtDateTime(QString channel, QDateTime &dtime);
static ProgramInfo *GetProgramFromRecorded(QString channel, QString starttime);
+ static QString GetChanNumFromChanid(QString channel);
+
QString title;
QString subtitle;
QString description;
diff -ur MC/libs/libmythtv/tv_play.cpp MC.clean.patched/libs/libmythtv/tv_play.cpp
--- MC/libs/libmythtv/tv_play.cpp Fri Apr 25 07:45:25 2003
+++ MC.clean.patched/libs/libmythtv/tv_play.cpp Sun Apr 27 22:34:37 2003
@@ -522,6 +522,8 @@
activerbuffer = prbuffer;
activerecorder = recorder;
+ FindLowestChanid();
+
frameRate = nvp->GetFrameRate();
osd = nvp->GetOSD();
}
@@ -1407,6 +1409,8 @@
UpdateOSDInput();
activenvp->Unpause();
+
+ FindLowestChanid();
}
void TV::ToggleChannelFavorite(void)
@@ -1471,6 +1475,13 @@
if (key > 256)
thekey = key - 256 - 0xb0 + '0';
+ QString channelSorting = gContext->GetSetting("ChannelSorting");
+
+ if(channelSorting == "chanid")
+ {
+ chanidqueued = true;
+ }
+
if (channelkeysstored == 4)
{
channelKeys[0] = channelKeys[1];
@@ -1512,6 +1523,15 @@
}
QString chan = QString(channelKeys).stripWhiteSpace();
+
+ // Translate to channum
+ if(chanidqueued)
+ {
+ chan = QString::number(chan.toInt() + lowestChanid - 1);
+ chan = ProgramInfo::GetChanNumFromChanid(chan);
+ chanidqueued = false;
+ }
+
ChangeChannelByString(chan);
channelqueued = false;
@@ -1660,6 +1680,12 @@
GetChannelInfo(activerecorder, regexpMap);
+ QString channelSorting = gContext->GetSetting("ChannelSorting");
+
+ if(channelSorting == "chanid")
+ { regexpMap["channum"] = QString::number(regexpMap["chanid"].toInt() - lowestChanid + 1);
+ }
+
osd->ClearAllText("program_info");
osd->SetTextByRegexp("program_info", regexpMap, osd_display_time);
osd->ClearAllText("channel_number");
@@ -1791,6 +1817,26 @@
enc->GetChannelInfo(title, subtitle, desc, category, starttime, endtime,
callsign, iconpath, channelname, chanid);
+}
+
+void TV::FindLowestChanid(void)
+{
+ QString name = "";
+
+ activerecorder->GetInputName(name);
+
+ QString thequery = QString("SELECT MIN(chanid)
+ FROM cardinput i, channel c
+ WHERE i.inputname = '%1'
+ AND c.sourceid = i.sourceid").arg(name);
+
+ QSqlQuery query = m_db->exec(thequery);
+ if (query.isActive() && query.numRowsAffected() > 0)
+ {
+ query.next();
+
+ lowestChanid = query.value(0).toInt();
+ }
}
void TV::EmbedOutput(unsigned long wid, int x, int y, int w, int h)
Only in MC.clean.patched/libs/libmythtv: tv_play.cpp~
diff -ur MC/libs/libmythtv/tv_play.h MC.clean.patched/libs/libmythtv/tv_play.h
--- MC/libs/libmythtv/tv_play.h Wed Apr 23 23:15:18 2003
+++ MC.clean.patched/libs/libmythtv/tv_play.h Sun Apr 27 22:34:39 2003
@@ -90,6 +90,7 @@
void ToggleChannelFavorite(void);
void ChangeChannel(int direction);
void ChangeChannelByString(QString &name);
+ void FindLowestChanid(void);
void ChangeVolume(bool up);
void ToggleMute(void);
@@ -142,8 +143,11 @@
int osd_display_time;
bool channelqueued;
+ bool chanidqueued;
char channelKeys[5];
int channelkeysstored;
+
+ int lowestChanid;
bool menurunning;
More information about the mythtv-dev
mailing list