mirror of
https://projects.vdr-developer.org/git/vdr-plugin-tvguide.git
synced 2023-10-05 15:01:48 +02:00
Simplify cRecMenuSearchTimerEdit::GetSearchTimer
This commit is contained in:
parent
bff9d78ff3
commit
3f9327b8e4
89
recmenus.c
89
recmenus.c
@ -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);
|
||||
sT.dayOfWeek = 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);
|
||||
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) {
|
||||
|
@ -231,6 +231,8 @@ private:
|
||||
int useChannelPos;
|
||||
int useTimePos;
|
||||
int useDayOfWeekPos;
|
||||
int DayOfWeek(int dayofWeek = 0);
|
||||
int SetDayOfWeek(int VDRDayOfWeek);
|
||||
int avoidRepeatsPos;
|
||||
char searchString[TEXTINPUTLENGTH];
|
||||
bool timerActive;
|
||||
|
@ -97,31 +97,6 @@ void cTVGuideSearchTimer::SetTemplate(std::string tmpl) {
|
||||
strTimer = searchTimerString.str();
|
||||
}
|
||||
|
||||
int cTVGuideSearchTimer::DayOfWeek(void) {
|
||||
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;
|
||||
}
|
||||
|
||||
void cTVGuideSearchTimer::SetDayOfWeek(int VDRDayOfWeek) {
|
||||
int epgSearchDayOfWeek = 0;
|
||||
for (int i=0; i < 7; i++) {
|
||||
if (VDRDayOfWeek & (1 << i)) {
|
||||
epgSearchDayOfWeek += pow(2, (i+1)%7);
|
||||
}
|
||||
}
|
||||
this->dayOfWeek = epgSearchDayOfWeek * (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
0 - unique search timer id
|
||||
1 - the search term
|
||||
|
@ -74,54 +74,9 @@ public:
|
||||
//GETTER
|
||||
std::string GetSearchString(void) const { return searchString; };
|
||||
bool IsActive(void);
|
||||
int DayOfWeek(void);
|
||||
bool UseInFavorites(void) { return useInFavorites; };
|
||||
//SETTER
|
||||
void SetSearchString(std::string searchString) { this->searchString = searchString; };
|
||||
void SetSearchMode(int mode) { this->mode = mode; };
|
||||
void SetFuzzyTolerance(int fuzzyTolerance) { this->fuzzyTolerance = fuzzyTolerance; };
|
||||
void SetUseCase(bool useCase) { this->useCase = useCase; };
|
||||
void SetUseTitle(bool useTitle) { this->useTitle = useTitle; };
|
||||
void SetUseSubtitle(bool useSubtitle) { this->useSubtitle = useSubtitle; };
|
||||
void SetUseDesription(bool useDescription) { this->useDescription = useDescription; };
|
||||
void SetUseChannel(int useChannel) { this->useChannel = useChannel; };
|
||||
void SetStartChannel(const cChannel *channelMin) { this->channelMin = channelMin; };
|
||||
void SetStopChannel(const cChannel *channelMax) { this->channelMax = channelMax; };
|
||||
void SetChannelGroup(std::string channelGroup) { this->channelGroup = channelGroup; };
|
||||
void SetUseTime(bool useTime) { this->useTime = useTime; };
|
||||
void SetStartTime(int startTime) { this->startTime = startTime; };
|
||||
void SetStopTime(int stopTime) { this->stopTime = stopTime; };
|
||||
void SetUseDayOfWeek(bool useDayOfWeek) { this->useDayOfWeek = useDayOfWeek; };
|
||||
void SetDayOfWeek(int VDRDayOfWeek);
|
||||
void SetUseDuration(bool useDuration) { this->useDuration = useDuration; };
|
||||
void SetMinDuration(int minDuration) { this->minDuration = minDuration; };
|
||||
void SetMaxDuration(int maxDuration) { this->maxDuration = maxDuration; };
|
||||
void SetUseEpisode(int useEpisode) { this->useEpisode = useEpisode; };
|
||||
void SetDirectory(std::string directory) { this-> directory = directory; };
|
||||
void SetDelAfterDays(int delAfterDays) { this->delAfterDays = delAfterDays; };
|
||||
void SetRecordingsKeep(int recordingsKeep) { this->recordingsKeep = recordingsKeep; };
|
||||
void SetPauseOnNrRecordings(int pauseOnNrRecordings) { this-> pauseOnNrRecordings = pauseOnNrRecordings; };
|
||||
void SetPriority(int priority) { this->priority = priority; };
|
||||
void SetLifetime(int lifetime) { this->lifetime = lifetime; };
|
||||
void SetMarginStart(int marginStart) { this->marginStart = marginStart; };
|
||||
void SetMarginStop(int marginStop) { this->marginStop = marginStop; };
|
||||
void SetUseVPS(bool useVPS) { this->useVPS = useVPS; };
|
||||
void SetAvoidRepeats(bool avoidRepeats) { this->avoidRepeats = avoidRepeats; };
|
||||
void SetAllowedRepeats(int allowedRepeats) { this->allowedRepeats = allowedRepeats; };
|
||||
void SetRepeatsWithinDays(int repeatsWithinDays) { this-> repeatsWithinDays = repeatsWithinDays; };
|
||||
void SetCompareTitle(bool compareTitle) { this->compareTitle = compareTitle; };
|
||||
void SetCompareSubtitle(bool compareSubtitle) { this->compareSubtitle = compareSubtitle; };
|
||||
void SetCompareSummary(bool compareSummary) { this->compareSummary = compareSummary; };
|
||||
void SetCompareSummaryMatchInPercent(int compareSummaryMatchInPercent) { this->compareSummaryMatchInPercent = compareSummaryMatchInPercent; };
|
||||
void SetCompareDate(int compareDate) { this->compareDate = compareDate; };
|
||||
void SetUseInFavorites(bool useInFavorites) { this->useInFavorites = useInFavorites; };
|
||||
void SetUseAsSearchTimer(bool useAsSearchTimer) { this->useAsSearchTimer = useAsSearchTimer; };
|
||||
void SetAction(int action) { this->action = action; };
|
||||
void SetSwitchMinsBefore(int switchMinsBefore) { this->switchMinsBefore = switchMinsBefore; };
|
||||
void SetUnmuteSoundOnSwitch(bool unmuteSoundOnSwitch) { this->unmuteSoundOnSwitch = unmuteSoundOnSwitch; };
|
||||
void SetDelMode(bool delMode) { this->delMode = delMode; };
|
||||
void SetDelAfterCountRecs(bool delAfterCountRecs) { this->delAfterCountRecs = delAfterCountRecs; };
|
||||
void SetDelAfterDaysOfFirstRec(bool delAfterDaysOfFirstRec) { this->delAfterDaysOfFirstRec = delAfterDaysOfFirstRec; };
|
||||
//COMMON
|
||||
int GetNumTimers(void);
|
||||
int GetNumRecordings(void);
|
||||
|
Loading…
Reference in New Issue
Block a user