Change cGrid to cGridElement

This commit is contained in:
kamel5 2019-07-11 15:06:07 +02:00
parent 5ff172c987
commit d21b1496f0
14 changed files with 63 additions and 63 deletions

View File

@ -115,7 +115,7 @@ bool cChannelEpg::readGrids() {
}
void cChannelEpg::drawGrids() {
for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) {
for (cGridElement *grid = grids.First(); grid; grid = grids.Next(grid)) {
grid->SetViewportHeight();
grid->PositionPixmap();
grid->Draw();
@ -130,41 +130,41 @@ int cChannelEpg::getY() {
return geoManager.statusHeaderHeight + geoManager.timeLineHeight + num*geoManager.rowHeight;
}
cGrid * cChannelEpg::getActive() {
cGridElement *cChannelEpg::getActive() {
cTimeManager t;
t.Now();
for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) {
for (cGridElement *grid = grids.First(); grid; grid = grids.Next(grid)) {
if (grid->Match(t.Get()))
return grid;
}
return grids.First();
}
cGrid * cChannelEpg::getNext(cGrid *activeGrid) {
cGridElement *cChannelEpg::getNext(cGridElement *activeGrid) {
if (activeGrid == NULL)
return NULL;
cGrid *next = grids.Next(activeGrid);
cGridElement *next = grids.Next(activeGrid);
if (next)
return next;
return NULL;
}
cGrid * cChannelEpg::getPrev(cGrid *activeGrid) {
cGridElement *cChannelEpg::getPrev(cGridElement *activeGrid) {
if (activeGrid == NULL)
return NULL;
cGrid *prev = grids.Prev(activeGrid);
cGridElement *prev = grids.Prev(activeGrid);
if (prev)
return prev;
return NULL;
}
cGrid * cChannelEpg::getNeighbor(cGrid *activeGrid) {
cGridElement *cChannelEpg::getNeighbor(cGridElement *activeGrid) {
if (!activeGrid)
return NULL;
cGrid *neighbor = NULL;
cGridElement *neighbor = NULL;
int overlap = 0;
int overlapNew = 0;
cGrid *grid = NULL;
cGridElement *grid = NULL;
grid = grids.First();
if (grid) {
for (; grid; grid = grids.Next(grid)) {
@ -184,14 +184,14 @@ cGrid * cChannelEpg::getNeighbor(cGrid *activeGrid) {
return neighbor;
}
bool cChannelEpg::isFirst(cGrid *grid) {
bool cChannelEpg::isFirst(cGridElement *grid) {
if (grid == grids.First())
return true;
return false;
}
void cChannelEpg::AddNewGridsAtStart() {
cGrid *firstGrid = NULL;
cGridElement *firstGrid = NULL;
firstGrid = grids.First();
if (firstGrid == NULL)
return;
@ -226,7 +226,7 @@ void cChannelEpg::AddNewGridsAtStart() {
if (event->EndTime() < timeManager->GetStart()) {
break;
}
cGrid *grid = addEpgGrid(event, firstGrid, col);
cGridElement *grid = addEpgGrid(event, firstGrid, col);
col = !col;
firstGrid = grid;
if (event->StartTime() <= timeManager->GetStart()) {
@ -247,7 +247,7 @@ void cChannelEpg::AddNewGridsAtStart() {
}
void cChannelEpg::AddNewGridsAtEnd() {
cGrid *lastGrid = NULL;
cGridElement *lastGrid = NULL;
lastGrid = grids.Last();
if (lastGrid == NULL)
return;
@ -302,7 +302,7 @@ void cChannelEpg::AddNewGridsAtEnd() {
}
void cChannelEpg::ClearOutdatedStart() {
cGrid *firstGrid = NULL;
cGridElement *firstGrid = NULL;
while (true) {
firstGrid = grids.First();
if (!firstGrid)
@ -313,7 +313,7 @@ void cChannelEpg::ClearOutdatedStart() {
} else {
if (firstGrid->isDummy()) {
firstGrid->SetStartTime(timeManager->GetStart());
cGrid *next = getNext(firstGrid);
cGridElement *next = getNext(firstGrid);
if (next) {
firstGrid->SetEndTime(next->StartTime());
} else {
@ -326,7 +326,7 @@ void cChannelEpg::ClearOutdatedStart() {
}
void cChannelEpg::ClearOutdatedEnd() {
cGrid *lastGrid = NULL;
cGridElement *lastGrid = NULL;
while (true) {
lastGrid = grids.Last();
if (!lastGrid)
@ -337,7 +337,7 @@ void cChannelEpg::ClearOutdatedEnd() {
} else {
if (lastGrid->isDummy()) {
lastGrid->SetEndTime(timeManager->GetEnd());
cGrid *prev = getPrev(lastGrid);
cGridElement *prev = getPrev(lastGrid);
if (prev) {
lastGrid->SetStartTime(prev->EndTime());
} else {
@ -349,8 +349,8 @@ void cChannelEpg::ClearOutdatedEnd() {
}
}
cGrid *cChannelEpg::addEpgGrid(const cEvent *event, cGrid *firstGrid, bool color) {
cGrid *grid = new cEpgGrid(this, event);
cGridElement *cChannelEpg::addEpgGrid(const cEvent *event, cGridElement *firstGrid, bool color) {
cGridElement *grid = new cEpgGrid(this, event);
grid->setText();
grid->SetColor(color);
if (!firstGrid)
@ -360,8 +360,8 @@ cGrid *cChannelEpg::addEpgGrid(const cEvent *event, cGrid *firstGrid, bool color
return grid;
}
cGrid *cChannelEpg::addDummyGrid(time_t start, time_t end, cGrid *firstGrid, bool color) {
cGrid *dummy = new cDummyGrid(this, start, end);
cGridElement *cChannelEpg::addDummyGrid(time_t start, time_t end, cGridElement *firstGrid, bool color) {
cGridElement *dummy = new cDummyGrid(this, start, end);
dummy->setText();
dummy->SetColor(color);
if (!firstGrid)
@ -376,7 +376,7 @@ void cChannelEpg::SetTimers() {
hasTimer = channel->HasTimer();
#endif
hasSwitchTimer = SwitchTimers.ChannelInSwitchList(channel);
for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) {
for (cGridElement *grid = grids.First(); grid; grid = grids.Next(grid)) {
bool gridHadTimer = grid->HasTimer();
grid->SetTimer();
if (gridHadTimer || gridHadTimer != grid->HasTimer())
@ -392,7 +392,7 @@ void cChannelEpg::SetTimers() {
void cChannelEpg::dumpGrids() {
esyslog("tvguide: ------Channel %s %d: %d entires ---------", channel->Name(), num, grids.Count());
int i=1;
for (cGrid *grid = grids.First(); grid; grid = grids.Next(grid)) {
for (cGridElement *grid = grids.First(); grid; grid = grids.Next(grid)) {
esyslog("tvguide: grid %d: start: %s, stop: %s", i, *cTimeManager::printTime(grid->StartTime()), *cTimeManager::printTime(grid->EndTime()));
i++;
}

View File

@ -7,7 +7,7 @@
#include "headergrid.h"
#include "switchtimer.h"
class cGrid;
class cGridElement;
class cEpgGrid;
class cHeaderGrid;
@ -19,7 +19,7 @@ private:
int num;
const cChannel *channel;
cHeaderGrid *header;
cList<cGrid> grids;
cList<cGridElement> grids;
#if VDRVERSNUM >= 20301
#else
cSchedulesLock *schedulesLock;
@ -27,8 +27,8 @@ private:
const cSchedules *schedules;
bool hasTimer;
bool hasSwitchTimer;
cGrid *addEpgGrid(const cEvent *event, cGrid *firstGrid, bool color);
cGrid *addDummyGrid(time_t start, time_t end, cGrid *firstGrid, bool color);
cGridElement *addEpgGrid(const cEvent *event, cGridElement *firstGrid, bool color);
cGridElement *addDummyGrid(time_t start, time_t end, cGridElement *firstGrid, bool color);
public:
cChannelEpg(int num, const cChannel *channel, cTimeManager *timeManager);
virtual ~cChannelEpg(void);
@ -42,11 +42,11 @@ public:
int Stop() { return timeManager->GetEnd(); };
const char* Name() { return channel->Name(); };
const cChannel *getChannel() {return channel;}
cGrid * getActive();
cGrid * getNext(cGrid *activeGrid);
cGrid * getPrev(cGrid *activeGrid);
cGrid * getNeighbor(cGrid *activeGrid);
bool isFirst(cGrid *grid);
cGridElement *getActive();
cGridElement *getNext(cGridElement *activeGrid);
cGridElement *getPrev(cGridElement *activeGrid);
cGridElement *getNeighbor(cGridElement *activeGrid);
bool isFirst(cGridElement *grid);
void AddNewGridsAtStart();
void AddNewGridsAtEnd();
void ClearOutdatedStart();

View File

@ -1,6 +1,6 @@
#include "dummygrid.h"
cDummyGrid::cDummyGrid(cChannelEpg *c, time_t start, time_t end) : cGrid(c) {
cDummyGrid::cDummyGrid(cChannelEpg *c, time_t start, time_t end) : cGridElement(c) {
this->start = start;
this->end = end;
strText = tr("No EPG Information available");

View File

@ -6,7 +6,7 @@
// --- cDummyGrid -------------------------------------------------------------
class cDummyGrid : public cGrid {
class cDummyGrid : public cGridElement {
private:
time_t start;
time_t end;
@ -24,7 +24,7 @@ public:
time_t EndTime() { return end; };
void SetStartTime(time_t start) { this->start = start; };
void SetEndTime(time_t end) { this->end = end; };
int calcOverlap(cGrid *neighbor);
int calcOverlap(cGridElement *neighbor);
void setTimer() {};
cString getText(void);
cString getTimeString(void);

View File

@ -3,7 +3,7 @@
#include "tools.h"
#include "epggrid.h"
cEpgGrid::cEpgGrid(cChannelEpg *c, const cEvent *event) : cGrid(c) {
cEpgGrid::cEpgGrid(cChannelEpg *c, const cEvent *event) : cGridElement(c) {
this->event = event;
extText = new cTextWrapper();
hasTimer = false;

View File

@ -6,7 +6,7 @@
// --- cEpgGrid -------------------------------------------------------------
class cEpgGrid : public cGrid {
class cEpgGrid : public cGridElement {
private:
const cTimer *timer;
const cEvent *event;

16
grid.c
View File

@ -1,7 +1,7 @@
#include "channelepg.h"
#include "grid.h"
cGrid::cGrid(cChannelEpg *c) {
cGridElement::cGridElement(cChannelEpg *c) {
this->column = c;
text = new cTextWrapper();
dirty = true;
@ -10,11 +10,11 @@ cGrid::cGrid(cChannelEpg *c) {
borderWidth = 10;
}
cGrid::~cGrid(void) {
cGridElement::~cGridElement(void) {
delete text;
}
void cGrid::setBackground() {
void cGridElement::setBackground() {
if (active) {
color = theme.Color(clrHighlight);
colorBlending = theme.Color(clrHighlightBlending);
@ -29,7 +29,7 @@ void cGrid::setBackground() {
}
}
void cGrid::Draw() {
void cGridElement::Draw() {
if (!pixmap) {
return;
}
@ -48,20 +48,20 @@ void cGrid::Draw() {
}
}
bool cGrid::isFirst(void) {
bool cGridElement::isFirst(void) {
if (column->isFirst(this))
return true;
return false;
}
bool cGrid::Match(time_t t) {
bool cGridElement::Match(time_t t) {
if ((StartTime() < t) && (EndTime() > t))
return true;
else
return false;
}
int cGrid::calcOverlap(cGrid *neighbor) {
int cGridElement::calcOverlap(cGridElement *neighbor) {
int overlap = 0;
if (intersects(neighbor)) {
if ((StartTime() <= neighbor->StartTime()) && (EndTime() <= neighbor->EndTime())) {
@ -77,6 +77,6 @@ int cGrid::calcOverlap(cGrid *neighbor) {
return overlap;
}
bool cGrid::intersects(cGrid *neighbor) {
bool cGridElement::intersects(cGridElement *neighbor) {
return ! ( (neighbor->EndTime() <= StartTime()) || (neighbor->StartTime() >= EndTime()) );
}

10
grid.h
View File

@ -8,7 +8,7 @@ class cChannelEpg;
// --- cEpgGrid -------------------------------------------------------------
class cGrid : public cListObject, public cStyledPixmap {
class cGridElement : public cListObject, public cStyledPixmap {
protected:
cTextWrapper *text;
int viewportHeight;
@ -19,13 +19,13 @@ protected:
bool dirty;
bool hasTimer;
bool hasSwitchTimer;
bool intersects(cGrid *neighbor);
bool intersects(cGridElement *neighbor);
virtual time_t Duration(void) { return 0; };
virtual void drawText(void) {};
bool dummy;
public:
cGrid(cChannelEpg *c);
virtual ~cGrid(void);
cGridElement(cChannelEpg *c);
virtual ~cGridElement(void);
cChannelEpg *column;
virtual void SetViewportHeight(void) {};
virtual void PositionPixmap(void) {};
@ -43,7 +43,7 @@ public:
virtual time_t EndTime(void) { return 0; };
virtual void SetStartTime(time_t start) {};
virtual void SetEndTime(time_t end) {};
int calcOverlap(cGrid *neighbor);
int calcOverlap(cGridElement *neighbor);
virtual void SetTimer(void) {};
virtual void SetSwitchTimer(void) {};
virtual cString getText(void) { return cString("");};

View File

@ -2,7 +2,7 @@
#include "tools.h"
#include "headergrid.h"
cHeaderGrid::cHeaderGrid(void) : cGrid(NULL) {
cHeaderGrid::cHeaderGrid(void) : cGridElement(NULL) {
pixmap = NULL;
pixmapLogo = NULL;
}

View File

@ -5,7 +5,7 @@
// --- cHeaderGrid -------------------------------------------------------------
class cHeaderGrid : public cGrid {
class cHeaderGrid : public cGridElement {
private:
cPixmap *pixmapLogo;
void drawChannelHorizontal(const cChannel *channel);

View File

@ -55,7 +55,7 @@ void cStatusHeader::ScaleVideo(void) {
}
}
void cStatusHeader::DrawInfoText(cGrid *grid) {
void cStatusHeader::DrawInfoText(cGridElement *grid) {
int border = 10;
int textWidth = 0;
textWidth = width - 2 * border;

View File

@ -19,7 +19,7 @@ public:
virtual ~cStatusHeader(void);
void Draw(void);
void ScaleVideo(void);
void DrawInfoText(cGrid *grid);
void DrawInfoText(cGridElement *grid);
};
#endif //__TVGUIDE_STATUSHEADER_H

View File

@ -219,7 +219,7 @@ void cTvGuideOsd::drawGridsTimeJump() {
}
}
void cTvGuideOsd::setNextActiveGrid(cGrid *next) {
void cTvGuideOsd::setNextActiveGrid(cGridElement *next) {
if (!next || !activeGrid) {
return;
}
@ -278,7 +278,7 @@ void cTvGuideOsd::channelForward() {
}
}
if (colRight) {
cGrid *right = colRight->getNeighbor(activeGrid);
cGridElement *right = colRight->getNeighbor(activeGrid);
if (right) {
setNextActiveGrid(right);
}
@ -335,7 +335,7 @@ void cTvGuideOsd::channelBack() {
}
if (colLeft) {
cGrid *left = colLeft->getNeighbor(activeGrid);
cGridElement *left = colLeft->getNeighbor(activeGrid);
if (left) {
setNextActiveGrid(left);
}
@ -356,7 +356,7 @@ void cTvGuideOsd::timeForward() {
ScrollForward();
actionDone = true;
}
cGrid *next = activeGrid->column->getNext(activeGrid);
cGridElement *next = activeGrid->column->getNext(activeGrid);
if (next) {
if ( (next->EndTime() < timeManager->GetEnd())
|| ( (timeManager->GetEnd() - next->StartTime())/60 > 30 ) ) {
@ -388,7 +388,7 @@ void cTvGuideOsd::timeBack() {
ScrollBack();
actionDone = true;
}
cGrid *prev = activeGrid->column->getPrev(activeGrid);
cGridElement *prev = activeGrid->column->getPrev(activeGrid);
if (prev) {
if ( (prev->StartTime() > timeManager->GetStart())
|| ( (prev->EndTime() - timeManager->GetStart())/60 > 30 )

View File

@ -18,7 +18,7 @@ class cTvGuideOsd : public cOsdObject {
private:
cTimeManager *timeManager;
cList<cChannelEpg> columns;
cGrid *activeGrid;
cGridElement *activeGrid;
cStatusHeader *statusHeader;
cDetailView *detailView;
cTimeLine *timeLine;
@ -45,7 +45,7 @@ private:
void TimeJump(int mode);
void ChannelJump(int num);
void CheckTimeout(void);
void setNextActiveGrid(cGrid *next);
void setNextActiveGrid(cGridElement *next);
void channelForward();
void channelBack();
void timeForward();