Rework cRecMenuItemChannelChooser

This commit is contained in:
kamel5 2019-07-18 16:41:04 +02:00
parent a1aa300259
commit 31f72f2ad8
3 changed files with 29 additions and 42 deletions

View File

@ -1943,14 +1943,21 @@ eRecMenuState cRecMenuItemEvent::ProcessKey(eKeys Key) {
// --- cRecMenuItemChannelChooser ------------------------------------------------------- // --- cRecMenuItemChannelChooser -------------------------------------------------------
cRecMenuItemChannelChooser::cRecMenuItemChannelChooser(cString text, cRecMenuItemChannelChooser::cRecMenuItemChannelChooser(cString text,
const cChannel *initialChannel,
bool active, bool active,
int *callback, int *callback,
eRecMenuState action) { eRecMenuState action) {
selectable = true; selectable = true;
this->text = text; this->text = text;
this->channel = initialChannel; #if VDRVERSNUM >= 20301
if (initialChannel) {
LOCK_CHANNELS_READ;
channels = Channels;
}
#else
channels = &Channels;
#endif
this->channel = channels->GetByNumber(*callback);
if (callback)
initialChannelSet = true; initialChannelSet = true;
else else
initialChannelSet = false; initialChannelSet = false;
@ -2029,12 +2036,6 @@ eRecMenuState cRecMenuItemChannelChooser::ProcessKey(eKeys Key) {
if (!channel) if (!channel)
return rmsConsumed; return rmsConsumed;
const cChannel *prev = channel; const cChannel *prev = channel;
#if VDRVERSNUM >= 20301
LOCK_CHANNELS_READ;
const cChannels* channels = Channels;
#else
const cChannels* channels = &Channels;
#endif
const cChannel *firstChannel = channels->First(); const cChannel *firstChannel = channels->First();
if(firstChannel->GroupSep()) if(firstChannel->GroupSep())
firstChannel = channels->Next(firstChannel); firstChannel = channels->Next(firstChannel);
@ -2060,12 +2061,6 @@ eRecMenuState cRecMenuItemChannelChooser::ProcessKey(eKeys Key) {
break; } break; }
case kRight: { case kRight: {
fresh = true; fresh = true;
#if VDRVERSNUM >= 20301
LOCK_CHANNELS_READ;
const cChannels* channels = Channels;
#else
const cChannels* channels = &Channels;
#endif
if (!channel) { if (!channel) {
channel = channels->First(); channel = channels->First();
if(channel->GroupSep()) if(channel->GroupSep())
@ -2094,12 +2089,7 @@ eRecMenuState cRecMenuItemChannelChooser::ProcessKey(eKeys Key) {
fresh = false; fresh = false;
} }
channelNumber = channelNumber * 10 + (Key - k0); channelNumber = channelNumber * 10 + (Key - k0);
#if VDRVERSNUM >= 20301 chanNew = channels->GetByNumber(channelNumber);
LOCK_CHANNELS_READ;
const cChannel *chanNew = Channels->GetByNumber(channelNumber);
#else
const cChannel *chanNew = Channels.GetByNumber(channelNumber);
#endif
if (chanNew) { if (chanNew) {
channel = chanNew; channel = chanNew;
DrawValue(); DrawValue();

View File

@ -496,6 +496,13 @@ public:
class cRecMenuItemChannelChooser : public cRecMenuItem { class cRecMenuItemChannelChooser : public cRecMenuItem {
private: private:
cString text; cString text;
#if VDRVERSNUM >= 20301
const cChannels *channels;
const cChannel *chanNew;
#else
cChannels *channels;
cChannel *chanNew;
#endif
const cChannel *channel; const cChannel *channel;
int channelNumber; int channelNumber;
int *callback; int *callback;
@ -505,7 +512,6 @@ private:
void DrawValue(void); void DrawValue(void);
public: public:
cRecMenuItemChannelChooser (cString text, cRecMenuItemChannelChooser (cString text,
const cChannel *initialChannel,
bool active = false, bool active = false,
int *callback = NULL, int *callback = NULL,
eRecMenuState action = rmsNotConsumed); eRecMenuState action = rmsNotConsumed);

View File

@ -523,11 +523,7 @@ cRecMenuSeriesTimer::cRecMenuSeriesTimer(const cChannel *initialChannel, const c
SetHeader(infoItem); SetHeader(infoItem);
AddMenuItem(new cRecMenuItemBool(tr("Timer Active"), timerActive, false, &timerActive)); AddMenuItem(new cRecMenuItemBool(tr("Timer Active"), timerActive, false, &timerActive));
#if VDRVERSNUM >= 20301 AddMenuItem(new cRecMenuItemChannelChooser(tr("Channel"), false, &channel));
AddMenuItem(new cRecMenuItemChannelChooser(tr("Channel"), initialChannel, false, &channel));
#else
AddMenuItem(new cRecMenuItemChannelChooser(tr("Channel"), (cChannel*)initialChannel, false, &channel));
#endif
AddMenuItem(new cRecMenuItemTime(tr("Series Timer start time"), start, false, &start)); AddMenuItem(new cRecMenuItemTime(tr("Series Timer start time"), start, false, &start));
AddMenuItem(new cRecMenuItemTime(tr("Series Timer stop time"), stop, false, &stop)); AddMenuItem(new cRecMenuItemTime(tr("Series Timer stop time"), stop, false, &stop));
AddMenuItem(new cRecMenuItemDayChooser(tr("Days to record"), dayOfWeek, false, &dayOfWeek)); AddMenuItem(new cRecMenuItemDayChooser(tr("Days to record"), dayOfWeek, false, &dayOfWeek));
@ -730,6 +726,13 @@ cRecMenuSearchTimerEdit::cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer
dayOfWeek = DayOfWeek(sT.dayOfWeek); dayOfWeek = DayOfWeek(sT.dayOfWeek);
indent = " "; indent = " ";
if (sT.useChannel == 1) {
startChannel = (sT.channelMin) ? sT.channelMin->Number() : 0;
stopChannel = (sT.channelMax) ? sT.channelMax->Number() : 0;
if (startChannel == 0) startChannel = 1;
if (stopChannel == 0) stopChannel = 1;
}
sT.GetSearchModes(&searchModes); sT.GetSearchModes(&searchModes);
sT.GetUseChannelModes(&useChannelModes); sT.GetUseChannelModes(&useChannelModes);
sT.GetCompareDateModes(&compareDateModes); sT.GetCompareDateModes(&compareDateModes);
@ -828,20 +831,8 @@ void cRecMenuSearchTimerEdit::CreateMenuItems(void) {
// mainMenuItems.push_back(new cRecMenuItemBool(tr("Use content descriptor"), sT.useContentDescriptors, false, &sT.useContentDescriptors, rmsSearchTimerSave)); // mainMenuItems.push_back(new cRecMenuItemBool(tr("Use content descriptor"), sT.useContentDescriptors, false, &sT.useContentDescriptors, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemSelect(tr("Use channel"), useChannelModes, sT.useChannel, false, &sT.useChannel, rmsSearchTimerSave, true)); mainMenuItems.push_back(new cRecMenuItemSelect(tr("Use channel"), useChannelModes, sT.useChannel, false, &sT.useChannel, rmsSearchTimerSave, true));
if (sT.useChannel == 1) { if (sT.useChannel == 1) {
startChannel = (sT.channelMin) ? sT.channelMin->Number() : 0; mainMenuItems.push_back(new cRecMenuItemChannelChooser(cString::sprintf("%s%s", *indent, tr("from channel")), false, &startChannel, rmsSearchTimerSave));
stopChannel = (sT.channelMax) ? sT.channelMax->Number() : 0; mainMenuItems.push_back(new cRecMenuItemChannelChooser(cString::sprintf("%s%s", *indent, tr("to channel")), false, &stopChannel, rmsSearchTimerSave));
if (startChannel == 0) startChannel = 1;
if (stopChannel == 0) stopChannel = 1;
#if VDRVERSNUM >= 20301
{
LOCK_CHANNELS_READ;
mainMenuItems.push_back(new cRecMenuItemChannelChooser(cString::sprintf("%s%s", *indent, tr("from channel")), Channels->GetByNumber(startChannel), false, &startChannel, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemChannelChooser(cString::sprintf("%s%s", *indent, tr("to channel")), Channels->GetByNumber(stopChannel), false, &stopChannel, rmsSearchTimerSave));
}
#else
mainMenuItems.push_back(new cRecMenuItemChannelChooser(cString::sprintf("%s%s", *indent, tr("from channel")), Channels.GetByNumber(startChannel), false, &startChannel, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemChannelChooser(cString::sprintf("%s%s", *indent, tr("to channel")), Channels.GetByNumber(stopChannel), false, &stopChannel, rmsSearchTimerSave));
#endif
} }
else if ((sT.useChannel == 2) && (channelgroups.size() > 0)) { else if ((sT.useChannel == 2) && (channelgroups.size() > 0)) {
mainMenuItems.push_back(new cRecMenuItemSelect(cString::sprintf("%s%s", *indent, tr("Channel group")), channelgroups, channelgroupIndex, false, &channelgroupIndex, rmsSearchTimerSave, false)); mainMenuItems.push_back(new cRecMenuItemSelect(cString::sprintf("%s%s", *indent, tr("Channel group")), channelgroups, channelgroupIndex, false, &channelgroupIndex, rmsSearchTimerSave, false));
@ -1211,7 +1202,7 @@ cRecMenuSearch::cRecMenuSearch(std::string searchString, bool withOptions) {
cTVGuideSearchTimer searchTimer; cTVGuideSearchTimer searchTimer;
searchTimer.GetSearchModes(&searchModes); searchTimer.GetSearchModes(&searchModes);
AddMenuItemInitial(new cRecMenuItemSelect(tr("Search Mode"), searchModes, 0, false, &mode)); AddMenuItemInitial(new cRecMenuItemSelect(tr("Search Mode"), searchModes, 0, false, &mode));
AddMenuItemInitial(new cRecMenuItemChannelChooser(tr("Channel to Search"), NULL, false, &channelNr)); AddMenuItemInitial(new cRecMenuItemChannelChooser(tr("Channel to Search"), false, &channelNr));
AddMenuItemInitial(new cRecMenuItemBool(tr("Search in title"), true, false, &useTitle)); AddMenuItemInitial(new cRecMenuItemBool(tr("Search in title"), true, false, &useTitle));
AddMenuItemInitial(new cRecMenuItemBool(tr("Search in Subtitle"), true, false, &useSubTitle)); AddMenuItemInitial(new cRecMenuItemBool(tr("Search in Subtitle"), true, false, &useSubTitle));
AddMenuItemInitial(new cRecMenuItemBool(tr("Search in Description"), false, false, &useDescription)); AddMenuItemInitial(new cRecMenuItemBool(tr("Search in Description"), false, false, &useDescription));