From 37a31d07684d06417a9b1abe7f988dd9ec828882 Mon Sep 17 00:00:00 2001 From: kamel5 Date: Sat, 9 Nov 2019 15:09:37 +0100 Subject: [PATCH] Refactor cRecMenuSearchConfirmTimer --- recmenus.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/recmenus.c b/recmenus.c index 71accdc..80b696c 100644 --- a/recmenus.c +++ b/recmenus.c @@ -1259,27 +1259,27 @@ cRecMenuSearchNothingFound::cRecMenuSearchNothingFound(std::string searchString, } // --- cRecMenuSearchConfirmTimer --------------------------------------------------------- -cRecMenuSearchConfirmTimer::cRecMenuSearchConfirmTimer(const cEvent *event, eRecMenuState nextAction) { +cRecMenuSearchConfirmTimer::cRecMenuSearchConfirmTimer(const cEvent *event, eRecMenuState nextAction) { // OK SetWidthPercent(50); + + const cChannels *channels = NULL; #if VDRVERSNUM >= 20301 + { LOCK_CHANNELS_READ; - const cString channelName = Channels->GetByChannelID(event->ChannelID())->Name(); + channels = Channels; + } #else - const cString channelName = Channels.GetByChannelID(event->ChannelID())->Name(); + channels = &Channels; #endif - cString message = tr("Timer created"); - cString text = cString::sprintf("%s\n%s\n%s %s - %s\n%s", - *message, - *channelName, - *event->GetDateString(), - *event->GetTimeString(), - *event->GetEndTimeString(), - event->Title() - ); - cRecMenuItemInfo *infoItem = new cRecMenuItemInfo(*text); - infoItem->CalculateHeight(width - 2 * border); - AddMenuItem(infoItem); - AddMenuItem(new cRecMenuItemButton(tr("OK"), nextAction, true, true)); + const cString channelName = channels->GetByChannelID(event->ChannelID())->Name(); + + const cString line1 = tr("Timer created"); + const cString line3 = cString::sprintf("%s %s - %s", *event->GetDateString(), *event->GetTimeString(), *event->GetEndTimeString()); + const cString line4 = (event && event->Title()) ? cString::sprintf("\"%s\"", event->Title()) : ""; + + AddHeader(new cRecMenuItemInfo(*line1, 4, *channelName, *line3, *line4, width - 2 * border)); + AddFooter(new cRecMenuItemButton(tr("OK"), nextAction, true, true)); + CalculateHeight(); CreatePixmap(); Arrange();