diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2019-07-14 12:35:15 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2019-07-14 14:22:26 +0200 |
commit | 3f9327b8e40e0dc34c9a0202bdbee090a7e3c8a3 (patch) | |
tree | d0912e21f3ccc925e59fd9ff4f6193c3f8d5799d /recmenus.c | |
parent | bff9d78ff3751e35434594c5849c8ba4a085d9d1 (diff) | |
download | vdr-plugin-tvguide-3f9327b8e40e0dc34c9a0202bdbee090a7e3c8a3.tar.gz vdr-plugin-tvguide-3f9327b8e40e0dc34c9a0202bdbee090a7e3c8a3.tar.bz2 |
Simplify cRecMenuSearchTimerEdit::GetSearchTimer
Diffstat (limited to 'recmenus.c')
-rw-r--r-- | recmenus.c | 91 |
1 files changed, 32 insertions, 59 deletions
@@ -721,14 +721,13 @@ int cRecMenuSearchTimers::GetTotalNumMenuItems(void) { cRecMenuSearchTimerEdit::cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups) { init = true; deleteMenuItems = false; - this->searchTimer = searchTimer; this->sT = searchTimer; this->channelGroups = channelGroups; strncpy(searchString, sT.searchString.c_str(), TEXTINPUTLENGTH); channelgroupIndex = -1; std::string dir = sT.directory; strncpy(directory, dir.c_str(), TEXTINPUTLENGTH); - dayOfWeek = sT.DayOfWeek(); + dayOfWeek = DayOfWeek(sT.dayOfWeek); sT.GetSearchModes(&searchModes); sT.GetUseChannelModes(&useChannelModes); @@ -759,6 +758,31 @@ cRecMenuSearchTimerEdit::~cRecMenuSearchTimerEdit(void) { mainMenuItems.clear(); } +int cRecMenuSearchTimerEdit::DayOfWeek(int dayofWeek) { + int vdrDayOfWeek = 0; + if (dayofWeek >= 0) { + vdrDayOfWeek = pow(2, (dayofWeek + 6) % 7); + } else if (dayofWeek < 0) { + int absDayOfWeek = abs(dayofWeek); + for (int i = 0; i < 7; i++) { + if (absDayOfWeek & (1 << i)) { + vdrDayOfWeek += pow(2, (i + 6) % 7); + } + } + } + return vdrDayOfWeek; +} + +int cRecMenuSearchTimerEdit::SetDayOfWeek(int VDRDayOfWeek) { + int epgSearchDayOfWeek = 0; + for (int i=0; i < 7; i++) { + if (VDRDayOfWeek & (1 << i)) { + epgSearchDayOfWeek += pow(2, (i+1)%7); + } + } + return epgSearchDayOfWeek * (-1); +} + int cRecMenuSearchTimerEdit::SplitChannelGroups(std::vector<std::string> *channelGroups, std::vector<std::string> *channelgroups) { int i = 0; int j = 0; @@ -908,13 +932,7 @@ void cRecMenuSearchTimerEdit::CreateMenuItems(void) { } cTVGuideSearchTimer cRecMenuSearchTimerEdit::GetSearchTimer(void) { - searchTimer.SetSearchString(searchString); - searchTimer.SetSearchMode(sT.mode); - searchTimer.SetFuzzyTolerance(sT.fuzzyTolerance); - searchTimer.SetUseCase(sT.useCase); - searchTimer.SetUseTitle(sT.useTitle); - searchTimer.SetUseSubtitle(sT.useSubtitle); - searchTimer.SetUseDesription(sT.useDescription); + sT.searchString = searchString; if (sT.useChannel == 1) { #if VDRVERSNUM >= 20301 { @@ -926,67 +944,22 @@ cTVGuideSearchTimer cRecMenuSearchTimerEdit::GetSearchTimer(void) { sT.channelMin = Channels.GetByNumber(startChannel); sT.channelMax = Channels.GetByNumber(stopChannel); #endif - searchTimer.SetStartChannel(sT.channelMin); - searchTimer.SetStopChannel(sT.channelMax); } if (sT.useChannel == 2) { if (channelgroups.size() > 0) { std::string & channelGroup = channelgroups[channelgroupIndex]; - searchTimer.SetChannelGroup(channelGroup); + sT.channelGroup = channelGroup; } else { sT.useChannel = 0; } } - searchTimer.SetUseChannel(sT.useChannel); - searchTimer.SetUseTime(sT.useTime); - if (sT.useTime) { - searchTimer.SetStartTime(sT.startTime); - searchTimer.SetStopTime(sT.stopTime); - } - searchTimer.SetUseDuration(sT.useDuration); - if (sT.useDuration) { - searchTimer.SetMinDuration(sT.minDuration); - searchTimer.SetMaxDuration(sT.maxDuration); - } - searchTimer.SetUseDayOfWeek(sT.useDayOfWeek); if (sT.useDayOfWeek) { - searchTimer.SetDayOfWeek(dayOfWeek); - } - searchTimer.SetUseAsSearchTimer(sT.useAsSearchTimer); - searchTimer.SetAction(sT.action); - searchTimer.SetSwitchMinsBefore(sT.switchMinsBefore); - searchTimer.SetUnmuteSoundOnSwitch(sT.unmuteSoundOnSwitch); - searchTimer.SetPriority(sT.priority); - searchTimer.SetLifetime(sT.lifetime); - searchTimer.SetUseEpisode(sT.useEpisode); + sT.dayOfWeek = SetDayOfWeek(dayOfWeek); + } std::string dir(directory); std::replace(dir.begin(), dir.end(), '/', '~'); - searchTimer.SetDirectory(dir); - searchTimer.SetDelAfterDays(sT.delAfterDays); - searchTimer.SetRecordingsKeep(sT.recordingsKeep); - searchTimer.SetPauseOnNrRecordings(sT.pauseOnNrRecordings); - searchTimer.SetMarginStart(sT.marginStart); - searchTimer.SetMarginStop(sT.marginStop); - searchTimer.SetUseVPS(sT.useVPS); - searchTimer.SetAvoidRepeats(sT.avoidRepeats); - if (sT.avoidRepeats) { - searchTimer.SetAllowedRepeats(sT.allowedRepeats); - if (sT.repeatsWithinDays > 0) { - searchTimer.SetRepeatsWithinDays(sT.repeatsWithinDays); - } - searchTimer.SetCompareTitle(sT.compareTitle); - searchTimer.SetCompareSubtitle(sT.compareSubtitle); - searchTimer.SetCompareSummary(sT.compareSummary); - if (sT.compareSummary) { - searchTimer.SetCompareSummaryMatchInPercent(sT.compareSummaryMatchInPercent); - } - searchTimer.SetCompareDate(sT.compareDate); - } - searchTimer.SetUseInFavorites(sT.useInFavorites); - searchTimer.SetDelMode(sT.delMode); - searchTimer.SetDelAfterCountRecs(sT.delAfterCountRecs); - searchTimer.SetDelAfterDaysOfFirstRec(sT.delAfterDaysOfFirstRec); - return searchTimer; + sT.directory = dir; + return sT; } int cRecMenuSearchTimerEdit::GetTotalNumMenuItems(void) { |