Ticket #4504: guide_unav.diff

File guide_unav.diff, 11.6 KB (added by Mark Buechler <Mark.Buechler@…>, 16 years ago)

The patch

  • libs/libmyth/uitypes.cpp

    diff -rup mythtv.old/libs/libmyth/uitypes.cpp mythtv/libs/libmyth/uitypes.cpp
    old new  
    1 
    21#include <iostream>
    32#include <math.h>
    43
    void UIGuideType::Draw(QPainter *dr, int 
    613612    {
    614613        for (data = allData[i].first(); data; data = allData[i].next())
    615614        {
    616             if (data->recStat == 0)
     615            if (data->unavStat && (data->recStat != 1))
     616                drawBox(dr, data, unavcolor);
     617            else if (data->recStat == 0)
    617618                drawBackground(dr, data);
    618619            else if (data->recStat == 1)
    619620                drawBox(dr, data, reccolor);
    void UIGuideType::drawText(QPainter *dr, 
    842843
    843844void UIGuideType::SetProgramInfo(int row, int col, const QRect &area,
    844845                                 const QString &title, const QString &genre,
    845                                  int arrow, int recType, int recStat,
     846                                 int arrow, int recType, int recStat, bool unavStat,
    846847                                 bool selected)
    847848{
    848849    (void)col;
    849     UIGTCon *data = new UIGTCon(area, title, genre, arrow, recType, recStat);
     850    UIGTCon *data = new UIGTCon(area, title, genre, arrow, recType, recStat, unavStat);
    850851
    851852    allData[row].append(data);
    852853
    853854    if (drawCategoryColors)
    854855    {
    855856        data->categoryColor = categoryColors[data->category.lower()];
     857
    856858        if (!data->categoryColor.isValid())
    857859            data->categoryColor = categoryColors["none"];
    858860    }
  • libs/libmyth/uitypes.h

    diff -rup mythtv.old/libs/libmyth/uitypes.h mythtv/libs/libmyth/uitypes.h
    old new class MPUBLIC UIGuideType : public UITyp 
    232232    UIGuideType(const QString &name, int order);
    233233    ~UIGuideType();
    234234
    235     enum FillType { Alpha = 10, Dense, Eco, Solid };
     235    enum FillType { Alpha = 10, Dense, Eco, Solid, Unavailable };
    236236
    237237    void Draw(QPainter *dr, int drawlayer, int context);
    238238
    class MPUBLIC UIGuideType : public UITyp 
    246246    void SetNumRows(int numRows) { this->numRows = numRows; }
    247247    void SetWindow(MythDialog *win) { window = win; }
    248248
    249     void SetRecordingColors(const QString &reccol, const QString &concol)
    250                   { reccolor = QColor(reccol); concolor = QColor(concol); }
     249    void SetRecordingColors(const QString &reccol, const QString &concol,
     250                            const QString &unavcol)
     251                  { reccolor = QColor(reccol); concolor = QColor(concol);
     252                    unavcolor = QColor(unavcol); }
    251253    void SetSelectorColor(const QString &col) { selcolor = QColor(col); }
    252254    void SetSolidColor(const QString &col) { solidcolor = QColor(col); }
    253255    void SetCategoryColors(const QMap<QString, QString> &catColors);
    class MPUBLIC UIGuideType : public UITyp 
    259261    void LoadImage(int, const QString &file);
    260262    void SetProgramInfo(int row, int col, const QRect &area,
    261263                        const QString &title, const QString &category,
    262                         int arrow, int recType, int recStat, bool selected);
     264                        int arrow, int recType, int recStat, bool unavStat,
     265                        bool selected);
    263266    void ResetData();
    264267    void ResetRow(int row);
    265268    void SetProgPast(int ppast);
    class MPUBLIC UIGuideType : public UITyp 
    269272    class UIGTCon
    270273    {
    271274      public:
    272         UIGTCon() { arrow = recType = recStat = 0; };
     275        UIGTCon() { arrow = recType = recStat = 0; unavStat = false; };
    273276        UIGTCon(const QRect &drawArea, const QString &title,
    274                 const QString &category, int arrow, int recType, int recStat)
     277                const QString &category, int arrow, int recType,
     278                int recStat, bool unavStat)
    275279        {
    276280            this->drawArea = drawArea;
    277281            this->title = title;
    class MPUBLIC UIGuideType : public UITyp 
    279283            this->arrow = arrow;
    280284            this->recType = recType;
    281285            this->recStat = recStat;
     286            this->unavStat = unavStat;
    282287        }
    283288
    284289        UIGTCon(const UIGTCon &o)
    class MPUBLIC UIGuideType : public UITyp 
    290295            arrow = o.arrow;
    291296            recType = o.recType;
    292297            recStat = o.recStat;
     298            unavStat = o.unavStat;
    293299        }
    294300
    295301        QRect drawArea;
    class MPUBLIC UIGuideType : public UITyp 
    299305        int arrow;
    300306        int recType;
    301307        int recStat;
     308        bool unavStat;
    302309    };
    303310
    304311    void drawBackground(QPainter *dr, UIGTCon *data);
    class MPUBLIC UIGuideType : public UITyp 
    331338
    332339    QColor reccolor;
    333340    QColor concolor;
     341    QColor unavcolor;
    334342
    335343    int filltype;
    336344    bool cutdown;
  • libs/libmyth/xmlparse.cpp

    diff -rup mythtv.old/libs/libmyth/xmlparse.cpp mythtv/libs/libmyth/xmlparse.cpp
    old new void XMLParse::parseGuideGrid(LayerSet * 
    725725    QString selcolor = "";
    726726    QString reccolor = "";
    727727    QString concolor = "";
     728    QString unavcolor = "";
    728729    QRect area;
    729730    QPoint textoff = QPoint(0, 0);
    730731    bool cutdown = true;
    void XMLParse::parseGuideGrid(LayerSet * 
    799800            {
    800801                concolor = getFirstText(info);
    801802            }
     803            else if (info.tagName() == "unavailablecolor")
     804            {
     805                unavcolor = getFirstText(info);
     806            }
    802807            else if (info.tagName() == "multiline")
    803808            {
    804809                if (getFirstText(info).lower() == "yes")
    void XMLParse::parseGuideGrid(LayerSet * 
    884889    guide->SetTextOffset(textoff);
    885890    if (concolor == "")
    886891        concolor = reccolor;
    887     guide->SetRecordingColors(reccolor, concolor);
     892    guide->SetRecordingColors(reccolor, concolor, unavcolor);
    888893    guide->SetSelectorColor(selcolor);
    889894    for (int i = 1; i <= 7; i++)
    890895        guide->LoadImage(i, recImgs[i]);
  • libs/libmythtv/guidegrid.cpp

    diff -rup mythtv.old/libs/libmythtv/guidegrid.cpp mythtv/libs/libmythtv/guidegrid.cpp
    old new void GuideGrid::fillProgramRowInfos(unsi 
    10541054    QRect tempRect;
    10551055    bool isCurrent = false;
    10561056
     1057    bool channelsChanged = false;
     1058
     1059    uint chanNumber = row + m_currentStartChannel;
     1060    if (chanNumber >= m_channelInfos.size())
     1061        chanNumber -= m_channelInfos.size();
     1062
     1063    PixmapChannel *chinfo = GetChannelInfo(chanNumber);
     1064
     1065    bool unavStat = isUnavailable(chinfo->chanid, chanNumber, channelsChanged);
     1066
    10571067    for (int x = 0; x < DISPLAY_TIMES; x++)
    10581068    {
    10591069        proginfo = m_programInfos[row][x];
    void GuideGrid::fillProgramRowInfos(unsi 
    11501160
    11511161                type->SetProgramInfo(row, cnt, tempRect, proginfo->title,
    11521162                                     proginfo->category, arrow, recFlag,
    1153                                      recStat, isCurrent);
     1163                                     recStat, unavStat, isCurrent);
    11541164
    11551165                cnt++;
    11561166            }
    void GuideGrid::paintEvent(QPaintEvent * 
    11851195
    11861196    if (r.intersects(channelRect) && paintChannels(&p))
    11871197    {
     1198        chan_unavailable.clear();
    11881199        fillProgramInfos();
    11891200        update(programRect|curInfoRect|r);
    11901201        qApp->unlock();
    bool GuideGrid::paintChannels(QPainter * 
    13281339    UIImageType *itype = NULL;
    13291340    container = theme->GetSet("chanbar");
    13301341    infocontainer = theme->GetSet("program_info");
     1342
    13311343    if (container)
    13321344        type = (UIBarType *)container->GetType("chans");
    13331345    if (infocontainer)
    bool GuideGrid::paintChannels(QPainter * 
    13461358        if (chanNumber >= m_channelInfos.size())
    13471359            chanNumber -= m_channelInfos.size();
    13481360        if (chanNumber >= m_channelInfos.size())
    1349             break; 
     1361            break;
    13501362
    13511363        chinfo = GetChannelInfo(chanNumber);
    13521364
    1353         bool unavailable = false;
    1354         if (m_player && !m_player->IsTunable(chinfo->chanid, true))
    1355         {
    1356             unavailable = true;
     1365        bool unavailable = isUnavailable(chinfo->chanid, chanNumber, channelsChanged);
    13571366
    1358             // Try alternates with same channum if applicable
    1359             uint alt = GetAlternateChannelIndex(chanNumber, true);
    1360             if (alt != m_channelInfoIdx[chanNumber])
    1361             {
    1362                 unavailable = false;
    1363                 m_channelInfoIdx[chanNumber] = alt;
    1364                 chinfo = GetChannelInfo(chanNumber);
    1365                 channelsChanged = true;
    1366             }
     1367        if (channelsChanged)
     1368            chinfo = GetChannelInfo(chanNumber);
    13671369
    1368             // Try alternates with different channum if applicable
    1369             if (unavailable && GetProgramList(chinfo->chanid).count())
    1370             {
    1371                 alt = GetAlternateChannelIndex(chanNumber, false);
    1372                 unavailable = (alt == m_channelInfoIdx[chanNumber]);
    1373             }
    1374         }
     1370        if (!chinfo || (chanNumber >= m_channelInfos.size()))
     1371            break;
    13751372
    13761373        if ((y == (unsigned int)2 && scrolltype != 1) ||
    13771374            ((signed int)y == m_currentRow && scrolltype == 1))
    void GuideGrid::paintInfo(QPainter *p) 
    15661563    p->drawPixmap(pr.topLeft(), pix);
    15671564}
    15681565
     1566bool GuideGrid::isUnavailable(uint chanid, uint chanNumber, bool &channelsChanged)
     1567{
     1568    if (chan_unavailable.contains(chanNumber))
     1569      return chan_unavailable[chanNumber];
     1570
     1571    bool unavailable = false;
     1572    if (m_player && !m_player->IsTunable(chanid, true))
     1573    {
     1574        unavailable = true;
     1575
     1576        // Try alternates with same channum if applicable
     1577        uint alt = GetAlternateChannelIndex(chanNumber, true);
     1578        if (alt != m_channelInfoIdx[chanNumber])
     1579        {
     1580            unavailable = false;
     1581            m_channelInfoIdx[chanNumber] = alt;
     1582            channelsChanged = true;
     1583        }
     1584
     1585        // Try alternates with different channum if applicable
     1586        if (unavailable && GetProgramList(chanid).count())
     1587        {
     1588            alt = GetAlternateChannelIndex(chanNumber, false);
     1589            unavailable = (alt == m_channelInfoIdx[chanNumber]);
     1590        }
     1591    }
     1592
     1593    chan_unavailable[chanNumber] = unavailable;
     1594
     1595    return unavailable;
     1596}
     1597
    15691598void GuideGrid::toggleGuideListing()
    15701599{
    15711600    showFavorites = (!showFavorites);
    void GuideGrid::showProgFinder() 
    19001929
    19011930void GuideGrid::enter()
    19021931{
     1932    bool channelsChanged = false;
     1933
     1934    uint chanNumber = m_currentRow + m_currentStartChannel;
     1935    if (chanNumber >= m_channelInfos.size())
     1936        chanNumber -= m_channelInfos.size();
     1937
     1938    PixmapChannel *chinfo = GetChannelInfo(chanNumber);
     1939
     1940    if (isUnavailable(chinfo->chanid, chanNumber, channelsChanged))
     1941      return;
     1942
    19031943    if (timeCheck)
    19041944    {
    19051945        timeCheck->stop();
  • libs/libmythtv/guidegrid.h

    diff -rup mythtv.old/libs/libmythtv/guidegrid.h mythtv/libs/libmythtv/guidegrid.h
    old new class MPUBLIC GuideGrid : public MythDia 
    109109    void paintPrograms(QPainter *);
    110110    void paintCurrentInfo(QPainter *);
    111111    void paintInfo(QPainter *);
     112
     113    bool isUnavailable(uint chanid, uint chanNumber, bool &channelsChanged);
    112114 
    113115    void resizeImage(QPixmap *, QString);
    114116    void LoadWindow(QDomElement &);
    class MPUBLIC GuideGrid : public MythDia 
    211213    bool jumpToChannelActive;
    212214    bool jumpToChannelHasRect;
    213215    QTimer *jumpToChannelTimer;
     216
     217    QMap<uint,bool> chan_unavailable;
    214218};
    215219
    216220#endif