Refactor cRecMenuFavorites

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

View File

@ -1501,25 +1501,20 @@ 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;
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); const cString line1 = cString::sprintf("%s", (numFavorites > 0) ? tr("Favorites") : tr("No Favorites available"));
SetFooter(button);
AddHeader(new cRecMenuItemInfo(*line1, 1, "", "", "", width - 2 * border, true));
CreateFavoritesMenuItems();
// AddFooter has to be after CreateFavoritesMenuItems because of numFavorites
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)
@ -1568,7 +1563,7 @@ 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) {