Refactor cRecMenuSearchResults

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

View File

@ -1200,26 +1200,26 @@ 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->numResults = numResults;
cString message1 = tr("search results for");
cString message2 = tr("search result for");
cString infoText = cString::sprintf("%d %s:\n\"%s\"", numResults, (numResults>1)?(*message1):(*message2), searchString.c_str());
cRecMenuItem *infoItem = new cRecMenuItemInfo(*infoText, true);
infoItem->CalculateHeight(width - 2 * border);
SetHeader(infoItem);
cRecMenuItem *buttons = new cRecMenuItemButtonYesNo(tr("Adapt Search"), tr("Close"), rmsSearch, rmsClose, false); this->searchString = searchString;
SetFooter(buttons); this->searchResults = searchResults;
this->numResults = numResults;
const cString line1 = cString::sprintf("%d %s:", numResults, (numResults > 1) ? tr("search results for") : tr("search result for"));
const cString line2 = cString::sprintf("\"%s\"", searchString.c_str());
AddHeader(new cRecMenuItemInfo(*line1, 2, *line2, "", "", width - 2 * border, true));
AddFooter(new cRecMenuItemButtonYesNo(tr("Adapt Search"), tr("Close"), rmsSearch, rmsClose, false));
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();
@ -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;
} }