Rework recmenuview.c

This commit is contained in:
kamel5 2019-07-10 18:53:07 +02:00
parent e09279ca32
commit ceadc0bbfe

View File

@ -84,12 +84,76 @@ void cRecMenuView::DeleteBackground(void) {
osdManager.releasePixmap(pixmapBackground); osdManager.releasePixmap(pixmapBackground);
} }
void cRecMenuView::DisplaySearchTimerList(void) {
delete activeMenu;
std::vector<cTVGuideSearchTimer> searchTimers;
recManager->GetSearchTimers(&searchTimers);
activeMenu = new cRecMenuSearchTimers(searchTimers);
activeMenu->Display();
}
bool cRecMenuView::DisplayTimerConflict(const cTimer *timer) {
int timerID = 0;
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
for (const cTimer *t = Timers->First(); t; t = Timers->Next(t)) {
#else
for (const cTimer *t = Timers.First(); t; t = Timers.Next(t)) {
#endif
if (t == timer)
return DisplayTimerConflict(timerID);
timerID++;
}
return false;
}
bool cRecMenuView::DisplayTimerConflict(int timerID) {
if (timerConflicts)
delete timerConflicts;
timerConflicts = recManager->CheckTimerConflict();
if (!timerConflicts)
return false;
int showTimerConflict = timerConflicts->GetCorrespondingConflict(timerID);
if (showTimerConflict > -1) {
timerConflicts->SetCurrentConflict(showTimerConflict);
cTVGuideTimerConflict *conflict = timerConflicts->GetCurrentConflict();
if (!conflict)
return false;
activeMenu = new cRecMenuTimerConflict(conflict);
activeMenu->Display();
return true;
}
return false;
}
void cRecMenuView::DisplayFavoriteResults(std::string header, const cEvent **result, int numResults) {
if (numResults) {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerResults(header, result, numResults, "", rmsFavoritesRecord);
activeMenu->Display();
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerNothingFound(header);
activeMenu->Display();
}
}
void cRecMenuView::DisplayDetailedView(const cEvent *ev) {
activeMenu->Hide();
detailView = new cDetailView(ev, footer);
footer->SetDetailedViewMode(true);
detailView->Start();
detailViewActive = true;
}
eOSState cRecMenuView::StateMachine(eRecMenuState nextState) { eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
eOSState state = osContinue; eOSState state = osContinue;
switch (nextState) { switch (nextState) {
/*************************************************************************************** /***************************************************************************************
* INSTANT RECORDING * INSTANT RECORDING
****************************************************************************************/ ****************************************************************************************/
case rmsInstantRecord: { case rmsInstantRecord: {
//caller: main menu or folder chooser //caller: main menu or folder chooser
//Creating timer for active Event, if no conflict, confirm and exit //Creating timer for active Event, if no conflict, confirm and exit
@ -111,6 +175,47 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu = new cRecMenuAskFolder(event, rmsInstantRecord); activeMenu = new cRecMenuAskFolder(event, rmsInstantRecord);
activeMenu->Display(); activeMenu->Display();
break; break;
case rmsDeleteTimer: {
//caller: main menu
//delete timer for active event
delete activeMenu;
if (recManager->IsRecorded(event)) {
activeMenu = new cRecMenuAskDeleteTimer(event);
} else {
recManager->DeleteTimer(event);
activeMenu = new cRecMenuConfirmDeleteTimer(event);
}
activeMenu->Display();
break; }
case rmsDeleteTimerConfirmation: {
//delete running timer for active event
recManager->DeleteTimer(event);
delete activeMenu;
activeMenu = new cRecMenuConfirmDeleteTimer(event);
activeMenu->Display();
break; }
case rmsEditTimer: {
//edit timer for active event
const cTimer *timer = recManager->GetTimerForEvent(event);
if (timer) {
delete activeMenu;
activeMenu = new cRecMenuEditTimer(timer, rmsSaveTimer);
activeMenu->Display();
}
break; }
case rmsSaveTimer: {
//caller: cRecMenuEditTimer
//save timer for active event
cTimer timerModified;
const cTimer *originalTimer;
if (cRecMenuEditTimer *menu = dynamic_cast<cRecMenuEditTimer*>(activeMenu)) {
timerModified = menu->GetTimer();
originalTimer = menu->GetOriginalTimer();
} else break;
recManager->SaveTimer(originalTimer, timerModified);
Close();
state = osEnd;
break; }
case rmsIgnoreTimerConflict: case rmsIgnoreTimerConflict:
//caller: cRecMenuTimerConflict //caller: cRecMenuTimerConflict
//Confirming created Timer //Confirming created Timer
@ -189,58 +294,9 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu->Display(); activeMenu->Display();
} }
break; } break; }
case rmsDeleteTimer: /***************************************************************************************
//caller: main menu * SERIES TIMER
//delete timer for active event ****************************************************************************************/
delete activeMenu;
if (recManager->IsRecorded(event)) {
activeMenu = new cRecMenuAskDeleteTimer(event);
} else {
recManager->DeleteTimer(event);
activeMenu = new cRecMenuConfirmDeleteTimer(event);
}
activeMenu->Display();
break;
case rmsDeleteTimerConfirmation:
//delete running timer for active event
recManager->DeleteTimer(event);
delete activeMenu;
activeMenu = new cRecMenuConfirmDeleteTimer(event);
activeMenu->Display();
break;
case rmsEditTimer: {
//edit timer for active event
const cTimer *timer;
#if VDRVERSNUM >= 20301
{
LOCK_TIMERS_READ;
timer = recManager->GetTimerForEvent(event);
}
#else
timer = recManager->GetTimerForEvent(event);
#endif
if (timer) {
delete activeMenu;
activeMenu = new cRecMenuEditTimer(timer, rmsSaveTimer);
activeMenu->Display();
}
break; }
case rmsSaveTimer: {
//caller: cRecMenuEditTimer
//save timer for active event
cTimer timerModified;
const cTimer *originalTimer;
if (cRecMenuEditTimer *menu = dynamic_cast<cRecMenuEditTimer*>(activeMenu)) {
timerModified = menu->GetTimer();
originalTimer = menu->GetOriginalTimer();
} else break;
recManager->SaveTimer(originalTimer, timerModified);
state = osEnd;
Close();
break; }
/***************************************************************************************
* SERIES TIMER
****************************************************************************************/
case rmsSeriesTimer: { case rmsSeriesTimer: {
//caller: main menu oder folder chooser //caller: main menu oder folder chooser
std::string recFolder = ""; std::string recFolder = "";
@ -275,9 +331,9 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu = new cRecMenuConfirmSeriesTimer(seriesTimer); activeMenu = new cRecMenuConfirmSeriesTimer(seriesTimer);
activeMenu->Display(); activeMenu->Display();
break; } break; }
/********************************************************************************************** /**********************************************************************************************
* SEARCH TIMER * SEARCH TIMER
***********************************************************************************************/ ***********************************************************************************************/
case rmsSearchTimer: case rmsSearchTimer:
//Caller: main menu //Caller: main menu
//set search String for search timer //set search String for search timer
@ -363,13 +419,12 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenuBuffer = activeMenu; activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide(); activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerResults(searchTimer.GetSearchString(), searchResult, numSearchResults, "", recState); activeMenu = new cRecMenuSearchTimerResults(searchTimer.GetSearchString(), searchResult, numSearchResults, "", recState);
activeMenu->Display();
} else { } else {
activeMenuBuffer = activeMenu; activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide(); activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerNothingFound(searchTimer.GetSearchString()); activeMenu = new cRecMenuSearchTimerNothingFound(searchTimer.GetSearchString());
activeMenu->Display();
} }
activeMenu->Display();
break; } break; }
case rmsSearchTimerSave: { case rmsSearchTimerSave: {
//caller: cRecMenuSearchTimerEdit, cRecMenuSearchTimerTemplatesCreate //caller: cRecMenuSearchTimerEdit, cRecMenuSearchTimerTemplatesCreate
@ -448,66 +503,9 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu = new cRecMenuSearchConfirmTimer(ev, rmsFavoritesRecordConfirm); activeMenu = new cRecMenuSearchConfirmTimer(ev, rmsFavoritesRecordConfirm);
activeMenu->Display(); activeMenu->Display();
break; } break; }
/********************************************************************************************** /**********************************************************************************************
* SWITCH TIMER * SEARCH
***********************************************************************************************/ ***********************************************************************************************/
case rmsSwitchTimer:
delete activeMenu;
activeMenu = new cRecMenuSwitchTimer();
activeMenu->Display();
break;
case rmsSwitchTimerCreate: {
cSwitchTimer switchTimer;
if (cRecMenuSwitchTimer *menu = dynamic_cast<cRecMenuSwitchTimer*>(activeMenu)) {
switchTimer = menu->GetSwitchTimer();
} else break;
bool success = recManager->CreateSwitchTimer(event, switchTimer);
delete activeMenu;
activeMenu = new cRecMenuSwitchTimerConfirm(success);
activeMenu->Display();
break; }
case rmsSwitchTimerDelete:
recManager->DeleteSwitchTimer(event);
delete activeMenu;
activeMenu = new cRecMenuSwitchTimerDelete();
activeMenu->Display();
break;
/**********************************************************************************************
* RECORDINGS SEARCH
***********************************************************************************************/
case rmsRecordingSearch: {
//caller: main menu or rmsRecordingSearchResult
std::string searchString = event->Title();
if (cRecMenuRecordingSearchResults *menu = dynamic_cast<cRecMenuRecordingSearchResults*>(activeMenu)) {
searchString = menu->GetSearchString();
};
delete activeMenu;
activeMenu = new cRecMenuRecordingSearch(searchString);
activeMenu->Display();
break; }
case rmsRecordingSearchResult: {
//caller: cRecMenuRecordingSearch
std::string searchString;
if (cRecMenuRecordingSearch *menu = dynamic_cast<cRecMenuRecordingSearch*>(activeMenu)) {
searchString = menu->GetSearchString();
} else break;
delete activeMenu;
if (searchString.size() < 4) {
activeMenu = new cRecMenuRecordingSearch(searchString);
} else {
int numSearchResults = 0;
const cRecording **searchResult = recManager->SearchForRecordings(searchString, numSearchResults);
if (numSearchResults == 0) {
activeMenu = new cRecMenuRecordingSearchNotFound(searchString);
} else {
activeMenu = new cRecMenuRecordingSearchResults(searchString, searchResult, numSearchResults);
}
}
activeMenu->Display();
break; }
/**********************************************************************************************
* SEARCH
***********************************************************************************************/
case rmsSearch: case rmsSearch:
case rmsSearchWithOptions: { case rmsSearchWithOptions: {
//caller: main menu, cRecMenuSearch, cRecMenuSearchResults //caller: main menu, cRecMenuSearch, cRecMenuSearchResults
@ -587,9 +585,33 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu->UpdateActiveMenuItem(); activeMenu->UpdateActiveMenuItem();
activeMenu->Show(); activeMenu->Show();
break; break;
/********************************************************************************************** /**********************************************************************************************
* CHECK FOR TIMER CONFLICTS * SWITCH TIMER
***********************************************************************************************/ ***********************************************************************************************/
case rmsSwitchTimer:
delete activeMenu;
activeMenu = new cRecMenuSwitchTimer();
activeMenu->Display();
break;
case rmsSwitchTimerCreate: {
cSwitchTimer switchTimer;
if (cRecMenuSwitchTimer *menu = dynamic_cast<cRecMenuSwitchTimer*>(activeMenu)) {
switchTimer = menu->GetSwitchTimer();
} else break;
bool success = recManager->CreateSwitchTimer(event, switchTimer);
delete activeMenu;
activeMenu = new cRecMenuSwitchTimerConfirm(success);
activeMenu->Display();
break; }
case rmsSwitchTimerDelete:
recManager->DeleteSwitchTimer(event);
delete activeMenu;
activeMenu = new cRecMenuSwitchTimerDelete();
activeMenu->Display();
break;
/**********************************************************************************************
* CHECK FOR TIMER CONFLICTS
***********************************************************************************************/
case rmsTimerConflicts: { case rmsTimerConflicts: {
//caller: main menu //caller: main menu
//Show timer conflict //Show timer conflict
@ -645,13 +667,12 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenuBuffer = activeMenu; activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide(); activeMenuBuffer->Hide();
activeMenu = new cRecMenuRerunResults(event, reruns, numReruns); activeMenu = new cRecMenuRerunResults(event, reruns, numReruns);
activeMenu->Display();
} else { } else {
activeMenuBuffer = activeMenu; activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide(); activeMenuBuffer->Hide();
activeMenu = new cRecMenuNoRerunsFound((event->Title())?event->Title():""); activeMenu = new cRecMenuNoRerunsFound((event->Title()) ? event->Title() : "");
activeMenu->Display();
} }
activeMenu->Display();
} }
} }
break; } break; }
@ -695,9 +716,9 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu->Display(); activeMenu->Display();
} }
break; } break; }
/********************************************************************************************** /**********************************************************************************************
* TIMELINE * TIMELINE
***********************************************************************************************/ ***********************************************************************************************/
case rmsTimeline: { case rmsTimeline: {
if (timerConflicts) { if (timerConflicts) {
delete timerConflicts; delete timerConflicts;
@ -739,14 +760,7 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
if (cRecMenuEditTimer *menu = dynamic_cast<cRecMenuEditTimer*>(activeMenu)) { if (cRecMenuEditTimer *menu = dynamic_cast<cRecMenuEditTimer*>(activeMenu)) {
timer = menu->GetOriginalTimer(); timer = menu->GetOriginalTimer();
} else break; } else break;
#if VDRVERSNUM >= 20301 recManager->DeleteTimer(timer);
{
LOCK_TIMERS_WRITE;
recManager->DeleteTimer(Timers->GetTimer(timer));
}
#else
recManager->DeleteTimer(Timers.GetTimer((cTimer*)timer));
#endif
delete activeMenu; delete activeMenu;
if (timerConflicts) { if (timerConflicts) {
delete timerConflicts; delete timerConflicts;
@ -755,9 +769,42 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu = new cRecMenuTimeline(timerConflicts); activeMenu = new cRecMenuTimeline(timerConflicts);
activeMenu->Display(); activeMenu->Display();
break; } break; }
/********************************************************************************************** /**********************************************************************************************
* FAVORITES * RECORDINGS SEARCH
*********************************************************************************************/ ***********************************************************************************************/
case rmsRecordingSearch: {
//caller: main menu or rmsRecordingSearchResult
std::string searchString = event->Title();
if (cRecMenuRecordingSearchResults *menu = dynamic_cast<cRecMenuRecordingSearchResults*>(activeMenu)) {
searchString = menu->GetSearchString();
};
delete activeMenu;
activeMenu = new cRecMenuRecordingSearch(searchString);
activeMenu->Display();
break; }
case rmsRecordingSearchResult: {
//caller: cRecMenuRecordingSearch
std::string searchString;
if (cRecMenuRecordingSearch *menu = dynamic_cast<cRecMenuRecordingSearch*>(activeMenu)) {
searchString = menu->GetSearchString();
} else break;
delete activeMenu;
if (searchString.size() < 4) {
activeMenu = new cRecMenuRecordingSearch(searchString);
} else {
int numSearchResults = 0;
const cRecording **searchResult = recManager->SearchForRecordings(searchString, numSearchResults);
if (numSearchResults == 0) {
activeMenu = new cRecMenuRecordingSearchNotFound(searchString);
} else {
activeMenu = new cRecMenuRecordingSearchResults(searchString, searchResult, numSearchResults);
}
}
activeMenu->Display();
break; }
/**********************************************************************************************
* FAVORITES
*********************************************************************************************/
case rmsFavoritesRecord: { case rmsFavoritesRecord: {
//caller: cRecMenuSearchTimerResults //caller: cRecMenuSearchTimerResults
const cEvent *ev = NULL; const cEvent *ev = NULL;
@ -815,9 +862,9 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
DisplayFavoriteResults(tvguideConfig.descUser4, result, numResults); DisplayFavoriteResults(tvguideConfig.descUser4, result, numResults);
break; } break; }
/********************************************************************************************** /**********************************************************************************************
* COMMON * COMMON
*********************************************************************************************/ *********************************************************************************************/
case rmsClose: { case rmsClose: {
if (activeMenuBuffer == NULL) { if (activeMenuBuffer == NULL) {
state = osEnd; state = osEnd;
@ -837,70 +884,6 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
return state; return state;
} }
void cRecMenuView::DisplayFavoriteResults(std::string header, const cEvent **result, int numResults) {
if (numResults) {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerResults(header, result, numResults, "", rmsFavoritesRecord);
activeMenu->Display();
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerNothingFound(header);
activeMenu->Display();
}
}
void cRecMenuView::DisplaySearchTimerList(void) {
delete activeMenu;
std::vector<cTVGuideSearchTimer> searchTimers;
recManager->GetSearchTimers(&searchTimers);
activeMenu = new cRecMenuSearchTimers(searchTimers);
activeMenu->Display();
}
bool cRecMenuView::DisplayTimerConflict(const cTimer *timer) {
int timerID = 0;
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
for (const cTimer *t = Timers->First(); t; t = Timers->Next(t)) {
#else
for (const cTimer *t = Timers.First(); t; t = Timers.Next(t)) {
#endif
if (t == timer)
return DisplayTimerConflict(timerID);
timerID++;
}
return false;
}
bool cRecMenuView::DisplayTimerConflict(int timerID) {
if (timerConflicts)
delete timerConflicts;
timerConflicts = recManager->CheckTimerConflict();
if (!timerConflicts)
return false;
int showTimerConflict = timerConflicts->GetCorrespondingConflict(timerID);
if (showTimerConflict > -1) {
timerConflicts->SetCurrentConflict(showTimerConflict);
cTVGuideTimerConflict *conflict = timerConflicts->GetCurrentConflict();
if (!conflict)
return false;
activeMenu = new cRecMenuTimerConflict(conflict);
activeMenu->Display();
return true;
}
return false;
}
void cRecMenuView::DisplayDetailedView(const cEvent *ev) {
activeMenu->Hide();
detailView = new cDetailView(ev, footer);
footer->SetDetailedViewMode(true);
detailView->Start();
detailViewActive = true;
}
eOSState cRecMenuView::ProcessKey(eKeys Key) { eOSState cRecMenuView::ProcessKey(eKeys Key) {
eOSState state = osContinue; eOSState state = osContinue;
eRecMenuState nextState = rmsContinue; eRecMenuState nextState = rmsContinue;