Refactor cRecMenuSearchTimers

This commit is contained in:
kamel5 2019-11-09 14:01:19 +01:00
parent a4cc2a4fa8
commit 54ce728fa5
2 changed files with 16 additions and 27 deletions

View File

@ -665,39 +665,29 @@ TVGuideEPGSearchTemplate cRecMenuSearchTimerTemplates::GetTemplate(void) {
} }
// --- cRecMenuSearchTimers --------------------------------------------------------- // --- cRecMenuSearchTimers ---------------------------------------------------------
cRecMenuSearchTimers::cRecMenuSearchTimers(std::vector<cTVGuideSearchTimer> searchTimers) { cRecMenuSearchTimers::cRecMenuSearchTimers(std::vector<cTVGuideSearchTimer> searchTimers) { // OK
SetWidthPercent(70);
this->searchTimers = searchTimers; this->searchTimers = searchTimers;
numSearchTimers = searchTimers.size(); numSearchTimers = searchTimers.size();
SetWidthPercent(70);
cString headline; const cString line1 = (numSearchTimers > 0) ? tr("EPGSearch Search Timers") : tr("No Search Timers Configured");
AddHeader(new cRecMenuItemInfo(*line1, 1, "", "", "", width - 2 * border, true));
AddFooter(new cRecMenuItemButton(tr("Close"), rmsClose, (!numSearchTimers) ? true : false));
if (numSearchTimers > 0) { if (numSearchTimers > 0) {
headline = tr("EPGSearch Search Timers"); for (int i = 0; i < numSearchTimers; i++) {
} else { if (!AddMenuItemInitial(new cRecMenuItemSearchTimer(searchTimers[i], rmsSearchTimerTest, rmsSearchTimerEdit, rmsSearchTimerDeleteConfirm, (i == 0) ? true : false)))
headline = tr("No Search Timers Configured"); break;
}
} }
cRecMenuItemInfo *infoItem = new cRecMenuItemInfo(*headline, true);
infoItem->CalculateHeight(width - 2 * border);
SetHeader(infoItem);
cRecMenuItem *button = new cRecMenuItemButton(tr("Close"), rmsClose, (!numSearchTimers)?true:false);
SetFooter(button);
if (numSearchTimers > 0)
SetMenuItems();
CalculateHeight(); CalculateHeight();
CreatePixmap(); CreatePixmap();
Arrange(); Arrange();
} }
cRecMenuSearchTimers::~cRecMenuSearchTimers(void) {
}
void cRecMenuSearchTimers::SetMenuItems(void) {
for (int i = 0; i < numSearchTimers; i++) {
if (!AddMenuItemInitial(new cRecMenuItemSearchTimer(searchTimers[i], rmsSearchTimerTest, rmsSearchTimerEdit, rmsSearchTimerDeleteConfirm, (i==0)?true:false)))
break;
}
}
cTVGuideSearchTimer cRecMenuSearchTimers::GetSearchTimer(void) { cTVGuideSearchTimer cRecMenuSearchTimers::GetSearchTimer(void) {
cRecMenuItemSearchTimer *activeItem = dynamic_cast<cRecMenuItemSearchTimer*>(GetActiveMenuItem()); cRecMenuItemSearchTimer *activeItem = dynamic_cast<cRecMenuItemSearchTimer*>(GetActiveMenuItem());
return activeItem->GetTimer(); return activeItem->GetTimer();

View File

@ -205,13 +205,12 @@ class cRecMenuSearchTimers: public cRecMenu {
private: private:
int numSearchTimers; int numSearchTimers;
std::vector<cTVGuideSearchTimer> searchTimers; std::vector<cTVGuideSearchTimer> searchTimers;
void SetMenuItems(void);
public: public:
cRecMenuSearchTimers(std::vector<cTVGuideSearchTimer> searchTimers); cRecMenuSearchTimers(std::vector<cTVGuideSearchTimer> searchTimers);
virtual ~cRecMenuSearchTimers(void) {};
cRecMenuItem *GetMenuItem(int number); cRecMenuItem *GetMenuItem(int number);
int GetTotalNumMenuItems(void); int GetTotalNumMenuItems(void);
cTVGuideSearchTimer GetSearchTimer(void); cTVGuideSearchTimer GetSearchTimer(void);
virtual ~cRecMenuSearchTimers(void);
}; };
// --- cRecMenuSearchTimerEdit --------------------------------------------------------- // --- cRecMenuSearchTimerEdit ---------------------------------------------------------