Ticket #10161: lazystrings_v11.patch
File lazystrings_v11.patch, 11.5 KB (added by , 12 years ago) |
---|
-
mythtv/programs/mythfrontend/playbackbox.cpp
diff --git a/mythtv/programs/mythfrontend/playbackbox.cpp b/mythtv/programs/mythfrontend/playbackbox.cpp index 2e65654..e2e4b19 100644
a b void PlaybackBox::UpdateUIListItem(MythUIButtonListItem *item, 890 890 } 891 891 } 892 892 893 void PlaybackBox::ItemVisibleCore(MythUIButtonListItem *item) 894 { 895 ProgramInfo *pginfo = qVariantValue<ProgramInfo*>(item->GetData()); 896 if (item->GetText("is_item_initialized").isNull()) 897 { 898 QMap<AudioProps, QString> audioFlags; 899 audioFlags[AUD_DOLBY] = "dolby"; 900 audioFlags[AUD_SURROUND] = "surround"; 901 audioFlags[AUD_STEREO] = "stereo"; 902 audioFlags[AUD_MONO] = "mono"; 903 904 QMap<VideoProps, QString> videoFlags; 905 videoFlags[VID_1080] = "hd1080"; 906 videoFlags[VID_720] = "hd720"; 907 videoFlags[VID_HDTV] = "hdtv"; 908 videoFlags[VID_WIDESCREEN] = "widescreen"; 909 910 QMap<SubtitleTypes, QString> subtitleFlags; 911 subtitleFlags[SUB_SIGNED] = "deafsigned"; 912 subtitleFlags[SUB_ONSCREEN] = "onscreensub"; 913 subtitleFlags[SUB_NORMAL] = "subtitles"; 914 subtitleFlags[SUB_HARDHEAR] = "cc"; 915 916 QString groupname = m_groupList->GetItemCurrent()->GetData().toString(); 917 918 QString state = extract_main_state(*pginfo, m_player); 919 920 item->SetFontState(state); 921 922 InfoMap infoMap; 923 pginfo->ToMap(infoMap); 924 item->SetTextFromMap(infoMap); 925 926 QString tempSubTitle = extract_subtitle(*pginfo, groupname); 927 928 if (groupname == pginfo->GetTitle().toLower()) 929 item->SetText(tempSubTitle, "titlesubtitle"); 930 931 item->DisplayState(state, "status"); 932 933 item->DisplayState(QString::number(pginfo->GetStars(10)), "ratingstate"); 934 935 SetItemIcons(item, pginfo); 936 937 QMap<AudioProps, QString>::iterator ait; 938 for (ait = audioFlags.begin(); ait != audioFlags.end(); ++ait) 939 { 940 if (pginfo->GetAudioProperties() & ait.key()) 941 item->DisplayState(ait.value(), "audioprops"); 942 } 943 944 QMap<VideoProps, QString>::iterator vit; 945 for (vit = videoFlags.begin(); vit != videoFlags.end(); ++vit) 946 { 947 if (pginfo->GetVideoProperties() & vit.key()) 948 item->DisplayState(vit.value(), "videoprops"); 949 } 950 951 QMap<SubtitleTypes, QString>::iterator sit; 952 for (sit = subtitleFlags.begin(); sit != subtitleFlags.end(); ++sit) 953 { 954 if (pginfo->GetSubtitleType() & sit.key()) 955 item->DisplayState(sit.value(), "subtitletypes"); 956 } 957 958 item->DisplayState(pginfo->GetCategoryType(), "categorytype"); 959 960 // Mark this button list item as initialized. 961 item->SetText("yes", "is_item_initialized"); 962 } 963 964 } 965 893 966 void PlaybackBox::ItemVisible(MythUIButtonListItem *item) 894 967 { 895 968 ProgramInfo *pginfo = qVariantValue<ProgramInfo*>(item->GetData()); 896 969 970 ItemVisibleCore(item); 897 971 // Job status (recording, transcoding, flagging) 898 972 QString job = extract_job_state(*pginfo); 899 973 item->DisplayState(job, "jobstate"); … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1316 1390 1317 1391 ProgramList &progList = *pmit; 1318 1392 1319 QMap<AudioProps, QString> audioFlags;1320 audioFlags[AUD_DOLBY] = "dolby";1321 audioFlags[AUD_SURROUND] = "surround";1322 audioFlags[AUD_STEREO] = "stereo";1323 audioFlags[AUD_MONO] = "mono";1324 1325 QMap<VideoProps, QString> videoFlags;1326 videoFlags[VID_1080] = "hd1080";1327 videoFlags[VID_720] = "hd720";1328 videoFlags[VID_HDTV] = "hdtv";1329 videoFlags[VID_WIDESCREEN] = "widescreen";1330 1331 QMap<SubtitleTypes, QString> subtitleFlags;1332 subtitleFlags[SUB_SIGNED] = "deafsigned";1333 subtitleFlags[SUB_ONSCREEN] = "onscreensub";1334 subtitleFlags[SUB_NORMAL] = "subtitles";1335 subtitleFlags[SUB_HARDHEAR] = "cc";1336 1337 1393 ProgramList::iterator it = progList.begin(); 1338 1394 for (; it != progList.end(); ++it) 1339 1395 { … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1341 1397 (*it)->GetAvailableStatus() == asDeleted) 1342 1398 continue; 1343 1399 1344 MythUIButtonListItem *item = 1345 new PlaybackBoxListItem(this, m_recordingList, *it); 1346 1347 QString state = extract_main_state(**it, m_player); 1348 1349 item->SetFontState(state); 1350 1351 InfoMap infoMap; 1352 (*it)->ToMap(infoMap); 1353 item->SetTextFromMap(infoMap); 1354 1355 QString tempSubTitle = extract_subtitle(**it, groupname); 1356 1357 if (groupname == (*it)->GetTitle().toLower()) 1358 item->SetText(tempSubTitle, "titlesubtitle"); 1359 1360 item->DisplayState(state, "status"); 1361 1362 item->DisplayState(QString::number((*it)->GetStars(10)), "ratingstate"); 1363 1364 SetItemIcons(item, (*it)); 1365 1366 QMap<AudioProps, QString>::iterator ait; 1367 for (ait = audioFlags.begin(); ait != audioFlags.end(); ++ait) 1368 { 1369 if ((*it)->GetAudioProperties() & ait.key()) 1370 item->DisplayState(ait.value(), "audioprops"); 1371 } 1372 1373 QMap<VideoProps, QString>::iterator vit; 1374 for (vit = videoFlags.begin(); vit != videoFlags.end(); ++vit) 1375 { 1376 if ((*it)->GetVideoProperties() & vit.key()) 1377 item->DisplayState(vit.value(), "videoprops"); 1378 } 1379 1380 QMap<SubtitleTypes, QString>::iterator sit; 1381 for (sit = subtitleFlags.begin(); sit != subtitleFlags.end(); ++sit) 1382 { 1383 if ((*it)->GetSubtitleType() & sit.key()) 1384 item->DisplayState(sit.value(), "subtitletypes"); 1385 } 1386 1387 item->DisplayState((*it)->GetCategoryType(), "categorytype"); 1400 new PlaybackBoxListItem(this, m_recordingList, *it); 1388 1401 } 1402 m_helper.ComputeButtonListPage(0); 1389 1403 1390 1404 if (m_noRecordingsText) 1391 1405 { … … void PlaybackBox::customEvent(QEvent *event) 3845 3859 if (resultid == "transcode" && dce->GetResult() >= 0) 3846 3860 changeProfileAndTranscode(dce->GetData().toInt()); 3847 3861 } 3862 else if (event->type() == NextButtonListPageEvent::kEventType) 3863 { 3864 // Lazily compute a "page" of the next 20 button list items 3865 // before the next screen refresh. The value 20 is chosen to 3866 // be large enough that the background computation finishes 3867 // reasonably quickly, while small enough that it doesn't 3868 // noticeably affect scrolling/paging UI responsiveness. 3869 const int pageSize = 20; 3870 NextButtonListPageEvent *pue = 3871 dynamic_cast<NextButtonListPageEvent*>(event); 3872 if (m_recordingList) 3873 { 3874 int start = pue->getStart(); 3875 while (start < pue->getStart() + pageSize && 3876 start < m_recordingList->GetCount()) 3877 { 3878 ItemVisibleCore(m_recordingList->GetItemAt(start)); 3879 ++start; 3880 } 3881 if (start < m_recordingList->GetCount()) 3882 m_helper.ComputeButtonListPage(start, pue->getGeneration()); 3883 } 3884 } 3848 3885 else if ((MythEvent::Type)(event->type()) == MythEvent::MythEventMessage) 3849 3886 { 3850 3887 MythEvent *me = (MythEvent *)event; -
mythtv/programs/mythfrontend/playbackbox.h
diff --git a/mythtv/programs/mythfrontend/playbackbox.h b/mythtv/programs/mythfrontend/playbackbox.h index c6a9a2d..f7135fd 100644
a b class PlaybackBox : public ScheduleCommon 142 142 void ItemSelected(MythUIButtonListItem *item) 143 143 { UpdateUIListItem(item, true); } 144 144 void ItemVisible(MythUIButtonListItem *item); 145 void ItemVisibleCore(MythUIButtonListItem *item); 145 146 void selected(MythUIButtonListItem *item); 146 147 void PlayFromBookmark(MythUIButtonListItem *item = NULL); 147 148 void PlayFromBeginning(MythUIButtonListItem *item = NULL); -
mythtv/programs/mythfrontend/playbackboxhelper.cpp
diff --git a/mythtv/programs/mythfrontend/playbackboxhelper.cpp b/mythtv/programs/mythfrontend/playbackboxhelper.cpp index 06950e4..3d1d13d 100644
a b AvailableStatusType PBHEventHandler::CheckAvailability(const QStringList &slist) 126 126 return availableStatus; 127 127 } 128 128 129 QEvent::Type NextButtonListPageEvent::kEventType = 130 (QEvent::Type) QEvent::registerEventType(); 131 129 132 bool PBHEventHandler::event(QEvent *e) 130 133 { 131 134 if (e->type() == QEvent::Timer) … … bool PBHEventHandler::event(QEvent *e) 301 304 302 305 return true; 303 306 } 307 else if (me->Message() == "BUTTONLIST_NEXT_PAGE") 308 { 309 int current = me->ExtraData(0).toInt(); 310 int generation = me->ExtraData(1).toInt(); 311 QCoreApplication::postEvent( 312 m_pbh.m_listener, 313 new NextButtonListPageEvent(current, generation)); 314 } 304 315 } 305 316 306 317 return QObject::event(e); … … PlaybackBoxHelper::PlaybackBoxHelper(QObject *listener) : 320 331 MThread("PlaybackBoxHelper"), 321 332 m_listener(listener), m_eventHandler(new PBHEventHandler(*this)), 322 333 // Free Space Tracking Variables 323 m_freeSpaceTotalMB(0ULL), m_freeSpaceUsedMB(0ULL) 334 m_freeSpaceTotalMB(0ULL), m_freeSpaceUsedMB(0ULL), 335 m_buttonListItemCurrent(0), m_buttonListGeneration(0) 324 336 { 325 337 start(); 326 338 m_eventHandler->moveToThread(qthread()); … … QString PlaybackBoxHelper::GetPreviewImage( 479 491 480 492 return token; 481 493 } 494 495 void PlaybackBoxHelper::ComputeButtonListPage(int start, int generation) 496 { 497 // If a specific generation is requested, only honor it if someone 498 // else hasn't already reset the search and updated the current 499 // generation. 500 { 501 QMutexLocker locker(&m_lock); 502 if (generation >= 0 && generation != m_buttonListGeneration) 503 return; 504 // Restart any work in progress 505 if (start == 0) 506 generation = ++m_buttonListGeneration; 507 } 508 LOG(VB_GENERAL, LOG_INFO, 509 QString("Background buttonlist building: start=%1 gen=%2") 510 .arg(start).arg(generation)); 511 QStringList extraData; 512 extraData += QString::number(start); 513 extraData += QString::number(generation); 514 QCoreApplication::postEvent(m_eventHandler, 515 new MythEvent("BUTTONLIST_NEXT_PAGE", 516 extraData)); 517 } -
mythtv/programs/mythfrontend/playbackboxhelper.h
diff --git a/mythtv/programs/mythfrontend/playbackboxhelper.h b/mythtv/programs/mythfrontend/playbackboxhelper.h index a288b8b..a7ad37d 100644
a b class PlaybackBoxHelper : public MThread 53 53 uint64_t GetFreeSpaceTotalMB(void) const; 54 54 uint64_t GetFreeSpaceUsedMB(void) const; 55 55 56 void ComputeButtonListPage(int start, int generation = -1); 57 56 58 private: 57 59 void UpdateFreeSpace(void); 58 60 … … class PlaybackBoxHelper : public MThread 67 69 68 70 // Artwork Variables ////////////////////////////////////////////////////// 69 71 QHash<QString, QString> m_artworkFilenameCache; 72 73 // Background button list loading 74 int m_buttonListItemCurrent; 75 int m_buttonListGeneration; 76 }; 77 78 class NextButtonListPageEvent : public QEvent 79 { 80 public: 81 NextButtonListPageEvent(int start, int generation) : 82 QEvent(kEventType), m_start(start), m_generation(generation) {} 83 84 int getStart() { return m_start; } 85 int getGeneration() { return m_generation; } 86 87 static Type kEventType; 88 89 private: 90 int m_start; 91 int m_generation; 70 92 }; 71 93 72 94 #endif // _FREE_SPACE_H_