Ticket #11020: epg_v1_fixes27.patch

File epg_v1_fixes27.patch, 24.7 KB (added by Jim Stichnoth, 10 years ago)

Attempted fixes/0.27 backport of the Master version. Compiles, but not yet tested.

  • mythtv/programs/mythfrontend/guidegrid.cpp

    diff --git a/mythtv/programs/mythfrontend/guidegrid.cpp b/mythtv/programs/mythfrontend/guidegrid.cpp
    index 5a5f52c..142d810 100644
    a b bool JumpToChannel::Update(void) 
    164164    }
    165165}
    166166
     167class GuideStatus
     168{
     169public:
     170    unsigned int m_firstRow;
     171    int m_numRows;
     172    QVector<int> m_channums;
     173    uint m_currentStartChannel;
     174    QDateTime m_currentStartTime;
     175    QDateTime m_currentEndTime;
     176    int m_currentRow;
     177    int m_currentCol;
     178    int m_channelCount;
     179    int m_timeCount;
     180    bool m_verticalLayout;
     181    QDateTime m_firstTime;
     182    QDateTime m_lastTime;
     183    int m_channelInfos_size;
     184    MythRect m_gg_programRect;
     185    int m_gg_channelCount;
     186};
     187
     188class GuideUpdateClosure
     189{
     190public:
     191    GuideUpdateClosure(GuideGrid *guide) : m_guide(guide), m_seq(++s_seq) {}
     192
     193    // Execute the initial non-UI part (in a separate thread).  Return
     194    // true if ExecuteUI() should be run later, or false if the work
     195    // is no longer relevant (e.g., the UI elements have scrolled
     196    // offscreen by now).
     197    virtual bool ExecuteNonUI(void) = 0;
     198    // Execute the UI part in the UI thread.
     199    virtual void ExecuteUI(void) = 0;
     200
     201protected:
     202    GuideGrid *m_guide;
     203    unsigned m_seq;
     204    static unsigned s_seq;
     205};
     206unsigned GuideUpdateClosure::s_seq;
     207
     208struct UIGuideElement {
     209    UIGuideElement(int row, int col, const QRect &area,
     210                   const QString &title, const QString &category,
     211                   int arrow, int recType, int recStat, bool selected)
     212        : m_row(row), m_col(col), m_area(area), m_title(title),
     213          m_category(category), m_arrow(arrow), m_recType(recType),
     214          m_recStat(recStat), m_selected(selected) {}
     215    UIGuideElement(void) {}
     216    int m_row;
     217    int m_col;
     218    QRect m_area;
     219    QString m_title;
     220    QString m_category;
     221    int m_arrow;
     222    int m_recType;
     223    int m_recStat;
     224    bool m_selected;
     225};
     226
     227class GuideUpdateProgramRow : public GuideUpdateClosure
     228{
     229public:
     230    GuideUpdateProgramRow(GuideGrid *guide, GuideStatus gs,
     231                          const QVector<ProgramList*> &proglists
     232                          )
     233        : GuideUpdateClosure(guide),
     234          m_gs(gs),
     235          m_proglists(proglists)
     236    {
     237        for (int i = m_gs.m_firstRow; i < m_gs.m_firstRow + m_gs.m_numRows; ++i)
     238            for (int j = 0; j < MAX_DISPLAY_TIMES; ++j)
     239                m_programInfos[i][j] = NULL;
     240    }
     241    virtual bool ExecuteNonUI(void)
     242    {
     243        // Don't bother to do any work if the starting coordinates of
     244        // the guide have changed while the thread was waiting to
     245        // start.
     246        if (m_gs.m_currentStartChannel != m_guide->GetCurrentStartChannel() ||
     247            m_gs.m_currentStartTime != m_guide->GetCurrentStartTime())
     248        {
     249            return false;
     250        }
     251
     252        for (int i = 0; i < m_gs.m_numRows; ++i)
     253        {
     254            int row = i + m_gs.m_firstRow;
     255            if (!m_proglists[i])
     256                m_proglists[i] =
     257                    m_guide->getProgramListFromProgram(m_gs.m_channums[i]);
     258            fillProgramRowInfosWith(row, m_gs.m_channums[i], m_gs.m_currentStartTime,
     259                                    m_proglists[i]);
     260        }
     261        //sleep(1);
     262        return true;
     263    }
     264    virtual void ExecuteUI(void)
     265    {
     266        m_guide->updateProgramsUI(m_gs.m_firstRow, m_gs.m_numRows,
     267                                  m_progPast, m_proglists, m_result);
     268    }
     269    void fillProgramRowInfosWith(int row, int chanNum, QDateTime start,
     270                                 ProgramList *proglist);
     271    const GuideStatus m_gs;
     272    QVector<ProgramList*> m_proglists;
     273    ProgramInfo *m_programInfos[MAX_DISPLAY_CHANS][MAX_DISPLAY_TIMES];
     274    int m_progPast;
     275    QVector<UIGuideElement> m_result;
     276};
     277
     278class GuideUpdateChannels : public GuideUpdateClosure
     279{
     280public:
     281    GuideUpdateChannels(GuideGrid *guide, uint startChan)
     282        : GuideUpdateClosure(guide), m_currentStartChannel(startChan) {}
     283    virtual bool ExecuteNonUI(void)
     284    {
     285        if (m_currentStartChannel != m_guide->GetCurrentStartChannel())
     286            return false;
     287        m_guide->updateChannelsNonUI(m_chinfos, m_unavailables);
     288        return true;
     289    }
     290    virtual void ExecuteUI(void)
     291    {
     292        m_guide->updateChannelsUI(m_chinfos, m_unavailables);
     293    }
     294    uint m_currentStartChannel;
     295    QVector<ChannelInfo *> m_chinfos;
     296    QVector<bool> m_unavailables;
     297};
     298
     299class UpdateGuideEvent : public QEvent
     300{
     301public:
     302    UpdateGuideEvent(GuideUpdateClosure *closure) :
     303        QEvent(kEventType), m_closure(closure) {}
     304    GuideUpdateClosure *m_closure;
     305    static Type kEventType;
     306};
     307QEvent::Type UpdateGuideEvent::kEventType =
     308    (QEvent::Type) QEvent::registerEventType();
     309
     310class GuideHelper : public QRunnable
     311{
     312public:
     313    GuideHelper(GuideGrid *guide, GuideUpdateClosure *closure)
     314        : m_guide(guide), m_closure(closure)
     315    {
     316        QMutexLocker locker(&s_lock);
     317        ++s_loading[m_guide];
     318    }
     319    virtual void run(void)
     320    {
     321        QThread::currentThread()->setPriority(QThread::IdlePriority);
     322        if (m_closure)
     323        {
     324            if (m_closure->ExecuteNonUI())
     325                QCoreApplication::postEvent(m_guide,
     326                                            new UpdateGuideEvent(m_closure));
     327            else
     328            {
     329                delete m_closure;
     330                m_closure = NULL;
     331            }
     332        }
     333
     334        QMutexLocker locker(&s_lock);
     335        --s_loading[m_guide];
     336        if (!s_loading[m_guide])
     337            s_wait.wakeAll();
     338    }
     339    static bool IsLoading(GuideGrid *guide)
     340    {
     341        QMutexLocker locker(&s_lock);
     342        return s_loading[guide];
     343    }
     344    static void Wait(GuideGrid *guide)
     345    {
     346        QMutexLocker locker(&s_lock);
     347        if (!s_loading[guide])
     348            return;
     349        while (s_wait.wait(&s_lock))
     350        {
     351            if (!s_loading[guide])
     352                return;
     353        }
     354    }
     355private:
     356    GuideGrid *m_guide;
     357    GuideUpdateClosure *m_closure;
     358
     359    static QMutex                s_lock;
     360    static QWaitCondition        s_wait;
     361    static QMap<GuideGrid*,uint> s_loading;
     362};
     363QMutex                GuideHelper::s_lock;
     364QWaitCondition        GuideHelper::s_wait;
     365QMap<GuideGrid*,uint> GuideHelper::s_loading;
     366
    167367void GuideGrid::RunProgramGuide(uint chanid, const QString &channum,
    168368                                const QDateTime startTime,
    169369                                TV *player, bool embedVideo,
    GuideGrid::GuideGrid(MythScreenStack *parent, 
    241441           m_previewVideoRefreshTimer(new QTimer(this)),
    242442           m_channelOrdering(gCoreContext->GetSetting("ChannelOrdering", "channum")),
    243443           m_updateTimer(NULL),
     444           m_threadPool("GuideGridHelperPool"),
    244445           m_changrpid(changrpid),
    245446           m_changrplist(ChannelGroup::GetChannelGroups(false)),
    246447           m_jumpToChannelLock(QMutex::Recursive),
    GuideGrid::GuideGrid(MythScreenStack *parent, 
    274475    int secsoffset = -((m_originalStartTime.time().minute() % 30) * 60 +
    275476                        m_originalStartTime.time().second());
    276477    m_currentStartTime = m_originalStartTime.addSecs(secsoffset);
     478    m_threadPool.setMaxThreadCount(1);
    277479}
    278480
    279481bool GuideGrid::Create()
    void GuideGrid::Init(void) 
    356558    updateChannels();
    357559
    358560    fillProgramInfos(true);
    359     updateInfo();
    360561
    361562    m_updateTimer = new QTimer(this);
    362563    connect(m_updateTimer, SIGNAL(timeout()), SLOT(updateTimeout()) );
    void GuideGrid::Init(void) 
    374575
    375576GuideGrid::~GuideGrid()
    376577{
     578    GuideHelper::Wait(this);
     579
    377580    gCoreContext->removeListener(this);
    378581
    379582    while (!m_programs.empty())
    void GuideGrid::fillTimeInfos() 
    10751278
    10761279void GuideGrid::fillProgramInfos(bool useExistingData)
    10771280{
    1078     m_guideGrid->ResetData();
    1079 
    1080     for (int y = 0; y < m_channelCount; ++y)
    1081     {
    1082         fillProgramRowInfos(y, useExistingData);
    1083     }
     1281    fillProgramRowInfos(-1, useExistingData);
    10841282}
    10851283
    10861284ProgramList *GuideGrid::getProgramListFromProgram(int chanNum)
    ProgramList *GuideGrid::getProgramListFromProgram(int chanNum) 
    11061304    return proglist;
    11071305}
    11081306
    1109 void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData)
     1307static ProgramList *CopyProglist(ProgramList *proglist)
    11101308{
    1111     m_guideGrid->ResetRow(row);
    1112 
    1113     // never divide by zero..
    1114     if (!m_guideGrid->getChannelCount() || !m_timeCount)
    1115         return;
     1309    if (!proglist)
     1310        return NULL;
     1311    ProgramList *result = new ProgramList();
     1312    for (ProgramList::iterator pi = proglist->begin(); pi != proglist->end(); ++pi)
     1313        result->push_back(new ProgramInfo(**pi));
     1314    return result;
     1315}
    11161316
    1117     for (int x = 0; x < m_timeCount; ++x)
     1317void GuideGrid::fillProgramRowInfos(int firstRow, bool useExistingData)
     1318{
     1319    bool allRows = false;
     1320    int numRows = 1;
     1321    if (firstRow < 0)
    11181322    {
    1119         m_programInfos[row][x] = NULL;
     1323        firstRow = 0;
     1324        allRows = true;
     1325        numRows = min((int)m_channelInfos.size(), m_guideGrid->getChannelCount());
    11201326    }
     1327    QVector<int> chanNums;
     1328    QVector<ProgramList*> proglists;
    11211329
    1122     if (m_channelInfos.empty())
    1123         return;
     1330    for (unsigned int i = 0; i < numRows; ++i)
     1331    {
     1332        unsigned int row = i + firstRow;
     1333        // never divide by zero..
     1334        if (!m_guideGrid->getChannelCount() || !m_timeCount)
     1335            return;
    11241336
    1125     int chanNum = row + m_currentStartChannel;
    1126     if (chanNum >= (int) m_channelInfos.size())
    1127         chanNum -= (int) m_channelInfos.size();
    1128     if (chanNum >= (int) m_channelInfos.size())
    1129         return;
     1337        for (int x = 0; x < m_timeCount; ++x)
     1338        {
     1339            m_programInfos[row][x] = NULL;
     1340        }
    11301341
    1131     if (chanNum < 0)
    1132         chanNum = 0;
     1342        if (m_channelInfos.empty())
     1343            return;
    11331344
    1134     if (!useExistingData)
     1345        int chanNum = row + m_currentStartChannel;
     1346        if (chanNum >= (int) m_channelInfos.size())
     1347            chanNum -= (int) m_channelInfos.size();
     1348        if (chanNum >= (int) m_channelInfos.size())
     1349            return;
     1350
     1351        if (chanNum < 0)
     1352            chanNum = 0;
     1353
     1354        ProgramList *proglist = NULL;
     1355        if (useExistingData)
     1356            proglist = CopyProglist(m_programs[row]);
     1357        chanNums.push_back(chanNum);
     1358        proglists.push_back(proglist);
     1359    }
     1360    if (allRows)
    11351361    {
    1136         delete m_programs[row];
    1137         m_programs[row] = getProgramListFromProgram(chanNum);
     1362        for (unsigned int i = numRows; i < m_guideGrid->getChannelCount(); ++i)
     1363        {
     1364            delete m_programs[i];
     1365            m_programs[i] = NULL;
     1366            m_guideGrid->ResetRow(i);
     1367        }
    11381368    }
    1139 
    1140     ProgramList *proglist = m_programs[row];
    1141     if (!proglist)
     1369    GuideStatus gs;
     1370    gs.m_firstRow = firstRow;
     1371    gs.m_numRows = chanNums.size();
     1372    gs.m_channums = chanNums;
     1373    gs.m_currentStartChannel = m_currentStartChannel;
     1374    gs.m_currentStartTime = m_currentStartTime;
     1375    gs.m_currentEndTime = m_currentEndTime;
     1376    gs.m_currentRow = m_currentRow;
     1377    gs.m_currentCol = m_currentCol;
     1378    gs.m_channelCount = m_channelCount;
     1379    gs.m_timeCount = m_timeCount;
     1380    gs.m_verticalLayout = m_verticalLayout;
     1381    gs.m_firstTime = m_firstTime;
     1382    gs.m_lastTime = m_lastTime;
     1383    gs.m_channelInfos_size = m_channelInfos.size();
     1384    gs.m_gg_programRect = m_guideGrid->GetArea();
     1385    gs.m_gg_channelCount = m_guideGrid->getChannelCount();
     1386    GuideUpdateProgramRow *closure =
     1387        new GuideUpdateProgramRow(this, gs, proglists);
     1388    m_threadPool.start(new GuideHelper(this, closure), "GuideHelper");
     1389}
     1390
     1391void GuideUpdateProgramRow::fillProgramRowInfosWith(int row, int chanNum, QDateTime start,
     1392                                                    ProgramList *proglist)
     1393{
     1394    if (row < 0 || row >= m_gs.m_channelCount ||
     1395        start != m_gs.m_currentStartTime)
     1396    {
     1397        delete proglist;
    11421398        return;
     1399    }
    11431400
    1144     QDateTime ts = m_currentStartTime;
     1401    QDateTime ts = m_gs.m_currentStartTime;
    11451402
    11461403    QDateTime tnow = MythDate::current();
    11471404    int progPast = 0;
    1148     if (tnow > m_currentEndTime)
     1405    if (tnow > m_gs.m_currentEndTime)
    11491406        progPast = 100;
    1150     else if (tnow < m_currentStartTime)
     1407    else if (tnow < m_gs.m_currentStartTime)
    11511408        progPast = 0;
    11521409    else
    11531410    {
    1154         int played = m_currentStartTime.secsTo(tnow);
    1155         int length = m_currentStartTime.secsTo(m_currentEndTime);
     1411        int played = m_gs.m_currentStartTime.secsTo(tnow);
     1412        int length = m_gs.m_currentStartTime.secsTo(m_gs.m_currentEndTime);
    11561413        if (length)
    11571414            progPast = played * 100 / length;
    11581415    }
    11591416
    1160     m_guideGrid->SetProgPast(progPast);
     1417    m_progPast = progPast;
    11611418
    11621419    ProgramList::iterator program = proglist->begin();
    11631420    vector<ProgramInfo*> unknownlist;
    11641421    bool unknown = false;
    11651422    ProgramInfo *proginfo = NULL;
    1166     for (int x = 0; x < m_timeCount; ++x)
     1423    for (int x = 0; x < m_gs.m_timeCount; ++x)
    11671424    {
    11681425        if (program != proglist->end() &&
    11691426            (ts >= (*program)->GetScheduledEndTime()))
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12151472    for (; it != unknownlist.end(); ++it)
    12161473        proglist->push_back(*it);
    12171474
    1218     MythRect programRect = m_guideGrid->GetArea();
     1475    MythRect programRect = m_gs.m_gg_programRect;
    12191476
    12201477    /// use doubles to avoid large gaps at end..
    12211478    double ydifference = 0.0, xdifference = 0.0;
    12221479
    1223     if (m_verticalLayout)
     1480    if (m_gs.m_verticalLayout)
    12241481    {
    12251482        ydifference = programRect.width() /
    1226             (double) m_guideGrid->getChannelCount();
     1483            (double) m_gs.m_gg_channelCount;
    12271484        xdifference = programRect.height() /
    1228             (double) m_timeCount;
     1485            (double) m_gs.m_timeCount;
    12291486    }
    12301487    else
    12311488    {
    12321489        ydifference = programRect.height() /
    1233             (double) m_guideGrid->getChannelCount();
     1490            (double) m_gs.m_gg_channelCount;
    12341491        xdifference = programRect.width() /
    1235             (double) m_timeCount;
     1492            (double) m_gs.m_timeCount;
    12361493    }
    12371494
    12381495    int arrow = 0;
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12421499    QRect tempRect;
    12431500    bool isCurrent = false;
    12441501
    1245     for (int x = 0; x < m_timeCount; ++x)
     1502    for (int x = 0; x < m_gs.m_timeCount; ++x)
    12461503    {
    12471504        ProgramInfo *pginfo = m_programInfos[row][x];
    12481505        if (!pginfo)
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12521509        if (pginfo->GetScheduledStartTime() != lastprog)
    12531510        {
    12541511            arrow = 0;
    1255             if (pginfo->GetScheduledStartTime() < m_firstTime.addSecs(-300))
     1512            if (pginfo->GetScheduledStartTime() < m_gs.m_firstTime.addSecs(-300))
    12561513                arrow = arrow + 1;
    1257             if (pginfo->GetScheduledEndTime() > m_lastTime.addSecs(2100))
     1514            if (pginfo->GetScheduledEndTime() > m_gs.m_lastTime.addSecs(2100))
    12581515                arrow = arrow + 2;
    12591516
    12601517            if (pginfo->spread != -1)
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12631520            }
    12641521            else
    12651522            {
    1266                 for (int z = x + 1; z < m_timeCount; ++z)
     1523                for (int z = x + 1; z < m_gs.m_timeCount; ++z)
    12671524                {
    12681525                    ProgramInfo *test = m_programInfos[row][z];
    12691526                    if (test && (test->GetScheduledStartTime() ==
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12841541                }
    12851542            }
    12861543
    1287             if (m_verticalLayout)
     1544            if (m_gs.m_verticalLayout)
    12881545            {
    12891546                tempRect = QRect((int)(row * ydifference),
    12901547                                 (int)(x * xdifference),
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    13051562            if (tempRect.bottom() + 2 >=  programRect.bottom())
    13061563                tempRect.setBottom(programRect.bottom());
    13071564
    1308             if (m_currentRow == (int)row && (m_currentCol >= x) &&
    1309                 (m_currentCol < (x + spread)))
     1565            if (m_gs.m_currentRow == (int)row && (m_gs.m_currentCol >= x) &&
     1566                (m_gs.m_currentCol < (x + spread)))
    13101567                isCurrent = true;
    13111568            else
    13121569                isCurrent = false;
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    13491606                recStat = 0;
    13501607
    13511608            QString title = (pginfo->GetTitle() == kUnknownTitle) ?
    1352                                 tr("Unknown", "Unknown program title") :
     1609                GuideGrid::tr("Unknown", "Unknown program title") :
    13531610                                pginfo->GetTitle();
    1354             m_guideGrid->SetProgramInfo(
     1611            m_result.push_back(UIGuideElement(
    13551612                row, cnt, tempRect, title,
    13561613                pginfo->GetCategory(), arrow, recFlag,
    1357                 recStat, isCurrent);
     1614                recStat, isCurrent));
    13581615
    13591616            cnt++;
    13601617        }
    13611618
    13621619        lastprog = pginfo->GetScheduledStartTime();
    13631620    }
     1621
    13641622}
    13651623
    13661624void GuideGrid::customEvent(QEvent *event)
    void GuideGrid::customEvent(QEvent *event) 
    13741632        {
    13751633            LoadFromScheduler(m_recList);
    13761634            fillProgramInfos();
    1377             updateInfo();
    13781635        }
    13791636        else if (message == "STOP_VIDEO_REFRESH_TIMER")
    13801637        {
    void GuideGrid::customEvent(QEvent *event) 
    15131770        else
    15141771            ScheduleCommon::customEvent(event);
    15151772    }
     1773    else if (event->type() == UpdateGuideEvent::kEventType)
     1774    {
     1775        UpdateGuideEvent *uge = static_cast<UpdateGuideEvent*>(event);
     1776        if (uge->m_closure)
     1777        {
     1778            uge->m_closure->ExecuteUI();
     1779            delete uge->m_closure;
     1780            uge->m_closure = NULL;
     1781        }
     1782    }
    15161783}
    15171784
    15181785void GuideGrid::updateDateText(void)
    void GuideGrid::updateDateText(void) 
    15241791                                                 (MythDate::kDateFull | MythDate::kSimplify)));
    15251792}
    15261793
     1794void GuideGrid::updateProgramsUI(unsigned int firstRow, int numRows,
     1795                                 int progPast,
     1796                                 const QVector<ProgramList*> &proglists,
     1797                                 const QVector<struct UIGuideElement> &elements)
     1798{
     1799    for (int i = 0; i < numRows; ++i)
     1800    {
     1801        int row = i + firstRow;
     1802        m_guideGrid->ResetRow(row);
     1803        if (m_programs[row] != proglists[i])
     1804        {
     1805            delete m_programs[row];
     1806            m_programs[row] = proglists[i];
     1807        }
     1808    }
     1809    m_guideGrid->SetProgPast(progPast);
     1810    for (int i = 0; i < elements.size(); ++i)
     1811    {
     1812        UIGuideElement r = elements[i];
     1813        m_guideGrid->SetProgramInfo(r.m_row, r.m_col, r.m_area, r.m_title,
     1814                                    r.m_category, r.m_arrow, r.m_recType,
     1815                                    r.m_recStat, r.m_selected);
     1816    }
     1817    for (int i = firstRow; i < firstRow + numRows; ++i)
     1818    {
     1819        for (int j = 0; j < MAX_DISPLAY_TIMES; ++j)
     1820            m_programInfos[i][j] = m_programInfos[i][j];
     1821        if (i == m_currentRow)
     1822            updateInfo();
     1823    }
     1824    m_guideGrid->SetRedraw();
     1825}
     1826
    15271827void GuideGrid::updateChannels(void)
    15281828{
    1529     m_channelList->Reset();
     1829    m_threadPool.start(new GuideHelper(this, new GuideUpdateChannels(this, m_currentStartChannel)),
     1830                       "GuideHelper");
     1831}
    15301832
     1833void GuideGrid::updateChannelsNonUI(QVector<ChannelInfo *> &chinfos,
     1834                                    QVector<bool> &unavailables)
     1835{
    15311836    ChannelInfo *chinfo = GetChannelInfo(m_currentStartChannel);
    15321837
    15331838    if (m_player)
    void GuideGrid::updateChannels(void) 
    15751880                unavailable = (alt == m_channelInfoIdx[chanNumber]);
    15761881            }
    15771882        }
     1883        chinfos.push_back(chinfo);
     1884        unavailables.push_back(unavailable);
     1885    }
     1886}
    15781887
     1888void GuideGrid::updateChannelsUI(const QVector<ChannelInfo *> &chinfos,
     1889                                 const QVector<bool> &unavailables)
     1890{
     1891    m_channelList->Reset();
     1892    for (int i = 0; i < chinfos.size(); ++i)
     1893    {
     1894        ChannelInfo *chinfo = chinfos[i];
     1895        bool unavailable = unavailables[i];
    15791896        MythUIButtonListItem *item =
    15801897            new MythUIButtonListItem(m_channelList,
    15811898                                     chinfo ? chinfo->GetFormatted(ChannelInfo::kChannelShort) : QString());
    void GuideGrid::updateInfo(void) 
    16601977        QString rating = QString::number(pginfo->GetStars(10));
    16611978        ratingState->DisplayState(rating);
    16621979    }
     1980    m_guideGrid->SetRedraw();
    16631981}
    16641982
    16651983void GuideGrid::toggleGuideListing()
    void GuideGrid::cursorLeft() 
    18092127    }
    18102128    else
    18112129    {
    1812         fillProgramRowInfos(m_currentRow);
    1813         m_guideGrid->SetRedraw();
    1814         updateInfo();
     2130        fillProgramRowInfos(m_currentRow, true);
    18152131    }
    18162132}
    18172133
    void GuideGrid::cursorRight() 
    18372153    }
    18382154    else
    18392155    {
    1840         fillProgramRowInfos(m_currentRow);
    1841         m_guideGrid->SetRedraw();
    1842         updateInfo();
     2156        fillProgramRowInfos(m_currentRow, true);
    18432157    }
    18442158}
    18452159
    void GuideGrid::cursorDown() 
    18542168    }
    18552169    else
    18562170    {
    1857         fillProgramRowInfos(m_currentRow);
    1858         m_guideGrid->SetRedraw();
    1859         updateInfo();
    1860         updateChannels();
     2171        fillProgramRowInfos(m_currentRow, true);
    18612172    }
    18622173}
    18632174
    void GuideGrid::cursorUp() 
    18722183    }
    18732184    else
    18742185    {
    1875         fillProgramRowInfos(m_currentRow);
    1876         m_guideGrid->SetRedraw();
    1877         updateInfo();
    1878         updateChannels();
     2186        fillProgramRowInfos(m_currentRow, true);
    18792187    }
    18802188}
    18812189
    void GuideGrid::moveLeftRight(MoveVector movement) 
    19072215
    19082216    fillTimeInfos();
    19092217    fillProgramInfos();
    1910     m_guideGrid->SetRedraw();
    1911     updateInfo();
    19122218    updateDateText();
    19132219}
    19142220
    void GuideGrid::moveUpDown(MoveVector movement) 
    19332239    }
    19342240
    19352241    fillProgramInfos();
    1936     m_guideGrid->SetRedraw();
    1937     updateInfo();
    19382242    updateChannels();
    19392243}
    19402244
    void GuideGrid::moveToTime(QDateTime datetime) 
    19472251
    19482252    fillTimeInfos();
    19492253    fillProgramInfos();
    1950     m_guideGrid->SetRedraw();
    1951     updateInfo();
    19522254    updateDateText();
    19532255}
    19542256
    void GuideGrid::quickRecord() 
    20162318    QuickRecord(pginfo);
    20172319    LoadFromScheduler(m_recList);
    20182320    fillProgramInfos();
    2019     updateInfo();
    20202321}
    20212322
    20222323void GuideGrid::editRecSchedule()
    void GuideGrid::GoTo(int start, int cur_row) 
    21632464    m_currentRow = cur_row % m_channelCount;
    21642465    updateChannels();
    21652466    fillProgramInfos();
    2166     updateInfo();
    21672467    updateJumpToChannel();
    21682468}
    21692469
  • mythtv/programs/mythfrontend/guidegrid.h

    diff --git a/mythtv/programs/mythfrontend/guidegrid.h b/mythtv/programs/mythfrontend/guidegrid.h
    index fd11d27..665d4ea 100644
    a b using namespace std; 
    1717#include "channelgroup.h"
    1818#include "channelutil.h"
    1919#include "mythuiguidegrid.h"
     20#include "mthreadpool.h"
    2021
    2122// mythfrontend
    2223#include "schedulecommon.h"
    class GuideGrid : public ScheduleCommon, public JumpToChannelListener 
    102103
    103104    virtual void aboutToShow();
    104105    virtual void aboutToHide();
     106    // Allow class GuideUpdateProgramRow to figure out whether the
     107    // current start time/channel coordinates are the same, so that it can
     108    // skip the work if not.
     109    uint GetCurrentStartChannel(void) const { return m_currentStartChannel; }
     110    QDateTime GetCurrentStartTime(void) const { return m_currentStartTime; }
    105111
    106112  protected slots:
    107113    void cursorLeft();
    class GuideGrid : public ScheduleCommon, public JumpToChannelListener 
    179185    void fillChannelInfos(bool gotostartchannel = true);
    180186    void fillTimeInfos(void);
    181187    void fillProgramInfos(bool useExistingData = false);
    182     void fillProgramRowInfos(unsigned int row, bool useExistingData = false);
     188    // Set row=-1 to fill all rows.
     189    void fillProgramRowInfos(int row, bool useExistingData);
     190public:
     191    // These need to be public so that the helper classes can operate.
    183192    ProgramList *getProgramListFromProgram(int chanNum);
     193    void updateProgramsUI(unsigned int firstRow, int numRows,
     194                          int progPast,
     195                          const QVector<ProgramList*> &proglists,
     196                          const QVector<struct UIGuideElement> &elements);
     197    void updateChannelsNonUI(QVector<ChannelInfo *> &chinfos,
     198                             QVector<bool> &unavailables);
     199    void updateChannelsUI(const QVector<ChannelInfo *> &chinfos,
     200                          const QVector<bool> &unavailables);
     201private:
    184202
    185203    void setStartChannel(int newStartChannel);
    186204
    class GuideGrid : public ScheduleCommon, public JumpToChannelListener 
    235253
    236254    QTimer *m_updateTimer; // audited ref #5318
    237255
     256    MThreadPool       m_threadPool;
     257
    238258    int               m_changrpid;
    239259    ChannelGroupList  m_changrplist;
    240260