Some refatoring to searchTimer

This commit is contained in:
kamel5 2019-06-17 14:19:13 +02:00
parent 1c591b5408
commit ef4ff3d115
3 changed files with 71 additions and 140 deletions

View File

@ -727,36 +727,10 @@ cRecMenuSearchTimerEdit::cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer
deleteMenuItems = false; deleteMenuItems = false;
this->searchTimer = searchTimer; this->searchTimer = searchTimer;
this->channelGroups = channelGroups; this->channelGroups = channelGroups;
strncpy(searchString, searchTimer.GetSearchString().c_str(), TEXTINPUTLENGTH); strncpy(searchString, searchTimer.searchString.c_str(), TEXTINPUTLENGTH);
timerActive = searchTimer.IsActive();
mode = searchTimer.SearchMode();
useTitle = searchTimer.UseTitle();
useSubtitle = searchTimer.UseSubtitle();
useDescription = searchTimer.UseDescription();
useChannel = searchTimer.UseChannel();
startChannel = searchTimer.StartChannel();
stopChannel = searchTimer.StopChannel();
channelGroup = searchTimer.ChannelGroup();
channelgroupIndex = -1; channelgroupIndex = -1;
useTime = searchTimer.UseTime(); std::string dir = searchTimer.directory;
startTime = searchTimer.StartTime();
stopTime = searchTimer.StopTime();
useDayOfWeek = searchTimer.UseDayOfWeek();
dayOfWeek = searchTimer.DayOfWeek();
priority = searchTimer.Priority();
lifetime = searchTimer.Lifetime();
useEpisode = searchTimer.UseEpisode();
std::string dir = searchTimer.Directory();
strncpy(directory, dir.c_str(), TEXTINPUTLENGTH); strncpy(directory, dir.c_str(), TEXTINPUTLENGTH);
marginStart = searchTimer.MarginStart();
marginStop = searchTimer.MarginStop();
useVPS = searchTimer.UseVPS();
avoidRepeats = searchTimer.AvoidRepeats();
allowedRepeats = searchTimer.AllowedRepeats();
compareTitle = searchTimer.CompareTitle();
compareSubtitle = searchTimer.CompareSubtitle();
compareSummary = searchTimer.CompareSummary();
useInFavorites = searchTimer.UseInFavorites();
searchTimer.GetSearchModes(&searchModes); searchTimer.GetSearchModes(&searchModes);
searchTimer.GetUseChannelModes(&useChannelModes); searchTimer.GetUseChannelModes(&useChannelModes);
@ -798,7 +772,7 @@ int cRecMenuSearchTimerEdit::SplitChannelGroups(std::vector<std::string> *channe
std::vector<std::string>::iterator ito = value.begin(); std::vector<std::string>::iterator ito = value.begin();
channelgroups->push_back(*ito); channelgroups->push_back(*ito);
std::string b = *ito; std::string b = *ito;
if (b.compare(channelGroup) == 0) if (b.compare(searchTimer.channelGroup) == 0)
j = i; j = i;
i++; i++;
} }
@ -820,48 +794,53 @@ void cRecMenuSearchTimerEdit::CreateMenuItems(void) {
} }
mainMenuItems.push_back(new cRecMenuItemText(tr("Search String"), searchString, TEXTINPUTLENGTH, false, searchString)); mainMenuItems.push_back(new cRecMenuItemText(tr("Search String"), searchString, TEXTINPUTLENGTH, false, searchString));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Active"), timerActive, false, false, &timerActive, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Active"), searchTimer.useAsSearchTimer, true, false, &searchTimer.useAsSearchTimer, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemSelect(tr("Search Mode"), searchModes, mode, false, &mode, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemSelect(tr("Search Mode"), searchModes, searchTimer.mode, false, &searchTimer.mode, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Title"), useTitle, false, false, &useTitle, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Title"), searchTimer.useTitle, false, false, &searchTimer.useTitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Subtitle"), useSubtitle, false, false, &useSubtitle, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Subtitle"), searchTimer.useSubtitle, false, false, &searchTimer.useSubtitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Description"), useDescription, false, false, &useDescription, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Description"), searchTimer.useDescription, false, false, &searchTimer.useDescription, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemSelect(tr("Limit Channels"), useChannelModes, useChannel, false, &useChannel, rmsSearchTimerSave, true)); mainMenuItems.push_back(new cRecMenuItemSelect(tr("Limit Channels"), useChannelModes, searchTimer.useChannel, false, &searchTimer.useChannel, rmsSearchTimerSave, true));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Time"), useTime, true, false, &useTime, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Use Time"), searchTimer.useTime, true, false, &searchTimer.useTime, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Limit Days of the Week"), useDayOfWeek, true, false, &useDayOfWeek, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Limit Days of the Week"), searchTimer.useDayOfWeek, true, false, &searchTimer.useDayOfWeek, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemInt(tr("Priority"), priority, 0, 99, false, &priority, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemInt(tr("Priority"), searchTimer.priority, 0, 99, false, &searchTimer.priority, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemInt(tr("Lifetime"), lifetime, 0, 99, false, &lifetime, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemInt(tr("Lifetime"), searchTimer.lifetime, 0, 99, false, &searchTimer.lifetime, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemInt(tr("Time margin for start in minutes"), marginStart, 0, 30, false, &marginStart, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemInt(tr("Time margin for start in minutes"), searchTimer.marginStart, 0, 30, false, &searchTimer.marginStart, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemInt(tr("Time margin for stop in minutes"), marginStop, 0, 30, false, &marginStop, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemInt(tr("Time margin for stop in minutes"), searchTimer.marginStop, 0, 30, false, &searchTimer.marginStop, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Series Recording"), useEpisode, false, false, &useEpisode, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Series Recording"), searchTimer.useEpisode, false, false, &searchTimer.useEpisode, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemSelectDirectory(tr("Folder"), std::string(directory), false, directory, rmsSearchTimerSave, true)); mainMenuItems.push_back(new cRecMenuItemSelectDirectory(tr("Folder"), std::string(directory), false, directory, rmsSearchTimerSave, true));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Use VPS"), useVPS, false, false, &useVPS, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Use VPS"), searchTimer.useVPS, false, false, &searchTimer.useVPS, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Avoid Repeats"), avoidRepeats, true, false, &avoidRepeats, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Avoid Repeats"), searchTimer.avoidRepeats, true, false, &searchTimer.avoidRepeats, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Use in Favorites"), useInFavorites, false, false, &useInFavorites, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Use in Favorites"), searchTimer.useInFavorites, false, false, &searchTimer.useInFavorites, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemButton(tr("Display Results for Search Timer"), rmsSearchTimerTest, false)); mainMenuItems.push_back(new cRecMenuItemButton(tr("Display Results for Search Timer"), rmsSearchTimerTest, false));
if (startChannel == 0) if (searchTimer.useChannel == 1) {
startChannel = 1; startChannel = (searchTimer.channelMin) ? searchTimer.channelMin->Number() : 0;
if (stopChannel == 0) stopChannel = (searchTimer.channelMax) ? searchTimer.channelMax->Number() : 0;
stopChannel = 1; if (startChannel == 0) startChannel = 1;
if (stopChannel == 0) stopChannel = 1;
#if VDRVERSNUM >= 20301 #if VDRVERSNUM >= 20301
LOCK_CHANNELS_READ; {
mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Start Channel"), Channels->GetByNumber(startChannel), false, &startChannel, rmsSearchTimerSave)); LOCK_CHANNELS_READ;
mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Stop Channel"), Channels->GetByNumber(stopChannel), false, &stopChannel, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Start Channel"), Channels->GetByNumber(startChannel), false, &startChannel, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Stop Channel"), Channels->GetByNumber(stopChannel), false, &stopChannel, rmsSearchTimerSave));
}
#else #else
mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Start Channel"), Channels.GetByNumber(startChannel), false, &startChannel, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Start Channel"), Channels.GetByNumber(startChannel), false, &startChannel, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Stop Channel"), Channels.GetByNumber(stopChannel), false, &stopChannel, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemChannelChooser(tr("Stop Channel"), Channels.GetByNumber(stopChannel), false, &stopChannel, rmsSearchTimerSave));
#endif #endif
}
else if ((searchTimer.useChannel == 2) && (channelgroups.size() > 0)) {
mainMenuItems.push_back(new cRecMenuItemSelect(tr("Channel Group"), channelgroups, channelgroupIndex, false, &channelgroupIndex, rmsSearchTimerSave));
}
mainMenuItems.push_back(new cRecMenuItemSelect(tr("Channel Group"), channelgroups, channelgroupIndex, false, &channelgroupIndex, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemTime(tr("Start after"), searchTimer.startTime, false, &searchTimer.startTime, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemTime(tr("Start before"), searchTimer.stopTime, false, &searchTimer.stopTime, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemTime(tr("Start after"), startTime, false, &startTime, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemDayChooser(tr("Select Days"), searchTimer.dayOfWeek, false, &searchTimer.dayOfWeek));
mainMenuItems.push_back(new cRecMenuItemTime(tr("Start before"), stopTime, false, &stopTime, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemInt(tr("Number of allowed repeats"), searchTimer.allowedRepeats, 0, 30, false, &searchTimer.allowedRepeats, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Title"), searchTimer.compareTitle, false, false, &searchTimer.compareTitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemDayChooser(tr("Select Days"), dayOfWeek, false, &dayOfWeek)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Subtitle"), searchTimer.compareSubtitle, false, false, &searchTimer.compareSubtitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemInt(tr("Number of allowed repeats"), allowedRepeats, 0, 30, false, &allowedRepeats, rmsSearchTimerSave)); mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Description"), searchTimer.compareSummary, false, false, &searchTimer.compareSummary, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Title"), compareTitle, false, false, &compareTitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Subtitle"), compareSubtitle, false, false, &compareSubtitle, rmsSearchTimerSave));
mainMenuItems.push_back(new cRecMenuItemBool(tr("Compare Description"), compareSummary, false, false, &compareSummary, rmsSearchTimerSave));
bool reDraw = false; bool reDraw = false;
if (GetCurrentNumMenuItems() > 0) { if (GetCurrentNumMenuItems() > 0) {
@ -891,50 +870,50 @@ void cRecMenuSearchTimerEdit::CreateMenuItems(void) {
cTVGuideSearchTimer cRecMenuSearchTimerEdit::GetSearchTimer(void) { cTVGuideSearchTimer cRecMenuSearchTimerEdit::GetSearchTimer(void) {
dsyslog ("%s %s %d\n", __FILE__, __func__, __LINE__); dsyslog ("%s %s %d\n", __FILE__, __func__, __LINE__);
searchTimer.SetSearchString(searchString); searchTimer.SetSearchString(searchString);
searchTimer.SetActive(timerActive); searchTimer.SetSearchMode(searchTimer.mode);
searchTimer.SetSearchMode(mode); searchTimer.SetUseTitle(searchTimer.useTitle);
searchTimer.SetUseTitle(useTitle); searchTimer.SetUseSubtitle(searchTimer.useSubtitle);
searchTimer.SetUseSubtitle(useSubtitle); searchTimer.SetUseDesription(searchTimer.useDescription);
searchTimer.SetUseDesription(useDescription); if (searchTimer.useChannel == 1) {
if (useChannel == 1) {
searchTimer.SetStartChannel(startChannel); searchTimer.SetStartChannel(startChannel);
searchTimer.SetStopChannel(stopChannel); searchTimer.SetStopChannel(stopChannel);
} }
if (useChannel == 2) { if (searchTimer.useChannel == 2) {
if (channelgroups.size() > 0) { if (channelgroups.size() > 0) {
std::string & channelGroup = channelgroups[channelgroupIndex]; std::string & channelGroup = channelgroups[channelgroupIndex];
searchTimer.SetChannelGroup(channelGroup); searchTimer.SetChannelGroup(channelGroup);
} else { } else {
useChannel = 0; searchTimer.useChannel = 0;
} }
} }
searchTimer.SetUseChannel(useChannel); searchTimer.SetUseChannel(searchTimer.useChannel);
searchTimer.SetUseTime(useTime); searchTimer.SetUseTime(searchTimer.useTime);
if (useTime) { if (searchTimer.useTime) {
searchTimer.SetStartTime(startTime); searchTimer.SetStartTime(searchTimer.startTime);
searchTimer.SetStopTime(stopTime); searchTimer.SetStopTime(searchTimer.stopTime);
} }
searchTimer.SetUseDayOfWeek(useDayOfWeek); searchTimer.SetUseDayOfWeek(searchTimer.useDayOfWeek);
if (useDayOfWeek) { if (searchTimer.useDayOfWeek) {
searchTimer.SetDayOfWeek(dayOfWeek); searchTimer.SetDayOfWeek(searchTimer.dayOfWeek);
} }
searchTimer.SetPriority(priority); searchTimer.SetUseAsSearchTimer(searchTimer.useAsSearchTimer);
searchTimer.SetLifetime(lifetime); searchTimer.SetPriority(searchTimer.priority);
searchTimer.SetUseEpisode(useEpisode); searchTimer.SetLifetime(searchTimer.lifetime);
searchTimer.SetUseEpisode(searchTimer.useEpisode);
std::string dir(directory); std::string dir(directory);
std::replace(dir.begin(), dir.end(), '/', '~'); std::replace(dir.begin(), dir.end(), '/', '~');
searchTimer.SetDirectory(dir); searchTimer.SetDirectory(dir);
searchTimer.SetMarginStart(marginStart); searchTimer.SetMarginStart(searchTimer.marginStart);
searchTimer.SetMarginStop(marginStop); searchTimer.SetMarginStop(searchTimer.marginStop);
searchTimer.SetUseVPS(useVPS); searchTimer.SetUseVPS(searchTimer.useVPS);
searchTimer.SetAvoidRepeats(avoidRepeats); searchTimer.SetAvoidRepeats(searchTimer.avoidRepeats);
if (avoidRepeats) { if (searchTimer.avoidRepeats) {
searchTimer.SetAllowedRepeats(allowedRepeats); searchTimer.SetAllowedRepeats(searchTimer.allowedRepeats);
searchTimer.SetCompareTitle(compareTitle); searchTimer.SetCompareTitle(searchTimer.compareTitle);
searchTimer.SetCompareSubtitle(compareSubtitle); searchTimer.SetCompareSubtitle(searchTimer.compareSubtitle);
searchTimer.SetCompareSummary(compareSummary); searchTimer.SetCompareSummary(searchTimer.compareSummary);
} }
searchTimer.SetUseInFavorites(useInFavorites); searchTimer.SetUseInFavorites(searchTimer.useInFavorites);
return searchTimer; return searchTimer;
} }

View File

@ -226,33 +226,10 @@ private:
int avoidRepeatsPos; int avoidRepeatsPos;
char searchString[TEXTINPUTLENGTH]; char searchString[TEXTINPUTLENGTH];
bool timerActive; bool timerActive;
int mode;
bool useTitle;
bool useSubtitle;
bool useDescription;
int useChannel;
int startChannel; int startChannel;
int stopChannel; int stopChannel;
std::string channelGroup;
int channelgroupIndex; int channelgroupIndex;
bool useTime;
int startTime;
int stopTime;
bool useDayOfWeek;
int dayOfWeek;
int priority;
int lifetime;
bool useEpisode;
char directory[TEXTINPUTLENGTH]; char directory[TEXTINPUTLENGTH];
int marginStart;
int marginStop;
bool useVPS;
bool avoidRepeats;
int allowedRepeats;
bool compareTitle;
bool compareSubtitle;
bool compareSummary;
bool useInFavorites;
int SplitChannelGroups(std::vector<std::string> *channelGroups, std::vector<std::string> *channelgroups); int SplitChannelGroups(std::vector<std::string> *channelGroups, std::vector<std::string> *channelgroups);
public: public:
cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups); cRecMenuSearchTimerEdit(cTVGuideSearchTimer searchTimer, std::vector<std::string> channelGroups);

View File

@ -79,35 +79,10 @@ public:
//GETTER //GETTER
std::string GetSearchString(void) const { return searchString; }; std::string GetSearchString(void) const { return searchString; };
bool IsActive(void); bool IsActive(void);
bool UseTitle(void) { return useTitle; };
bool UseSubtitle(void) { return useSubtitle; };
bool UseDescription(void) { return useDescription; };
int SearchMode(void) { return mode; };
int UseChannel(void) { return useChannel; };
int StartChannel(void) { return (channelMin)?channelMin->Number():0; };
int StopChannel(void) { return (channelMax)?channelMax->Number():0; };
std::string ChannelGroup(void) { return channelGroup; };
bool UseTime(void) { return useTime; };
int StartTime(void) { return startTime; };
int StopTime(void) { return stopTime; };
bool UseDayOfWeek(void) { return useDayOfWeek; };
int DayOfWeek(void); int DayOfWeek(void);
int UseEpisode(void) { return useEpisode; };
std::string Directory(void) { return directory; };
int Priority(void) { return priority; };
int Lifetime(void) { return lifetime; };
int MarginStart(void) { return marginStart; };
int MarginStop(void) { return marginStop; };
bool UseVPS(void) { return useVPS; };
bool AvoidRepeats(void) { return avoidRepeats; };
int AllowedRepeats(void) { return allowedRepeats; };
bool CompareTitle(void) { return compareTitle; };
bool CompareSubtitle(void) { return compareSubtitle; };
bool CompareSummary(void) { return compareSummary; };
bool UseInFavorites(void) { return useInFavorites; }; bool UseInFavorites(void) { return useInFavorites; };
//SETTER //SETTER
void SetSearchString(std::string searchString) { this->searchString = searchString; }; void SetSearchString(std::string searchString) { this->searchString = searchString; };
void SetActive(bool active) { useAsSearchTimer = active; };
void SetSearchMode(int searchMode) { mode = searchMode; }; void SetSearchMode(int searchMode) { mode = searchMode; };
void SetFuzzyTolerance(int fuzzyTolerance) { this->fuzzyTolerance = fuzzyTolerance; }; void SetFuzzyTolerance(int fuzzyTolerance) { this->fuzzyTolerance = fuzzyTolerance; };
void SetUseCase(bool useCase) { this->useCase = useCase; }; void SetUseCase(bool useCase) { this->useCase = useCase; };