Ticket #4501: mythtv_browseall_03.diff

File mythtv_browseall_03.diff, 8.1 KB (added by Shane Shrybman <gnome42@…>, 16 years ago)

Browse across all tuners

  • libs/libmythtv/tv_play.h

     
    221221    void SetCurrentlyPlaying(ProgramInfo *pginfo);
    222222
    223223    void GetNextProgram(RemoteEncoder *enc, int direction,
    224                         InfoMap &infoMap);
     224                        InfoMap &infoMap) const;
    225225
    226226    // static functions
    227227    static void InitKeys(void);
     
    399399    void ToggleRecord(void);
    400400    void BrowseChannel(const QString &channum);
    401401
     402    uint    GetChanIDAnyTuner(const QString &chan) const;
     403    QString GetChanNumAnyTuner(const uint &chanid) const;
     404    void    GetNextProgramAnyTuner(int direction, InfoMap &infoMap,
     405                                   ProgramInfo *prog) const;
     406
    402407    void DoTogglePictureAttribute(PictureAdjustType type);
    403408    void DoChangePictureAttribute(
    404409        PictureAdjustType type, PictureAttribute attr, bool up);
     
    586591    QString browsechannum;
    587592    QString browsechanid;
    588593    QString browsestarttime;
     594    bool browsealltuners;
     595    DBChanList allchannels;   
    589596
    590597    // Program Info for currently playing video
    591598    // (or next video if InChangeState() is true)
  • libs/libmythtv/tv_play.cpp

     
    586586      browsemode(false), persistentbrowsemode(false),
    587587      browseTimer(new QTimer(this)),
    588588      browsechannum(""), browsechanid(""), browsestarttime(""),
     589      browsealltuners(false),
    589590      // Program Info for currently playing video
    590591      recorderPlaybackInfo(NULL),
    591592      playbackinfo(NULL), playbackLen(0),
     
    675676        ff_rew_speeds.push_back(
    676677            gContext->GetNumSetting(QString("FFRewSpeed%1").arg(i), def[i]));
    677678
     679    browsealltuners = gContext->GetNumSetting("BrowseAllTuners", 0);
     680    if (browsealltuners)
     681    {
     682        QString channelOrdering = gContext->GetSetting("ChannelOrdering", "channum");
     683        allchannels = ChannelUtil::GetChannels(0, true, "channum, callsign");
     684        ChannelUtil::SortChannels(allchannels, channelOrdering, true);
     685    };
     686
    678687    vbimode = VBIMode::Parse(gContext->GetSetting("VbiFormat"));
    679688
    680689    if (createWindow)
     
    56185627 *  \param infoMap InfoMap to fill in with returned data
    56195628 */
    56205629void TV::GetNextProgram(RemoteEncoder *enc, int direction,
    5621                         InfoMap &infoMap)
     5630                        InfoMap &infoMap) const
    56225631{
    56235632    QString title, subtitle, desc, category, endtime, callsign, iconpath;
    56245633    QDateTime begts, endts;
     
    57725781    is_tunable_cache_inputs.clear();
    57735782}
    57745783
     5784uint TV::GetChanIDAnyTuner(const QString &chan) const
     5785{
     5786    for (uint i = 0; i < allchannels.size(); ++i)
     5787        if (allchannels[i].channum == chan)
     5788            return allchannels[i].chanid;
     5789    return 0;
     5790}
     5791
     5792QString TV::GetChanNumAnyTuner(const uint &chanid) const
     5793{
     5794    for (uint i = 0; i < allchannels.size(); ++i)
     5795        if (allchannels[i].chanid == chanid)
     5796            return allchannels[i].channum;
     5797    return "";
     5798}
     5799
     5800void TV::GetNextProgramAnyTuner(int direction, InfoMap &infoMap,
     5801                                ProgramInfo *prog) const
     5802{
     5803    uint chanid = infoMap["chanid"].toUInt();
     5804    if (!chanid)
     5805        chanid = GetChanIDAnyTuner(infoMap["channum"]);
     5806       
     5807    int chandir = -1;
     5808    switch(direction)
     5809    {
     5810        case BROWSE_UP:          chandir = CHANNEL_DIRECTION_UP;         break;
     5811        case BROWSE_DOWN:        chandir = CHANNEL_DIRECTION_DOWN;       break;
     5812        case BROWSE_FAVORITE:    chandir = CHANNEL_DIRECTION_FAVORITE;   break;
     5813    };
     5814    if (direction != -1)
     5815        chanid = ChannelUtil::GetNextChannel(allchannels, chanid, 0, chandir);
     5816
     5817    infoMap["chanid"] = QString("%1").arg(chanid);
     5818    infoMap["channum"] = GetChanNumAnyTuner(chanid);
     5819
     5820    QDateTime nowtime = QDateTime::currentDateTime();
     5821    QDateTime latesttime = nowtime.addSecs(6*60*60);
     5822    QDateTime browsetime = QDateTime::fromString(infoMap["dbstarttime"], Qt::ISODate);
     5823
     5824    MSqlBindings bindings;
     5825    bindings[":CHANID"] = chanid;
     5826    bindings[":NOWTS"] = nowtime.toString("yyyy-MM-ddThh:mm:ss");
     5827    bindings[":LATESTTS"] = latesttime.toString("yyyy-MM-ddThh:mm:ss");
     5828    bindings[":BROWSETS"] = browsetime.toString("yyyy-MM-ddThh:mm:ss");
     5829
     5830    QString querystr = " WHERE program.chanid = :CHANID ";
     5831    switch(direction)
     5832    {
     5833        case BROWSE_LEFT:
     5834                querystr += " AND program.endtime <= :BROWSETS "
     5835                            " AND program.endtime > :NOWTS ";
     5836                break;
     5837
     5838        case BROWSE_RIGHT:
     5839                querystr += " AND program.starttime > :BROWSETS "
     5840                            " AND program.starttime < :LATESTTS ";
     5841                break;
     5842           
     5843        default:
     5844                querystr += " AND program.starttime <= :BROWSETS "
     5845                            " AND program.endtime > :BROWSETS ";
     5846    };
     5847
     5848    ProgramList progList;
     5849    progList.FromProgram(querystr, bindings);
     5850   
     5851    if (progList.isEmpty())
     5852    {
     5853        infoMap["dbstarttime"] = "";
     5854        return;
     5855    };
     5856
     5857    prog = (direction == BROWSE_LEFT) ? progList.take(progList.count() - 1)
     5858                                      : progList.take(0);
     5859   
     5860    infoMap["dbstarttime"] = prog->startts.toString(Qt::ISODate);
     5861}
     5862
    57755863void TV::EmbedOutput(WId wid, int x, int y, int w, int h)
    57765864{
    57775865    embedWinID = wid;
     
    66026690    infoMap["channum"]     = browsechannum;
    66036691    infoMap["chanid"]      = browsechanid;
    66046692   
    6605     GetNextProgram(activerecorder, direction, infoMap);
     6693    ProgramInfo *program_info = NULL;
     6694    if (browsealltuners)
     6695        GetNextProgramAnyTuner(direction, infoMap, program_info);
     6696    else
     6697        GetNextProgram(activerecorder, direction, infoMap);
    66066698   
    66076699    browsechannum = infoMap["channum"];
    66086700    browsechanid  = infoMap["chanid"];
     
    66136705        browsestarttime = infoMap["dbstarttime"];
    66146706    }
    66156707
    6616     QDateTime startts = QDateTime::fromString(browsestarttime, Qt::ISODate);
    6617     ProgramInfo *program_info =
    6618         ProgramInfo::GetProgramAtDateTime(browsechanid, startts);
     6708    if (!program_info)
     6709    {
     6710        QDateTime startts = QDateTime::fromString(browsestarttime, Qt::ISODate);
     6711        program_info =
     6712            ProgramInfo::GetProgramAtDateTime(browsechanid, startts);
     6713    }
    66196714   
    66206715    if (program_info)
    66216716        program_info->ToMap(infoMap);
    66226717
     6718    if (browsealltuners && !IsTunable(browsechanid.toUInt()))
     6719        infoMap["channum"] = "x" + infoMap["channum"];
     6720   
    66236721    GetOSD()->ClearAllText("browse_info");
    66246722    GetOSD()->SetText("browse_info", infoMap, -1);
    66256723
     
    67176815
    67186816void TV::BrowseChannel(const QString &chan)
    67196817{
    6720     if (!activerecorder->CheckChannel(chan))
     6818    if (browsealltuners)
     6819    {
     6820        if (!GetChanIDAnyTuner(chan))
     6821            return;
     6822    }
     6823    else if (!activerecorder->CheckChannel(chan))
    67216824        return;
    67226825
    67236826    browsechannum = chan;
  • programs/mythfrontend/globalsettings.cpp

     
    19131913    return gc;
    19141914}
    19151915
     1916static HostCheckBox *BrowseAllTuners()
     1917{
     1918    HostCheckBox *gc = new HostCheckBox("BrowseAllTuners");
     1919    gc->setLabel(QObject::tr("Browse channels from all tuners"));
     1920    gc->setValue(true);
     1921    gc->setHelpText(QObject::tr("By default, browse mode only shows channels "
     1922                    "on the currently active tuner. If enabled, browse mode "
     1923                    "will shows all channels, no matter what tuner they "
     1924                    "exist on."));
     1925    return gc;
     1926}
     1927
    19161928static HostCheckBox *AggressiveBuffer()
    19171929{
    19181930    HostCheckBox *gc = new HostCheckBox("AggressiveSoundcardBuffer");
     
    47014713    osd->addChild(OSDThemeFontSizeType());
    47024714    osd->addChild(EnableMHEG());
    47034715    osd->addChild(PersistentBrowseMode());
     4716    osd->addChild(BrowseAllTuners());
    47044717    addChild(osd);
    47054718
    47064719    VerticalConfigurationGroup *udp = new VerticalConfigurationGroup(false);