Ticket #199: myth_guide_groups_r10968.diff

File myth_guide_groups_r10968.diff, 12.5 KB (added by Mark.Buechler@…, 18 years ago)

Guide Groups patch

  • libs/libmythtv/channelutil.cpp

    diff -rup mythtv.orig/libs/libmythtv/channelutil.cpp mythtv/libs/libmythtv/channelutil.cpp
    old new bool ChannelUtil::GetChannelData( 
    12651265                           dvb_transportid, dvb_networkid);
    12661266}
    12671267
    1268 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp)
     1268DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp,
     1269                                    int guideGroup)
    12691270{
    12701271    DBChanList list;
    12711272    QMap<uint,uint> favorites;
    DBChanList ChannelUtil::GetChannels(uint 
    12821283    }
    12831284
    12841285    QString qstr =
    1285         "SELECT channum, callsign, chanid, "
     1286        "SELECT channum, callsign, channel.chanid, "
    12861287        "       atsc_major_chan, atsc_minor_chan, "
    12871288        "       name, icon, visible "
    12881289        "FROM channel ";
    12891290
     1291    if (guideGroup > -1)
     1292        qstr += ", guidechannels ";
     1293
    12901294    if (sourceid)
    12911295        qstr += QString("WHERE sourceid='%1' ").arg(sourceid);
    12921296    else
    DBChanList ChannelUtil::GetChannels(uint 
    12971301    if (vis_only)
    12981302        qstr += "AND visible=1 ";
    12991303
     1304    if (guideGroup > -1)
     1305        qstr += "AND channel.chanid = guidechannels.chanid AND "
     1306                "    guidechannels.groupid = :GUIDEGROUP ";
     1307
    13001308    if (!grp.isEmpty())
    13011309        qstr += QString("GROUP BY %1 ").arg(grp);
    13021310
    13031311    query.prepare(qstr);
     1312
     1313    if (guideGroup > -1)
     1314        query.bindValue(":GUIDEGROUP", guideGroup);
     1315
    13041316    if (!query.exec() || !query.isActive())
    13051317    {
    13061318        MythContext::DBError("get channels -- sourceid", query);
    13071319        return list;
    13081320    }
    13091321
     1322    if ((guideGroup > -1) && (query.size() == 0))
     1323    {
     1324        VERBOSE(VB_PLAYBACK, QString("GetChannels(): failed to find any channels "
     1325            "associated with group %1").arg(guideGroup));
     1326        return GetChannels(sourceid, vis_only, grp, -1);
     1327    }
     1328
    13101329    while (query.next())
    13111330    {
    13121331        if (query.value(0).toString().isEmpty() || !query.value(2).toUInt())
  • libs/libmythtv/channelutil.h

    diff -rup mythtv.orig/libs/libmythtv/channelutil.h mythtv/libs/libmythtv/channelutil.h
    old new class ChannelUtil 
    146146    static QString GetVideoFilters(uint sourceid, const QString &channum)
    147147        { return GetChannelValueStr("videofilters", sourceid, channum); }
    148148
    149     static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="");
     149    static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="",
     150                                  int guideGroup = -1);
    150151    static void    SortChannels(DBChanList &list, const QString &order,
    151152                                bool eliminate_duplicates = false);
    152153    static void    EliminateDuplicateChanNum(DBChanList &list);
  • libs/libmythtv/guidegrid.cpp

    diff -rup mythtv.orig/libs/libmythtv/guidegrid.cpp mythtv/libs/libmythtv/guidegrid.cpp
    old new using namespace std; 
    3535
    3636bool RunProgramGuide(uint &chanid, QString &channum,
    3737                     bool thread, TV *player,
    38                      bool allowsecondaryepg)
     38                     bool allowsecondaryepg,
     39                     int guideGroup)
    3940{
    4041    bool channel_changed = false;
    4142
    bool RunProgramGuide(uint &chanid, QStri 
    4647
    4748    GuideGrid *gg = new GuideGrid(gContext->GetMainWindow(),
    4849                                  chanid, channum,
    49                                   player, allowsecondaryepg, "guidegrid");
     50                                  player, allowsecondaryepg,
     51                                  guideGroup, "guidegrid");
    5052
    5153    gg->Show();
    5254
    bool RunProgramGuide(uint &chanid, QStri 
    8385GuideGrid::GuideGrid(MythMainWindow *parent,
    8486                     uint chanid, QString channum,
    8587                     TV *player, bool allowsecondaryepg,
     88                     int guideGroup,
    8689                     const char *name)
    8790         : MythDialog(parent, name)
    8891{
    GuideGrid::GuideGrid(MythMainWindow *par 
    9194    int maxchannel = 0;
    9295    m_currentStartChannel = 0;
    9396
     97    m_currentGuideGroup = guideGroup;
     98
    9499    m_player = player;
    95100
    96101    m_context = 0;
    void GuideGrid::fillChannelInfos(bool go 
    562567{
    563568    m_channelInfos.clear();
    564569
     570    // Handle any special guide groups
     571    if (m_currentGuideGroup == GUIDEGROUP_FAVORITES)
     572        showFavorites = true;
     573
    565574    DBChanList channels = ChannelUtil::GetChannels(0, true,
    566                                                    "channum, callsign");
     575                                                   "channum, callsign",
     576                                                   m_currentGuideGroup);
    567577    ChannelUtil::SortChannels(channels, channelOrdering, true);
    568578
    569579    if (showFavorites)
  • libs/libmythtv/guidegrid.h

    diff -rup mythtv.orig/libs/libmythtv/guidegrid.h mythtv/libs/libmythtv/guidegrid.h
    old new class QWidget; 
    2525#define MAX_DISPLAY_CHANS 12
    2626#define MAX_DISPLAY_TIMES 30
    2727
     28#define GUIDEGROUP_FAVORITES   9999  // Guide Group Favorites
     29
    2830// Use this function to instantiate a guidegrid instance.
    2931bool RunProgramGuide(uint &startChanId, QString &startChanNum,
    3032                     bool thread = false, TV *player = NULL,
    31                      bool allowsecondaryepg = true);
     33                     bool allowsecondaryepg = true,
     34                     int guideGroup = -1);
    3235
    3336
    3437class GuideGrid : public MythDialog
    class GuideGrid : public MythDialog 
    3841    GuideGrid(MythMainWindow *parent,
    3942              uint chanid = 0, QString channum = "",
    4043              TV *player = NULL, bool allowsecondaryepg = true,
     44              int guideGroup = -1,
    4145              const char *name = "GuideGrid");
    4246   ~GuideGrid();
    4347
    class GuideGrid : public MythDialog 
    108112
    109113    int m_context;
    110114
     115    int m_currentGuideGroup;
     116
    111117    bool selectChangesChannel;
    112118    int selectRecThreshold;
    113119   
  • libs/libmythtv/tv_play.cpp

    diff -rup mythtv.orig/libs/libmythtv/tv_play.cpp mythtv/libs/libmythtv/tv_play.cpp
    old new bool TV::Init(bool createWindow) 
    378378        return false;
    379379    }
    380380
     381    currentGuideGroup = -1;
     382    GetGuideGroups();
     383
    381384    baseFilters         += gContext->GetSetting("CustomFilters");
    382385    db_time_format       = gContext->GetSetting("TimeFormat", "h:mm AP");
    383386    db_short_date_format = gContext->GetSetting("ShortDateFormat", "M/d");
    void TV::ProcessKeypress(QKeyEvent *e) 
    27442747                ToggleInputs();
    27452748            else if (action == "SWITCHCARDS")
    27462749                SwitchCards();
    2747             else if (action == "GUIDE")
    2748                 EditSchedule(kScheduleProgramGuide);
     2750            else if (!action.find("GUIDE"))
     2751                ProcessGuideEntry(action);
    27492752            else if (action == "TOGGLEPIPMODE")
    27502753                TogglePIPView();
    27512754            else if (action == "TOGGLEPIPWINDOW")
    void TV::ProcessKeypress(QKeyEvent *e) 
    27982801            }
    27992802            else if (action == "JUMPTODVDROOTMENU")
    28002803                activenvp->GoToDVDMenu("menu");
    2801             else if (action == "GUIDE")
    2802                 EditSchedule(kScheduleProgramGuide);
     2804            else if (!action.find("GUIDE"))
     2805                ProcessGuideEntry(action);
    28032806            else if (action == "FINDER")
    28042807                EditSchedule(kScheduleProgramFinder);
    28052808            else if (action == "TOGGLEEDIT" && !activerbuffer->isDVD())
    void TV::ProcessKeypress(QKeyEvent *e) 
    28382841    }
    28392842}
    28402843
     2844void TV::ProcessGuideEntry(QString action)
     2845{
     2846    currentGuideGroup = -1;
     2847
     2848    if (action == "GUIDE_FAVORITES")
     2849        currentGuideGroup = GUIDEGROUP_FAVORITES;
     2850    else if (!action.find("GUIDE_"))
     2851    {
     2852        action.remove("GUIDE_");
     2853
     2854        QMapIterator<QString, int> it;
     2855
     2856        for(it = guideGroups.begin(); it != guideGroups.end(); ++it)
     2857        {
     2858            if(action == it.key())
     2859                currentGuideGroup = it.data();
     2860        }
     2861    }
     2862
     2863    EditSchedule(kScheduleProgramGuide);
     2864}
     2865
    28412866void TV::processNetworkControlCommand(QString command)
    28422867{
    28432868    QStringList tokens = QStringList::split(" ", command);
    void TV::doEditSchedule(int editType) 
    47614786        return;
    47624787    }
    47634788
     4789    if (currentGuideGroup > -1)
     4790        VERBOSE(VB_PLAYBACK, QString("doEditSchedule(): using guide groupid %1")
     4791            .arg(currentGuideGroup));
     4792    else
     4793        VERBOSE(VB_PLAYBACK, "doEditSchedule(): guide defaulting to all channels");
     4794
    47644795    // Resize window to the MythTV GUI size
    47654796    MythMainWindow *mwnd = gContext->GetMainWindow();
    47664797    bool using_gui_size_for_tv = gContext->GetNumSetting("GuiSizeForTV", 0);
    void TV::doEditSchedule(int editType) 
    47874818            allowsecondary = nvp->getVideoOutput()->AllowPreviewEPG();
    47884819
    47894820        // Start up EPG
    4790         changeChannel = RunProgramGuide(chanid, channum, true, this, allowsecondary);
     4821        changeChannel = RunProgramGuide(chanid, channum, true, this,
     4822                                        allowsecondary, currentGuideGroup);
    47914823
    47924824        StopEmbeddingOutput();
    47934825    }
    void TV::TreeMenuSelected(OSDListTreeTyp 
    61186150        ToggleLetterbox(action.right(1).toInt());
    61196151        hidetree = false;
    61206152    }
    6121     else if (action == "GUIDE")
    6122         EditSchedule(kScheduleProgramGuide);
     6153    else if (!action.find("GUIDE"))
     6154        ProcessGuideEntry(action);
    61236155    else if (action == "FINDER")
    61246156        EditSchedule(kScheduleProgramFinder);
    61256157    else if (action == "SCHEDULE")
    void TV::BuildOSDTreeMenu(void) 
    63096341        if (!freeRecorders)
    63106342            freeRecorders = RemoteGetFreeRecorderCount();
    63116343
    6312         item = new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
     6344        item = new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");     
     6345        BuildOSDGuideMenu(item);
    63136346
    63146347        if (freeRecorders)
    63156348        {
    void TV::BuildOSDTreeMenu(void) 
    65346567    subitem = new OSDGenericTree(item, "120 " + tr("minutes"), "TOGGLESLEEP120");
    65356568}
    65366569
     6570void TV::BuildOSDGuideMenu(OSDGenericTree *treeMenu)
     6571{
     6572    OSDGenericTree *subitem;
     6573
     6574    subitem = new OSDGenericTree(treeMenu, tr("All Channels"), "GUIDE");
     6575    subitem = new OSDGenericTree(treeMenu, tr("Favorites"), "GUIDE_FAVORITES");
     6576
     6577    QMapIterator<QString, int> it;
     6578
     6579    for(it = guideGroups.begin(); it != guideGroups.end(); ++it)
     6580    {
     6581        QString name = it.key();
     6582        QString int_name = name;
     6583        int_name.prepend("GUIDE_");
     6584
     6585        subitem = new OSDGenericTree(treeMenu, name, int_name.latin1());
     6586    }
     6587}
     6588
     6589void TV::GetGuideGroups(void)
     6590{
     6591    guideGroups.clear();
     6592
     6593    MSqlQuery query(MSqlQuery::InitCon());
     6594    query.prepare("SELECT groupid, name FROM guidegroups ORDER BY groupid");
     6595
     6596    if (query.exec() && query.isActive() && query.size() > 0)
     6597        while(query.next())
     6598            guideGroups.insert(query.value(1).toString(), query.value(0).toInt());
     6599}
     6600
    65376601bool TV::FillMenuTracks(OSDGenericTree *treeMenu, uint type)
    65386602{
    65396603    QString mainMsg = QString::null;
  • libs/libmythtv/tv_play.h

    diff -rup mythtv.orig/libs/libmythtv/tv_play.h mythtv/libs/libmythtv/tv_play.h
    old new class TV : public QObject 
    213213    void ChangeTrack(uint type, int dir);
    214214    void SetTrack(uint type, int trackNo);
    215215
     216    void GetGuideGroups(void);
     217    void ProcessGuideEntry(QString action);
     218
    216219    // key queue commands
    217220    void AddKeyToInputQueue(char key);
    218221    void ClearInputQueues(bool hideosd = false);
    class TV : public QObject 
    327330    void DoChangePictureAttribute(int type, int control, bool up);
    328331
    329332    void BuildOSDTreeMenu(void);
     333    void BuildOSDGuideMenu(OSDGenericTree *treeMenu);
    330334    void ShowOSDTreeMenu(void);
    331335
    332336    void UpdateLCD(void);
    class TV : public QObject 
    411415    bool needToJumpMenu;
    412416    QMap<QString,ProgramList> progLists;
    413417
     418    QMap<QString,int> guideGroups;
     419    int currentGuideGroup;
     420
    414421    mutable QMutex chanEditMapLock; ///< Lock for chanEditMap and ddMap
    415422    InfoMap   chanEditMap;          ///< Channel Editing initial map
    416423    DDKeyMap  ddMap;                ///< DataDirect channel map