From e4ef6c4ee5a5b3d2b75a553fa5bc0e7d4d964bcb Mon Sep 17 00:00:00 2001 From: kamel5 Date: Sat, 9 Nov 2019 13:06:00 +0100 Subject: [PATCH] Refactor cRecMenuConfirmRerunUsed --- recmenus.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/recmenus.c b/recmenus.c index b421faf..87c871b 100644 --- a/recmenus.c +++ b/recmenus.c @@ -380,33 +380,29 @@ cRecMenuNoRerunsFound::cRecMenuNoRerunsFound(cString searchString) { // OK } // --- cRecMenuConfirmRerunUsed --------------------------------------------------------- -cRecMenuConfirmRerunUsed::cRecMenuConfirmRerunUsed(const cEvent *original, const cEvent *replace) { +cRecMenuConfirmRerunUsed::cRecMenuConfirmRerunUsed(const cEvent *original, const cEvent *replace) { // OK SetWidthPercent(70); + + const cChannels *channels = NULL; #if VDRVERSNUM >= 20301 + { LOCK_CHANNELS_READ; - const cString channelOrig = Channels->GetByChannelID(original->ChannelID())->Name(); - const cString channelReplace = Channels->GetByChannelID(replace->ChannelID())->Name(); + channels = Channels; + } #else - const cString channelOrig = Channels.GetByChannelID(original->ChannelID())->Name(); - const cString channelReplace = Channels.GetByChannelID(replace->ChannelID())->Name(); + channels = &Channels; #endif - cString message1 = tr("Timer for"); - cString message2 = tr("replaced by rerun"); - cString text = cString::sprintf("%s\n\"%s\", %s %s, %s\n%s\n\"%s\", %s %s, %s", - *message1, - original->Title(), - *original->GetDateString(), - *original->GetTimeString(), - *channelOrig, - *message2, - replace->Title(), - *replace->GetDateString(), - *replace->GetTimeString(), - *channelReplace); - cRecMenuItemInfo *infoItem = new cRecMenuItemInfo(*text); - infoItem->CalculateHeight(width - 2 * border); - AddMenuItem(infoItem); - AddMenuItem(new cRecMenuItemButton(tr("OK"), rmsTimerConflicts, true, true)); + const cString channelOrig = channels->GetByChannelID(original->ChannelID())->Name(); + const cString channelReplace = channels->GetByChannelID(replace->ChannelID())->Name(); + + const cString line1 = tr("Timer for"); + const cString line2 = *cString::sprintf("\"%s\", %s %s, %s", original->Title(), *original->GetDateString(), *original->GetTimeString(), *channelOrig); + const cString line3 = tr("replaced by rerun"); + const cString line4 = *cString::sprintf("\"%s\", %s %s, %s", replace->Title(), *replace->GetDateString(), *replace->GetTimeString(), *channelReplace); + + AddHeader(new cRecMenuItemInfo(*line1, 4, *line2, *line3, *line4, width - 2 * border)); + AddFooter(new cRecMenuItemButton(tr("OK"), rmsTimerConflicts, true, true)); + CalculateHeight(); CreatePixmap(); Arrange();