Ticket #10161: lazystrings_v1.patch

File lazystrings_v1.patch, 35.0 KB (added by Jim Stichnoth <stichnot@…>, 12 years ago)
  • mythtv/libs/libmyth/programinfo.cpp

    diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
    index 3326694..11599de 100644
    a b bool ProgramInfo::FromStringList(QStringList::const_iterator &it, 
    13201320    return true;
    13211321}
    13221322
     1323const QString ProgramInfo::MakeString_titlesubtitle(const ProgramInfo *ths)
     1324{
     1325    QString tempSubTitle = ths->title;
     1326    if (!ths->subtitle.trimmed().isEmpty())
     1327    {
     1328        tempSubTitle = QString("%1 - \"%2\"")
     1329            .arg(tempSubTitle).arg(ths->subtitle);
     1330    }
     1331
     1332    return tempSubTitle;
     1333}
     1334
     1335const QString ProgramInfo::MakeString_s00e00(const ProgramInfo *ths)
     1336{
     1337    return QString("s%1e%2").arg(GetDisplaySeasonEpisode
     1338                                 (ths->GetSeason(), 2))
     1339        .arg(GetDisplaySeasonEpisode(ths->GetEpisode(), 2));
     1340}
     1341
     1342const QString ProgramInfo::MakeString_00x00(const ProgramInfo *ths)
     1343{
     1344    return QString("%1x%2").arg(GetDisplaySeasonEpisode
     1345                                (ths->GetSeason(), 1))
     1346        .arg(GetDisplaySeasonEpisode(ths->GetEpisode(), 2));
     1347}
     1348
     1349const QString ProgramInfo::MakeString_startdate(const ProgramInfo *ths)
     1350{
     1351    if (ths->IsVideo())
     1352    {
     1353        if (ths->startts.date().year() == 1895)
     1354            return "";
     1355        else
     1356            return ths->startts.toString("yyyy");
     1357    }
     1358    else
     1359    {
     1360        return MythDateTimeToString(ths->startts, kDateFull | kSimplify);
     1361    }
     1362}
     1363
     1364const QString ProgramInfo::MakeString_recstartdate(const ProgramInfo *ths)
     1365{
     1366    if (ths->IsVideo())
     1367    {
     1368        if (ths->startts.date().year() == 1895)
     1369            return "";
     1370        else
     1371            return ths->startts.toString("yyyy");
     1372    }
     1373    else
     1374    {
     1375        return MythDateTimeToString(ths->recstartts, kTime);
     1376    }
     1377}
     1378
     1379const QString ProgramInfo::MakeString_starttime(const ProgramInfo *ths)
     1380{
     1381    return MythDateTimeToString(ths->startts, kTime);
     1382}
     1383
     1384const QString ProgramInfo::MakeString_shortstartdate(const ProgramInfo *ths)
     1385{
     1386    return MythDateTimeToString(ths->startts, kDateShort);
     1387}
     1388
     1389const QString ProgramInfo::MakeString_endtime(const ProgramInfo *ths)
     1390{
     1391    return MythDateTimeToString(ths->endts, kTime);
     1392}
     1393
     1394const QString ProgramInfo::MakeString_enddate(const ProgramInfo *ths)
     1395{
     1396    return MythDateTimeToString(ths->endts, kDateFull | kSimplify);
     1397}
     1398
     1399const QString ProgramInfo::MakeString_shortenddate(const ProgramInfo *ths)
     1400{
     1401    return MythDateTimeToString(ths->endts, kDateShort);
     1402}
     1403
     1404const QString ProgramInfo::MakeString_recstarttime(const ProgramInfo *ths)
     1405{
     1406    return MythDateTimeToString(ths->recstartts, kTime);
     1407}
     1408
     1409const QString ProgramInfo::MakeString_recendtime(const ProgramInfo *ths)
     1410{
     1411    return MythDateTimeToString(ths->recendts, kTime);
     1412}
     1413
     1414const QString ProgramInfo::MakeString_recenddate(const ProgramInfo *ths)
     1415{
     1416    return MythDateTimeToString(ths->recendts, kDateShort);
     1417}
     1418
     1419const QString ProgramInfo::MakeString_startts(const ProgramInfo *ths)
     1420{
     1421    return QString::number(ths->startts.toTime_t());
     1422}
     1423
     1424const QString ProgramInfo::MakeString_endts(const ProgramInfo *ths)
     1425{
     1426    return QString::number(ths->endts.toTime_t());
     1427}
     1428
     1429const QString ProgramInfo::MakeString_timedate(const ProgramInfo *ths)
     1430{
     1431    return MythDateTimeToString(ths->recstartts, kDateTimeFull | kSimplify) +
     1432        " - " + MythDateTimeToString(ths->recendts, kTime);
     1433}
     1434
     1435const QString ProgramInfo::MakeString_shorttimedate(const ProgramInfo *ths)
     1436{
     1437    return MythDateTimeToString(ths->recstartts, kDateTimeShort | kSimplify) +
     1438        " - " + MythDateTimeToString(ths->recendts, kTime);
     1439}
     1440
     1441const QString ProgramInfo::MakeString_starttimedate(const ProgramInfo *ths)
     1442{
     1443    return MythDateTimeToString(ths->recstartts, kDateTimeFull | kSimplify);
     1444}
     1445
     1446const QString ProgramInfo::MakeString_shortstarttimedate(const ProgramInfo *ths)
     1447{
     1448    return MythDateTimeToString(ths->recstartts, kDateTimeShort | kSimplify);
     1449}
     1450
     1451const QString ProgramInfo::MakeString_lastmodifiedtime(const ProgramInfo *ths)
     1452{
     1453    return MythDateTimeToString(ths->lastmodified, kTime);
     1454}
     1455
     1456const QString ProgramInfo::MakeString_lastmodifieddate(const ProgramInfo *ths)
     1457{
     1458    return MythDateTimeToString(ths->lastmodified, kDateFull | kSimplify);
     1459}
     1460
     1461const QString ProgramInfo::MakeString_lastmodified(const ProgramInfo *ths)
     1462{
     1463    return MythDateTimeToString(ths->lastmodified, kDateTimeFull | kSimplify);
     1464}
     1465
     1466const QString ProgramInfo::MakeString_channel(const ProgramInfo *ths)
     1467{
     1468    QString channelFormat =
     1469        gCoreContext->GetSetting("ChannelFormat", "<num> <sign>");
     1470    return ths->ChannelText(channelFormat);
     1471}
     1472
     1473const QString ProgramInfo::MakeString_longchannel(const ProgramInfo *ths)
     1474{
     1475    QString longChannelFormat =
     1476        gCoreContext->GetSetting("LongChannelFormat", "<num> <name>");
     1477    return ths->ChannelText(longChannelFormat);
     1478}
     1479
     1480const QString ProgramInfo::MakeString_filesize_str(const ProgramInfo *ths)
     1481{
     1482    QString tmpSize;
     1483
     1484    tmpSize.sprintf("%0.2f ", ths->filesize * (1.0 / (1024.0 * 1024.0 * 1024.0)));
     1485    tmpSize += QObject::tr("GB", "GigaBytes");
     1486    return tmpSize;
     1487}
     1488
     1489const QString ProgramInfo::MakeString_lenmins(const ProgramInfo *ths)
     1490{
     1491    int minutes, seconds;
     1492    seconds = ths->recstartts.secsTo(ths->recendts);
     1493    minutes = seconds / 60;
     1494
     1495    QString min_str = QObject::tr("%n minute(s)","",minutes);
     1496
     1497    return min_str;
     1498}
     1499
     1500const QString ProgramInfo::MakeString_lentime(const ProgramInfo *ths)
     1501{
     1502    int hours, minutes, seconds;
     1503    seconds = ths->recstartts.secsTo(ths->recendts);
     1504    minutes = seconds / 60;
     1505
     1506    QString min_str = QObject::tr("%n minute(s)","",minutes);
     1507
     1508    hours   = minutes / 60;
     1509    minutes = minutes % 60;
     1510
     1511    if (hours > 0 && minutes > 0)
     1512    {
     1513        min_str = QObject::tr("%n minute(s)","",minutes);
     1514        return QString("%1 %2")
     1515            .arg(QObject::tr("%n hour(s)","", hours))
     1516            .arg(min_str);
     1517    }
     1518    else if (hours > 0)
     1519    {
     1520        return QObject::tr("%n hour(s)","", hours);
     1521    }
     1522
     1523    return min_str;
     1524}
     1525
     1526const QString ProgramInfo::MakeString_repeat(const ProgramInfo *ths)
     1527{
     1528    if (ths->IsRepeat())
     1529        return QString("(%1) ").arg(QObject::tr("Repeat"));
     1530    else
     1531        return "";
     1532}
     1533
     1534const QString ProgramInfo::MakeString_longrepeat(const ProgramInfo *ths)
     1535{
     1536    if (ths->IsRepeat())
     1537    {
     1538        if (ths->originalAirDate.isValid())
     1539            return QString("(%1 %2) ")
     1540                .arg(QObject::tr("Repeat"))
     1541                .arg(MythDateToString(ths->originalAirDate, kDateFull | kAddYear));
     1542        else
     1543            return QString("(%1) ").arg(QObject::tr("Repeat"));
     1544    }
     1545    else
     1546        return "";
     1547}
     1548
     1549const QString ProgramInfo::MakeString_originalairdate(const ProgramInfo *ths)
     1550{
     1551    if (!ths->originalAirDate.isValid() ||
     1552        (!ths->programid.isEmpty() && (ths->programid.left(2) == "MV")))
     1553        return "";
     1554    else
     1555        return MythDateToString(ths->originalAirDate, kDateFull);
     1556}
     1557
     1558const QString ProgramInfo::MakeString_shortoriginalairdate(const ProgramInfo *ths)
     1559{
     1560    if (!ths->originalAirDate.isValid() ||
     1561        (!ths->programid.isEmpty() && (ths->programid.left(2) == "MV")))
     1562        return "";
     1563    else
     1564        return MythDateToString(ths->originalAirDate, kDateShort);
     1565}
     1566
     1567void ProgramInfo::ToLazyMap(LazyInfoMap &progMap,
     1568                            bool showrerecord,
     1569                            uint star_range) const
     1570{
     1571    progMap["title"] = title;
     1572    progMap["subtitle"] = subtitle;
     1573    progMap["titlesubtitle"] = LazyMapEntry(MakeString_titlesubtitle, this);
     1574    progMap["description"] = description;
     1575    if (season > 0 || episode > 0)
     1576    {
     1577        progMap["season"] = QString::number(season);
     1578        progMap["episode"] = QString::number(episode);
     1579
     1580        progMap["s00e00"] = LazyMapEntry(MakeString_s00e00, this);
     1581        progMap["00x00"] = LazyMapEntry(MakeString_00x00, this);
     1582    }
     1583    progMap["category"] = category;
     1584    progMap["callsign"] = chansign;
     1585    progMap["commfree"] = QString((programflags & FL_CHANCOMMFREE) ? 1 : 0);
     1586    progMap["outputfilters"] = chanplaybackfilters;
     1587    if (IsVideo())
     1588    {
     1589        progMap["starttime"] = "";
     1590        //progMap["startdate"] = "";
     1591        progMap["endtime"] = "";
     1592        progMap["enddate"] = "";
     1593        progMap["recstarttime"] = "";
     1594        //progMap["recstartdate"] = "";
     1595        progMap["recendtime"] = "";
     1596        progMap["recenddate"] = "";
     1597        progMap["startdate"] = LazyMapEntry(MakeString_startdate, this);
     1598        progMap["recstartdate"] = LazyMapEntry(MakeString_recstartdate, this);
     1599    }
     1600    else // if (IsRecording())
     1601    {
     1602        progMap["starttime"] = LazyMapEntry(MakeString_starttime, this);
     1603        progMap["startdate"] = LazyMapEntry(MakeString_startdate, this);
     1604        progMap["shortstartdate"] = LazyMapEntry(MakeString_shortstartdate, this);
     1605        progMap["endtime"] = LazyMapEntry(MakeString_endtime, this);
     1606        progMap["enddate"] = LazyMapEntry(MakeString_enddate, this);
     1607        progMap["shortenddate"] = LazyMapEntry(MakeString_shortenddate, this);
     1608        progMap["recstarttime"] = LazyMapEntry(MakeString_recstarttime, this);
     1609        progMap["recstartdate"] = LazyMapEntry(MakeString_recstartdate, this);
     1610        progMap["recendtime"] = LazyMapEntry(MakeString_recendtime, this);
     1611        progMap["recenddate"] = LazyMapEntry(MakeString_recenddate, this);
     1612        progMap["startts"] = LazyMapEntry(MakeString_startts, this);
     1613        progMap["endts"]   = LazyMapEntry(MakeString_endts, this);
     1614    }
     1615
     1616    progMap["timedate"] = LazyMapEntry(MakeString_timedate, this);
     1617
     1618    progMap["shorttimedate"] = LazyMapEntry(MakeString_shorttimedate, this);
     1619
     1620    progMap["starttimedate"] = LazyMapEntry(MakeString_starttimedate, this);
     1621
     1622    progMap["shortstarttimedate"] = LazyMapEntry(MakeString_shortstarttimedate, this);
     1623
     1624    progMap["lastmodifiedtime"] = LazyMapEntry(MakeString_lastmodifiedtime, this);
     1625    progMap["lastmodifieddate"] = LazyMapEntry(MakeString_lastmodifieddate, this);
     1626    progMap["lastmodified"] = LazyMapEntry(MakeString_lastmodified, this);
     1627
     1628    progMap["channum"] = chanstr;
     1629    progMap["chanid"] = QString(chanid);
     1630    progMap["channame"] = channame;
     1631    progMap["channel"] = LazyMapEntry(MakeString_channel, this);
     1632    progMap["longchannel"] = LazyMapEntry(MakeString_longchannel, this);
     1633
     1634    progMap["filesize_str"] = LazyMapEntry(MakeString_filesize_str, this);
     1635    progMap["filesize"] = QString::number(filesize);
     1636
     1637    progMap["lenmins"] = LazyMapEntry(MakeString_lenmins, this);
     1638    progMap["lentime"] = LazyMapEntry(MakeString_lentime, this);
     1639
     1640    progMap["rectypechar"] = QString(toQChar(GetRecordingRuleType()));
     1641    progMap["rectype"] = ::toString(GetRecordingRuleType());
     1642
     1643    // Hard to compute rectypestatus lazily because of the use of
     1644    // showrerecord.
     1645    QString tmp_rec = ::toString(GetRecordingRuleType());
     1646    if (GetRecordingRuleType() != kNotRecording)
     1647    {
     1648        QDateTime timeNow = QDateTime::currentDateTime();
     1649        if (((recendts > timeNow) && (recstatus <= rsWillRecord)) ||
     1650            (recstatus == rsConflict) || (recstatus == rsLaterShowing))
     1651        {
     1652            tmp_rec += QString().sprintf(" %+d", recpriority);
     1653            if (recpriority2)
     1654                tmp_rec += QString().sprintf("/%+d", recpriority2);
     1655            tmp_rec += " ";
     1656        }
     1657        else
     1658        {
     1659            tmp_rec += " -- ";
     1660        }
     1661        if (showrerecord && (GetRecordingStatus() == rsRecorded) &&
     1662            !IsDuplicate())
     1663        {
     1664            tmp_rec += QObject::tr("Re-Record");
     1665        }
     1666        else
     1667        {
     1668            tmp_rec += ::toString(GetRecordingStatus(), GetRecordingRuleType());
     1669        }
     1670    }
     1671    progMap["rectypestatus"] = tmp_rec;
     1672
     1673    progMap["card"] = ::toString(GetRecordingStatus(), cardid);
     1674
     1675    progMap["recpriority"] = QString(recpriority);
     1676    progMap["recpriority2"] = QString(recpriority2);
     1677    progMap["recordingggroup"] = (recgroup == "Default")
     1678                                            ? QObject::tr("Default") : recgroup;
     1679    progMap["playgroup"] = playgroup;
     1680
     1681    if (storagegroup == "Default")
     1682        progMap["storagegroup"] = QObject::tr("Default");
     1683    else if (StorageGroup::kSpecialGroups.contains(storagegroup))
     1684        progMap["storagegroup"] = QObject::tr(storagegroup.toUtf8().constData());
     1685    else
     1686        progMap["storagegroup"] = storagegroup;
     1687
     1688    progMap["programflags"] = QString(programflags);
     1689
     1690    progMap["audioproperties"] = QString(GetAudioProperties());
     1691    progMap["videoproperties"] = QString(GetVideoProperties());
     1692    progMap["subtitleType"] = QString(GetSubtitleType());
     1693
     1694    progMap["recstatus"] = ::toString(GetRecordingStatus(),
     1695                                      GetRecordingRuleType());
     1696
     1697    progMap["repeat"] = LazyMapEntry(MakeString_repeat, this);
     1698    progMap["longrepeat"] = LazyMapEntry(MakeString_longrepeat, this);
     1699
     1700    progMap["seriesid"] = seriesid;
     1701    progMap["programid"] = programid;
     1702    progMap["inetref"] = inetref;
     1703    progMap["catType"] = catType;
     1704
     1705    progMap["year"] = year ? QString::number(year) : "";
     1706
     1707    QString star_str = (stars != 0.0f) ?
     1708        QObject::tr("%n star(s)", "", GetStars(star_range)) : "";
     1709    progMap["stars"] = star_str;
     1710    progMap["numstars"] = QString().number(GetStars(star_range));
     1711
     1712    if (stars != 0.0f && year)
     1713        progMap["yearstars"] = QString("(%1, %2)").arg(year).arg(star_str);
     1714    else if (stars != 0.0f)
     1715        progMap["yearstars"] = QString("(%1)").arg(star_str);
     1716    else if (year)
     1717        progMap["yearstars"] = QString("(%1)").arg(year);
     1718    else
     1719        progMap["yearstars"] = "";
     1720
     1721    progMap["originalairdate"] = LazyMapEntry(MakeString_originalairdate, this);
     1722    progMap["shortoriginalairdate"] = LazyMapEntry(MakeString_shortoriginalairdate, this);
     1723}
     1724
    13231725/** \brief Converts ProgramInfo into QString QHash containing each field
    13241726 *         in ProgramInfo converted into localized strings.
    13251727 */
  • mythtv/libs/libmyth/programinfo.h

    diff --git a/mythtv/libs/libmyth/programinfo.h b/mythtv/libs/libmyth/programinfo.h
    index a18a27a..9b4f40f 100644
    a b  
    1818#include "mythdbcon.h"
    1919#include "mythexp.h"
    2020
     21#include "util.h" // for LazyInfoMap/LazyMapEntry
     22
    2123/* If NUMPROGRAMLINES gets updated following files need
    2224   updates and code changes:
    2325   mythplugins/mythweb/classes/MythBackend.php
    class MPUBLIC ProgramInfo 
    275277    virtual void ToMap(QHash<QString, QString> &progMap,
    276278                       bool showrerecord = false,
    277279                       uint star_range = 10) const;
     280    virtual void ToLazyMap(LazyInfoMap &progMap,
     281                       bool showrerecord = false,
     282                       uint star_range = 10) const;
    278283    virtual void SubstituteMatches(QString &str);
    279284
    280285    // Used for scheduling recordings
    class MPUBLIC ProgramInfo 
    710715
    711716    static QMutex staticDataLock;
    712717    static ProgramInfoUpdater *updater;
     718 public:
     719    static const QString MakeString_titlesubtitle(const ProgramInfo *ths);
     720    static const QString MakeString_s00e00(const ProgramInfo *ths);
     721    static const QString MakeString_00x00(const ProgramInfo *ths);
     722    static const QString MakeString_startdate(const ProgramInfo *ths);
     723    static const QString MakeString_recstartdate(const ProgramInfo *ths);
     724    static const QString MakeString_starttime(const ProgramInfo *ths);
     725    static const QString MakeString_shortstartdate(const ProgramInfo *ths);
     726    static const QString MakeString_endtime(const ProgramInfo *ths);
     727    static const QString MakeString_enddate(const ProgramInfo *ths);
     728    static const QString MakeString_shortenddate(const ProgramInfo *ths);
     729    static const QString MakeString_recstarttime(const ProgramInfo *ths);
     730    static const QString MakeString_recendtime(const ProgramInfo *ths);
     731    static const QString MakeString_recenddate(const ProgramInfo *ths);
     732    static const QString MakeString_startts(const ProgramInfo *ths);
     733    static const QString MakeString_endts(const ProgramInfo *ths);
     734    static const QString MakeString_timedate(const ProgramInfo *ths);
     735    static const QString MakeString_shorttimedate(const ProgramInfo *ths);
     736    static const QString MakeString_starttimedate(const ProgramInfo *ths);
     737    static const QString MakeString_shortstarttimedate(const ProgramInfo *ths);
     738    static const QString MakeString_lastmodifiedtime(const ProgramInfo *ths);
     739    static const QString MakeString_lastmodifieddate(const ProgramInfo *ths);
     740    static const QString MakeString_lastmodified(const ProgramInfo *ths);
     741    static const QString MakeString_channel(const ProgramInfo *ths);
     742    static const QString MakeString_longchannel(const ProgramInfo *ths);
     743    static const QString MakeString_filesize_str(const ProgramInfo *ths);
     744    static const QString MakeString_lenmins(const ProgramInfo *ths);
     745    static const QString MakeString_lentime(const ProgramInfo *ths);
     746    static const QString MakeString_repeat(const ProgramInfo *ths);
     747    static const QString MakeString_longrepeat(const ProgramInfo *ths);
     748    static const QString MakeString_originalairdate(const ProgramInfo *ths);
     749    static const QString MakeString_shortoriginalairdate(const ProgramInfo *ths);
    713750};
    714751
    715752Q_DECLARE_METATYPE(ProgramInfo*)
  • mythtv/libs/libmythbase/util.h

    diff --git a/mythtv/libs/libmythbase/util.h b/mythtv/libs/libmythbase/util.h
    index 0b72549..fe448e1 100644
    a b inline void rdtsc(uint64_t &x) 
    143143inline void rdtsc(uint64_t &x) { x = 0ULL; }
    144144#endif // !MMX
    145145
     146class ProgramInfo;
     147typedef const QString (*LazyMapFunc)(const ProgramInfo *);
     148class LazyMapEntry {
     149 public:
     150    LazyMapEntry(LazyMapFunc f, const ProgramInfo *p)
     151    : isComputed(false), value(), func(f), pi(p) {}
     152    LazyMapEntry(const QString &v)
     153    : isComputed(true), value(v), func(0), pi(0) {}
     154    LazyMapEntry() {}
     155    LazyMapEntry &operator=(const char *other) {
     156        isComputed = true;
     157        value = other;
     158        return *this;
     159    }
     160    const QString &getValue(void) {
     161        if (!isComputed) {
     162            value = func(pi);
     163            isComputed = true;
     164        }
     165        return value;
     166    }
     167 private:
     168    bool isComputed;
     169    QString value;
     170    LazyMapFunc func;
     171    const ProgramInfo *pi;
     172};
     173typedef QHash<QString,LazyMapEntry> LazyInfoMap;
     174
    146175#endif // UTIL_H_
  • mythtv/libs/libmythui/mythgenerictree.cpp

    diff --git a/mythtv/libs/libmythui/mythgenerictree.cpp b/mythtv/libs/libmythui/mythgenerictree.cpp
    index 1d8afd8..a80beda 100644
    a b void MythGenericTree::SetText(const QString &text, const QString &name, 
    746746{
    747747    if (!name.isEmpty())
    748748    {
    749         TextProperties textprop;
    750         textprop.text = text;
    751         textprop.state = state;
     749        TextProperties textprop(text, state);
    752750        m_strings.insert(name, textprop);
    753751    }
    754752    else
    void MythGenericTree::SetTextFromMap(QHash<QString, QString> &infoMap, 
    761759    QHash<QString, QString>::iterator map_it = infoMap.begin();
    762760    while (map_it != infoMap.end())
    763761    {
    764         TextProperties textprop;
    765         textprop.text = (*map_it);
    766         textprop.state = state;
     762        TextProperties textprop(*map_it, state);
    767763        m_strings[map_it.key()] = textprop;
    768764        ++map_it;
    769765    }
    770766}
    771767
    772 QString MythGenericTree::GetText(const QString &name) const
     768QString MythGenericTree::GetText(const QString &name)
    773769{
    774770    if (name.isEmpty())
    775771        return m_text;
    776772    else if (m_strings.contains(name))
    777         return m_strings[name].text;
     773        return m_strings[name].text();
    778774    else
    779775        return QString();
    780776}
  • mythtv/libs/libmythui/mythgenerictree.h

    diff --git a/mythtv/libs/libmythui/mythgenerictree.h b/mythtv/libs/libmythui/mythgenerictree.h
    index 5333e1f..4c983c8 100644
    a b class MUI_PUBLIC MythGenericTree 
    7373    void SetText(const QString &text, const QString &name="",
    7474                 const QString &state="");
    7575    void SetTextFromMap(QHash<QString, QString> &infoMap, const QString &state="");
    76     QString GetText(const QString &name="") const;
     76    QString GetText(const QString &name="");
    7777
    7878    void SetImage(const QString &filename, const QString &name="");
    7979    QString GetImage(const QString &name="") const;
  • mythtv/libs/libmythui/mythscreentype.cpp

    diff --git a/mythtv/libs/libmythui/mythscreentype.cpp b/mythtv/libs/libmythui/mythscreentype.cpp
    index 0c495a1..2214faa 100644
    a b void MythScreenType::SetTextFromMap(QHash<QString, QString> &infoMap) 
    416416    DoSetTextFromMap((MythUIType*) this, infoMap);
    417417}
    418418
     419static void DoSetTextFromLazyMap(MythUIType *UItype, LazyInfoMap &infoMap)
     420{
     421    QList<MythUIType *> *children = UItype->GetAllChildren();
     422
     423    MythUIText *textType;
     424
     425    QMutableListIterator<MythUIType *> i(*children);
     426    while (i.hasNext())
     427    {
     428        MythUIType *type = i.next();
     429        if (!type->IsVisible())
     430            continue;
     431
     432        textType = dynamic_cast<MythUIText *> (type);
     433        if (textType && infoMap.contains(textType->objectName()))
     434            textType->SetTextFromLazyMap(infoMap);
     435
     436
     437        MythUIGroup *group = dynamic_cast<MythUIGroup *> (type);
     438        if (group)
     439            DoSetTextFromLazyMap(type, infoMap);
     440    }
     441}
     442
     443void MythScreenType::SetTextFromLazyMap(LazyInfoMap &infoMap)
     444{
     445    DoSetTextFromLazyMap((MythUIType*) this, infoMap);
     446}
     447
    419448static void DoResetMap(MythUIType *UItype, QHash<QString, QString> &infoMap)
    420449{
    421450    if (infoMap.isEmpty())
  • mythtv/libs/libmythui/mythscreentype.h

    diff --git a/mythtv/libs/libmythui/mythscreentype.h b/mythtv/libs/libmythui/mythscreentype.h
    index b83b39b..977f1cc 100644
    a b class MUI_PUBLIC MythScreenType : public MythUIType 
    7575    bool IsLoaded(void) { return m_IsLoaded; }
    7676
    7777    void SetTextFromMap(InfoMap &infoMap);
     78    void SetTextFromLazyMap(LazyInfoMap &infoMap);
    7879    void ResetMap(InfoMap &infoMap);
    7980
    8081    virtual MythPainter *GetPainter(void);
  • mythtv/libs/libmythui/mythuibuttonlist.cpp

    diff --git a/mythtv/libs/libmythui/mythuibuttonlist.cpp b/mythtv/libs/libmythui/mythuibuttonlist.cpp
    index ed473e0..2bbaf60 100644
    a b void MythUIButtonList::updateLCD(void) 
    27462746                TextProperties props = item->m_strings[m_lcdColumns[x]];
    27472747
    27482748                if (text.isEmpty())
    2749                     text = props.text;
     2749                    text = props.text();
    27502750                else
    2751                     text += " ~ " + props.text;
     2751                    text += " ~ " + props.text();
    27522752            }
    27532753            else
    27542754            {
    void MythUIButtonListItem::SetText(const QString &text, const QString &name, 
    29152915{
    29162916    if (!name.isEmpty())
    29172917    {
    2918         TextProperties textprop;
    2919         textprop.text = text;
    2920         textprop.state = state;
     2918        TextProperties textprop(text, state);
    29212919        m_strings.insert(name, textprop);
    29222920    }
    29232921    else
    void MythUIButtonListItem::SetTextFromMap(QHash<QString, QString> &infoMap, 
    29342932
    29352933    while (map_it != infoMap.end())
    29362934    {
    2937         TextProperties textprop;
    2938         textprop.text = (*map_it);
    2939         textprop.state = state;
     2935        TextProperties textprop(*map_it, state);
     2936        m_strings[map_it.key()] = textprop;
     2937        ++map_it;
     2938    }
     2939
     2940    if (m_parent)
     2941        m_parent->Update();
     2942}
     2943
     2944void MythUIButtonListItem::SetTextFromLazyMap(LazyInfoMap &infoMap,
     2945                                              const QString &state)
     2946{
     2947    LazyInfoMap::iterator map_it = infoMap.begin();
     2948
     2949    while (map_it != infoMap.end())
     2950    {
     2951        TextProperties textprop(*map_it, state);
    29402952        m_strings[map_it.key()] = textprop;
    29412953        ++map_it;
    29422954    }
    void MythUIButtonListItem::SetTextFromMap(QMap<QString, TextProperties> &stringM 
    29512963    m_strings = stringMap;
    29522964}
    29532965
    2954 QString MythUIButtonListItem::GetText(const QString &name) const
     2966QString MythUIButtonListItem::GetText(const QString &name)
    29552967{
    29562968    if (name.isEmpty())
    29572969        return m_text;
    29582970    else if (m_strings.contains(name))
    2959         return m_strings[name].text;
     2971        return m_strings[name].text();
    29602972    else
    29612973        return QString();
    29622974}
    29632975
    29642976bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fieldList,
    2965                                     bool startsWith) const
     2977                                    bool startsWith)
    29662978{
    29672979    if (fieldList.isEmpty())
    29682980    {
    bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fie 
    29842996                return true;
    29852997        }
    29862998
    2987         QMap<QString, TextProperties>::const_iterator i = m_strings.constBegin();
     2999        QMap<QString, TextProperties>::iterator i = m_strings.begin();
    29883000
    2989         while (i != m_strings.constEnd())
     3001        while (i != m_strings.end())
    29903002        {
    29913003            if (startsWith)
    29923004            {
    2993                 if (i.value().text.startsWith(searchStr, Qt::CaseInsensitive))
     3005                if (i.value().text().startsWith(searchStr, Qt::CaseInsensitive))
    29943006                    return true;
    29953007            }
    29963008            else
    29973009            {
    2998                 if (i.value().text.contains(searchStr, Qt::CaseInsensitive))
     3010                if (i.value().text().contains(searchStr, Qt::CaseInsensitive))
    29993011                    return true;
    30003012            }
    30013013
    bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fie 
    30123024            {
    30133025                if (startsWith)
    30143026                {
    3015                     if (m_strings[fields.at(x)].text.startsWith(searchStr, Qt::CaseInsensitive))
     3027                    if (m_strings[fields.at(x)].text().startsWith(searchStr, Qt::CaseInsensitive))
    30163028                        return true;
    30173029                }
    30183030                else
    30193031                {
    3020                     if (m_strings[fields.at(x)].text.contains(searchStr, Qt::CaseInsensitive))
     3032                    if (m_strings[fields.at(x)].text().contains(searchStr, Qt::CaseInsensitive))
    30213033                        return true;
    30223034                }
    30233035            }
    void MythUIButtonListItem::SetToRealButton(MythUIStateType *button, bool selecte 
    33273339                {
    33283340                    QString key = regexp.cap(4).toLower().trimmed();
    33293341                    QString replacement;
    3330                     QString value = m_strings.value(key).text;
     3342                    QString value = m_strings[key].text();
    33313343
    33323344                    if (!value.isEmpty())
    33333345                    {
    33343346                        replacement = QString("%1%2%3%4")
    33353347                                      .arg(regexp.cap(2))
    33363348                                      .arg(regexp.cap(3))
    3337                                       .arg(m_strings.value(key).text)
     3349                                      .arg(m_strings[key].text())
    33383350                                      .arg(regexp.cap(6));
    33393351                    }
    33403352
    void MythUIButtonListItem::SetToRealButton(MythUIStateType *button, bool selecte 
    33453357                newText = tempString;
    33463358            }
    33473359            else
    3348                 newText = textprop.text;
     3360                newText = textprop.text();
    33493361
    33503362            if (newText.isEmpty())
    33513363                text->Reset();
  • mythtv/libs/libmythui/mythuibuttonlist.h

    diff --git a/mythtv/libs/libmythui/mythuibuttonlist.h b/mythtv/libs/libmythui/mythuibuttonlist.h
    index b6cbebd..1934c7f 100644
    a b  
    1515class MythUIButtonList;
    1616class MythUIStateType;
    1717
    18 struct TextProperties {
    19     QString text;
     18class TextProperties {
     19public:
     20    TextProperties(const QString t, const QString s)
     21        : state(s), value(LazyMapEntry(t)) {}
     22    TextProperties(const LazyMapEntry &e, const QString s)
     23        : state(s), value(e) {}
     24    TextProperties() {}
     25    const QString &text() { return value.getValue(); }
    2026    QString state;
     27private:
     28    LazyMapEntry value;
    2129};
    2230
    2331class MUI_PUBLIC MythUIButtonListItem
    class MUI_PUBLIC MythUIButtonListItem 
    4351    void SetText(const QString &text, const QString &name="",
    4452                 const QString &state="");
    4553    void SetTextFromMap(InfoMap &infoMap, const QString &state="");
     54    void SetTextFromLazyMap(LazyInfoMap &infoMap, const QString &state="");
    4655    void SetTextFromMap(QMap<QString, TextProperties> &stringMap);
    47     QString GetText(const QString &name="") const;
     56    QString GetText(const QString &name="");
    4857
    4958    bool FindText(const QString &searchStr, const QString &fieldList = "**ALL**",
    50                   bool startsWith = false) const;
     59                  bool startsWith = false);
    5160
    5261    void SetFontState(const QString &state, const QString &name="");
    5362
  • mythtv/libs/libmythui/mythuitext.cpp

    diff --git a/mythtv/libs/libmythui/mythuitext.cpp b/mythtv/libs/libmythui/mythuitext.cpp
    index aa996df..dae9991 100644
    a b void MythUIText::SetTextFromMap(QHash<QString, QString> &map) 
    176176    }
    177177}
    178178
     179void MythUIText::SetTextFromLazyMap(LazyInfoMap &map)
     180{
     181    if (!IsVisible())
     182        return;
     183
     184    if (map.contains(objectName()))
     185    {
     186        QString newText = GetTemplateText();
     187
     188        if (newText.isEmpty())
     189            newText = GetDefaultText();
     190
     191        QRegExp regexp("%(([^\\|%]+)?\\||\\|(.))?(\\w+)(\\|(.+))?%");
     192        regexp.setMinimal(true);
     193
     194        if (!newText.isEmpty() && newText.contains(regexp))
     195        {
     196            int pos = 0;
     197            QString tempString = newText;
     198
     199            while ((pos = regexp.indexIn(newText, pos)) != -1)
     200            {
     201                QString key = regexp.cap(4).toLower().trimmed();
     202                QString replacement;
     203
     204                if (!map[key].getValue().isEmpty())
     205                {
     206                    replacement = QString("%1%2%3%4")
     207                                  .arg(regexp.cap(2))
     208                                  .arg(regexp.cap(3))
     209                                  .arg(map[key].getValue())
     210                                  .arg(regexp.cap(6));
     211                }
     212
     213                tempString.replace(regexp.cap(0), replacement);
     214                pos += regexp.matchedLength();
     215            }
     216
     217            newText = tempString;
     218        }
     219        else
     220            newText = map[objectName()].getValue();
     221
     222        SetText(newText);
     223    }
     224}
     225
    179226QString MythUIText::GetText(void) const
    180227{
    181228    return m_Message;
  • mythtv/libs/libmythui/mythuitext.h

    diff --git a/mythtv/libs/libmythui/mythuitext.h b/mythtv/libs/libmythui/mythuitext.h
    index 91ba820..626b9f4 100644
    a b  
    1111// Mythui headers
    1212#include "mythuitype.h"
    1313
     14#include "util.h" // for LazyInfoMap/LazyMapEntry
     15
    1416class MythFontProperties;
    1517
    1618/**
    class MUI_PUBLIC MythUIText : public MythUIType, public StorageUser 
    3941    QString GetDefaultText(void) const;
    4042
    4143    void SetTextFromMap(QHash<QString, QString> &map);
     44    void SetTextFromLazyMap(LazyInfoMap &map);
    4245
    4346    void SetTemplateText(const QString &text) { m_TemplateText = text; }
    4447    QString GetTemplateText(void) const { return m_TemplateText; }
  • mythtv/programs/mythfrontend/playbackbox.cpp

    diff --git a/mythtv/programs/mythfrontend/playbackbox.cpp b/mythtv/programs/mythfrontend/playbackbox.cpp
    index dc76ecf..772a8c0 100644
    a b  
     1// Uncomment the next line to disable use of lazy maps, e.g. for doing
     2// timing comparisons.
     3//#define USE_OLD_MAPS
    14
    25#include "playbackbox.h"
    36
    void PlaybackBox::UpdateUIListItem( 
    794797    // frontend
    795798    if (m_groupList && m_groupList->GetItemCurrent())
    796799    {
     800#ifdef USE_OLD_MAPS
    797801        InfoMap infoMap;
    798802        pginfo->ToMap(infoMap);
    799803        item->SetTextFromMap(infoMap);
     804#else
     805        LazyInfoMap infoMap;
     806        pginfo->ToLazyMap(infoMap);
     807        item->SetTextFromLazyMap(infoMap);
     808#endif
    800809
    801810        QString groupname =
    802811            m_groupList->GetItemCurrent()->GetData().toString();
    void PlaybackBox::UpdateUIListItem( 
    830839
    831840    if ((GetFocusWidget() == m_recordingList) && is_sel)
    832841    {
     842#ifdef USE_OLD_MAPS
    833843        InfoMap infoMap;
    834844
    835845        pginfo->ToMap(infoMap);
    836846        ResetMap(m_currentMap);
    837847        SetTextFromMap(infoMap);
    838848        m_currentMap = infoMap;
     849#else
     850        LazyInfoMap infoMap;
     851
     852        pginfo->ToLazyMap(infoMap);
     853        ResetMap(m_currentMap);
     854        SetTextFromLazyMap(infoMap);
     855        m_currentMap.clear();
     856        for (LazyInfoMap::const_iterator it = infoMap.begin(); it != infoMap.end(); ++it)
     857            m_currentMap[it.key()] = "<undefined>";
     858#endif
    839859
    840860        MythUIStateType *ratingState = dynamic_cast<MythUIStateType*>
    841861                                                    (GetChild("ratingstate"));
    void PlaybackBox::UpdateUIRecGroupList(void) 
    12101230
    12111231void PlaybackBox::UpdateUIGroupList(const QStringList &groupPreferences)
    12121232{
     1233    LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUIGroupList begin"));
    12131234    m_groupList->Reset();
    12141235
    12151236    if (!m_titleList.isEmpty())
    void PlaybackBox::UpdateUIGroupList(const QStringList &groupPreferences) 
    12501271        if (!sel_idx)
    12511272            updateRecList(m_groupList->GetItemCurrent());
    12521273    }
     1274    LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUIGroupList end"));
    12531275}
    12541276
    12551277void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item)
    void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 
    12981320    subtitleFlags[SUB_HARDHEAR] = "cc";
    12991321
    13001322    ProgramList::iterator it = progList.begin();
     1323    int tomapcount = 0;
    13011324    for (; it != progList.end(); ++it)
    13021325    {
    13031326        if ((*it)->GetAvailableStatus() == asPendingDelete ||
    void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 
    13111334
    13121335        item->SetFontState(state);
    13131336
     1337#ifdef USE_OLD_MAPS
    13141338        InfoMap infoMap;
    13151339        (*it)->ToMap(infoMap);
    13161340        item->SetTextFromMap(infoMap);
     1341#else
     1342        LazyInfoMap infoMap;
     1343        (*it)->ToLazyMap(infoMap);
     1344        item->SetTextFromLazyMap(infoMap);
     1345#endif
     1346        ++tomapcount;
    13171347
    13181348        QString tempSubTitle  = extract_subtitle(**it, groupname);
    13191349
    void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 
    13471377                item->DisplayState(sit.value(), "subtitletypes");
    13481378        }
    13491379    }
     1380    LOG(VB_GENERAL, LOG_INFO, QString("LZY ToMap count = %1").arg(tomapcount));
    13501381
    13511382    if (m_noRecordingsText)
    13521383    {
    static void restore_position( 
    14991530
    15001531bool PlaybackBox::UpdateUILists(void)
    15011532{
     1533    LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUILists() m_recGroup=%1 begin").arg(m_recGroup));
    15021534    m_isFilling = true;
    15031535
    15041536    // Save selection, including next few items & groups
    bool PlaybackBox::UpdateUILists(void) 
    15461578    QMap<int, QString> searchRule;
    15471579    QMap<int, int> recidEpisodes;
    15481580
     1581    LOG(VB_GENERAL, LOG_INFO, QString("LZY m_programInfoCache.Refresh() begin"));
    15491582    m_programInfoCache.Refresh();
     1583    LOG(VB_GENERAL, LOG_INFO, QString("LZY m_programInfoCache.Refresh() end"));
    15501584
    15511585    if (!m_programInfoCache.empty())
    15521586    {
    bool PlaybackBox::UpdateUILists(void) 
    20822116
    20832117    m_isFilling = false;
    20842118
     2119    LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUILists() end"));
    20852120    return true;
    20862121}
    20872122