Ticket #10161: lazystrings_v4.patch
File lazystrings_v4.patch, 17.2 KB (added by , 12 years ago) |
---|
-
mythtv/libs/libmythui/mythuibuttonlist.cpp
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.cpp b/mythtv/libs/libmythui/mythuibuttonlist.cpp index ed473e0..8e612fe 100644
a b MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2852 2852 const QString &text, const QString &image, 2853 2853 bool checkable, CheckState state, 2854 2854 bool showArrow, int listPosition) 2855 : m_strings(this), m_states(this) 2855 2856 { 2856 2857 if (!lbtype) 2857 2858 LOG(VB_GENERAL, LOG_ERR, "Cannot add a button to a non-existent list!"); … … MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2875 2876 MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2876 2877 const QString &text, 2877 2878 QVariant data, int listPosition) 2879 : m_strings(this), m_states(this) 2878 2880 { 2879 2881 if (!lbtype) 2880 2882 LOG(VB_GENERAL, LOG_ERR, "Cannot add a button to a non-existent list!"); … … void MythUIButtonListItem::SetTextFromMap(QMap<QString, TextProperties> &stringM 2951 2953 m_strings = stringMap; 2952 2954 } 2953 2955 2954 QString MythUIButtonListItem::GetText(const QString &name) const2956 QString MythUIButtonListItem::GetText(const QString &name) 2955 2957 { 2956 2958 if (name.isEmpty()) 2957 2959 return m_text; … … QString MythUIButtonListItem::GetText(const QString &name) const 2962 2964 } 2963 2965 2964 2966 bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fieldList, 2965 bool startsWith) const2967 bool startsWith) 2966 2968 { 2967 2969 if (fieldList.isEmpty()) 2968 2970 { … … bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fie 2984 2986 return true; 2985 2987 } 2986 2988 2987 QMap<QString, TextProperties>::const_iterator i = m_strings. constBegin();2989 QMap<QString, TextProperties>::const_iterator i = m_strings.begin(); 2988 2990 2989 while (i != m_strings. constEnd())2991 while (i != m_strings.end()) 2990 2992 { 2991 2993 if (startsWith) 2992 2994 { … … void SearchButtonListDialog::prevClicked(void) 3503 3505 if (m_searchState) 3504 3506 m_searchState->DisplayState(found ? "found" : "notfound"); 3505 3507 } 3508 3509 void TextPropertiesWrapper::FillIn(void) 3510 { 3511 if (pbb) 3512 { 3513 PlaybackBox *oldPbb = pbb; 3514 pbb = 0; 3515 func(oldPbb, progInfo, str, parent); 3516 progInfo = 0; 3517 func = 0; 3518 } 3519 } 3520 3521 void QStringWrapper::FillIn(void) 3522 { 3523 if (pbb) 3524 { 3525 PlaybackBox *oldPbb = pbb; 3526 pbb = 0; 3527 func(oldPbb, progInfo, parent); 3528 progInfo = 0; 3529 func = 0; 3530 } 3531 } -
mythtv/libs/libmythui/mythuibuttonlist.h
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.h b/mythtv/libs/libmythui/mythuibuttonlist.h index b6cbebd..fdd3dac 100644
a b 14 14 15 15 class MythUIButtonList; 16 16 class MythUIStateType; 17 class ProgramInfo; 18 class PlaybackBox; 17 19 18 20 struct TextProperties { 19 21 QString text; 20 22 QString state; 21 23 }; 22 24 25 typedef void (*DeferredFillInStringsFunc)(PlaybackBox *, ProgramInfo *, 26 QString &, MythUIButtonListItem *); 27 // TextPropertiesWrapper is a wrapper around a 28 // QMap<QString,TextProperties> object such that initialization of 29 // MythUIButtonListItem::m_strings can be deferred until the next 30 // access to the object. 31 class TextPropertiesWrapper { 32 public: 33 TextPropertiesWrapper(MythUIButtonListItem *p) 34 : parent(p), pbb(0), progInfo(0), func(0) {} 35 void SetDeferredMap(PlaybackBox *pb, ProgramInfo *pi, 36 QString &s, DeferredFillInStringsFunc f) { 37 pbb = pb; 38 progInfo = pi; 39 str = s; 40 func = f; 41 } 42 QMap<QString, TextProperties>::iterator begin(void) { 43 FillIn(); 44 return map.begin(); 45 } 46 void clear(void) { 47 FillIn(); 48 map.clear(); 49 } 50 bool contains(const QString &key) { 51 FillIn(); 52 return map.contains(key); 53 } 54 QMap<QString, TextProperties>::iterator end(void) { 55 FillIn(); 56 return map.end(); 57 } 58 QMap<QString, TextProperties>::iterator insert(const QString &key, const TextProperties &value) { 59 FillIn(); 60 return map.insert(key, value); 61 } 62 const TextProperties value(const QString &key) { 63 FillIn(); 64 return map.value(key); 65 } 66 TextProperties &operator[](const QString &key) { 67 FillIn(); 68 return map[key]; 69 } 70 TextPropertiesWrapper &operator=(const QMap<QString, TextProperties> &other) { 71 FillIn(); 72 map = other; 73 return *this; 74 } 75 private: 76 void FillIn(void); 77 MythUIButtonListItem *parent; 78 PlaybackBox *pbb; 79 ProgramInfo *progInfo; 80 QString str; 81 DeferredFillInStringsFunc func; 82 QMap<QString, TextProperties> map; 83 }; 84 85 typedef void (*DeferredFillInStatesFunc)(PlaybackBox *, ProgramInfo *, MythUIButtonListItem *); 86 class QStringWrapper { 87 public: 88 QStringWrapper(MythUIButtonListItem *p) 89 : parent(p), pbb(0), progInfo(0), func(0) {} 90 void SetDeferredMap(PlaybackBox *pb, ProgramInfo *pi, 91 DeferredFillInStatesFunc f) { 92 pbb = pb; 93 progInfo = pi; 94 func = f; 95 } 96 QMap<QString, QString>::iterator begin(void) { 97 FillIn(); 98 return map.begin(); 99 } 100 QMap<QString, QString>::iterator find(const QString &key) { 101 FillIn(); 102 return map.find(key); 103 } 104 QMap<QString, QString>::iterator end(void) { 105 FillIn(); 106 return map.end(); 107 } 108 QMap<QString, QString>::iterator insert(const QString &key, const QString &value) { 109 FillIn(); 110 return map.insert(key, value); 111 } 112 private: 113 void FillIn(void); 114 MythUIButtonListItem *parent; 115 PlaybackBox *pbb; 116 ProgramInfo *progInfo; 117 DeferredFillInStatesFunc func; 118 QMap<QString, QString> map; 119 }; 120 23 121 class MUI_PUBLIC MythUIButtonListItem 24 122 { 25 123 public: … … class MUI_PUBLIC MythUIButtonListItem 44 142 const QString &state=""); 45 143 void SetTextFromMap(InfoMap &infoMap, const QString &state=""); 46 144 void SetTextFromMap(QMap<QString, TextProperties> &stringMap); 47 QString GetText(const QString &name="") const; 145 void SetStringsDeferred(PlaybackBox *pb, ProgramInfo *pi, 146 QString &s, DeferredFillInStringsFunc f) { 147 m_strings.SetDeferredMap(pb, pi, s, f); 148 } 149 void SetStatesDeferred(PlaybackBox *pb, ProgramInfo *pi, 150 DeferredFillInStatesFunc f) { 151 m_states.SetDeferredMap(pb, pi, f); 152 } 153 QString GetText(const QString &name=""); 48 154 49 155 bool FindText(const QString &searchStr, const QString &fieldList = "**ALL**", 50 bool startsWith = false) const;156 bool startsWith = false); 51 157 52 158 void SetFontState(const QString &state, const QString &name=""); 53 159 … … class MUI_PUBLIC MythUIButtonListItem 95 201 QVariant m_data; 96 202 bool m_showArrow; 97 203 98 QMap<QString, TextProperties>m_strings;204 TextPropertiesWrapper m_strings; 99 205 QMap<QString, MythImage*> m_images; 100 206 QMap<QString, QString> m_imageFilenames; 101 Q Map<QString, QString>m_states;207 QStringWrapper m_states; 102 208 103 209 friend class MythUIButtonList; 104 210 friend class MythGenericTree; -
mythtv/programs/mythfrontend/main.cpp
diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp index 5a6967a..60d24a6 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..cbd9b28 100644
a b PlaybackBox::~PlaybackBox(void) 499 499 500 500 bool PlaybackBox::Create() 501 501 { 502 LOG(VB_GENERAL, LOG_INFO, QString("LZY LoadWindowFromXML begin")); 502 503 if (m_type == kDeleteBox && 503 504 LoadWindowFromXML("recordings-ui.xml", "deleterecordings", this)) 504 505 LOG(VB_GENERAL, LOG_DEBUG, … … bool PlaybackBox::Create() 506 507 else 507 508 if (!LoadWindowFromXML("recordings-ui.xml", "watchrecordings", this)) 508 509 return false; 510 LOG(VB_GENERAL, LOG_INFO, QString("LZY LoadWindowFromXML end")); 509 511 510 512 m_recgroupList = dynamic_cast<MythUIButtonList *> (GetChild("recgroups")); 511 513 m_groupList = dynamic_cast<MythUIButtonList *> (GetChild("groups")); … … void PlaybackBox::UpdateUIRecGroupList(void) 1210 1212 1211 1213 void PlaybackBox::UpdateUIGroupList(const QStringList &groupPreferences) 1212 1214 { 1215 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUIGroupList begin")); 1213 1216 m_groupList->Reset(); 1214 1217 1215 1218 if (!m_titleList.isEmpty()) … … void PlaybackBox::UpdateUIGroupList(const QStringList &groupPreferences) 1250 1253 if (!sel_idx) 1251 1254 updateRecList(m_groupList->GetItemCurrent()); 1252 1255 } 1256 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUIGroupList end")); 1253 1257 } 1254 1258 1255 1259 void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1259 1263 1260 1264 QString groupname = sel_item->GetData().toString(); 1261 1265 QString grouplabel = sel_item->GetText(); 1266 LOG(VB_GENERAL, LOG_INFO, QString("LZY updateRecList begin groupname=%1").arg(groupname)); 1262 1267 1263 1268 updateGroupInfo(groupname, grouplabel); 1264 1269 … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1279 1284 1280 1285 ProgramList &progList = *pmit; 1281 1286 1282 QMap<AudioProps, QString> audioFlags;1283 audioFlags[AUD_DOLBY] = "dolby";1284 audioFlags[AUD_SURROUND] = "surround";1285 audioFlags[AUD_STEREO] = "stereo";1286 audioFlags[AUD_MONO] = "mono";1287 1288 QMap<VideoProps, QString> videoFlags;1289 videoFlags[VID_1080] = "hd1080";1290 videoFlags[VID_720] = "hd720";1291 videoFlags[VID_HDTV] = "hdtv";1292 videoFlags[VID_WIDESCREEN] = "widescreen";1293 1294 QMap<SubtitleTypes, QString> subtitleFlags;1295 subtitleFlags[SUB_SIGNED] = "deafsigned";1296 subtitleFlags[SUB_ONSCREEN] = "onscreensub";1297 subtitleFlags[SUB_NORMAL] = "subtitles";1298 subtitleFlags[SUB_HARDHEAR] = "cc";1299 1300 1287 ProgramList::iterator it = progList.begin(); 1288 int itemcount = 0; 1301 1289 for (; it != progList.end(); ++it) 1302 1290 { 1303 1291 if ((*it)->GetAvailableStatus() == asPendingDelete || … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1307 1295 MythUIButtonListItem *item = 1308 1296 new PlaybackBoxListItem(this, m_recordingList, *it); 1309 1297 1310 QString state = extract_main_state(**it, m_player); 1311 1312 item->SetFontState(state); 1298 item->SetStringsDeferred(this, *it, groupname, DeferredFillInStrings); 1299 item->SetStatesDeferred(this, *it, DeferredFillInStates); 1313 1300 1314 InfoMap infoMap; 1315 (*it)->ToMap(infoMap); 1316 item->SetTextFromMap(infoMap); 1317 1318 QString tempSubTitle = extract_subtitle(**it, groupname); 1319 1320 if (groupname == (*it)->GetTitle().toLower()) 1321 item->SetText(tempSubTitle, "titlesubtitle"); 1322 1323 item->DisplayState(state, "status"); 1324 1325 item->DisplayState(QString::number((*it)->GetStars(10)), "ratingstate"); 1326 1327 SetItemIcons(item, (*it)); 1328 1329 QMap<AudioProps, QString>::iterator ait; 1330 for (ait = audioFlags.begin(); ait != audioFlags.end(); ++ait) 1331 { 1332 if ((*it)->GetAudioProperties() & ait.key()) 1333 item->DisplayState(ait.value(), "audioprops"); 1334 } 1335 1336 QMap<VideoProps, QString>::iterator vit; 1337 for (vit = videoFlags.begin(); vit != videoFlags.end(); ++vit) 1338 { 1339 if ((*it)->GetVideoProperties() & vit.key()) 1340 item->DisplayState(vit.value(), "videoprops"); 1341 } 1342 1343 QMap<SubtitleTypes, QString>::iterator sit; 1344 for (sit = subtitleFlags.begin(); sit != subtitleFlags.end(); ++sit) 1345 { 1346 if ((*it)->GetSubtitleType() & sit.key()) 1347 item->DisplayState(sit.value(), "subtitletypes"); 1348 } 1301 ++itemcount; 1349 1302 } 1303 LOG(VB_GENERAL, LOG_INFO, QString("LZY item creation count = %1").arg(itemcount)); 1350 1304 1351 1305 if (m_noRecordingsText) 1352 1306 { … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1361 1315 m_noRecordingsText->SetVisible(true); 1362 1316 } 1363 1317 } 1318 LOG(VB_GENERAL, LOG_INFO, QString("LZY updateRecList end")); 1364 1319 } 1365 1320 1366 1321 static bool save_position( … … static void restore_position( 1499 1454 1500 1455 bool PlaybackBox::UpdateUILists(void) 1501 1456 { 1457 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUILists() m_recGroup=%1 begin").arg(m_recGroup)); 1502 1458 m_isFilling = true; 1503 1459 1504 1460 // Save selection, including next few items & groups … … bool PlaybackBox::UpdateUILists(void) 1546 1502 QMap<int, QString> searchRule; 1547 1503 QMap<int, int> recidEpisodes; 1548 1504 1505 LOG(VB_GENERAL, LOG_INFO, QString("LZY m_programInfoCache.Refresh() begin")); 1549 1506 m_programInfoCache.Refresh(); 1507 LOG(VB_GENERAL, LOG_INFO, QString("LZY m_programInfoCache.Refresh() end")); 1550 1508 1551 1509 if (!m_programInfoCache.empty()) 1552 1510 { … … bool PlaybackBox::UpdateUILists(void) 2082 2040 2083 2041 m_isFilling = false; 2084 2042 2043 LOG(VB_GENERAL, LOG_INFO, QString("LZY UpdateUILists() end")); 2085 2044 return true; 2086 2045 } 2087 2046 … … void PlaybackBox::SetRecGroupPassword(const QString &newPassword) 4847 4806 m_recGroupPwCache[m_recGroup] = newPassword; 4848 4807 } 4849 4808 4809 void PlaybackBox::DeferredFillInStrings(PlaybackBox *pbb, ProgramInfo *pi, 4810 QString &groupname, MythUIButtonListItem *item) 4811 { 4812 QString state = extract_main_state(*pi, pbb->m_player); 4813 4814 item->SetFontState(state); 4815 4816 InfoMap infoMap; 4817 pi->ToMap(infoMap); 4818 item->SetTextFromMap(infoMap); 4819 4820 QString tempSubTitle = extract_subtitle(*pi, groupname); 4821 4822 if (groupname == pi->GetTitle().toLower()) 4823 item->SetText(tempSubTitle, "titlesubtitle"); 4824 } 4825 4826 void PlaybackBox::DeferredFillInStates(PlaybackBox *pbb, ProgramInfo *pi, 4827 MythUIButtonListItem *item) 4828 { 4829 QMap<AudioProps, QString> audioFlags; 4830 audioFlags[AUD_DOLBY] = "dolby"; 4831 audioFlags[AUD_SURROUND] = "surround"; 4832 audioFlags[AUD_STEREO] = "stereo"; 4833 audioFlags[AUD_MONO] = "mono"; 4834 4835 QMap<VideoProps, QString> videoFlags; 4836 videoFlags[VID_1080] = "hd1080"; 4837 videoFlags[VID_720] = "hd720"; 4838 videoFlags[VID_HDTV] = "hdtv"; 4839 videoFlags[VID_WIDESCREEN] = "widescreen"; 4840 4841 QMap<SubtitleTypes, QString> subtitleFlags; 4842 subtitleFlags[SUB_SIGNED] = "deafsigned"; 4843 subtitleFlags[SUB_ONSCREEN] = "onscreensub"; 4844 subtitleFlags[SUB_NORMAL] = "subtitles"; 4845 subtitleFlags[SUB_HARDHEAR] = "cc"; 4846 4847 QString state = extract_main_state(*pi, pbb->m_player); 4848 4849 item->DisplayState(state, "status"); 4850 4851 item->DisplayState(QString::number(pi->GetStars(10)), "ratingstate"); 4852 4853 pbb->SetItemIcons(item, pi); 4854 4855 QMap<AudioProps, QString>::iterator ait; 4856 for (ait = audioFlags.begin(); ait != audioFlags.end(); ++ait) 4857 { 4858 if (pi->GetAudioProperties() & ait.key()) 4859 item->DisplayState(ait.value(), "audioprops"); 4860 } 4861 4862 QMap<VideoProps, QString>::iterator vit; 4863 for (vit = videoFlags.begin(); vit != videoFlags.end(); ++vit) 4864 { 4865 if (pi->GetVideoProperties() & vit.key()) 4866 item->DisplayState(vit.value(), "videoprops"); 4867 } 4868 4869 QMap<SubtitleTypes, QString>::iterator sit; 4870 for (sit = subtitleFlags.begin(); sit != subtitleFlags.end(); ++sit) 4871 { 4872 if (pi->GetSubtitleType() & sit.key()) 4873 item->DisplayState(sit.value(), "subtitletypes"); 4874 } 4875 item->DisplayState(state, "status"); 4876 } 4877 4850 4878 /////////////////////////////////////////////////// 4851 4879 4852 4880 GroupSelector::GroupSelector(MythScreenStack *lparent, const QString &label, -
mythtv/programs/mythfrontend/playbackbox.h
diff --git a/mythtv/programs/mythfrontend/playbackbox.h b/mythtv/programs/mythfrontend/playbackbox.h index e6f4ed9..8c6814a 100644
a b class PlaybackBox : public ScheduleCommon 441 441 PlaybackBoxHelper m_helper; 442 442 /// Outstanding preview image requests 443 443 QSet<QString> m_preview_tokens; 444 445 static void DeferredFillInStrings(PlaybackBox *pbb, ProgramInfo *pi, 446 QString &groupname, MythUIButtonListItem *item); 447 static void DeferredFillInStates(PlaybackBox *pbb, ProgramInfo *pi, 448 MythUIButtonListItem *item); 444 449 }; 445 450 446 451 class GroupSelector : public MythScreenType