Ticket #10161: lazystrings_v3.patch
File lazystrings_v3.patch, 35.3 KB (added by , 12 years ago) |
---|
-
mythtv/libs/libmyth/programinfo.cpp
diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp index 3326694..b34b7af 100644
a b bool ProgramInfo::FromStringList(QStringList::const_iterator &it, 1320 1320 return true; 1321 1321 } 1322 1322 1323 static const QString MakeString_titlesubtitle(const ProgramInfo *ths) 1324 { 1325 QString tempSubTitle = ths->GetTitle(); 1326 if (!ths->GetSubtitle().trimmed().isEmpty()) 1327 { 1328 tempSubTitle = QString("%1 - \"%2\"") 1329 .arg(tempSubTitle).arg(ths->GetSubtitle()); 1330 } 1331 1332 return tempSubTitle; 1333 } 1334 1335 static const QString 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 1342 static const QString 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 1349 static const QString MakeString_startdate(const ProgramInfo *ths) 1350 { 1351 if (ths->IsVideo()) 1352 { 1353 if (ths->GetScheduledStartTime().date().year() == 1895) 1354 return ""; 1355 else 1356 return ths->GetScheduledStartTime().toString("yyyy"); 1357 } 1358 else 1359 { 1360 return MythDateTimeToString(ths->GetScheduledStartTime(), kDateFull | kSimplify); 1361 } 1362 } 1363 1364 static const QString MakeString_recstartdate(const ProgramInfo *ths) 1365 { 1366 if (ths->IsVideo()) 1367 { 1368 if (ths->GetScheduledStartTime().date().year() == 1895) 1369 return ""; 1370 else 1371 return ths->GetScheduledStartTime().toString("yyyy"); 1372 } 1373 else 1374 { 1375 return MythDateTimeToString(ths->GetRecordingStartTime(), kTime); 1376 } 1377 } 1378 1379 static const QString MakeString_starttime(const ProgramInfo *ths) 1380 { 1381 return MythDateTimeToString(ths->GetScheduledStartTime(), kTime); 1382 } 1383 1384 static const QString MakeString_shortstartdate(const ProgramInfo *ths) 1385 { 1386 return MythDateTimeToString(ths->GetScheduledStartTime(), kDateShort); 1387 } 1388 1389 static const QString MakeString_endtime(const ProgramInfo *ths) 1390 { 1391 return MythDateTimeToString(ths->GetScheduledEndTime(), kTime); 1392 } 1393 1394 static const QString MakeString_enddate(const ProgramInfo *ths) 1395 { 1396 return MythDateTimeToString(ths->GetScheduledEndTime(), kDateFull | kSimplify); 1397 } 1398 1399 static const QString MakeString_shortenddate(const ProgramInfo *ths) 1400 { 1401 return MythDateTimeToString(ths->GetScheduledEndTime(), kDateShort); 1402 } 1403 1404 static const QString MakeString_recstarttime(const ProgramInfo *ths) 1405 { 1406 return MythDateTimeToString(ths->GetRecordingStartTime(), kTime); 1407 } 1408 1409 static const QString MakeString_recendtime(const ProgramInfo *ths) 1410 { 1411 return MythDateTimeToString(ths->GetRecordingEndTime(), kTime); 1412 } 1413 1414 static const QString MakeString_recenddate(const ProgramInfo *ths) 1415 { 1416 return MythDateTimeToString(ths->GetRecordingEndTime(), kDateShort); 1417 } 1418 1419 static const QString MakeString_startts(const ProgramInfo *ths) 1420 { 1421 return QString::number(ths->GetScheduledStartTime().toTime_t()); 1422 } 1423 1424 static const QString MakeString_endts(const ProgramInfo *ths) 1425 { 1426 return QString::number(ths->GetScheduledEndTime().toTime_t()); 1427 } 1428 1429 static const QString MakeString_timedate(const ProgramInfo *ths) 1430 { 1431 return MythDateTimeToString(ths->GetRecordingStartTime(), kDateTimeFull | kSimplify) + 1432 " - " + MythDateTimeToString(ths->GetRecordingEndTime(), kTime); 1433 } 1434 1435 static const QString MakeString_shorttimedate(const ProgramInfo *ths) 1436 { 1437 return MythDateTimeToString(ths->GetRecordingStartTime(), kDateTimeShort | kSimplify) + 1438 " - " + MythDateTimeToString(ths->GetRecordingEndTime(), kTime); 1439 } 1440 1441 static const QString MakeString_starttimedate(const ProgramInfo *ths) 1442 { 1443 return MythDateTimeToString(ths->GetRecordingStartTime(), kDateTimeFull | kSimplify); 1444 } 1445 1446 static const QString MakeString_shortstarttimedate(const ProgramInfo *ths) 1447 { 1448 return MythDateTimeToString(ths->GetRecordingStartTime(), kDateTimeShort | kSimplify); 1449 } 1450 1451 static const QString MakeString_lastmodifiedtime(const ProgramInfo *ths) 1452 { 1453 return MythDateTimeToString(ths->GetLastModifiedTime(), kTime); 1454 } 1455 1456 static const QString MakeString_lastmodifieddate(const ProgramInfo *ths) 1457 { 1458 return MythDateTimeToString(ths->GetLastModifiedTime(), kDateFull | kSimplify); 1459 } 1460 1461 static const QString MakeString_lastmodified(const ProgramInfo *ths) 1462 { 1463 return MythDateTimeToString(ths->GetLastModifiedTime(), kDateTimeFull | kSimplify); 1464 } 1465 1466 static const QString MakeString_channel(const ProgramInfo *ths) 1467 { 1468 QString channelFormat = 1469 gCoreContext->GetSetting("ChannelFormat", "<num> <sign>"); 1470 return ths->ChannelText(channelFormat); 1471 } 1472 1473 static const QString MakeString_longchannel(const ProgramInfo *ths) 1474 { 1475 QString longChannelFormat = 1476 gCoreContext->GetSetting("LongChannelFormat", "<num> <name>"); 1477 return ths->ChannelText(longChannelFormat); 1478 } 1479 1480 static const QString MakeString_filesize_str(const ProgramInfo *ths) 1481 { 1482 QString tmpSize; 1483 1484 tmpSize.sprintf("%0.2f ", ths->GetFilesize() * (1.0 / (1024.0 * 1024.0 * 1024.0))); 1485 tmpSize += QObject::tr("GB", "GigaBytes"); 1486 return tmpSize; 1487 } 1488 1489 static const QString MakeString_lenmins(const ProgramInfo *ths) 1490 { 1491 int minutes, seconds; 1492 seconds = ths->GetRecordingStartTime().secsTo(ths->GetRecordingEndTime()); 1493 minutes = seconds / 60; 1494 1495 QString min_str = QObject::tr("%n minute(s)","",minutes); 1496 1497 return min_str; 1498 } 1499 1500 static const QString MakeString_lentime(const ProgramInfo *ths) 1501 { 1502 int hours, minutes, seconds; 1503 seconds = ths->GetRecordingStartTime().secsTo(ths->GetRecordingEndTime()); 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 1526 static const QString MakeString_repeat(const ProgramInfo *ths) 1527 { 1528 if (ths->IsRepeat()) 1529 return QString("(%1) ").arg(QObject::tr("Repeat")); 1530 else 1531 return ""; 1532 } 1533 1534 static const QString MakeString_longrepeat(const ProgramInfo *ths) 1535 { 1536 if (ths->IsRepeat()) 1537 { 1538 if (ths->GetOriginalAirDate().isValid()) 1539 return QString("(%1 %2) ") 1540 .arg(QObject::tr("Repeat")) 1541 .arg(MythDateToString(ths->GetOriginalAirDate(), kDateFull | kAddYear)); 1542 else 1543 return QString("(%1) ").arg(QObject::tr("Repeat")); 1544 } 1545 else 1546 return ""; 1547 } 1548 1549 static const QString MakeString_originalairdate(const ProgramInfo *ths) 1550 { 1551 if (!ths->GetOriginalAirDate().isValid() || 1552 (!ths->GetProgramID().isEmpty() && (ths->GetProgramID().left(2) == "MV"))) 1553 return ""; 1554 else 1555 return MythDateToString(ths->GetOriginalAirDate(), kDateFull); 1556 } 1557 1558 static const QString MakeString_shortoriginalairdate(const ProgramInfo *ths) 1559 { 1560 if (!ths->GetOriginalAirDate().isValid() || 1561 (!ths->GetProgramID().isEmpty() && (ths->GetProgramID().left(2) == "MV"))) 1562 return ""; 1563 else 1564 return MythDateToString(ths->GetOriginalAirDate(), kDateShort); 1565 } 1566 1567 void 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 1323 1725 /** \brief Converts ProgramInfo into QString QHash containing each field 1324 1726 * in ProgramInfo converted into localized strings. 1325 1727 */ -
mythtv/libs/libmyth/programinfo.h
diff --git a/mythtv/libs/libmyth/programinfo.h b/mythtv/libs/libmyth/programinfo.h index a18a27a..70529ff 100644
a b 18 18 #include "mythdbcon.h" 19 19 #include "mythexp.h" 20 20 21 #include "util.h" // for LazyInfoMap/LazyMapEntry 22 21 23 /* If NUMPROGRAMLINES gets updated following files need 22 24 updates and code changes: 23 25 mythplugins/mythweb/classes/MythBackend.php … … class MPUBLIC ProgramInfo 275 277 virtual void ToMap(QHash<QString, QString> &progMap, 276 278 bool showrerecord = false, 277 279 uint star_range = 10) const; 280 virtual void ToLazyMap(LazyInfoMap &progMap, 281 bool showrerecord = false, 282 uint star_range = 10) const; 278 283 virtual void SubstituteMatches(QString &str); 279 284 280 285 // Used for scheduling recordings -
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) 143 143 inline void rdtsc(uint64_t &x) { x = 0ULL; } 144 144 #endif // !MMX 145 145 146 class ProgramInfo; 147 typedef const QString (*LazyMapFunc)(const ProgramInfo *); 148 class 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 }; 173 typedef QHash<QString,LazyMapEntry> LazyInfoMap; 174 146 175 #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, 746 746 { 747 747 if (!name.isEmpty()) 748 748 { 749 TextProperties textprop; 750 textprop.text = text; 751 textprop.state = state; 749 TextProperties textprop(text, state); 752 750 m_strings.insert(name, textprop); 753 751 } 754 752 else … … void MythGenericTree::SetTextFromMap(QHash<QString, QString> &infoMap, 761 759 QHash<QString, QString>::iterator map_it = infoMap.begin(); 762 760 while (map_it != infoMap.end()) 763 761 { 764 TextProperties textprop; 765 textprop.text = (*map_it); 766 textprop.state = state; 762 TextProperties textprop(*map_it, state); 767 763 m_strings[map_it.key()] = textprop; 768 764 ++map_it; 769 765 } 770 766 } 771 767 772 QString MythGenericTree::GetText(const QString &name) const768 QString MythGenericTree::GetText(const QString &name) 773 769 { 774 770 if (name.isEmpty()) 775 771 return m_text; 776 772 else if (m_strings.contains(name)) 777 return m_strings[name].text ;773 return m_strings[name].text(); 778 774 else 779 775 return QString(); 780 776 } -
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 73 73 void SetText(const QString &text, const QString &name="", 74 74 const QString &state=""); 75 75 void SetTextFromMap(QHash<QString, QString> &infoMap, const QString &state=""); 76 QString GetText(const QString &name="") const;76 QString GetText(const QString &name=""); 77 77 78 78 void SetImage(const QString &filename, const QString &name=""); 79 79 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) 416 416 DoSetTextFromMap((MythUIType*) this, infoMap); 417 417 } 418 418 419 static 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 443 void MythScreenType::SetTextFromLazyMap(LazyInfoMap &infoMap) 444 { 445 DoSetTextFromLazyMap((MythUIType*) this, infoMap); 446 } 447 419 448 static void DoResetMap(MythUIType *UItype, QHash<QString, QString> &infoMap) 420 449 { 421 450 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 75 75 bool IsLoaded(void) { return m_IsLoaded; } 76 76 77 77 void SetTextFromMap(InfoMap &infoMap); 78 void SetTextFromLazyMap(LazyInfoMap &infoMap); 78 79 void ResetMap(InfoMap &infoMap); 79 80 80 81 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..e182439 100644
a b void MythUIButtonList::updateLCD(void) 2743 2743 if (!m_lcdColumns[x].isEmpty() && item->m_strings.contains(m_lcdColumns[x])) 2744 2744 { 2745 2745 // named text column 2746 TextProperties props = item->m_strings[m_lcdColumns[x]];2746 TextProperties &props = item->m_strings[m_lcdColumns[x]]; 2747 2747 2748 2748 if (text.isEmpty()) 2749 text = props.text ;2749 text = props.text(); 2750 2750 else 2751 text += " ~ " + props.text ;2751 text += " ~ " + props.text(); 2752 2752 } 2753 2753 else 2754 2754 { … … void MythUIButtonListItem::SetText(const QString &text, const QString &name, 2915 2915 { 2916 2916 if (!name.isEmpty()) 2917 2917 { 2918 TextProperties textprop; 2919 textprop.text = text; 2920 textprop.state = state; 2918 TextProperties textprop(text, state); 2921 2919 m_strings.insert(name, textprop); 2922 2920 } 2923 2921 else … … void MythUIButtonListItem::SetTextFromMap(QHash<QString, QString> &infoMap, 2934 2932 2935 2933 while (map_it != infoMap.end()) 2936 2934 { 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 2944 void 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); 2940 2952 m_strings[map_it.key()] = textprop; 2941 2953 ++map_it; 2942 2954 } … … void MythUIButtonListItem::SetTextFromMap(QMap<QString, TextProperties> &stringM 2951 2963 m_strings = stringMap; 2952 2964 } 2953 2965 2954 QString MythUIButtonListItem::GetText(const QString &name) const2966 QString MythUIButtonListItem::GetText(const QString &name) 2955 2967 { 2956 2968 if (name.isEmpty()) 2957 2969 return m_text; 2958 2970 else if (m_strings.contains(name)) 2959 return m_strings[name].text ;2971 return m_strings[name].text(); 2960 2972 else 2961 2973 return QString(); 2962 2974 } 2963 2975 2964 2976 bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fieldList, 2965 bool startsWith) const2977 bool startsWith) 2966 2978 { 2967 2979 if (fieldList.isEmpty()) 2968 2980 { … … bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fie 2984 2996 return true; 2985 2997 } 2986 2998 2987 QMap<QString, TextProperties>:: const_iterator i = m_strings.constBegin();2999 QMap<QString, TextProperties>::iterator i = m_strings.begin(); 2988 3000 2989 while (i != m_strings. constEnd())3001 while (i != m_strings.end()) 2990 3002 { 2991 3003 if (startsWith) 2992 3004 { 2993 if (i.value().text .startsWith(searchStr, Qt::CaseInsensitive))3005 if (i.value().text().startsWith(searchStr, Qt::CaseInsensitive)) 2994 3006 return true; 2995 3007 } 2996 3008 else 2997 3009 { 2998 if (i.value().text .contains(searchStr, Qt::CaseInsensitive))3010 if (i.value().text().contains(searchStr, Qt::CaseInsensitive)) 2999 3011 return true; 3000 3012 } 3001 3013 … … bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fie 3012 3024 { 3013 3025 if (startsWith) 3014 3026 { 3015 if (m_strings[fields.at(x)].text .startsWith(searchStr, Qt::CaseInsensitive))3027 if (m_strings[fields.at(x)].text().startsWith(searchStr, Qt::CaseInsensitive)) 3016 3028 return true; 3017 3029 } 3018 3030 else 3019 3031 { 3020 if (m_strings[fields.at(x)].text .contains(searchStr, Qt::CaseInsensitive))3032 if (m_strings[fields.at(x)].text().contains(searchStr, Qt::CaseInsensitive)) 3021 3033 return true; 3022 3034 } 3023 3035 } … … void MythUIButtonListItem::SetToRealButton(MythUIStateType *button, bool selecte 3311 3323 3312 3324 if (text) 3313 3325 { 3314 TextProperties textprop = string_it.value();3326 TextProperties &textprop = string_it.value(); 3315 3327 3316 3328 QString newText = text->GetTemplateText(); 3317 3329 … … void MythUIButtonListItem::SetToRealButton(MythUIStateType *button, bool selecte 3327 3339 { 3328 3340 QString key = regexp.cap(4).toLower().trimmed(); 3329 3341 QString replacement; 3330 QString value = m_strings .value(key).text;3342 QString value = m_strings[key].text(); 3331 3343 3332 3344 if (!value.isEmpty()) 3333 3345 { 3334 3346 replacement = QString("%1%2%3%4") 3335 3347 .arg(regexp.cap(2)) 3336 3348 .arg(regexp.cap(3)) 3337 .arg(m_strings .value(key).text)3349 .arg(m_strings[key].text()) 3338 3350 .arg(regexp.cap(6)); 3339 3351 } 3340 3352 … … void MythUIButtonListItem::SetToRealButton(MythUIStateType *button, bool selecte 3345 3357 newText = tempString; 3346 3358 } 3347 3359 else 3348 newText = textprop.text ;3360 newText = textprop.text(); 3349 3361 3350 3362 if (newText.isEmpty()) 3351 3363 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 15 15 class MythUIButtonList; 16 16 class MythUIStateType; 17 17 18 struct TextProperties { 19 QString text; 18 class TextProperties { 19 public: 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(); } 20 26 QString state; 27 private: 28 LazyMapEntry value; 21 29 }; 22 30 23 31 class MUI_PUBLIC MythUIButtonListItem … … class MUI_PUBLIC MythUIButtonListItem 43 51 void SetText(const QString &text, const QString &name="", 44 52 const QString &state=""); 45 53 void SetTextFromMap(InfoMap &infoMap, const QString &state=""); 54 void SetTextFromLazyMap(LazyInfoMap &infoMap, const QString &state=""); 46 55 void SetTextFromMap(QMap<QString, TextProperties> &stringMap); 47 QString GetText(const QString &name="") const;56 QString GetText(const QString &name=""); 48 57 49 58 bool FindText(const QString &searchStr, const QString &fieldList = "**ALL**", 50 bool startsWith = false) const;59 bool startsWith = false); 51 60 52 61 void SetFontState(const QString &state, const QString &name=""); 53 62 -
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) 176 176 } 177 177 } 178 178 179 void 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 179 226 QString MythUIText::GetText(void) const 180 227 { 181 228 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 11 11 // Mythui headers 12 12 #include "mythuitype.h" 13 13 14 #include "util.h" // for LazyInfoMap/LazyMapEntry 15 14 16 class MythFontProperties; 15 17 16 18 /** … … class MUI_PUBLIC MythUIText : public MythUIType, public StorageUser 39 41 QString GetDefaultText(void) const; 40 42 41 43 void SetTextFromMap(QHash<QString, QString> &map); 44 void SetTextFromLazyMap(LazyInfoMap &map); 42 45 43 46 void SetTemplateText(const QString &text) { m_TemplateText = text; } 44 47 QString GetTemplateText(void) const { return m_TemplateText; } -
mythtv/programs/mythfrontend/main.cpp
diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp index 0f5c2c7..1d96b77 100644
a b static void startCustomPriority(void) 467 467 468 468 static void startPlaybackWithGroup(QString recGroup = "") 469 469 { 470 LOG(VB_GENERAL, LOG_INFO, QString("LZY startPlaybackWithGroup begin")); 470 471 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 471 472 472 473 PlaybackBox *pbb = new PlaybackBox( … … static void startPlaybackWithGroup(QString recGroup = "") 481 482 } 482 483 else 483 484 delete pbb; 485 LOG(VB_GENERAL, LOG_INFO, QString("LZY startPlaybackWithGroup end")); 484 486 } 485 487 486 488 static void startPlayback(void) -
mythtv/programs/mythfrontend/playbackbox.cpp
diff --git a/mythtv/programs/mythfrontend/playbackbox.cpp b/mythtv/programs/mythfrontend/playbackbox.cpp index dc76ecf..ebcf44e 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 1 4 2 5 #include "playbackbox.h" 3 6 … … PlaybackBox::~PlaybackBox(void) 499 502 500 503 bool PlaybackBox::Create() 501 504 { 505 LOG(VB_GENERAL, LOG_INFO, QString("LZY LoadWindowFromXML begin")); 502 506 if (m_type == kDeleteBox && 503 507 LoadWindowFromXML("recordings-ui.xml", "deleterecordings", this)) 504 508 LOG(VB_GENERAL, LOG_DEBUG, … … bool PlaybackBox::Create() 506 510 else 507 511 if (!LoadWindowFromXML("recordings-ui.xml", "watchrecordings", this)) 508 512 return false; 513 LOG(VB_GENERAL, LOG_INFO, QString("LZY LoadWindowFromXML end")); 509 514 510 515 m_recgroupList = dynamic_cast<MythUIButtonList *> (GetChild("recgroups")); 511 516 m_groupList = dynamic_cast<MythUIButtonList *> (GetChild("groups")); … … void PlaybackBox::UpdateUIListItem( 794 799 // frontend 795 800 if (m_groupList && m_groupList->GetItemCurrent()) 796 801 { 802 #ifdef USE_OLD_MAPS 797 803 InfoMap infoMap; 798 804 pginfo->ToMap(infoMap); 799 805 item->SetTextFromMap(infoMap); 806 #else 807 LazyInfoMap infoMap; 808 pginfo->ToLazyMap(infoMap); 809 item->SetTextFromLazyMap(infoMap); 810 #endif 800 811 801 812 QString groupname = 802 813 m_groupList->GetItemCurrent()->GetData().toString(); … … void PlaybackBox::UpdateUIListItem( 830 841 831 842 if ((GetFocusWidget() == m_recordingList) && is_sel) 832 843 { 844 #ifdef USE_OLD_MAPS 833 845 InfoMap infoMap; 834 846 835 847 pginfo->ToMap(infoMap); 836 848 ResetMap(m_currentMap); 837 849 SetTextFromMap(infoMap); 838 850 m_currentMap = infoMap; 851 #else 852 LazyInfoMap infoMap; 853 854 pginfo->ToLazyMap(infoMap); 855 ResetMap(m_currentMap); 856 SetTextFromLazyMap(infoMap); 857 m_currentMap.clear(); 858 for (LazyInfoMap::const_iterator it = infoMap.begin(); it != infoMap.end(); ++it) 859 m_currentMap[it.key()] = "<undefined>"; 860 #endif 839 861 840 862 MythUIStateType *ratingState = dynamic_cast<MythUIStateType*> 841 863 (GetChild("ratingstate")); … … void PlaybackBox::UpdateUIRecGroupList(void) 1210 1232 1211 1233 void PlaybackBox::UpdateUIGroupList(const QStringList &groupPreferences) 1212 1234 { 1235 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUIGroupList begin")); 1213 1236 m_groupList->Reset(); 1214 1237 1215 1238 if (!m_titleList.isEmpty()) … … void PlaybackBox::UpdateUIGroupList(const QStringList &groupPreferences) 1250 1273 if (!sel_idx) 1251 1274 updateRecList(m_groupList->GetItemCurrent()); 1252 1275 } 1276 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUIGroupList end")); 1253 1277 } 1254 1278 1255 1279 void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1256 1280 { 1257 1281 if (!sel_item) 1258 1282 return; 1283 LOG(VB_GENERAL, LOG_INFO, QString("LZY updateRecList begin")); 1259 1284 1260 1285 QString groupname = sel_item->GetData().toString(); 1261 1286 QString grouplabel = sel_item->GetText(); … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1298 1323 subtitleFlags[SUB_HARDHEAR] = "cc"; 1299 1324 1300 1325 ProgramList::iterator it = progList.begin(); 1326 int tomapcount = 0; 1301 1327 for (; it != progList.end(); ++it) 1302 1328 { 1303 1329 if ((*it)->GetAvailableStatus() == asPendingDelete || … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1311 1337 1312 1338 item->SetFontState(state); 1313 1339 1340 #ifdef USE_OLD_MAPS 1314 1341 InfoMap infoMap; 1315 1342 (*it)->ToMap(infoMap); 1316 1343 item->SetTextFromMap(infoMap); 1344 #else 1345 LazyInfoMap infoMap; 1346 (*it)->ToLazyMap(infoMap); 1347 item->SetTextFromLazyMap(infoMap); 1348 #endif 1349 ++tomapcount; 1317 1350 1318 1351 QString tempSubTitle = extract_subtitle(**it, groupname); 1319 1352 … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1347 1380 item->DisplayState(sit.value(), "subtitletypes"); 1348 1381 } 1349 1382 } 1383 LOG(VB_GENERAL, LOG_INFO, QString("LZY ToMap count = %1").arg(tomapcount)); 1350 1384 1351 1385 if (m_noRecordingsText) 1352 1386 { … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1361 1395 m_noRecordingsText->SetVisible(true); 1362 1396 } 1363 1397 } 1398 LOG(VB_GENERAL, LOG_INFO, QString("LZY updateRecList end")); 1364 1399 } 1365 1400 1366 1401 static bool save_position( … … static void restore_position( 1499 1534 1500 1535 bool PlaybackBox::UpdateUILists(void) 1501 1536 { 1537 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUILists() m_recGroup=%1 begin").arg(m_recGroup)); 1502 1538 m_isFilling = true; 1503 1539 1504 1540 // Save selection, including next few items & groups … … bool PlaybackBox::UpdateUILists(void) 1546 1582 QMap<int, QString> searchRule; 1547 1583 QMap<int, int> recidEpisodes; 1548 1584 1585 LOG(VB_GENERAL, LOG_INFO, QString("LZY m_programInfoCache.Refresh() begin")); 1549 1586 m_programInfoCache.Refresh(); 1587 LOG(VB_GENERAL, LOG_INFO, QString("LZY m_programInfoCache.Refresh() end")); 1550 1588 1551 1589 if (!m_programInfoCache.empty()) 1552 1590 { … … bool PlaybackBox::UpdateUILists(void) 2082 2120 2083 2121 m_isFilling = false; 2084 2122 2123 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUILists() end")); 2085 2124 return true; 2086 2125 } 2087 2126