Ticket #11020: epg_v1_master.patch

File epg_v1_master.patch, 25.0 KB (added by Jim Stichnoth, 10 years ago)

Work-in-progress patch for Master. Still some slight stuttering on an ION-1 frontend, but a vast improvement.

  • mythtv/programs/mythfrontend/guidegrid.cpp

    diff --git a/mythtv/programs/mythfrontend/guidegrid.cpp b/mythtv/programs/mythfrontend/guidegrid.cpp
    index 5cdbb1b..51fb310 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() 
    10461249
    10471250void GuideGrid::fillProgramInfos(bool useExistingData)
    10481251{
    1049     m_guideGrid->ResetData();
    1050 
    1051     for (int y = 0; y < m_channelCount; ++y)
    1052     {
    1053         fillProgramRowInfos(y, useExistingData);
    1054     }
     1252    fillProgramRowInfos(-1, useExistingData);
    10551253}
    10561254
    10571255ProgramList *GuideGrid::getProgramListFromProgram(int chanNum)
    ProgramList *GuideGrid::getProgramListFromProgram(int chanNum) 
    10771275    return proglist;
    10781276}
    10791277
    1080 void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData)
     1278static ProgramList *CopyProglist(ProgramList *proglist)
    10811279{
    1082     m_guideGrid->ResetRow(row);
    1083 
    1084     // never divide by zero..
    1085     if (!m_guideGrid->getChannelCount() || !m_timeCount)
    1086         return;
     1280    if (!proglist)
     1281        return NULL;
     1282    ProgramList *result = new ProgramList();
     1283    for (ProgramList::iterator pi = proglist->begin(); pi != proglist->end(); ++pi)
     1284        result->push_back(new ProgramInfo(**pi));
     1285    return result;
     1286}
    10871287
    1088     for (int x = 0; x < m_timeCount; ++x)
     1288void GuideGrid::fillProgramRowInfos(int firstRow, bool useExistingData)
     1289{
     1290    bool allRows = false;
     1291    int numRows = 1;
     1292    if (firstRow < 0)
    10891293    {
    1090         m_programInfos[row][x] = NULL;
     1294        firstRow = 0;
     1295        allRows = true;
     1296        numRows = min((int)m_channelInfos.size(), m_guideGrid->getChannelCount());
    10911297    }
     1298    QVector<int> chanNums;
     1299    QVector<ProgramList*> proglists;
    10921300
    1093     if (m_channelInfos.empty())
    1094         return;
     1301    for (unsigned int i = 0; i < numRows; ++i)
     1302    {
     1303        unsigned int row = i + firstRow;
     1304        // never divide by zero..
     1305        if (!m_guideGrid->getChannelCount() || !m_timeCount)
     1306            return;
    10951307
    1096     int chanNum = row + m_currentStartChannel;
    1097     if (chanNum >= (int) m_channelInfos.size())
    1098         chanNum -= (int) m_channelInfos.size();
    1099     if (chanNum >= (int) m_channelInfos.size())
    1100         return;
     1308        for (int x = 0; x < m_timeCount; ++x)
     1309        {
     1310            m_programInfos[row][x] = NULL;
     1311        }
    11011312
    1102     if (chanNum < 0)
    1103         chanNum = 0;
     1313        if (m_channelInfos.empty())
     1314            return;
    11041315
    1105     if (!useExistingData)
     1316        int chanNum = row + m_currentStartChannel;
     1317        if (chanNum >= (int) m_channelInfos.size())
     1318            chanNum -= (int) m_channelInfos.size();
     1319        if (chanNum >= (int) m_channelInfos.size())
     1320            return;
     1321
     1322        if (chanNum < 0)
     1323            chanNum = 0;
     1324
     1325        ProgramList *proglist = NULL;
     1326        if (useExistingData)
     1327            proglist = CopyProglist(m_programs[row]);
     1328        chanNums.push_back(chanNum);
     1329        proglists.push_back(proglist);
     1330    }
     1331    if (allRows)
    11061332    {
    1107         delete m_programs[row];
    1108         m_programs[row] = getProgramListFromProgram(chanNum);
     1333        for (unsigned int i = numRows; i < m_guideGrid->getChannelCount(); ++i)
     1334        {
     1335            delete m_programs[i];
     1336            m_programs[i] = NULL;
     1337            m_guideGrid->ResetRow(i);
     1338        }
    11091339    }
    1110 
    1111     ProgramList *proglist = m_programs[row];
    1112     if (!proglist)
     1340    GuideStatus gs;
     1341    gs.m_firstRow = firstRow;
     1342    gs.m_numRows = chanNums.size();
     1343    gs.m_channums = chanNums;
     1344    gs.m_currentStartChannel = m_currentStartChannel;
     1345    gs.m_currentStartTime = m_currentStartTime;
     1346    gs.m_currentEndTime = m_currentEndTime;
     1347    gs.m_currentRow = m_currentRow;
     1348    gs.m_currentCol = m_currentCol;
     1349    gs.m_channelCount = m_channelCount;
     1350    gs.m_timeCount = m_timeCount;
     1351    gs.m_verticalLayout = m_verticalLayout;
     1352    gs.m_firstTime = m_firstTime;
     1353    gs.m_lastTime = m_lastTime;
     1354    gs.m_channelInfos_size = m_channelInfos.size();
     1355    gs.m_gg_programRect = m_guideGrid->GetArea();
     1356    gs.m_gg_channelCount = m_guideGrid->getChannelCount();
     1357    GuideUpdateProgramRow *closure =
     1358        new GuideUpdateProgramRow(this, gs, proglists);
     1359    m_threadPool.start(new GuideHelper(this, closure), "GuideHelper");
     1360}
     1361
     1362void GuideUpdateProgramRow::fillProgramRowInfosWith(int row, int chanNum, QDateTime start,
     1363                                                    ProgramList *proglist)
     1364{
     1365    if (row < 0 || row >= m_gs.m_channelCount ||
     1366        start != m_gs.m_currentStartTime)
     1367    {
     1368        delete proglist;
    11131369        return;
     1370    }
    11141371
    1115     QDateTime ts = m_currentStartTime;
     1372    QDateTime ts = m_gs.m_currentStartTime;
    11161373
    11171374    QDateTime tnow = MythDate::current();
    11181375    int progPast = 0;
    1119     if (tnow > m_currentEndTime)
     1376    if (tnow > m_gs.m_currentEndTime)
    11201377        progPast = 100;
    1121     else if (tnow < m_currentStartTime)
     1378    else if (tnow < m_gs.m_currentStartTime)
    11221379        progPast = 0;
    11231380    else
    11241381    {
    1125         int played = m_currentStartTime.secsTo(tnow);
    1126         int length = m_currentStartTime.secsTo(m_currentEndTime);
     1382        int played = m_gs.m_currentStartTime.secsTo(tnow);
     1383        int length = m_gs.m_currentStartTime.secsTo(m_gs.m_currentEndTime);
    11271384        if (length)
    11281385            progPast = played * 100 / length;
    11291386    }
    11301387
    1131     m_guideGrid->SetProgPast(progPast);
     1388    m_progPast = progPast;
    11321389
    11331390    ProgramList::iterator program = proglist->begin();
    11341391    vector<ProgramInfo*> unknownlist;
    11351392    bool unknown = false;
    11361393    ProgramInfo *proginfo = NULL;
    1137     for (int x = 0; x < m_timeCount; ++x)
     1394    for (int x = 0; x < m_gs.m_timeCount; ++x)
    11381395    {
    11391396        if (program != proglist->end() &&
    11401397            (ts >= (*program)->GetScheduledEndTime()))
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    11531410            }
    11541411            else
    11551412            {
    1156                 proginfo = new ProgramInfo(kUnknownTitle, tr("Unknown"),
     1413                proginfo = new ProgramInfo(kUnknownTitle,
     1414                                           GuideGrid::tr("Unknown"),
    11571415                                           ts, ts.addSecs(5*60));
    11581416                unknownlist.push_back(proginfo);
    11591417                proginfo->startCol = x;
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    11861444    for (; it != unknownlist.end(); ++it)
    11871445        proglist->push_back(*it);
    11881446
    1189     MythRect programRect = m_guideGrid->GetArea();
     1447    MythRect programRect = m_gs.m_gg_programRect;
    11901448
    11911449    /// use doubles to avoid large gaps at end..
    11921450    double ydifference = 0.0, xdifference = 0.0;
    11931451
    1194     if (m_verticalLayout)
     1452    if (m_gs.m_verticalLayout)
    11951453    {
    11961454        ydifference = programRect.width() /
    1197             (double) m_guideGrid->getChannelCount();
     1455            (double) m_gs.m_gg_channelCount;
    11981456        xdifference = programRect.height() /
    1199             (double) m_timeCount;
     1457            (double) m_gs.m_timeCount;
    12001458    }
    12011459    else
    12021460    {
    12031461        ydifference = programRect.height() /
    1204             (double) m_guideGrid->getChannelCount();
     1462            (double) m_gs.m_gg_channelCount;
    12051463        xdifference = programRect.width() /
    1206             (double) m_timeCount;
     1464            (double) m_gs.m_timeCount;
    12071465    }
    12081466
    12091467    int arrow = 0;
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12131471    QRect tempRect;
    12141472    bool isCurrent = false;
    12151473
    1216     for (int x = 0; x < m_timeCount; ++x)
     1474    for (int x = 0; x < m_gs.m_timeCount; ++x)
    12171475    {
    12181476        ProgramInfo *pginfo = m_programInfos[row][x];
    12191477        if (!pginfo)
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12231481        if (pginfo->GetScheduledStartTime() != lastprog)
    12241482        {
    12251483            arrow = 0;
    1226             if (pginfo->GetScheduledStartTime() < m_firstTime.addSecs(-300))
     1484            if (pginfo->GetScheduledStartTime() < m_gs.m_firstTime.addSecs(-300))
    12271485                arrow = arrow + 1;
    1228             if (pginfo->GetScheduledEndTime() > m_lastTime.addSecs(2100))
     1486            if (pginfo->GetScheduledEndTime() > m_gs.m_lastTime.addSecs(2100))
    12291487                arrow = arrow + 2;
    12301488
    12311489            if (pginfo->spread != -1)
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12341492            }
    12351493            else
    12361494            {
    1237                 for (int z = x + 1; z < m_timeCount; ++z)
     1495                for (int z = x + 1; z < m_gs.m_timeCount; ++z)
    12381496                {
    12391497                    ProgramInfo *test = m_programInfos[row][z];
    12401498                    if (test && (test->GetScheduledStartTime() ==
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12551513                }
    12561514            }
    12571515
    1258             if (m_verticalLayout)
     1516            if (m_gs.m_verticalLayout)
    12591517            {
    12601518                tempRect = QRect((int)(row * ydifference),
    12611519                                 (int)(x * xdifference),
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    12761534            if (tempRect.bottom() + 2 >=  programRect.bottom())
    12771535                tempRect.setBottom(programRect.bottom());
    12781536
    1279             if (m_currentRow == (int)row && (m_currentCol >= x) &&
    1280                 (m_currentCol < (x + spread)))
     1537            if (m_gs.m_currentRow == (int)row && (m_gs.m_currentCol >= x) &&
     1538                (m_gs.m_currentCol < (x + spread)))
    12811539                isCurrent = true;
    12821540            else
    12831541                isCurrent = false;
    void GuideGrid::fillProgramRowInfos(unsigned int row, bool useExistingData) 
    13201578                recStat = 0;
    13211579
    13221580            QString title = (pginfo->GetTitle() == kUnknownTitle) ?
    1323                                 tr("Unknown", "Unknown program title") :
     1581                GuideGrid::tr("Unknown", "Unknown program title") :
    13241582                                pginfo->GetTitle();
    1325             m_guideGrid->SetProgramInfo(
     1583            m_result.push_back(UIGuideElement(
    13261584                row, cnt, tempRect, title,
    13271585                pginfo->GetCategory(), arrow, recFlag,
    1328                 recStat, isCurrent);
     1586                recStat, isCurrent));
    13291587
    13301588            cnt++;
    13311589        }
    13321590
    13331591        lastprog = pginfo->GetScheduledStartTime();
    13341592    }
     1593
    13351594}
    13361595
    13371596void GuideGrid::customEvent(QEvent *event)
    void GuideGrid::customEvent(QEvent *event) 
    13451604        {
    13461605            LoadFromScheduler(m_recList);
    13471606            fillProgramInfos();
    1348             updateInfo();
    13491607        }
    13501608        else if (message == "STOP_VIDEO_REFRESH_TIMER")
    13511609        {
    void GuideGrid::customEvent(QEvent *event) 
    14891747        else
    14901748            ScheduleCommon::customEvent(event);
    14911749    }
     1750    else if (event->type() == UpdateGuideEvent::kEventType)
     1751    {
     1752        UpdateGuideEvent *uge = static_cast<UpdateGuideEvent*>(event);
     1753        if (uge->m_closure)
     1754        {
     1755            uge->m_closure->ExecuteUI();
     1756            delete uge->m_closure;
     1757            uge->m_closure = NULL;
     1758        }
     1759    }
    14921760}
    14931761
    14941762void GuideGrid::updateDateText(void)
    void GuideGrid::updateDateText(void) 
    15001768                                                 (MythDate::kDateFull | MythDate::kSimplify)));
    15011769}
    15021770
     1771void GuideGrid::updateProgramsUI(unsigned int firstRow, int numRows,
     1772                                 int progPast,
     1773                                 const QVector<ProgramList*> &proglists,
     1774                                 const QVector<struct UIGuideElement> &elements)
     1775{
     1776    for (int i = 0; i < numRows; ++i)
     1777    {
     1778        int row = i + firstRow;
     1779        m_guideGrid->ResetRow(row);
     1780        if (m_programs[row] != proglists[i])
     1781        {
     1782            delete m_programs[row];
     1783            m_programs[row] = proglists[i];
     1784        }
     1785    }
     1786    m_guideGrid->SetProgPast(progPast);
     1787    for (int i = 0; i < elements.size(); ++i)
     1788    {
     1789        UIGuideElement r = elements[i];
     1790        m_guideGrid->SetProgramInfo(r.m_row, r.m_col, r.m_area, r.m_title,
     1791                                    r.m_category, r.m_arrow, r.m_recType,
     1792                                    r.m_recStat, r.m_selected);
     1793    }
     1794    for (int i = firstRow; i < firstRow + numRows; ++i)
     1795    {
     1796        for (int j = 0; j < MAX_DISPLAY_TIMES; ++j)
     1797            m_programInfos[i][j] = m_programInfos[i][j];
     1798        if (i == m_currentRow)
     1799            updateInfo();
     1800    }
     1801    m_guideGrid->SetRedraw();
     1802}
     1803
    15031804void GuideGrid::updateChannels(void)
    15041805{
    1505     m_channelList->Reset();
     1806    m_threadPool.start(new GuideHelper(this, new GuideUpdateChannels(this, m_currentStartChannel)),
     1807                       "GuideHelper");
     1808}
    15061809
     1810void GuideGrid::updateChannelsNonUI(QVector<ChannelInfo *> &chinfos,
     1811                                    QVector<bool> &unavailables)
     1812{
    15071813    ChannelInfo *chinfo = GetChannelInfo(m_currentStartChannel);
    15081814
    15091815    if (m_player)
    void GuideGrid::updateChannels(void) 
    15511857                unavailable = (alt == m_channelInfoIdx[chanNumber]);
    15521858            }
    15531859        }
     1860        chinfos.push_back(chinfo);
     1861        unavailables.push_back(unavailable);
     1862    }
     1863}
    15541864
     1865void GuideGrid::updateChannelsUI(const QVector<ChannelInfo *> &chinfos,
     1866                                 const QVector<bool> &unavailables)
     1867{
     1868    m_channelList->Reset();
     1869    for (int i = 0; i < chinfos.size(); ++i)
     1870    {
     1871        ChannelInfo *chinfo = chinfos[i];
     1872        bool unavailable = unavailables[i];
    15551873        MythUIButtonListItem *item =
    15561874            new MythUIButtonListItem(m_channelList,
    15571875                                     chinfo ? chinfo->GetFormatted(ChannelInfo::kChannelShort) : QString());
    void GuideGrid::updateInfo(void) 
    16361954        QString rating = QString::number(pginfo->GetStars(10));
    16371955        ratingState->DisplayState(rating);
    16381956    }
     1957    m_guideGrid->SetRedraw();
    16391958}
    16401959
    16411960void GuideGrid::toggleGuideListing()
    void GuideGrid::cursorLeft() 
    17862105    else
    17872106    {
    17882107        fillProgramRowInfos(m_currentRow, true);
    1789         m_guideGrid->SetRedraw();
    1790         updateInfo();
    17912108    }
    17922109}
    17932110
    void GuideGrid::cursorRight() 
    18142131    else
    18152132    {
    18162133        fillProgramRowInfos(m_currentRow, true);
    1817         m_guideGrid->SetRedraw();
    1818         updateInfo();
    18192134    }
    18202135}
    18212136
    void GuideGrid::cursorDown() 
    18312146    else
    18322147    {
    18332148        fillProgramRowInfos(m_currentRow, true);
    1834         m_guideGrid->SetRedraw();
    1835         updateInfo();
    1836         updateChannels();
    18372149    }
    18382150}
    18392151
    void GuideGrid::cursorUp() 
    18492161    else
    18502162    {
    18512163        fillProgramRowInfos(m_currentRow, true);
    1852         m_guideGrid->SetRedraw();
    1853         updateInfo();
    1854         updateChannels();
    18552164    }
    18562165}
    18572166
    void GuideGrid::moveLeftRight(MoveVector movement) 
    18832192
    18842193    fillTimeInfos();
    18852194    fillProgramInfos();
    1886     m_guideGrid->SetRedraw();
    1887     updateInfo();
    18882195    updateDateText();
    18892196}
    18902197
    void GuideGrid::moveUpDown(MoveVector movement) 
    19092216    }
    19102217
    19112218    fillProgramInfos();
    1912     m_guideGrid->SetRedraw();
    1913     updateInfo();
    19142219    updateChannels();
    19152220}
    19162221
    void GuideGrid::moveToTime(QDateTime datetime) 
    19232228
    19242229    fillTimeInfos();
    19252230    fillProgramInfos();
    1926     m_guideGrid->SetRedraw();
    1927     updateInfo();
    19282231    updateDateText();
    19292232}
    19302233
    void GuideGrid::quickRecord() 
    19922295    QuickRecord(pginfo);
    19932296    LoadFromScheduler(m_recList);
    19942297    fillProgramInfos();
    1995     updateInfo();
    19962298}
    19972299
    19982300void GuideGrid::editRecSchedule()
    void GuideGrid::GoTo(int start, int cur_row) 
    21392441    m_currentRow = cur_row % m_channelCount;
    21402442    updateChannels();
    21412443    fillProgramInfos();
    2142     updateInfo();
    21432444    updateJumpToChannel();
    21442445}
    21452446
  • 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