Ticket #8011: mythtv.grouptotals.patch

File mythtv.grouptotals.patch, 6.8 KB (added by James Hook <mythtv.hook@…>, 14 years ago)

Patch

  • programs/mythfrontend/playbackbox.cpp

     
    667667    infoMap["description"] = desc;
    668668    infoMap["rec_count"] = QString("%1").arg(countInGroup);
    669669
     670// H O O K: Include the total time and filesize for the group
     671
     672    int totalsecs = 0;
     673    uint64_t totalsize = 0ULL;
     674
     675    ProgramList::iterator totalit = m_progLists[groupname].begin();
     676    while (totalit != m_progLists[groupname].end())
     677    {
     678        totalsecs += (*totalit)->startts.secsTo((*totalit)->endts);
     679        totalsize += (*totalit)->filesize;
     680        ++totalit;
     681    }
     682
     683
     684    int minutes     = totalsecs / 60;
     685    int totalh     = minutes / 60;
     686    int totalm     = minutes % 60;
     687    QString tmpSize;
     688
     689    tmpSize.sprintf("%0.2f ", totalsize * (1.0 / (1024.0 * 1024.0 * 1024.0)));
     690    tmpSize += QObject::tr("GB", "GigaBytes");
     691    infoMap["filesize_str"] = tmpSize;
     692    infoMap["filesize"] = QString::number(totalsize);
     693
     694
     695    infoMap["lenmins"] = tr("%n minute(s)", "", minutes);
     696
     697    if(totalh > 0 && totalm > 0) {
     698        infoMap["lentime"] = QString("%1 %2")
     699                                    .arg(QObject::tr("%n hour(s)", "", totalh))
     700                                    .arg(QObject::tr("%n minute(s)", "", totalm));
     701    } else if(totalh > 0) {
     702        infoMap["lentime"] = QObject::tr("%n hour(s)", "", totalh);
     703    } else {
     704        infoMap["lentime"] = QObject::tr("%n minute(s)", "", totalm);
     705    }
     706// HOOK... Done.
     707
    670708    ResetMap(m_currentMap);
    671709    SetTextFromMap(infoMap);
    672710    m_currentMap = infoMap;
     
    15261564
    15271565                if ((m_viewMask & VIEW_WATCHLIST) && (p->recgroup != "LiveTV"))
    15281566                {
     1567                    VERBOSE(VB_FILE, QString("watchlist: Testing:  %1 (%2) %3")
     1568                                              .arg(p->title).arg(p->startts.toString(m_formatShortDate)).arg(p->recordid));
    15291569                    if (m_watchListAutoExpire && !(p->programflags & FL_AUTOEXP))
    15301570                    {
    15311571                        p->recpriority2 = wlExpireOff;
    1532                         VERBOSE(VB_FILE, QString("Auto-expire off:  %1")
     1572                        VERBOSE(VB_FILE, QString("watchlist: Auto-expire off:  %1")
    15331573                                                 .arg(p->title));
    15341574                    }
    15351575                    else if (p->programflags & FL_WATCHED)
    15361576                    {
    15371577                        p->recpriority2 = wlWatched;
    1538                         VERBOSE(VB_FILE, QString("Marked as 'watched':  %1")
     1578                        VERBOSE(VB_FILE, QString("watchlist: Marked as 'watched':  %1")
    15391579                                                 .arg(p->title));
    15401580                    }
    15411581                    else
    15421582                    {
    1543                         if (p->recordid > 0)
    1544                             recidEpisodes[p->recordid] += 1;
    1545                         if (recidEpisodes[p->recordid] == 1 ||
    1546                             p->recordid == 0 )
    1547                         {
    1548                             m_progLists[m_watchGroupLabel].push_front(p);
    1549                             m_progLists[m_watchGroupLabel].setAutoDelete(false);
    1550                         }
    1551                         else
    1552                         {
    1553                             p->recpriority2 = wlEarlier;
    1554                             VERBOSE(VB_FILE, QString("Not the earliest:  %1")
    1555                                                      .arg(p->title));
    1556                         }
     1583                        if (p->recordid > 0) {
     1584                                recidEpisodes[p->recordid] += 1;
     1585                            // H O O K: Track the old iterator, so we can delete the newer items next time we see this record
     1586                            if (recidEpisodes[p->recordid] > 1) {
     1587                                ProgramList::iterator pit = m_progLists[m_watchGroupLabel].begin();
     1588                                while (pit != m_progLists[m_watchGroupLabel].end())
     1589                                {
     1590                                    if((*pit)->recordid == p->recordid) {
     1591                                        m_progLists[m_watchGroupLabel].erase(pit);
     1592                                        VERBOSE(VB_FILE, QString("watchlist:   Overrides last one "));
     1593                                        break;
     1594                                    }
     1595
     1596                                    ++pit;
     1597                               }
     1598                                 }
     1599                        }
     1600
     1601                        m_progLists[m_watchGroupLabel].push_front(p);
     1602                        m_progLists[m_watchGroupLabel].setAutoDelete(false);
     1603                        // HOOK... Done.
     1604
    15571605                    }
    15581606                }
    15591607            }
     
    17101758                if (delHours[recid] < m_watchListBlackOut * 4)
    17111759                {
    17121760                    (*pit)->recpriority2 = wlDeleted;
    1713                     VERBOSE(VB_FILE, QString("Recently deleted daily:  %1")
     1761                    VERBOSE(VB_FILE, QString("watchlist: Recently deleted daily:  %1")
    17141762                                             .arg((*pit)->title));
    17151763                    pit = m_progLists[m_watchGroupLabel].erase(pit);
    17161764                    continue;
    17171765                }
    17181766                else
    17191767                {
    1720                     VERBOSE(VB_FILE, QString("Daily interval:  %1")
     1768                    VERBOSE(VB_FILE, QString("watchlist: Daily interval:  %1")
    17211769                                             .arg((*pit)->title));
    17221770
    17231771                    if (maxEpisodes[recid] > 0)
     
    17351783                if (delHours[recid] < (m_watchListBlackOut * 24) - 4)
    17361784                {
    17371785                    (*pit)->recpriority2 = wlDeleted;
    1738                     VERBOSE(VB_FILE, QString("Recently deleted weekly:  %1")
     1786                    VERBOSE(VB_FILE, QString("watchlist: Recently deleted weekly:  %1")
    17391787                                             .arg((*pit)->title));
    17401788                    pit = m_progLists[m_watchGroupLabel].erase(pit);
    17411789                    continue;
    17421790                }
    17431791                else
    17441792                {
    1745                     VERBOSE(VB_FILE, QString("Weekly interval: %1")
     1793                    VERBOSE(VB_FILE, QString("watchlist: Weekly interval: %1")
    17461794                                             .arg((*pit)->title));
    17471795
    17481796                    if (maxEpisodes[recid] > 0)
     
    17941842            else if (avgd > 100)
    17951843                (*pit)->recpriority2 = (*pit)->recpriority2 * 100 / delaypct;
    17961844
    1797             VERBOSE(VB_FILE, QString(" %1  %2  %3")
     1845            VERBOSE(VB_FILE, QString("watchlist: %1  %2  %3")
    17981846                    .arg((*pit)->startts.toString(m_formatShortDate))
    17991847                    .arg((*pit)->recpriority2).arg((*pit)->title));
    18001848