Refactor cRecMenuSearchResults

This commit is contained in:
kamel5 2019-11-09 14:54:02 +01:00
parent 5cc50e465d
commit 412a78a112

View File

@ -991,7 +991,7 @@ cRecMenuSearchTimerCreateConfirm::cRecMenuSearchTimerCreateConfirm(bool success)
AddHeader(new cRecMenuItemInfo(*line1, i, *line2, "", "", width - 2 * border)); AddHeader(new cRecMenuItemInfo(*line1, i, *line2, "", "", width - 2 * border));
AddFooter(new cRecMenuItemButton(tr("OK"), rmsClose, true)); AddFooter(new cRecMenuItemButton(tr("OK"), rmsClose, true));
CalculateHeight(); CalculateHeight();
CreatePixmap(); CreatePixmap();
Arrange(); Arrange();
@ -1200,32 +1200,32 @@ Epgsearch_searchresults_v1_0 cRecMenuSearch::GetEPGSearchStruct(void) {
// --- cRecMenuSearchResults --------------------------------------------------------- // --- cRecMenuSearchResults ---------------------------------------------------------
cRecMenuSearchResults::cRecMenuSearchResults(std::string searchString, const cEvent **searchResults, int numResults) { cRecMenuSearchResults::cRecMenuSearchResults(std::string searchString, const cEvent **searchResults, int numResults) { // OK
this->searchResults = searchResults;
SetWidthPercent(70); SetWidthPercent(70);
this->searchString = searchString; this->searchString = searchString;
this->searchResults = searchResults;
this->numResults = numResults; this->numResults = numResults;
cString message1 = tr("search results for");
cString message2 = tr("search result for"); const cString line1 = cString::sprintf("%d %s:", numResults, (numResults > 1) ? tr("search results for") : tr("search result for"));
cString infoText = cString::sprintf("%d %s:\n\"%s\"", numResults, (numResults>1)?(*message1):(*message2), searchString.c_str()); const cString line2 = cString::sprintf("\"%s\"", searchString.c_str());
cRecMenuItem *infoItem = new cRecMenuItemInfo(*infoText, true);
infoItem->CalculateHeight(width - 2 * border); AddHeader(new cRecMenuItemInfo(*line1, 2, *line2, "", "", width - 2 * border, true));
SetHeader(infoItem); AddFooter(new cRecMenuItemButtonYesNo(tr("Adapt Search"), tr("Close"), rmsSearch, rmsClose, false));
cRecMenuItem *buttons = new cRecMenuItemButtonYesNo(tr("Adapt Search"), tr("Close"), rmsSearch, rmsClose, false);
SetFooter(buttons);
if (searchResults && (numResults > 0)) { if (searchResults && (numResults > 0)) {
for (int i=0; i<numResults; i++) { for (int i = 0; i < numResults; i++) {
if (!AddMenuItemInitial(new cRecMenuItemEvent(searchResults[i], rmsSearchShowInfo, rmsSearchRecord, (i==0)?true:false))) if (!AddMenuItemInitial(new cRecMenuItemEvent(searchResults[i], rmsSearchShowInfo, rmsSearchRecord, (i == 0) ? true : false)))
break; break;
} }
} }
CalculateHeight(); CalculateHeight();
CreatePixmap(); CreatePixmap();
Arrange(); Arrange();
} }
cRecMenuItem *cRecMenuSearchResults::GetMenuItem(int number) { cRecMenuItem *cRecMenuSearchResults::GetMenuItem(int number) {
if ((number >= 0) && (number < numResults)) { if ((number >= 0) && (number < numResults)) {
cRecMenuItem *result = new cRecMenuItemEvent(searchResults[number], rmsSearchShowInfo, rmsSearchRecord, false); cRecMenuItem *result = new cRecMenuItemEvent(searchResults[number], rmsSearchShowInfo, rmsSearchRecord, false);
return result; return result;
@ -1238,10 +1238,9 @@ int cRecMenuSearchResults::GetTotalNumMenuItems(void) {
} }
const cEvent *cRecMenuSearchResults::GetEvent(void) { const cEvent *cRecMenuSearchResults::GetEvent(void) {
const cEvent *ev = NULL;
if (cRecMenuItemEvent *activeItem = dynamic_cast<cRecMenuItemEvent*>(GetActiveMenuItem())) if (cRecMenuItemEvent *activeItem = dynamic_cast<cRecMenuItemEvent*>(GetActiveMenuItem()))
ev = activeItem->GetEventValue(); return activeItem->GetEventValue();
return ev; return NULL;
} }