Rework recmenuview.c

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

View File

@ -84,6 +84,70 @@ void cRecMenuView::DeleteBackground(void) {
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 state = osContinue;
switch (nextState) {
@ -111,6 +175,47 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu = new cRecMenuAskFolder(event, rmsInstantRecord);
activeMenu->Display();
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:
//caller: cRecMenuTimerConflict
//Confirming created Timer
@ -189,55 +294,6 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu->Display();
}
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;
#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
****************************************************************************************/
@ -363,13 +419,12 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerResults(searchTimer.GetSearchString(), searchResult, numSearchResults, "", recState);
activeMenu->Display();
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuSearchTimerNothingFound(searchTimer.GetSearchString());
activeMenu->Display();
}
activeMenu->Display();
break; }
case rmsSearchTimerSave: {
//caller: cRecMenuSearchTimerEdit, cRecMenuSearchTimerTemplatesCreate
@ -448,63 +503,6 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu = new cRecMenuSearchConfirmTimer(ev, rmsFavoritesRecordConfirm);
activeMenu->Display();
break; }
/**********************************************************************************************
* 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;
/**********************************************************************************************
* 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
***********************************************************************************************/
@ -588,6 +586,30 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenu->Show();
break;
/**********************************************************************************************
* 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: {
@ -645,13 +667,12 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuRerunResults(event, reruns, numReruns);
activeMenu->Display();
} else {
activeMenuBuffer = activeMenu;
activeMenuBuffer->Hide();
activeMenu = new cRecMenuNoRerunsFound((event->Title()) ? event->Title() : "");
activeMenu->Display();
}
activeMenu->Display();
}
}
break; }
@ -739,14 +760,7 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
if (cRecMenuEditTimer *menu = dynamic_cast<cRecMenuEditTimer*>(activeMenu)) {
timer = menu->GetOriginalTimer();
} else break;
#if VDRVERSNUM >= 20301
{
LOCK_TIMERS_WRITE;
recManager->DeleteTimer(Timers->GetTimer(timer));
}
#else
recManager->DeleteTimer(Timers.GetTimer((cTimer*)timer));
#endif
recManager->DeleteTimer(timer);
delete activeMenu;
if (timerConflicts) {
delete timerConflicts;
@ -756,6 +770,39 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
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; }
/**********************************************************************************************
* FAVORITES
*********************************************************************************************/
case rmsFavoritesRecord: {
@ -837,70 +884,6 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
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 state = osContinue;
eRecMenuState nextState = rmsContinue;