Ticket #4501: mythtv_browseall_03-trunk.patch

File mythtv_browseall_03-trunk.patch, 8.4 KB (added by skerit@…, 4 years ago)

Browse across all tuners patch for trunk (QT4)

  • libs/libmythtv/tv_play.cpp

    diff -Naur mythtv/libs/libmythtv/tv_play.cpp mythtv-browsepatch/libs/libmythtv/tv_play.cpp
    old new  
    585585      // channel browsing state variables 
    586586      browsemode(false), persistentbrowsemode(false), 
    587587      browsechannum(""), browsechanid(""), browsestarttime(""), 
     588      browsealltuners(false), 
    588589      // Program Info for currently playing video 
    589590      recorderPlaybackInfo(NULL), 
    590591      playbackinfo(NULL), playbackLen(0), 
     
    673674        ff_rew_speeds.push_back( 
    674675            gContext->GetNumSetting(QString("FFRewSpeed%1").arg(i), def[i])); 
    675676 
     677    browsealltuners = gContext->GetNumSetting("BrowseAllTuners", 0); 
     678    if (browsealltuners) 
     679    { 
     680        QString channelOrdering = gContext->GetSetting("ChannelOrdering", "channum"); 
     681        allchannels = ChannelUtil::GetChannels(0, true, "channum, callsign"); 
     682        ChannelUtil::SortChannels(allchannels, channelOrdering, true); 
     683    }; 
     684 
    676685    vbimode = VBIMode::Parse(gContext->GetSetting("VbiFormat")); 
    677686    QString feVBI = gContext->GetSetting("DecodeVBIFormat", ""); 
    678687    if (!feVBI.isEmpty()) 
     
    56455654 *  \param infoMap InfoMap to fill in with returned data 
    56465655 */ 
    56475656void TV::GetNextProgram(RemoteEncoder *enc, int direction, 
    5648                         InfoMap &infoMap) 
     5657                        InfoMap &infoMap) const 
    56495658{ 
    56505659    QString title, subtitle, desc, category, endtime, callsign, iconpath; 
    56515660    QDateTime begts, endts; 
     
    57995808    is_tunable_cache_inputs.clear(); 
    58005809} 
    58015810 
     5811uint TV::GetChanIDAnyTuner(const QString &chan) const 
     5812{ 
     5813    for (uint i = 0; i < allchannels.size(); ++i) 
     5814        if (allchannels[i].channum == chan) 
     5815            return allchannels[i].chanid; 
     5816    return 0; 
     5817} 
     5818 
     5819QString TV::GetChanNumAnyTuner(const uint &chanid) const 
     5820{ 
     5821    for (uint i = 0; i < allchannels.size(); ++i) 
     5822        if (allchannels[i].chanid == chanid) 
     5823            return allchannels[i].channum; 
     5824    return ""; 
     5825} 
     5826 
     5827void TV::GetNextProgramAnyTuner(int direction, InfoMap &infoMap, 
     5828                                ProgramInfo *prog) const 
     5829{  
     5830    uint chanid = infoMap["chanid"].toUInt(); 
     5831    if (!chanid) 
     5832        chanid = GetChanIDAnyTuner(infoMap["channum"]); 
     5833         
     5834    int chandir = -1; 
     5835    switch(direction) 
     5836    { 
     5837        case BROWSE_UP:          chandir = CHANNEL_DIRECTION_UP;         break; 
     5838        case BROWSE_DOWN:        chandir = CHANNEL_DIRECTION_DOWN;       break; 
     5839        case BROWSE_FAVORITE:    chandir = CHANNEL_DIRECTION_FAVORITE;   break; 
     5840    }; 
     5841    if (direction != -1) 
     5842        chanid = ChannelUtil::GetNextChannel(allchannels, chanid, 0, chandir); 
     5843 
     5844    infoMap["chanid"] = QString("%1").arg(chanid); 
     5845    infoMap["channum"] = GetChanNumAnyTuner(chanid); 
     5846 
     5847    QDateTime nowtime = QDateTime::currentDateTime(); 
     5848    QDateTime latesttime = nowtime.addSecs(6*60*60); 
     5849    QDateTime browsetime = QDateTime::fromString(infoMap["dbstarttime"], Qt::ISODate); 
     5850 
     5851    MSqlBindings bindings; 
     5852    bindings[":CHANID"] = chanid; 
     5853    bindings[":NOWTS"] = nowtime.toString("yyyy-MM-ddThh:mm:ss"); 
     5854    bindings[":LATESTTS"] = latesttime.toString("yyyy-MM-ddThh:mm:ss"); 
     5855    bindings[":BROWSETS"] = browsetime.toString("yyyy-MM-ddThh:mm:ss"); 
     5856    bindings[":BROWSETS2"] = browsetime.toString("yyyy-MM-ddThh:mm:ss"); 
     5857 
     5858    QString querystr = " WHERE program.chanid = :CHANID "; 
     5859    switch(direction) 
     5860    { 
     5861        case BROWSE_LEFT: 
     5862                querystr += " AND program.endtime <= :BROWSETS " 
     5863                            " AND program.endtime > :NOWTS "; 
     5864                break; 
     5865 
     5866        case BROWSE_RIGHT: 
     5867                querystr += " AND program.starttime > :BROWSETS " 
     5868                            " AND program.starttime < :LATESTTS "; 
     5869                break; 
     5870             
     5871        default: 
     5872                querystr += " AND program.starttime <= :BROWSETS " 
     5873                            " AND program.endtime > :BROWSETS2 "; 
     5874    }; 
     5875 
     5876    ProgramList progList; 
     5877    progList.FromProgram(querystr, bindings); 
     5878     
     5879    if (progList.isEmpty()) 
     5880    { 
     5881        infoMap["dbstarttime"] = ""; 
     5882        return; 
     5883    }; 
     5884 
     5885    prog = (direction == BROWSE_LEFT) ? progList.take(progList.count() - 1) 
     5886                                      : progList.take(0); 
     5887     
     5888    infoMap["dbstarttime"] = prog->startts.toString(Qt::ISODate); 
     5889} 
     5890 
    58025891void TV::EmbedOutput(WId wid, int x, int y, int w, int h) 
    58035892{ 
    58045893    embedWinID = wid; 
     
    66456734    infoMap["channum"]     = browsechannum; 
    66466735    infoMap["chanid"]      = browsechanid; 
    66476736 
    6648     GetNextProgram(activerecorder, direction, infoMap); 
     6737     ProgramInfo *program_info = NULL; 
     6738     if (browsealltuners) 
     6739         GetNextProgramAnyTuner(direction, infoMap, program_info); 
     6740     else 
     6741         GetNextProgram(activerecorder, direction, infoMap); 
    66496742 
    66506743    browsechannum = infoMap["channum"]; 
    66516744    browsechanid  = infoMap["chanid"]; 
     
    66566749        browsestarttime = infoMap["dbstarttime"]; 
    66576750    } 
    66586751 
    6659     QDateTime startts = QDateTime::fromString(browsestarttime, Qt::ISODate); 
    6660     ProgramInfo *program_info = 
    6661         ProgramInfo::GetProgramAtDateTime(browsechanid, startts); 
     6752     if (!program_info) 
     6753     { 
     6754         QDateTime startts = QDateTime::fromString(browsestarttime, Qt::ISODate); 
     6755         program_info = 
     6756             ProgramInfo::GetProgramAtDateTime(browsechanid, startts); 
     6757     } 
    66626758 
    66636759    if (program_info) 
    66646760        program_info->ToMap(infoMap); 
    66656761 
     6762    if (browsealltuners && !IsTunable(browsechanid.toUInt())) 
     6763        infoMap["channum"] = "x" + infoMap["channum"]; 
     6764 
    66666765    GetOSD()->ClearAllText("browse_info"); 
    66676766    GetOSD()->SetText("browse_info", infoMap, -1); 
    66686767 
     
    67606859 
    67616860void TV::BrowseChannel(const QString &chan) 
    67626861{ 
    6763     if (!activerecorder->CheckChannel(chan)) 
     6862    if (browsealltuners) 
     6863    { 
     6864        if (!GetChanIDAnyTuner(chan)) 
     6865            return; 
     6866    }  
     6867    else if (!activerecorder->CheckChannel(chan)) 
    67646868        return; 
    67656869 
    67666870    browsechannum = chan; 
  • libs/libmythtv/tv_play.h

    diff -Naur mythtv/libs/libmythtv/tv_play.h mythtv-browsepatch/libs/libmythtv/tv_play.h
    old new  
    226226    void SetCurrentlyPlaying(ProgramInfo *pginfo); 
    227227 
    228228    void GetNextProgram(RemoteEncoder *enc, int direction, 
    229                         InfoMap &infoMap); 
     229                        InfoMap &infoMap) const; 
    230230 
    231231    // static functions 
    232232    static void InitKeys(void); 
     
    406406    void ToggleRecord(void); 
    407407    void BrowseChannel(const QString &channum); 
    408408 
     409    uint    GetChanIDAnyTuner(const QString &chan) const; 
     410    QString GetChanNumAnyTuner(const uint &chanid) const; 
     411    void    GetNextProgramAnyTuner(int direction, InfoMap &infoMap, 
     412                                   ProgramInfo *prog) const; 
     413 
    409414    void DoTogglePictureAttribute(PictureAdjustType type); 
    410415    void DoChangePictureAttribute( 
    411416        PictureAdjustType type, PictureAttribute attr, bool up); 
     
    600605    QString browsechannum; 
    601606    QString browsechanid; 
    602607    QString browsestarttime; 
     608    bool browsealltuners; 
     609    DBChanList allchannels;    
    603610 
    604611    // Program Info for currently playing video 
    605612    // (or next video if InChangeState() is true) 
  • programs/mythfrontend/globalsettings.cpp

    diff -Naur mythtv/programs/mythfrontend/globalsettings.cpp mythtv-browsepatch/programs/mythfrontend/globalsettings.cpp
    old new  
    19811981    return gc; 
    19821982} 
    19831983 
     1984static HostCheckBox *BrowseAllTuners() 
     1985{ 
     1986    HostCheckBox *gc = new HostCheckBox("BrowseAllTuners"); 
     1987    gc->setLabel(QObject::tr("Browse channels from all tuners")); 
     1988    gc->setValue(true); 
     1989    gc->setHelpText(QObject::tr("By default, browse mode only shows channels " 
     1990                    "on the currently active tuner. If enabled, browse mode " 
     1991                    "will shows all channels, no matter what tuner they " 
     1992                    "exist on.")); 
     1993    return gc; 
     1994} 
     1995 
    19841996static HostCheckBox *AggressiveBuffer() 
    19851997{ 
    19861998    HostCheckBox *gc = new HostCheckBox("AggressiveSoundcardBuffer"); 
     
    47954807    osd->addChild(OSDThemeFontSizeType()); 
    47964808    osd->addChild(EnableMHEG()); 
    47974809    osd->addChild(PersistentBrowseMode()); 
     4810    osd->addChild(BrowseAllTuners()); 
    47984811    addChild(osd); 
    47994812 
    48004813    VerticalConfigurationGroup *udp = new VerticalConfigurationGroup(false);