diff options
Diffstat (limited to 'channelcolumn.c')
-rw-r--r-- | channelcolumn.c | 252 |
1 files changed, 126 insertions, 126 deletions
diff --git a/channelcolumn.c b/channelcolumn.c index 7537ef2..e2aeb61 100644 --- a/channelcolumn.c +++ b/channelcolumn.c @@ -1,21 +1,21 @@ #include "channelcolumn.h" cChannelColumn::cChannelColumn(int num, const cChannel *channel, cMyTime *myTime) { - this->channel = channel; - this->num = num; - this->myTime = myTime; - hasTimer = channel->HasTimer(); + this->channel = channel; + this->num = num; + this->myTime = myTime; + hasTimer = channel->HasTimer(); schedulesLock = new cSchedulesLock(true, 100); } cChannelColumn::~cChannelColumn(void) { delete header; - grids.Clear(); + grids.Clear(); delete schedulesLock; } void cChannelColumn::clearGrids() { - grids.Clear(); + grids.Clear(); } void cChannelColumn::createHeader() { @@ -30,29 +30,29 @@ void cChannelColumn::drawHeader() { bool cChannelColumn::readGrids() { schedules = cSchedules::Schedules(*schedulesLock); - const cSchedule *Schedule = NULL; - Schedule = schedules->GetSchedule(channel); - if (!Schedule) { + const cSchedule *Schedule = NULL; + Schedule = schedules->GetSchedule(channel); + if (!Schedule) { addDummyGrid(myTime->GetStart(), myTime->GetEnd(), NULL, false); return true; - } - bool eventFound = false; + } + bool eventFound = false; bool dummyAtStart = false; - const cEvent *startEvent = Schedule->GetEventAround(myTime->GetStart()); - if (startEvent != NULL) { - eventFound = true; - } else { - for (int i=1; i<6; i++) { - startEvent = Schedule->GetEventAround(myTime->GetStart()+i*5*60); - if (startEvent) { - eventFound = true; + const cEvent *startEvent = Schedule->GetEventAround(myTime->GetStart()); + if (startEvent != NULL) { + eventFound = true; + } else { + for (int i=1; i<6; i++) { + startEvent = Schedule->GetEventAround(myTime->GetStart()+i*5*60); + if (startEvent) { + eventFound = true; dummyAtStart = true; - break; - } - } - } - if (eventFound) { - bool col = true; + break; + } + } + } + if (eventFound) { + bool col = true; if (dummyAtStart) { addDummyGrid(myTime->GetStart(), startEvent->StartTime(), NULL, col); col = !col; @@ -62,8 +62,8 @@ bool cChannelColumn::readGrids() { time_t endLast = myTime->GetStart(); const cEvent *event = startEvent; const cEvent *eventLast = NULL; - for (; event; event = Schedule->Events()->Next(event)) { - if (endLast < event->StartTime()) { + for (; event; event = Schedule->Events()->Next(event)) { + if (endLast < event->StartTime()) { //gap, dummy needed time_t endTime = event->StartTime(); if (endTime > myTime->GetEnd()) { @@ -77,19 +77,19 @@ bool cChannelColumn::readGrids() { break; } addEpgGrid(event, NULL, col); - col = !col; + col = !col; endLast = event->EndTime(); - if (event->EndTime() > myTime->GetEnd()) { + if (event->EndTime() > myTime->GetEnd()) { dummyNeeded = false; - break; - } + break; + } eventLast = event; - } + } if (dummyNeeded) { addDummyGrid(eventLast->EndTime(), myTime->GetEnd(), NULL, col); } - return true; - } else { + return true; + } else { addDummyGrid(myTime->GetStart(), myTime->GetEnd(), NULL, false); return true; } @@ -97,11 +97,11 @@ bool cChannelColumn::readGrids() { } void cChannelColumn::drawGrids() { - for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) { - grid->SetViewportHeight(); - grid->PositionPixmap(); - grid->Draw(); - } + for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) { + grid->SetViewportHeight(); + grid->PositionPixmap(); + grid->Draw(); + } } int cChannelColumn::getX() { @@ -113,57 +113,57 @@ int cChannelColumn::getY() { } cGrid * cChannelColumn::getActive() { - cMyTime t; - t.Now(); - for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) { - if (grid->Match(t.Get())) - return grid; - } - return grids.First(); + cMyTime t; + t.Now(); + for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) { + if (grid->Match(t.Get())) + return grid; + } + return grids.First(); } cGrid * cChannelColumn::getNext(cGrid *activeGrid) { - if (activeGrid == NULL) - return NULL; - cGrid *next = grids.Next(activeGrid); - if (next) - return next; - return NULL; + if (activeGrid == NULL) + return NULL; + cGrid *next = grids.Next(activeGrid); + if (next) + return next; + return NULL; } cGrid * cChannelColumn::getPrev(cGrid *activeGrid) { - if (activeGrid == NULL) - return NULL; - cGrid *prev = grids.Prev(activeGrid); - if (prev) - return prev; - return NULL; + if (activeGrid == NULL) + return NULL; + cGrid *prev = grids.Prev(activeGrid); + if (prev) + return prev; + return NULL; } cGrid * cChannelColumn::getNeighbor(cGrid *activeGrid) { - if (!activeGrid) - return NULL; - cGrid *neighbor = NULL; - int overlap = 0; - int overlapNew = 0; - cGrid *grid = NULL; - grid = grids.First(); - if (grid) { - for (; grid; grid = grids.Next(grid)) { - if ( (grid->StartTime() == activeGrid->StartTime()) ) { - neighbor = grid; - break; - } - overlapNew = activeGrid->calcOverlap(grid); - if (overlapNew > overlap) { - neighbor = grid; - overlap = overlapNew; - } - } - } - if (!neighbor) - neighbor = grids.First(); - return neighbor; + if (!activeGrid) + return NULL; + cGrid *neighbor = NULL; + int overlap = 0; + int overlapNew = 0; + cGrid *grid = NULL; + grid = grids.First(); + if (grid) { + for (; grid; grid = grids.Next(grid)) { + if ( (grid->StartTime() == activeGrid->StartTime()) ) { + neighbor = grid; + break; + } + overlapNew = activeGrid->calcOverlap(grid); + if (overlapNew > overlap) { + neighbor = grid; + overlap = overlapNew; + } + } + } + if (!neighbor) + neighbor = grids.First(); + return neighbor; } bool cChannelColumn::isFirst(cGrid *grid) { @@ -173,10 +173,10 @@ bool cChannelColumn::isFirst(cGrid *grid) { } void cChannelColumn::AddNewGridsAtStart() { - cGrid *firstGrid = NULL; - firstGrid = grids.First(); + cGrid *firstGrid = NULL; + firstGrid = grids.First(); if (firstGrid == NULL) - return; + return; //if first event is long enough, nothing to do. if (firstGrid->StartTime() <= myTime->GetStart()) { return; @@ -194,20 +194,20 @@ void cChannelColumn::AddNewGridsAtStart() { } bool col = !(firstGrid->IsColor1()); bool dummyNeeded = true; - for (const cEvent *event = Schedule->GetEventAround(firstGrid->StartTime()-60); event; event = Schedule->Events()->Prev(event)) { - if (!event) - break; + for (const cEvent *event = Schedule->GetEventAround(firstGrid->StartTime()-60); event; event = Schedule->Events()->Prev(event)) { + if (!event) + break; if (event->EndTime() < myTime->GetStart()) { break; } cGrid *grid = addEpgGrid(event, firstGrid, col); col = !col; firstGrid = grid; - if (event->StartTime() <= myTime->GetStart()) { + if (event->StartTime() <= myTime->GetStart()) { dummyNeeded = false; - break; - } - } + break; + } + } if (dummyNeeded) { firstGrid = grids.First(); if (firstGrid->isDummy()) { @@ -221,40 +221,40 @@ void cChannelColumn::AddNewGridsAtStart() { } void cChannelColumn::AddNewGridsAtEnd() { - cGrid *lastGrid = NULL; - lastGrid = grids.Last(); - if (lastGrid == NULL) - return; + cGrid *lastGrid = NULL; + lastGrid = grids.Last(); + if (lastGrid == NULL) + return; //if last event is long enough, nothing to do. - if (lastGrid->EndTime() >= myTime->GetEnd()) { + if (lastGrid->EndTime() >= myTime->GetEnd()) { return; - } - //if not, i have to add new ones to the list - schedules = cSchedules::Schedules(*schedulesLock); - const cSchedule *Schedule = NULL; - Schedule = schedules->GetSchedule(channel); - if (!Schedule) { + } + //if not, i have to add new ones to the list + schedules = cSchedules::Schedules(*schedulesLock); + const cSchedule *Schedule = NULL; + Schedule = schedules->GetSchedule(channel); + if (!Schedule) { if (lastGrid->isDummy()) { lastGrid->SetStartTime(myTime->GetStart()); lastGrid->SetEndTime(myTime->GetEnd()); } return; } - bool col = !(lastGrid->IsColor1()); + bool col = !(lastGrid->IsColor1()); bool dummyNeeded = true; - for (const cEvent *event = Schedule->GetEventAround(lastGrid->EndTime()+60); event; event = Schedule->Events()->Next(event)) { - if (!event) - break; + for (const cEvent *event = Schedule->GetEventAround(lastGrid->EndTime()+60); event; event = Schedule->Events()->Next(event)) { + if (!event) + break; if (event->StartTime() > myTime->GetEnd()) { break; } addEpgGrid(event, NULL, col); col = !col; - if (event->EndTime() > myTime->GetEnd()) { + if (event->EndTime() > myTime->GetEnd()) { dummyNeeded = false; - break; - } - } + break; + } + } if (dummyNeeded) { lastGrid = grids.Last(); if (lastGrid->isDummy()) { @@ -268,15 +268,15 @@ void cChannelColumn::AddNewGridsAtEnd() { } void cChannelColumn::ClearOutdatedStart() { - cGrid *firstGrid = NULL; - while (true) { - firstGrid = grids.First(); + cGrid *firstGrid = NULL; + while (true) { + firstGrid = grids.First(); if (!firstGrid) break; - if (firstGrid->EndTime() <= myTime->GetStart()) { + if (firstGrid->EndTime() <= myTime->GetStart()) { grids.Del(firstGrid); firstGrid = NULL; - } else { + } else { if (firstGrid->isDummy()) { firstGrid->SetStartTime(myTime->GetStart()); cGrid *next = getNext(firstGrid); @@ -287,20 +287,20 @@ void cChannelColumn::ClearOutdatedStart() { } } break; - } - } + } + } } void cChannelColumn::ClearOutdatedEnd() { - cGrid *lastGrid = NULL; - while (true) { - lastGrid = grids.Last(); + cGrid *lastGrid = NULL; + while (true) { + lastGrid = grids.Last(); if (!lastGrid) break; if (lastGrid->StartTime() >= myTime->GetEnd()) { grids.Del(lastGrid); lastGrid = NULL; - } else { + } else { if (lastGrid->isDummy()) { lastGrid->SetEndTime(myTime->GetEnd()); cGrid *prev = getPrev(lastGrid); @@ -311,8 +311,8 @@ void cChannelColumn::ClearOutdatedEnd() { } } break; - } - } + } + } } cGrid *cChannelColumn::addEpgGrid(const cEvent *event, cGrid *firstGrid, bool color) { @@ -338,10 +338,10 @@ cGrid *cChannelColumn::addDummyGrid(time_t start, time_t end, cGrid *firstGrid, } void cChannelColumn::dumpGrids() { - esyslog("tvguide: ------Channel %s: %d entires ---------", channel->Name(), grids.Count()); + esyslog("tvguide: ------Channel %s: %d entires ---------", channel->Name(), grids.Count()); int i=1; - for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) { - esyslog("tvguide: grid %d: start: %s, stop: %s", i, *cMyTime::printTime(grid->StartTime()), *cMyTime::printTime(grid->EndTime())); + for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) { + esyslog("tvguide: grid %d: start: %s, stop: %s", i, *cMyTime::printTime(grid->StartTime()), *cMyTime::printTime(grid->EndTime())); i++; } }
\ No newline at end of file |