Ticket #10161: lazystrings_v13a.patch
File lazystrings_v13a.patch, 15.6 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 8d4de31..dbef0f7 100644
a b void MythUIButtonList::Const(void) 86 86 87 87 m_buttontemplate = NULL; 88 88 89 m_nextItemInited = 0; 90 89 91 SetCanTakeFocus(true); 90 92 91 93 connect(this, SIGNAL(TakingFocus()), this, SLOT(Select())); … … void MythUIButtonList::Reset() 153 155 m_topPosition = 0; 154 156 m_itemCount = 0; 155 157 158 StopInit(); 156 159 Update(); 157 160 MythUIType::Reset(); 158 161 } … … bool MythUIButtonList::gestureEvent(MythGestureEvent *event) 2476 2479 return handled; 2477 2480 } 2478 2481 2482 class NextButtonListPageEvent : public QEvent 2483 { 2484 public: 2485 NextButtonListPageEvent(int start, int pageSize) : 2486 QEvent(kEventType), m_start(start), m_pageSize(pageSize) {} 2487 const int m_start; 2488 const int m_pageSize; 2489 static Type kEventType; 2490 }; 2491 2492 QEvent::Type NextButtonListPageEvent::kEventType = 2493 (QEvent::Type) QEvent::registerEventType(); 2494 2495 void MythUIButtonList::customEvent(QEvent *event) 2496 { 2497 if (event->type() == NextButtonListPageEvent::kEventType) 2498 { 2499 NextButtonListPageEvent *npe = 2500 dynamic_cast<NextButtonListPageEvent*>(event); 2501 int cur = npe->m_start; 2502 for (; cur < npe->m_start + npe->m_pageSize && cur < GetCount(); ++cur) 2503 { 2504 const int loginterval = (cur < 1000 ? 100 : 500); 2505 if (cur % loginterval == 0) 2506 LOG(VB_GENERAL, LOG_INFO, 2507 QString("Build background buttonlist item %1").arg(cur)); 2508 emit itemInited(GetItemAt(cur)); 2509 } 2510 m_nextItemInited = cur; 2511 if (cur < GetCount()) 2512 StartInit(cur, npe->m_pageSize); 2513 } 2514 } 2515 2516 void MythUIButtonList::StartInit(int start, int pageSize) 2517 { 2518 m_nextItemInited = start; 2519 QCoreApplication:: 2520 postEvent(this, new NextButtonListPageEvent(start, pageSize)); 2521 } 2522 2523 int MythUIButtonList::StopInit(void) 2524 { 2525 QCoreApplication:: 2526 removePostedEvents(this, NextButtonListPageEvent::kEventType); 2527 return m_nextItemInited; 2528 } 2529 2479 2530 QPoint MythUIButtonList::GetButtonPosition(int column, int row) const 2480 2531 { 2481 2532 int x = m_contentsRect.x() + -
mythtv/libs/libmythui/mythuibuttonlist.h
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.h b/mythtv/libs/libmythui/mythuibuttonlist.h index d42a204..8b731ef 100644
a b class MUI_PUBLIC MythUIButtonList : public MythUIType 128 128 129 129 virtual bool keyPressEvent(QKeyEvent *); 130 130 virtual bool gestureEvent(MythGestureEvent *event); 131 virtual void customEvent(QEvent *); 131 132 132 133 enum MovementUnit { MoveItem, MoveColumn, MoveRow, MovePage, MoveMax, 133 134 MoveMid, MoveByAmount }; … … class MUI_PUBLIC MythUIButtonList : public MythUIType 184 185 bool FindNext(void); 185 186 bool FindPrev(void); 186 187 188 void StartInit(int start = 0, int pageSize = 20); 189 int StopInit(void); 190 187 191 public slots: 188 192 void Select(); 189 193 void Deselect(); … … class MUI_PUBLIC MythUIButtonList : public MythUIType 192 196 void itemSelected(MythUIButtonListItem* item); 193 197 void itemClicked(MythUIButtonListItem* item); 194 198 void itemVisible(MythUIButtonListItem* item); 199 void itemInited(MythUIButtonListItem* item); 195 200 196 201 protected: 197 202 enum ScrollStyle { ScrollFree, ScrollCenter, ScrollGroupCenter }; … … class MUI_PUBLIC MythUIButtonList : public MythUIType 302 307 bool m_keepSelAtBottom; 303 308 304 309 QList<MythUIButtonListItem*> m_itemList; 310 int m_nextItemInited; 305 311 306 312 bool m_drawFromBottom; 307 313 -
mythtv/programs/mythfrontend/playbackbox.cpp
diff --git a/mythtv/programs/mythfrontend/playbackbox.cpp b/mythtv/programs/mythfrontend/playbackbox.cpp index 2e65654..82c36a5 100644
a b bool PlaybackBox::Create() 542 542 SLOT(PlayFromBookmark(MythUIButtonListItem*))); 543 543 connect(m_recordingList, SIGNAL(itemVisible(MythUIButtonListItem*)), 544 544 SLOT(ItemVisible(MythUIButtonListItem*))); 545 connect(m_recordingList, SIGNAL(itemInited(MythUIButtonListItem*)), 546 SLOT(ItemInited(MythUIButtonListItem*))); 545 547 546 548 // connect up timers... 547 549 connect(m_artTimer[kArtworkFanart], SIGNAL(timeout()), SLOT(fanartLoad())); … … void PlaybackBox::UpdateUIListItem(MythUIButtonListItem *item, 890 892 } 891 893 } 892 894 895 void PlaybackBox::ItemInited(MythUIButtonListItem *item) 896 { 897 ProgramInfo *pginfo = qVariantValue<ProgramInfo*>(item->GetData()); 898 if (item->GetText("is_item_initialized").isNull()) 899 { 900 QMap<AudioProps, QString> audioFlags; 901 audioFlags[AUD_DOLBY] = "dolby"; 902 audioFlags[AUD_SURROUND] = "surround"; 903 audioFlags[AUD_STEREO] = "stereo"; 904 audioFlags[AUD_MONO] = "mono"; 905 906 QMap<VideoProps, QString> videoFlags; 907 videoFlags[VID_1080] = "hd1080"; 908 videoFlags[VID_720] = "hd720"; 909 videoFlags[VID_HDTV] = "hdtv"; 910 videoFlags[VID_WIDESCREEN] = "widescreen"; 911 912 QMap<SubtitleTypes, QString> subtitleFlags; 913 subtitleFlags[SUB_SIGNED] = "deafsigned"; 914 subtitleFlags[SUB_ONSCREEN] = "onscreensub"; 915 subtitleFlags[SUB_NORMAL] = "subtitles"; 916 subtitleFlags[SUB_HARDHEAR] = "cc"; 917 918 QString groupname = 919 m_groupList->GetItemCurrent()->GetData().toString(); 920 921 QString state = extract_main_state(*pginfo, m_player); 922 923 item->SetFontState(state); 924 925 InfoMap infoMap; 926 pginfo->ToMap(infoMap); 927 item->SetTextFromMap(infoMap); 928 929 QString tempSubTitle = extract_subtitle(*pginfo, groupname); 930 931 if (groupname == pginfo->GetTitle().toLower()) 932 item->SetText(tempSubTitle, "titlesubtitle"); 933 934 item->DisplayState(state, "status"); 935 936 item->DisplayState(QString::number(pginfo->GetStars(10)), 937 "ratingstate"); 938 939 SetItemIcons(item, pginfo); 940 941 QMap<AudioProps, QString>::iterator ait; 942 for (ait = audioFlags.begin(); ait != audioFlags.end(); ++ait) 943 { 944 if (pginfo->GetAudioProperties() & ait.key()) 945 item->DisplayState(ait.value(), "audioprops"); 946 } 947 948 QMap<VideoProps, QString>::iterator vit; 949 for (vit = videoFlags.begin(); vit != videoFlags.end(); ++vit) 950 { 951 if (pginfo->GetVideoProperties() & vit.key()) 952 item->DisplayState(vit.value(), "videoprops"); 953 } 954 955 QMap<SubtitleTypes, QString>::iterator sit; 956 for (sit = subtitleFlags.begin(); sit != subtitleFlags.end(); ++sit) 957 { 958 if (pginfo->GetSubtitleType() & sit.key()) 959 item->DisplayState(sit.value(), "subtitletypes"); 960 } 961 962 item->DisplayState(pginfo->GetCategoryType(), "categorytype"); 963 964 // Mark this button list item as initialized. 965 item->SetText("yes", "is_item_initialized"); 966 } 967 968 } 969 893 970 void PlaybackBox::ItemVisible(MythUIButtonListItem *item) 894 971 { 895 972 ProgramInfo *pginfo = qVariantValue<ProgramInfo*>(item->GetData()); 896 973 974 ItemInited(item); 897 975 // Job status (recording, transcoding, flagging) 898 976 QString job = extract_job_state(*pginfo); 899 977 item->DisplayState(job, "jobstate"); … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1316 1394 1317 1395 ProgramList &progList = *pmit; 1318 1396 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 1397 ProgramList::iterator it = progList.begin(); 1338 1398 for (; it != progList.end(); ++it) 1339 1399 { … … void PlaybackBox::updateRecList(MythUIButtonListItem *sel_item) 1341 1401 (*it)->GetAvailableStatus() == asDeleted) 1342 1402 continue; 1343 1403 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"); 1404 new PlaybackBoxListItem(this, m_recordingList, *it); 1388 1405 } 1406 m_recordingList->StartInit(); 1389 1407 1390 1408 if (m_noRecordingsText) 1391 1409 { … … bool PlaybackBox::Play( 2418 2436 ProgramInfo tvrec(rec); 2419 2437 2420 2438 m_playingSomething = true; 2439 int initIndex = m_recordingList->StopInit(); 2421 2440 2422 2441 uint flags = 2423 2442 (inPlaylist ? kStartTVInPlayList : kStartTVNoFlags) | … … bool PlaybackBox::Play( 2427 2446 playCompleted = TV::StartTV(&tvrec, flags); 2428 2447 2429 2448 m_playingSomething = false; 2449 m_recordingList->StartInit(initIndex); 2430 2450 2431 2451 if (inPlaylist && !m_playListPlay.empty()) 2432 2452 { -
mythtv/programs/mythfrontend/playbackbox.h
diff --git a/mythtv/programs/mythfrontend/playbackbox.h b/mythtv/programs/mythfrontend/playbackbox.h index c6a9a2d..6ac220a 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 ItemInited(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/proglist.cpp
diff --git a/mythtv/programs/mythfrontend/proglist.cpp b/mythtv/programs/mythfrontend/proglist.cpp index ddda2af..b4b855a 100644
a b ProgLister::ProgLister(MythScreenStack *parent, ProgListType pltype, 44 44 m_viewTextList(), 45 45 46 46 m_itemList(), 47 m_itemListSave(), 47 48 m_schedList(), 48 49 49 50 m_typeList(), … … ProgLister::ProgLister( 93 94 m_viewTextList(), 94 95 95 96 m_itemList(), 97 m_itemListSave(), 96 98 m_schedList(), 97 99 98 100 m_typeList(), … … ProgLister::ProgLister( 115 117 ProgLister::~ProgLister() 116 118 { 117 119 m_itemList.clear(); 120 m_itemListSave.clear(); 118 121 gCoreContext->removeListener(this); 119 122 } 120 123 … … bool ProgLister::Create() 139 142 connect(m_progList, SIGNAL(itemSelected(MythUIButtonListItem*)), 140 143 this, SLOT( HandleSelected( MythUIButtonListItem*))); 141 144 145 connect(m_progList, SIGNAL(itemVisible(MythUIButtonListItem*)), 146 this, SLOT( HandleVisible( MythUIButtonListItem*))); 147 148 connect(m_progList, SIGNAL(itemInited(MythUIButtonListItem*)), 149 this, SLOT( HandleVisible( MythUIButtonListItem*))); 150 142 151 connect(m_progList, SIGNAL(itemClicked(MythUIButtonListItem*)), 143 152 this, SLOT( HandleClicked())); 144 153 … … void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 1342 1351 selectedP = &selected; 1343 1352 } 1344 1353 1354 // Save a copy of m_itemList so that deletion of the ProgramInfo 1355 // objects can be deferred until background processing of old 1356 // ProgramInfo objects has completed. 1357 m_itemListSave.clear(); 1358 m_itemListSave = m_itemList; 1359 m_itemList.setAutoDelete(false); 1345 1360 m_itemList.clear(); 1361 m_itemList.setAutoDelete(true); 1346 1362 1347 1363 if (m_type == plPreviouslyRecorded) 1348 1364 { … … void ProgLister::RestoreSelection(const ProgramInfo *selected, 1489 1505 m_progList->SetItemCurrent(i + 1, i + 1 - selectedOffset); 1490 1506 } 1491 1507 1492 void ProgLister:: UpdateButtonList(void)1508 void ProgLister::HandleVisible(MythUIButtonListItem *item) 1493 1509 { 1494 ProgramList::const_iterator it = m_itemList.begin(); 1495 for (; it != m_itemList.end(); ++it) 1496 { 1497 MythUIButtonListItem *item = 1498 new MythUIButtonListItem( 1499 m_progList, "", qVariantFromValue(*it)); 1510 ProgramInfo *pginfo = qVariantValue<ProgramInfo*>(item->GetData()); 1500 1511 1512 if (item->GetText("is_item_initialized").isNull()) 1513 { 1501 1514 InfoMap infoMap; 1502 (**it).ToMap(infoMap);1515 pginfo->ToMap(infoMap); 1503 1516 1504 QString state = toUIState( (**it).GetRecordingStatus());1517 QString state = toUIState(pginfo->GetRecordingStatus()); 1505 1518 if ((state == "warning") && (plPreviouslyRecorded == m_type)) 1506 1519 state = "disabled"; 1507 1520 … … void ProgLister::UpdateButtonList(void) 1509 1522 1510 1523 if (m_type == plTitle) 1511 1524 { 1512 QString tempSubTitle = (**it).GetSubtitle();1525 QString tempSubTitle = pginfo->GetSubtitle(); 1513 1526 if (tempSubTitle.trimmed().isEmpty()) 1514 tempSubTitle = (**it).GetTitle();1527 tempSubTitle = pginfo->GetTitle(); 1515 1528 item->SetText(tempSubTitle, "titlesubtitle", state); 1516 1529 } 1517 1530 1518 item->DisplayState( 1519 QString::number((**it).GetStars(10)),"ratingstate");1531 item->DisplayState(QString::number(pginfo->GetStars(10)), 1532 "ratingstate"); 1520 1533 1521 1534 item->DisplayState(state, "status"); 1535 1536 // Mark this button list item as initialized. 1537 item->SetText("yes", "is_item_initialized"); 1522 1538 } 1539 } 1540 1541 void ProgLister::UpdateButtonList(void) 1542 { 1543 ProgramList::const_iterator it = m_itemList.begin(); 1544 for (; it != m_itemList.end(); ++it) 1545 new MythUIButtonListItem(m_progList, "", qVariantFromValue(*it)); 1546 m_progList->StartInit(); 1523 1547 1524 1548 if (m_positionText) 1525 1549 { -
mythtv/programs/mythfrontend/proglist.h
diff --git a/mythtv/programs/mythfrontend/proglist.h b/mythtv/programs/mythfrontend/proglist.h index 1fc9020..5ecc84c 100644
a b class ProgLister : public ScheduleCommon 50 50 51 51 protected slots: 52 52 void HandleSelected(MythUIButtonListItem *item); 53 void HandleVisible(MythUIButtonListItem *item); 53 54 void HandleClicked(void); 54 55 55 56 void DeleteOldEpisode(bool ok); … … class ProgLister : public ScheduleCommon 115 116 QStringList m_viewTextList; 116 117 117 118 ProgramList m_itemList; 119 ProgramList m_itemListSave; 118 120 ProgramList m_schedList; 119 121 120 122 QStringList m_typeList;