Fixed a problem in DisplayTimerConflict

This commit is contained in:
kamel5 2020-02-23 19:41:24 +01:00
parent 9044e092f8
commit 874f5cd9d5
7 changed files with 47 additions and 34 deletions

View File

@ -130,7 +130,7 @@ cTimer *cRecManager::createLocalTimer(const cEvent *event, std::string path) {
isyslog("timer %s added (active)", *timer->ToDescr());
#endif
}
return timer;
return timers->GetTimer(timer);
}
cTimer *cRecManager::createRemoteTimer(const cEvent *event, std::string path) {

View File

@ -589,10 +589,14 @@ void cRecMenu::UpdateActiveMenuItem(void) {
void cRecMenu::DrawScrollBar(void) {
if (!pixmapScrollBar)
return;
pixmapScrollBar->Fill(theme.Color(clrBorder));
pixmapScrollBar->DrawRectangle(cRect(2,2,pixmapScrollBar->ViewPort().Width()-4, pixmapScrollBar->ViewPort().Height() - 4), theme.Color(clrBackground));
int totalNumItems = GetTotalNumMenuItems();
if (!totalNumItems)
return;
if (imgScrollBar == NULL) {
int scrollBarImgHeight = (pixmapScrollBar->ViewPort().Height() - 8) * numItems / totalNumItems;
imgScrollBar = createScrollbar(pixmapScrollBar->ViewPort().Width()-8, scrollBarImgHeight, theme.Color(clrHighlight), theme.Color(clrHighlightBlending));

View File

@ -1548,6 +1548,7 @@ cRecMenuItemTimer::cRecMenuItemTimer(const cTimer *timer,
this->overlapStop = overlapStop;
this->active = active;
height = 3 * font->Height();
pixmapStatus = NULL;
pixmapIcons = NULL;
}
@ -1585,6 +1586,8 @@ void cRecMenuItemTimer::Show(void) {
}
void cRecMenuItemTimer::Draw(void) {
if (!timer)
return;
const cChannel *channel = timer->Channel();
int channelTransponder = 0;
cString channelName = "";
@ -1740,8 +1743,13 @@ cRecMenuItemTimerConflictHeader::~cRecMenuItemTimerConflictHeader(void) {
}
void cRecMenuItemTimerConflictHeader::SetPixmaps(void) {
pixmap = osdManager.requestPixmap(4, cRect(x, y, width, height));
pixmapStatus = osdManager.requestPixmap(5, cRect(x, y, width, height));
if (!pixmap) {
pixmap = osdManager.requestPixmap(4, cRect(x, y, width, height));
pixmapStatus = osdManager.requestPixmap(5, cRect(x, y, width, height));
} else {
pixmap->SetViewPort(cRect(x, y, width, height));
pixmapStatus->SetViewPort(cRect(x, y, width, height));
}
pixmapStatus->Fill(clrTransparent);
}

View File

@ -194,8 +194,9 @@ cRecMenuAskDeleteTimer::cRecMenuAskDeleteTimer(const cEvent *event) {
// --- cRecMenuTimerConflicts ---------------------------------------------------------
cRecMenuTimerConflicts::cRecMenuTimerConflicts(cTVGuideTimerConflicts *conflicts) {
int numConflicts = conflicts->NumConflicts();
SetWidthPercent(50);
int numConflicts = (conflicts) ? conflicts->NumConflicts() : 0;
cString text;
if (numConflicts == 1) {
text = cString::sprintf("%s %s %s", tr("One"), tr("Timer Conflict"), tr("detected"));
@ -233,16 +234,18 @@ int cRecMenuTimerConflicts::GetTimerConflict(void) {
cRecMenuTimerConflict::cRecMenuTimerConflict(cTVGuideTimerConflict *conflict) {
SetWidthPercent(95);
this->conflict = conflict;
SetHeader(new cRecMenuItemTimerConflictHeader(conflict->timeStart,
conflict->timeStop,
conflict->overlapStart,
totalNumMenuItems = (int)conflict->timerIDs.size();
SetHeader(new cRecMenuItemTimerConflictHeader(conflict->timeStart,
conflict->timeStop,
conflict->overlapStart,
conflict->overlapStop));
SetFooter(new cRecMenuItemButton(tr("Ignore Conflict"), rmsIgnoreTimerConflict, false, true));
int i=0;
for(std::vector<int>::iterator it = conflict->timerIDs.begin(); it != conflict->timerIDs.end(); it++) {
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
const cTimer *timer = Timers->Get(*it);
const cTimer *timer = Timers->GetById(*it + 1);
#else
const cTimer *timer = Timers.Get(*it);
#endif
@ -268,7 +271,7 @@ cRecMenuTimerConflict::cRecMenuTimerConflict(cTVGuideTimerConflict *conflict) {
}
cRecMenuItem *cRecMenuTimerConflict::GetMenuItem(int number) {
if ((number >= 0) && (number < (int)conflict->timerIDs.size())) {
if ((number >= 0) && (number < totalNumMenuItems)) {
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
const cTimer *timer = Timers->Get(conflict->timerIDs[number]);
@ -290,8 +293,8 @@ cRecMenuItem *cRecMenuTimerConflict::GetMenuItem(int number) {
return NULL;
}
int cRecMenuTimerConflict::GetTotalNumMenuItems(void) {
return conflict->timerIDs.size();
int cRecMenuTimerConflict::GetTotalNumMenuItems(void) {
return totalNumMenuItems;
}
int cRecMenuTimerConflict::GetTimerConflictIndex(void) {

View File

@ -77,11 +77,12 @@ public:
class cRecMenuTimerConflict: public cRecMenu {
private:
cTVGuideTimerConflict *conflict;
int totalNumMenuItems;
public:
cRecMenuTimerConflict(cTVGuideTimerConflict *conflict);
virtual ~cRecMenuTimerConflict(void) {};
cRecMenuItem *GetMenuItem(int number);
int GetTotalNumMenuItems(void);
virtual ~cRecMenuTimerConflict(void) {};
int GetTimerConflictIndex(void);
};

View File

@ -93,7 +93,6 @@ void cRecMenuView::DisplaySearchTimerList(void) {
}
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)) {
@ -101,8 +100,7 @@ bool cRecMenuView::DisplayTimerConflict(const cTimer *timer) {
for (const cTimer *t = Timers.First(); t; t = Timers.Next(t)) {
#endif
if (t == timer)
return DisplayTimerConflict(timerID);
timerID++;
return DisplayTimerConflict(timer->Id() - 1);
}
return false;
}
@ -229,10 +227,10 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
if (cRecMenuTimerConflict *menu = dynamic_cast<cRecMenuTimerConflict*>(activeMenu)) {
timerIndex = menu->GetTimerConflictIndex();
} else break;
int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex);
int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex) + 1;
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
const cTimer *t = Timers->Get(timerID);
const cTimer *t = Timers->GetById(timerID);
#else
const cTimer *t = Timers.Get(timerID);
#endif
@ -250,7 +248,7 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
if (cRecMenuTimerConflict *menu = dynamic_cast<cRecMenuTimerConflict*>(activeMenu)) {
timerIndex = menu->GetTimerConflictIndex();
} else break;
int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex);
int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex) + 1;
const cTimers* timers;
#if VDRVERSNUM >= 20301
{
@ -260,10 +258,11 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
#else
timers = &Timers;
#endif
recManager->DeleteTimer(timers->Get(timerID)->Event());
const cEvent *event = timers->GetById(timerID)->Event();
recManager->DeleteTimer(event); // (timerID);
delete activeMenu;
if (!DisplayTimerConflict(timerID)) {
activeMenu = new cRecMenuConfirmTimer(timers->Get(timerID)->Event());
activeMenu = new cRecMenuConfirmDeleteTimer(event);
activeMenu->Display();
}
break; }
@ -274,10 +273,10 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
if (cRecMenuTimerConflict *menu = dynamic_cast<cRecMenuTimerConflict*>(activeMenu)) {
timerIndex = menu->GetTimerConflictIndex();
} else break;
int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex);
int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex) + 1;
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
const cTimer *timer = Timers->Get(timerID);
const cTimer *timer = Timers->GetById(timerID);
#else
const cTimer *timer = Timers.Get(timerID);
#endif
@ -660,10 +659,10 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) {
if (cRecMenuTimerConflict *menu = dynamic_cast<cRecMenuTimerConflict*>(activeMenu)) {
timerConflict = menu->GetTimerConflictIndex();
} else break;
int timerID = timerConflicts->GetCurrentConflictTimerID(timerConflict);
int timerID = timerConflicts->GetCurrentConflictTimerID(timerConflict) + 1;
#if VDRVERSNUM >= 20301
LOCK_TIMERS_READ;
const cTimer *timer = Timers->Get(timerID);
const cTimer *timer = Timers->GetById(timerID);
#else
cTimer *timer = Timers.Get(timerID);
#endif

View File

@ -16,12 +16,11 @@ cTVGuideTimerConflict::cTVGuideTimerConflict(void) {
}
cTVGuideTimerConflict::~cTVGuideTimerConflict(void) {
}
bool cTVGuideTimerConflict::timerInvolved(int involvedID) {
int numConflicts = timerIDs.size();
for (int i=0; i<numConflicts; i++) {
for (int i = 0; i < numConflicts; i++) {
if (timerIDs[i] == involvedID)
return true;
}
@ -44,13 +43,12 @@ cTVGuideTimerConflicts::~cTVGuideTimerConflicts(void) {
}
void cTVGuideTimerConflicts::AddConflict(std::string epgSearchConflictLine) {
/* TIMERCONFLICT FORMAT:
/* TIMERCONFLICT FORMAT:
The result list looks like this for example when we have 2 timer conflicts at one time:
1190232780:152|30|50#152#45:45|10|50#152#45
'1190232780' is the time of the conflict in seconds since 1970-01-01.
It's followed by list of timers that have a conflict at this time:
'152|30|50#1 int editTimer(cTimer *timer, bool active, int prio, int start, int stop);
52#45' is the description of the first conflicting timer. Here:
'152|30|50#152#45' is the description of the first conflicting timer. Here:
'152' is VDR's timer id of this timer as returned from VDR's LSTT command
'30' is the percentage of recording that would be done (0...100)
'50#152#45' is the list of concurrent timers at this conflict
@ -90,7 +88,7 @@ void cTVGuideTimerConflicts::CalculateConflicts(void) {
const cTimers* timers = &Timers;
#endif
for (int j=0; j < numTimers; j++) {
const cTimer *timer = timers->Get(conflicts[i]->timerIDs[j]);
const cTimer *timer = timers->GetById(conflicts[i]->timerIDs[j] + 1);
if (timer) {
if (!unionSet) {
unionSet = new cTimeInterval(timer->StartTime(), timer->StopTime());
@ -109,7 +107,7 @@ void cTVGuideTimerConflicts::CalculateConflicts(void) {
cTimeInterval *intersect = NULL;
for (int j=0; j < numTimers; j++) {
const cTimer *timer = timers->Get(conflicts[i]->timerIDs[j]);
const cTimer *timer = timers->GetById(conflicts[i]->timerIDs[j] + 1);
if (timer) {
if (!intersect) {
intersect = new cTimeInterval(timer->StartTime(), timer->StopTime());
@ -152,7 +150,7 @@ int cTVGuideTimerConflicts::GetCurrentConflictTimerID(int timerIndex) {
int cTVGuideTimerConflicts::GetCorrespondingConflict(int timerID) {
int conflictIndex = -1;
if (numConflicts > 0) {
for (int i=0; i<numConflicts; i++) {
for (int i = 0; i < numConflicts; i++) {
if (conflicts[i]->timerInvolved(timerID)) {
conflictIndex = i;
break;
@ -172,7 +170,7 @@ cTVGuideTimerConflict *cTVGuideTimerConflicts::GetConflict(int conflictIndex) {
std::vector<cTVGuideTimerConflict*> cTVGuideTimerConflicts::GetConflictsBetween(time_t start, time_t stop) {
std::vector<cTVGuideTimerConflict*> conflictsFound;
for (int i=0; i < numConflicts; i++) {
for (int i = 0; i < numConflicts; i++) {
if ((conflicts[i]->timeStart > start) && (conflicts[i]->timeStart < stop)||
(conflicts[i]->timeStop > start) && (conflicts[i]->timeStop < stop))
conflictsFound.push_back(conflicts[i]);