Refactor cRecMenuFavorites

This commit is contained in:
kamel5 2019-11-09 15:47:32 +01:00
parent bb7d03c7ed
commit e707ec7d4f

View File

@ -1501,28 +1501,23 @@ cRecMenuRecordingSearchNotFound::cRecMenuRecordingSearchNotFound(std::string sea
******************************************************************************************/ ******************************************************************************************/
// --- cRecMenuFavorites --------------------------------------------------------- // --- cRecMenuFavorites ---------------------------------------------------------
cRecMenuFavorites::cRecMenuFavorites(std::vector<cTVGuideSearchTimer> favorites) { // OK
SetWidthPercent(70);
cRecMenuFavorites::cRecMenuFavorites(std::vector<cTVGuideSearchTimer> favorites) {
deleteMenuItems = false; deleteMenuItems = false;
this->favorites = favorites; this->favorites = favorites;
const cString line1 = cString::sprintf("%s", (numFavorites > 0) ? tr("Favorites") : tr("No Favorites available"));
AddHeader(new cRecMenuItemInfo(*line1, 1, "", "", "", width - 2 * border, true));
CreateFavoritesMenuItems(); CreateFavoritesMenuItems();
numFavorites = myMenuItems.size();
SetWidthPercent(70);
cString header;
if (numFavorites > 0) {
header = tr("Favorites");
} else {
header = tr("No Favorites available");
}
cRecMenuItemInfo *headerItem = new cRecMenuItemInfo(*header, true);
headerItem->CalculateHeight(width - 2 * border);
SetHeader(headerItem);
cRecMenuItem *button = new cRecMenuItemButton(tr("Close"), rmsClose, (numFavorites==0)?true:false); // AddFooter has to be after CreateFavoritesMenuItems because of numFavorites
SetFooter(button); AddFooter(new cRecMenuItemButton(tr("Close"), rmsClose, (numFavorites) ? false : true));
for (int i=0; i<numFavorites; i++) { for (int i = 0; i < numFavorites; i++) {
if (i==0) if (i == 0)
myMenuItems[i]->setActive(); myMenuItems[i]->setActive();
if (!AddMenuItemInitial(myMenuItems[i])) if (!AddMenuItemInitial(myMenuItems[i]))
break; break;
@ -1568,11 +1563,11 @@ void cRecMenuFavorites::CreateFavoritesMenuItems(void) {
for (int i = 0; i < numAdditionalFavs; i++) { for (int i = 0; i < numAdditionalFavs; i++) {
myMenuItems.push_back(new cRecMenuItemFavorite(favorites[i], rmsSearchTimerTest, false)); myMenuItems.push_back(new cRecMenuItemFavorite(favorites[i], rmsSearchTimerTest, false));
} }
numFavorites = myMenuItems.size();
} }
std::string cRecMenuFavorites::NiceTime(int favTime) { std::string cRecMenuFavorites::NiceTime(int favTime) {
int hours = favTime/100; int hours = favTime / 100;
int mins = favTime - hours * 100; int mins = favTime - hours * 100;
return *cString::sprintf("%02d:%02d", hours, mins); return *cString::sprintf("%02d:%02d", hours, mins);
} }