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

View File

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

View File

@ -1,6 +1,6 @@
#include "dummygrid.h" #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->start = start;
this->end = end; this->end = end;
strText = tr("No EPG Information available"); strText = tr("No EPG Information available");

View File

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

View File

@ -3,7 +3,7 @@
#include "tools.h" #include "tools.h"
#include "epggrid.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; this->event = event;
extText = new cTextWrapper(); extText = new cTextWrapper();
hasTimer = false; hasTimer = false;

View File

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

16
grid.c
View File

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

10
grid.h
View File

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

View File

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

View File

@ -5,7 +5,7 @@
// --- cHeaderGrid ------------------------------------------------------------- // --- cHeaderGrid -------------------------------------------------------------
class cHeaderGrid : public cGrid { class cHeaderGrid : public cGridElement {
private: private:
cPixmap *pixmapLogo; cPixmap *pixmapLogo;
void drawChannelHorizontal(const cChannel *channel); 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 border = 10;
int textWidth = 0; int textWidth = 0;
textWidth = width - 2 * border; textWidth = width - 2 * border;

View File

@ -19,7 +19,7 @@ public:
virtual ~cStatusHeader(void); virtual ~cStatusHeader(void);
void Draw(void); void Draw(void);
void ScaleVideo(void); void ScaleVideo(void);
void DrawInfoText(cGrid *grid); void DrawInfoText(cGridElement *grid);
}; };
#endif //__TVGUIDE_STATUSHEADER_H #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) { if (!next || !activeGrid) {
return; return;
} }
@ -278,7 +278,7 @@ void cTvGuideOsd::channelForward() {
} }
} }
if (colRight) { if (colRight) {
cGrid *right = colRight->getNeighbor(activeGrid); cGridElement *right = colRight->getNeighbor(activeGrid);
if (right) { if (right) {
setNextActiveGrid(right); setNextActiveGrid(right);
} }
@ -335,7 +335,7 @@ void cTvGuideOsd::channelBack() {
} }
if (colLeft) { if (colLeft) {
cGrid *left = colLeft->getNeighbor(activeGrid); cGridElement *left = colLeft->getNeighbor(activeGrid);
if (left) { if (left) {
setNextActiveGrid(left); setNextActiveGrid(left);
} }
@ -356,7 +356,7 @@ void cTvGuideOsd::timeForward() {
ScrollForward(); ScrollForward();
actionDone = true; actionDone = true;
} }
cGrid *next = activeGrid->column->getNext(activeGrid); cGridElement *next = activeGrid->column->getNext(activeGrid);
if (next) { if (next) {
if ( (next->EndTime() < timeManager->GetEnd()) if ( (next->EndTime() < timeManager->GetEnd())
|| ( (timeManager->GetEnd() - next->StartTime())/60 > 30 ) ) { || ( (timeManager->GetEnd() - next->StartTime())/60 > 30 ) ) {
@ -388,7 +388,7 @@ void cTvGuideOsd::timeBack() {
ScrollBack(); ScrollBack();
actionDone = true; actionDone = true;
} }
cGrid *prev = activeGrid->column->getPrev(activeGrid); cGridElement *prev = activeGrid->column->getPrev(activeGrid);
if (prev) { if (prev) {
if ( (prev->StartTime() > timeManager->GetStart()) if ( (prev->StartTime() > timeManager->GetStart())
|| ( (prev->EndTime() - timeManager->GetStart())/60 > 30 ) || ( (prev->EndTime() - timeManager->GetStart())/60 > 30 )

View File

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