Eliminate InitMenuItems in cRecMenuSearchTimerEdit

This commit is contained in:
kamel5 2019-06-17 13:06:07 +02:00
parent 5b1e174316
commit 1c591b5408
2 changed files with 23 additions and 25 deletions

View File

@ -723,6 +723,7 @@ int cRecMenuSearchTimers::GetTotalNumMenuItems(void) {
// --- cRecMenuSearchTimerEdit --------------------------------------------------------- // --- cRecMenuSearchTimerEdit ---------------------------------------------------------
cRecMenuSearchTimerEdit::cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups) { cRecMenuSearchTimerEdit::cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups) {
init = true;
deleteMenuItems = false; deleteMenuItems = false;
this->searchTimer = searchTimer; this->searchTimer = searchTimer;
this->channelGroups = channelGroups; this->channelGroups = channelGroups;
@ -776,7 +777,6 @@ cRecMenuSearchTimerEdit::cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer
SetHeader(infoItem); SetHeader(infoItem);
cRecMenuItemButtonYesNo *footerButton = new cRecMenuItemButtonYesNo(tr("Save Search Timer"), tr("Cancel"), rmsSearchTimerSave, rmsSearchTimers, false); cRecMenuItemButtonYesNo *footerButton = new cRecMenuItemButtonYesNo(tr("Save Search Timer"), tr("Cancel"), rmsSearchTimerSave, rmsSearchTimers, false);
SetFooter(footerButton); SetFooter(footerButton);
InitMenuItems();
CreateMenuItems(); CreateMenuItems();
} }
@ -805,13 +805,19 @@ int cRecMenuSearchTimerEdit::SplitChannelGroups(std::vector<std::string> *channe
return j; return j;
} }
void cRecMenuSearchTimerEdit::InitMenuItems(void) { void cRecMenuSearchTimerEdit::CreateMenuItems(void) {
dsyslog ("%s %s %d\n", __FILE__, __func__, __LINE__);
useChannelPos = 6; int activeMenuItem = 0;
useTimePos = 7;
useDayOfWeekPos = 8; if (mainMenuItems.size() > 0) {
avoidRepeatsPos = 14; for (long unsigned int index = 0; index < mainMenuItems.size(); index++) {
if (mainMenuItems[index]->isActive()) {
activeMenuItem = index;
break;
}
}
mainMenuItems.clear();
}
mainMenuItems.push_back(new cRecMenuItemText(tr("Search String"), searchString, TEXTINPUTLENGTH, false, searchString)); mainMenuItems.push_back(new cRecMenuItemText(tr("Search String"), searchString, TEXTINPUTLENGTH, false, searchString));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Active"), timerActive, false, false, &timerActive, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Active"), timerActive, false, false, &timerActive, rmsSearchTimerSave));
@ -856,36 +862,28 @@ void cRecMenuSearchTimerEdit::InitMenuItems(void) {
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Title"), compareTitle, false, false, &compareTitle, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Title"), compareTitle, false, false, &compareTitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Subtitle"), compareSubtitle, false, false, &compareSubtitle, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Subtitle"), compareSubtitle, false, false, &compareSubtitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Description"), compareSummary, false, false, &compareSummary, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Description"), compareSummary, false, false, &compareSummary, rmsSearchTimerSave));
}
void cRecMenuSearchTimerEdit::CreateMenuItems(void) {
dsyslog ("%s %s %d\n", __FILE__, __func__, __LINE__);
bool reDraw = false; bool reDraw = false;
if (GetCurrentNumMenuItems() > 0) { if (GetCurrentNumMenuItems() > 0) {
InitMenu(false); InitMenu(false);
currentMenuItems.clear();
reDraw = true; reDraw = true;
} }
int numMainMenuItems = mainMenuItems.size(); numMenuItems = mainMenuItems.size();
for (int i = 0; i < numMainMenuItems; i++) {
currentMenuItems.push_back(mainMenuItems[i]);
}
int numMenuItemsAll = currentMenuItems.size();
int start = GetStartIndex(); int start = GetStartIndex();
for (int i = start; i < numMenuItemsAll; i++) { for (int i = start; i < numMenuItems; i++) {
if ((i == start) && !reDraw) {
currentMenuItems[i]->setActive();
}
if (!AddMenuItemInitial(currentMenuItems[i])) { if (!AddMenuItemInitial(currentMenuItems[i])) {
break; break;
} }
} }
numMenuItems = currentMenuItems.size(); if (reDraw)
CalculateHeight(); mainMenuItems[activeMenuItem]->setActive();
if (init) {
init = !init;
}
CalculateHeight(!reDraw);
CreatePixmap(); CreatePixmap();
Arrange(); Arrange();
} }

View File

@ -218,6 +218,7 @@ private:
std::vector<std::string> channelgroups; std::vector<std::string> channelgroups;
std::vector<cRecMenuItem*> mainMenuItems; std::vector<cRecMenuItem*> mainMenuItems;
std::vector<cRecMenuItem*> currentMenuItems; std::vector<cRecMenuItem*> currentMenuItems;
bool init;
int numMenuItems; int numMenuItems;
int useChannelPos; int useChannelPos;
int useTimePos; int useTimePos;
@ -252,7 +253,6 @@ private:
bool compareSubtitle; bool compareSubtitle;
bool compareSummary; bool compareSummary;
bool useInFavorites; bool useInFavorites;
void InitMenuItems(void);
int SplitChannelGroups(std::vector<std::string> *channelGroups, std::vector<std::string> *channelgroups); int SplitChannelGroups(std::vector<std::string> *channelGroups, std::vector<std::string> *channelgroups);
public: public:
cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups); cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups);