From 776f93d7db219e126482ea8d445d28df9a14dd03 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 11 Apr 2020 16:59:21 +0100 Subject: [PATCH] In VEPGListAdvanced: rewrote getCurrentOptionEvent() and all CWFs --- vepglistadvanced.cc | 125 +++++++++++++++----------------------------- vepglistadvanced.h | 2 +- 2 files changed, 43 insertions(+), 84 deletions(-) diff --git a/vepglistadvanced.cc b/vepglistadvanced.cc index a178e88..cd3c15c 100644 --- a/vepglistadvanced.cc +++ b/vepglistadvanced.cc @@ -77,7 +77,7 @@ VEpgListAdvanced::VEpgListAdvanced(VVideoLiveTV* tvideolive, ChannelList* tchanL epg.setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND); epgTVmedia.setPosition(epg.getRegionR().w - 100 - 10, 10); - epgTVmedia.setSize(100, (UINT)(150 / Osd::getInstance()->getPixelAspect())); + epgTVmedia.setSize(100, static_cast(150 / Osd::getInstance()->getPixelAspect())); epg.add(&epgTVmedia); boxRed.setBackgroundColour(DrawStyle::RED); @@ -237,6 +237,7 @@ void VEpgListAdvanced::doNext() draw(true); boxstack->update(this); } + void VEpgListAdvanced::doNow() { Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doNow"); @@ -304,7 +305,7 @@ void VEpgListAdvanced::doSwitch() void VEpgListAdvanced::doRecord() { - int channel; + ULONG channel; Event* current = getCurrentOptionEvent(channel); if (current) @@ -318,7 +319,7 @@ void VEpgListAdvanced::doRecord() { chan = (*chanList)[listIndex]; - if ((int)chan->number == channel) break; + if (chan->number == channel) break; } Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", @@ -328,7 +329,6 @@ void VEpgListAdvanced::doRecord() boxstack->add(vs); boxstack->update(vs); } - } void VEpgListAdvanced::doGrid() @@ -411,7 +411,7 @@ void VEpgListAdvanced::updateEpgDataNowNext(bool changeState) int startupdate = 0; int endupdate = 0; - unsigned int chanlistsize = chanList->size(); + UINT chanlistsize = chanList->size(); if (changeState) { @@ -421,7 +421,6 @@ void VEpgListAdvanced::updateEpgDataNowNext(bool changeState) for (UINT listIndex = 0; listIndex < chanlistsize; listIndex++) { - if (listIndex < 0) continue; if (listIndex >= chanlistsize) continue; chan = (*chanList)[listIndex]; @@ -448,7 +447,7 @@ void VEpgListAdvanced::updateEpgDataNowNext(bool changeState) for (int listIndex = startupdate; listIndex < endupdate; listIndex++) { if (listIndex < 0) continue; - if (listIndex >= (int)chanlistsize) continue; + if (listIndex >= static_cast(chanlistsize)) continue; chan = (*chanList)[listIndex]; @@ -468,25 +467,9 @@ void VEpgListAdvanced::updateEpgDataChannel() void VEpgListAdvanced::drawData(bool doIndexPop) { - switch (mode) - { - case OneChannel: - { - drawDataChannel(doIndexPop); - break; - } - case Next: - { - drawDataNowNext(true, doIndexPop); - break; - } - case Now: - { - drawDataNowNext(false, doIndexPop); - break; - } - }; - + if (mode == OneChannel) drawDataChannel(doIndexPop); + else if (mode == Next) drawDataNowNext(true, doIndexPop); + else if (mode == Now) drawDataNowNext(false, doIndexPop); } void VEpgListAdvanced::drawDataChannel(bool doIndexPop) @@ -516,14 +499,14 @@ void VEpgListAdvanced::drawDataChannel(bool doIndexPop) for (j = eventList->begin(); j != eventList->end(); j++) { currentEvent = *j; - time_t eventStartTime = (time_t)currentEvent->time; - time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration); + time_t eventStartTime = static_cast(currentEvent->time); + time_t eventEndTime = static_cast(currentEvent->time + currentEvent->duration); LOCALTIME_R(&eventStartTime, &btime); strftime(tempA, 300, "%d/%m/%y %H:%M ", &btime); LOCALTIME_R(&eventEndTime, &btime); strftime(tempB, 300, "- %H:%M ", &btime); - int check = SNPRINTF(tempC, 300, "\t %s\n \t \t%s%s", currentEvent->title, tempA, tempB); + int check = SNPRINTF(tempC, 300, "\t %s\n \t \t%s%s", currentEvent->title.c_str(), tempA, tempB); if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big"); @@ -567,7 +550,7 @@ void VEpgListAdvanced::drawDataNowNext(bool next, bool doIndexPop) Event* currentEvent = NULL; EventList::iterator j; - int minevents = 1; + UINT minevents = 1; if (next) minevents++; @@ -582,19 +565,19 @@ void VEpgListAdvanced::drawDataNowNext(bool next, bool doIndexPop) EventList* eventList = eventLista[listIndex]; - if (eventList && ((int)eventList->size() >= minevents)) + if (eventList && (eventList->size() >= minevents)) { j = eventList->begin(); currentEvent = j[minevents - 1]; - time_t eventStartTime = (time_t)currentEvent->time; - time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration); + time_t eventStartTime = static_cast(currentEvent->time); + time_t eventEndTime = static_cast(currentEvent->time + currentEvent->duration); LOCALTIME_R(&eventStartTime, &btime); strftime(tempA, 300, "%H:%M ", &btime); LOCALTIME_R(&eventEndTime, &btime); strftime(tempB, 300, "- %H:%M ", &btime); - int check = SNPRINTF(tempC, 300, "%s\n%s\t %s%s", currentEvent->title, chan->name, tempA, tempB); + int check = SNPRINTF(tempC, 300, "%s\n%s\t %s%s", currentEvent->title.c_str(), chan->name, tempA, tempB); if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big"); } @@ -708,61 +691,37 @@ void VEpgListAdvanced::draw(bool doIndexPop) // All static stuff done } -Event* VEpgListAdvanced::getCurrentOptionEvent(int& channel) +Event* VEpgListAdvanced::getCurrentOptionEvent(ULONG& channel) { - // version for channel - Event* currentEvent = NULL; - EventList::iterator j; - EventList* eventList = NULL; - ULONG slCurrentOption = reinterpret_cast(sl.getCurrentOptionData()); + if (mode == OneChannel) + { + channel = channelNumber; - switch (mode) - { - case OneChannel: { - eventList = eventLista[0]; - if (eventList) { - channel = channelNumber; - for (j = eventList->begin(); j != eventList->end(); j++) - { - currentEvent = *j; - if (currentEvent->index == slCurrentOption) return currentEvent; - } - - - } break; - case Next: { - eventList = eventLista[slCurrentOption]; - channel = (*chanList)[slCurrentOption]->number; - - - if (eventList && eventList->size()>1) { - j = eventList->begin(); - currentEvent = j[1]; - } else { - currentEvent = NULL; - } - } break; - case Now: { - eventList = eventLista[slCurrentOption]; - channel = (*chanList)[slCurrentOption]->number; - - if (eventList && eventList->size()>0) { - j = eventList->begin(); - currentEvent = j[0]; - } else { - currentEvent = NULL; - } - } break; - }; + EventList* eventList = eventLista[0]; + if (!eventList) return NULL; + for (Event* currentEvent : *eventList) + { + if (currentEvent->index == sl.getCurrentOption()) return currentEvent; + } + } + else if ((mode == Now) || (mode == Next)) + { + ULONG slCurrentOptionData = reinterpret_cast(sl.getCurrentOptionData()); + EventList* eventList = eventLista[slCurrentOptionData]; + if (!eventList) return NULL; + channel = (*chanList)[slCurrentOptionData]->number; + if ((mode == Now) && (eventList->size() > 0)) return (*eventList)[0]; + else if ((mode == Next) && (eventList->size() > 1)) return (*eventList)[1]; } - return currentEvent; + + return NULL; } void VEpgListAdvanced::updateSelection() { - int channel = 0; + ULONG channel = 0; if (mode == OneChannel) { @@ -918,12 +877,12 @@ int VEpgListAdvanced::handleCommand(int command) { if (sl.getNumOptions() == 0) return 2; - int channel; + ULONG channel; Event* current = getCurrentOptionEvent(channel); if (current) { - Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title, current->id); + Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title.c_str(), current->id); unsigned int chanlistsize = chanList->size(); Channel* chan; UINT listIndex; @@ -931,7 +890,7 @@ int VEpgListAdvanced::handleCommand(int command) for (listIndex = 0; listIndex < chanlistsize; listIndex++) { chan = (*chanList)[listIndex]; - if ((int)chan->number == channel) break; + if (chan->number == channel) break; } VEpgSummary* vr = new VEpgSummary(current, (*chanList)[listIndex]); diff --git a/vepglistadvanced.h b/vepglistadvanced.h index 1e1566d..9f9ed5d 100644 --- a/vepglistadvanced.h +++ b/vepglistadvanced.h @@ -88,7 +88,7 @@ class VEpgListAdvanced : public TBBoxx WSelectList sl; - Event* getCurrentOptionEvent(int& channel); + Event* getCurrentOptionEvent(ULONG& channel); ChannelList* chanList; ULONG channelNumber; -- 2.39.5