Optimize TimeJump

This commit is contained in:
kamel5 2020-01-06 12:51:49 +01:00
parent 2e4a43133e
commit 6540e21444
4 changed files with 43 additions and 41 deletions

View File

@ -8,7 +8,7 @@
#include "fontmanager.h"
#include "imagecache.h"
enum {
enum eTimeFormat {
e12Hours,
e24Hours
};

View File

@ -3,6 +3,14 @@
#include "config.h"
#include "timemanager.h"
cTimeManager::cTimeManager(void) {
if (config.displayMode == eVertical) {
displaySeconds = (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight) / geoManager.minutePixel * 60;
} else if (config.displayMode == eHorizontal) {
displaySeconds = (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth) / geoManager.minutePixel * 60;
}
}
cTimeManager::~cTimeManager(void) {
}
@ -18,40 +26,32 @@ void cTimeManager::Now() {
t = time(0);
tStart = t;
tStart = GetRounded();
if (config.displayMode == eVertical) {
tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60;
} else if (config.displayMode == eHorizontal) {
tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60;
}
tEnd = tStart + displaySeconds;
}
void cTimeManager::AddStep(int step) {
tStart += step*60;
tEnd += step*60;
tStart += step * 60;
tEnd = tStart + displaySeconds;
}
bool cTimeManager::DelStep(int step) {
if ((tStart - step*60)+30*60 < t) {
return true;
void cTimeManager::DelStep(int step) {
if ((tStart - step * 60) + 30 * 60 < t) {
Now();
} else {
tStart -= step * 60;
tEnd = tStart + displaySeconds;
}
tStart -= step*60;
tEnd -= step*60;
return false;
}
void cTimeManager::SetTime(time_t newTime) {
tStart = newTime;
if (config.displayMode == eVertical) {
tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60;
} else if (config.displayMode == eHorizontal) {
tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60;
}
tEnd = tStart + displaySeconds;
}
time_t cTimeManager::getPrevPrimetime(time_t current) {
tm *st = localtime(&current);
if (st->tm_hour < 21) {
current -= 24 * 60* 60;
current -= 24 * 60 * 60;
st = localtime(&current);
}
st->tm_hour = 20;
@ -63,7 +63,7 @@ time_t cTimeManager::getPrevPrimetime(time_t current) {
time_t cTimeManager::getNextPrimetime(time_t current){
tm *st = localtime(&current);
if (st->tm_hour > 19) {
current += 24 * 60* 60;
current += 24 * 60 * 60;
st = localtime(&current);
}
st->tm_hour = 20;

View File

@ -2,6 +2,7 @@
#define __TVGUIDE_TIMEMANAGER_H
#include <vdr/tools.h>
#include "config.h"
// --- cTimeManager -------------------------------------------------------------
@ -10,14 +11,16 @@ class cTimeManager {
time_t t;
time_t tStart;
time_t tEnd;
int displaySeconds;
eTimeFormat timeFormat;
public:
cTimeManager(){};
cTimeManager();
virtual ~cTimeManager(void);
static cString printTime(time_t displayTime);
void Now();
time_t GetNow() { return t; };
void AddStep(int step);
bool DelStep(int step);
void DelStep(int step);
void SetTime(time_t newTime);
time_t Get() {return t;};
time_t GetStart() {return tStart;};
@ -31,6 +34,7 @@ class cTimeManager {
int GetTimelineOffset();
time_t GetRounded();
bool NowVisible(void);
int GetDisplaySeconds(void) { return displaySeconds; };
void debug();
};

View File

@ -410,9 +410,7 @@ void cTvGuideOsd::timeBack() {
}
void cTvGuideOsd::ScrollBack() {
bool tooFarInPast = timeManager->DelStep(config.stepMinutes);
if (tooFarInPast)
return;
timeManager->DelStep(config.stepMinutes);
if (config.useHWAccel) {
drawGridsTimeJump();
timeLine->drawDateViewer();
@ -640,23 +638,19 @@ void cTvGuideOsd::processNumKey(int numKey) {
void cTvGuideOsd::TimeJump(int mode) {
switch (mode) {
case 1: {
bool tooFarInPast = timeManager->DelStep(config.bigStepHours*60);
if (tooFarInPast)
return;
timeManager->DelStep(config.bigStepHours * 60);
}
break;
case 3: {
timeManager->AddStep(config.bigStepHours*60);
timeManager->AddStep(config.bigStepHours * 60);
}
break;
case 4: {
bool tooFarInPast = timeManager->DelStep(config.hugeStepHours*60);
if (tooFarInPast)
return;
timeManager->DelStep(config.hugeStepHours * 60);
}
break;
case 6: {
timeManager->AddStep(config.hugeStepHours*60);
timeManager->AddStep(config.hugeStepHours * 60);
}
break;
case 7: {
@ -783,8 +777,12 @@ eOSState cTvGuideOsd::ProcessKey(eKeys Key) {
case kYellow: processKeyYellow(); break;
case kBlue: state = processKeyBlue(&alreadyUnlocked); break;
case kOk: state = processKeyOk(&alreadyUnlocked); break;
case kBack: state=osEnd; break;
case kBack: state = osEnd; break;
case k0 ... k9: processNumKey(Key - k0); break;
case kFastRew: TimeJump(1); break; // Doesnt work, if used from timeshiftmode
case kFastFwd: TimeJump(3); break;
case kPrev: TimeJump(4); break;
case kNext: TimeJump(6); break;
case kNone: if (channelJumper) CheckTimeout(); break;
default: break;
}