Ticket #10161: lazystrings_v5.patch
File lazystrings_v5.patch, 16.3 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 cf432bb..90e630e 100644
a b MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2854 2854 const QString &text, const QString &image, 2855 2855 bool checkable, CheckState state, 2856 2856 bool showArrow, int listPosition) 2857 : m_strings(this), m_states(this) 2857 2858 { 2858 2859 if (!lbtype) 2859 2860 LOG(VB_GENERAL, LOG_ERR, "Cannot add a button to a non-existent list!"); … … MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2877 2878 MythUIButtonListItem::MythUIButtonListItem(MythUIButtonList *lbtype, 2878 2879 const QString &text, 2879 2880 QVariant data, int listPosition) 2881 : m_strings(this), m_states(this) 2880 2882 { 2881 2883 if (!lbtype) 2882 2884 LOG(VB_GENERAL, LOG_ERR, "Cannot add a button to a non-existent list!"); … … void MythUIButtonListItem::SetTextFromMap(QMap<QString, TextProperties> &stringM 2953 2955 m_strings = stringMap; 2954 2956 } 2955 2957 2956 QString MythUIButtonListItem::GetText(const QString &name) const2958 QString MythUIButtonListItem::GetText(const QString &name) 2957 2959 { 2958 2960 if (name.isEmpty()) 2959 2961 return m_text; … … QString MythUIButtonListItem::GetText(const QString &name) const 2964 2966 } 2965 2967 2966 2968 bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fieldList, 2967 bool startsWith) const2969 bool startsWith) 2968 2970 { 2969 2971 if (fieldList.isEmpty()) 2970 2972 { … … bool MythUIButtonListItem::FindText(const QString &searchStr, const QString &fie 2986 2988 return true; 2987 2989 } 2988 2990 2989 QMap<QString, TextProperties>::const_iterator i = m_strings. constBegin();2991 QMap<QString, TextProperties>::const_iterator i = m_strings.begin(); 2990 2992 2991 while (i != m_strings. constEnd())2993 while (i != m_strings.end()) 2992 2994 { 2993 2995 if (startsWith) 2994 2996 { -
mythtv/libs/libmythui/mythuibuttonlist.h
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.h b/mythtv/libs/libmythui/mythuibuttonlist.h index b6cbebd..4db883a 100644
a b struct TextProperties { 20 20 QString state; 21 21 }; 22 22 23 class DeferredCallback { 24 public: 25 DeferredCallback() {}; 26 virtual void callback(void *parent) = 0; 27 }; 28 29 template <class T> 30 class DeferredItem { 31 public: 32 DeferredItem(void *p) 33 : parent(p), hasDeferred(false), callback(0) {} 34 void SetDeferredCallback(DeferredCallback *obj) { 35 callback = obj; 36 hasDeferred = true; 37 } 38 typename T::iterator begin(void) { 39 DoCallback(); 40 return map.begin(); 41 } 42 void clear(void) { 43 DoCallback(); 44 map.clear(); 45 } 46 bool contains(const typename T::key_type &key) { 47 DoCallback(); 48 return map.contains(key); 49 } 50 typename T::iterator end(void) { 51 DoCallback(); 52 return map.end(); 53 } 54 typename T::iterator find(const typename T::key_type &key) { 55 DoCallback(); 56 return map.find(key); 57 } 58 typename T::iterator insert(const typename T::key_type &key, 59 const typename T::mapped_type &value) { 60 DoCallback(); 61 return map.insert(key, value); 62 } 63 const typename T::mapped_type value(const typename T::key_type &key) { 64 DoCallback(); 65 return map.value(key); 66 } 67 typename T::mapped_type &operator[](const typename T::key_type &key) { 68 DoCallback(); 69 return map[key]; 70 } 71 DeferredItem &operator=(const T &other) { 72 DoCallback(); 73 map = other; 74 return *this; 75 } 76 private: 77 void *parent; 78 bool hasDeferred; 79 DeferredCallback *callback; 80 T map; 81 82 void DoCallback(void) { 83 if (hasDeferred) { 84 hasDeferred = false; 85 callback->callback(parent); 86 delete callback; 87 callback = 0; 88 } 89 } 90 }; 91 23 92 class MUI_PUBLIC MythUIButtonListItem 24 93 { 25 94 public: … … class MUI_PUBLIC MythUIButtonListItem 44 113 const QString &state=""); 45 114 void SetTextFromMap(InfoMap &infoMap, const QString &state=""); 46 115 void SetTextFromMap(QMap<QString, TextProperties> &stringMap); 47 QString GetText(const QString &name="") const; 116 void SetStringsCallback(DeferredCallback *callback) { 117 m_strings.SetDeferredCallback(callback); 118 } 119 void SetStatesCallback(DeferredCallback *callback) { 120 m_states.SetDeferredCallback(callback); 121 } 122 QString GetText(const QString &name=""); 48 123 49 124 bool FindText(const QString &searchStr, const QString &fieldList = "**ALL**", 50 bool startsWith = false) const;125 bool startsWith = false); 51 126 52 127 void SetFontState(const QString &state, const QString &name=""); 53 128 … … class MUI_PUBLIC MythUIButtonListItem 95 170 QVariant m_data; 96 171 bool m_showArrow; 97 172 98 QMap<QString, TextProperties> m_strings;173 DeferredItem<QMap<QString, TextProperties> > m_strings; 99 174 QMap<QString, MythImage*> m_images; 100 175 QMap<QString, QString> m_imageFilenames; 101 QMap<QString, QString> m_states;176 DeferredItem<QMap<QString, QString> > m_states; 102 177 103 178 friend class MythUIButtonList; 104 179 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..fc41954 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->SetStringsCallback(new DeferredStringsCallback(this, *it, groupname)); 1299 item->SetStatesCallback(new DeferredStatesCallback(this, *it)); 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(ProgramInfo *pi, 4810 QString &groupname, void *parent) 4811 { 4812 MythUIButtonListItem *item = (MythUIButtonListItem *) parent; 4813 QString state = extract_main_state(*pi, m_player); 4814 4815 item->SetFontState(state); 4816 4817 InfoMap infoMap; 4818 pi->ToMap(infoMap); 4819 item->SetTextFromMap(infoMap); 4820 4821 QString tempSubTitle = extract_subtitle(*pi, groupname); 4822 4823 if (groupname == pi->GetTitle().toLower()) 4824 item->SetText(tempSubTitle, "titlesubtitle"); 4825 } 4826 4827 void PlaybackBox::DeferredFillInStates(ProgramInfo *pi, void *parent) 4828 { 4829 MythUIButtonListItem *item = (MythUIButtonListItem *) parent; 4830 QMap<AudioProps, QString> audioFlags; 4831 audioFlags[AUD_DOLBY] = "dolby"; 4832 audioFlags[AUD_SURROUND] = "surround"; 4833 audioFlags[AUD_STEREO] = "stereo"; 4834 audioFlags[AUD_MONO] = "mono"; 4835 4836 QMap<VideoProps, QString> videoFlags; 4837 videoFlags[VID_1080] = "hd1080"; 4838 videoFlags[VID_720] = "hd720"; 4839 videoFlags[VID_HDTV] = "hdtv"; 4840 videoFlags[VID_WIDESCREEN] = "widescreen"; 4841 4842 QMap<SubtitleTypes, QString> subtitleFlags; 4843 subtitleFlags[SUB_SIGNED] = "deafsigned"; 4844 subtitleFlags[SUB_ONSCREEN] = "onscreensub"; 4845 subtitleFlags[SUB_NORMAL] = "subtitles"; 4846 subtitleFlags[SUB_HARDHEAR] = "cc"; 4847 4848 QString state = extract_main_state(*pi, m_player); 4849 4850 item->DisplayState(state, "status"); 4851 4852 item->DisplayState(QString::number(pi->GetStars(10)), "ratingstate"); 4853 4854 SetItemIcons(item, pi); 4855 4856 QMap<AudioProps, QString>::iterator ait; 4857 for (ait = audioFlags.begin(); ait != audioFlags.end(); ++ait) 4858 { 4859 if (pi->GetAudioProperties() & ait.key()) 4860 item->DisplayState(ait.value(), "audioprops"); 4861 } 4862 4863 QMap<VideoProps, QString>::iterator vit; 4864 for (vit = videoFlags.begin(); vit != videoFlags.end(); ++vit) 4865 { 4866 if (pi->GetVideoProperties() & vit.key()) 4867 item->DisplayState(vit.value(), "videoprops"); 4868 } 4869 4870 QMap<SubtitleTypes, QString>::iterator sit; 4871 for (sit = subtitleFlags.begin(); sit != subtitleFlags.end(); ++sit) 4872 { 4873 if (pi->GetSubtitleType() & sit.key()) 4874 item->DisplayState(sit.value(), "subtitletypes"); 4875 } 4876 item->DisplayState(state, "status"); 4877 } 4878 4850 4879 /////////////////////////////////////////////////// 4851 4880 4852 4881 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..2bd112b 100644
a b using namespace std; 27 27 #include "schedulecommon.h" 28 28 #include "programinfocache.h" 29 29 #include "playbackboxhelper.h" 30 #include "mythuibuttonlist.h" // for DeferredCallback class 30 31 31 32 class QKeyEvent; 32 33 class QEvent; … … class PlaybackBox : public ScheduleCommon 441 442 PlaybackBoxHelper m_helper; 442 443 /// Outstanding preview image requests 443 444 QSet<QString> m_preview_tokens; 445 446 public: 447 void DeferredFillInStrings(ProgramInfo *pi, 448 QString &groupname, void *parent); 449 void DeferredFillInStates(ProgramInfo *pi, void *parent); 444 450 }; 445 451 446 452 class GroupSelector : public MythScreenType … … class HelpPopup : public MythScreenType 556 562 MythUIButtonList *m_iconList; 557 563 }; 558 564 565 class DeferredStringsCallback : public DeferredCallback { 566 public: 567 DeferredStringsCallback(PlaybackBox *p, ProgramInfo *pi, QString &str) 568 : pbb(p), progInfo(pi), group(str) {} 569 void callback(void *parent) { 570 pbb->DeferredFillInStrings(progInfo, group, parent); 571 } 572 private: 573 PlaybackBox *pbb; 574 ProgramInfo *progInfo; 575 QString group; 576 }; 577 578 class DeferredStatesCallback : public DeferredCallback { 579 public: 580 DeferredStatesCallback(PlaybackBox *p, ProgramInfo *pi) 581 : pbb(p), progInfo(pi) {} 582 void callback(void *parent) { 583 pbb->DeferredFillInStates(progInfo, parent); 584 } 585 private: 586 PlaybackBox *pbb; 587 ProgramInfo *progInfo; 588 }; 589 559 590 #endif 560 591 /* vim: set expandtab tabstop=4 shiftwidth=4: */