From eb098ca715bba87841d2210e93f0f3b849eb590f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 6 Dec 2005 22:48:36 +0000 Subject: [PATCH] Internationalise EPG, add timed input code to vchannelselect --- vchannelselect.cc | 69 +++++++++++++++++++++++++----- vchannelselect.h | 10 ++++- vepg.cc | 106 +++++++++++++++++++++++----------------------- 3 files changed, 120 insertions(+), 65 deletions(-) diff --git a/vchannelselect.cc b/vchannelselect.cc index 24ce79e..14b4e01 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -33,11 +33,16 @@ VChannelSelect::VChannelSelect(VVideoLive* v, int command) first = -1; second = -1; third = command; - pos = 0; + numGot = 1; videoLive = v; } +VChannelSelect::~VChannelSelect() +{ + Timers::getInstance()->cancelTimer(this, 1); +} + void VChannelSelect::draw() { View::draw(); @@ -90,6 +95,8 @@ void VChannelSelect::draw() break; } } + + Timers::getInstance()->setTimer(this, 1, (struct timespec){3, 0}); } int VChannelSelect::handleCommand(int command) @@ -98,12 +105,15 @@ int VChannelSelect::handleCommand(int command) { case Remote::ZERO ... Remote::NINE: { - if (pos == 1) first = second; + if (numGot == 2) first = second; second = third; third = command; + ++numGot; + draw(); show(); - if (pos == 1) + + if (numGot == 3) { Message* m = new Message(); m->from = this; @@ -111,14 +121,17 @@ int VChannelSelect::handleCommand(int command) m->message = Message::CLOSE_ME; ViewMan::getInstance()->postMessage(m); - m = new Message(); - m->from = this; - m->to = videoLive; - m->message = Message::CHANNEL_CHANGE; - m->parameter = (first * 100) + (second * 10) + third; - ViewMan::getInstance()->postMessage(m); + // Is there valid data? + if ((first > 0) || (second > 0) || (third > 0)) + { + m = new Message(); + m->from = this; + m->to = videoLive; + m->message = Message::CHANNEL_CHANGE; + m->parameter = (first * 100) + (second * 10) + third; + ViewMan::getInstance()->postMessage(m); + } } - pos = 1; return 2; } @@ -127,3 +140,39 @@ int VChannelSelect::handleCommand(int command) // allow command to drop through to other views return 0; } + +void VChannelSelect::timercall(int clientReference) +{ + Log::getInstance()->log("VChannelSelect", Log::DEBUG, "Timer call"); + + // Close me + Message* m = new Message(); + m->from = this; + m->to = ViewMan::getInstance(); + m->message = Message::CLOSE_ME; + ViewMan::getInstance()->postMessage(m); + + // Is there valid data? + if ((first > 0) || (second > 0) || (third > 0)) + { + // Change channel + + ULONG newChannel = 0; + switch(numGot) + { + case 3: + newChannel += first * 100; + case 2: + newChannel += second * 10; + case 1: + newChannel += third; + } + + m = new Message(); + m->from = this; + m->to = videoLive; + m->message = Message::CHANNEL_CHANGE; + m->parameter = newChannel; + ViewMan::getInstance()->postMessage(m); + } +} diff --git a/vchannelselect.h b/vchannelselect.h index cb95c6e..a1cc793 100644 --- a/vchannelselect.h +++ b/vchannelselect.h @@ -29,22 +29,28 @@ #include "message.h" #include "viewman.h" #include "colour.h" +#include "log.h" +#include "timerreceiver.h" +#include "timers.h" class VVideoLive; -class VChannelSelect : public View +class VChannelSelect : public View, public TimerReceiver { public: VChannelSelect(VVideoLive* v, int command); + ~VChannelSelect(); + void draw(); int handleCommand(int command); + void timercall(int clientReference); private: int first; int second; int third; - int pos; + int numGot; VVideoLive* videoLive; }; diff --git a/vepg.cc b/vepg.cc index 014a90c..0f16515 100644 --- a/vepg.cc +++ b/vepg.cc @@ -175,35 +175,35 @@ void VEpg::draw() w.setSurfaceOffset(keyx + 50, keyy + 20); w.draw(); - drawText("OK", keyx + 18, keyy + 20, Colour::LIGHTTEXT); + drawText(tr("OK"), keyx + 18, keyy + 20, Colour::LIGHTTEXT); surface->fillblt(keyx + 72, keyy + 4, 104, Surface::getFontHeight() + 2, surface->rgba(200, 0, 0, 255)); - drawText("Page up", keyx + 74, keyy + 5, Colour::LIGHTTEXT); + drawText(tr("Page up"), keyx + 74, keyy + 5, Colour::LIGHTTEXT); surface->fillblt(keyx + 72, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, surface->rgba(0, 200, 0, 255)); - drawText("Page down", keyx + 74, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); + drawText(tr("Page down"), keyx + 74, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); surface->fillblt(keyx + 180, keyy + 4, 104, Surface::getFontHeight() + 2, surface->rgba(200, 200, 0, 255)); - drawText("-24 hours", keyx + 182, keyy + 5, Colour::LIGHTTEXT); + drawText(tr("-24 hours"), keyx + 182, keyy + 5, Colour::LIGHTTEXT); surface->fillblt(keyx + 180, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, surface->rgba( 0, 0, 200, 255)); - drawText("+24 hours", keyx + 182, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); + drawText(tr("+24 hours"), keyx + 182, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); surface->fillblt(keyx + 290, keyy + 4, 180, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255)); - drawText("Guide / Back: Close", keyx + 292 , keyy + 5, Colour::LIGHTTEXT); + drawText(tr("Guide / Back: Close"), keyx + 292 , keyy + 5, Colour::LIGHTTEXT); surface->fillblt(keyx + 290, keyy + Surface::getFontHeight() + 8, 180, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255)); Colour red = Colour(130, 0, 0); - drawText("Rec: Set timer", keyx + 292, keyy + Surface::getFontHeight() + 9, red); + drawText(tr("Rec: Set timer"), keyx + 292, keyy + Surface::getFontHeight() + 9, red); surface->fillblt(keyx + 474, keyy + 4, 128, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255)); w.nextSymbol = WSymbol::PLAY; w.setSurfaceOffset(keyx + 476, keyy + 5); w.draw(); - drawText("Sel channel", keyx + 496, keyy + 5, Colour::LIGHTTEXT); + drawText(tr("Sel channel"), keyx + 496, keyy + 5, Colour::LIGHTTEXT); surface->fillblt(keyx + 474, keyy + Surface::getFontHeight() + 8, 128, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255)); - drawText("Go: Preview", keyx + 476, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); + drawText(tr("Go: Preview"), keyx + 476, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); } int VEpg::handleCommand(int command) @@ -373,10 +373,10 @@ void VEpg::drawgrid() // redraws grid and select programme // TODO should the above two comditional statements be combined to avoid calling updateEventList() twice? Event* event; Event noevent; // an event to use if there are gaps in the epg - thisEvent.setdescription("There are no programme details available for this period"); + thisEvent.setdescription(tr("There are no programme details available for this period")); thisEvent.duration = WINDOW_WIDTH * 60; thisEvent.time = ltime; - thisEvent.settitle("No programme details"); + thisEvent.settitle(tr("No programme details")); thisEvent.id = 0; bool swapColour = FALSE; // alternate cell colour bool currentRow = FALSE; @@ -394,10 +394,10 @@ void VEpg::drawgrid() // redraws grid and select programme paintCell(&noevent, y, Colour::NOPROGRAMME, Colour::LIGHTTEXT); // fill row with no programme colour to be painted ove with valid programmes if (currentRow) { - thisEvent.setdescription("There are no programme details available for this period"); + thisEvent.setdescription(tr("There are no programme details available for this period")); thisEvent.duration = WINDOW_WIDTH * 60; thisEvent.time = ltime; - thisEvent.settitle("No programme details"); + thisEvent.settitle(tr("No programme details")); thisEvent.id = 0; } if (eventLista[listIndex]) @@ -405,48 +405,48 @@ void VEpg::drawgrid() // redraws grid and select programme sort(eventLista[listIndex]->begin(), eventLista[listIndex]->end(), EventSorter()); for(e = 0; e < (eventLista[listIndex])->size(); e++) // step through events for this channel { - fg = Colour::LIGHTTEXT; + fg = Colour::LIGHTTEXT; event = (*eventLista[listIndex])[e]; - if (event) - { - UINT end = event->time + event->duration; // programme end time - if(event->time >= UINT(ltime) + (WINDOW_WIDTH * 60)) // programme starts after RHS of window - continue; // that's enough of this channel's events - if(end <= UINT(ltime)) // programme ends before LHS of window - continue; // this event is before the window - let's try the next event - // this event is one we are interested in - bg = (swapColour)?Colour::PROGRAMMEA:Colour::PROGRAMMEB; // alternate cell colour - swapColour = !swapColour; // it wil be the other colour next time - if(event->time <= UINT(selTime) && end > UINT(selTime) && currentRow) - { - // this is the selected programme - thisEvent.setdescription(event->description); - thisEvent.duration = event->duration; - thisEvent.time = event->time; - thisEvent.settitle(event->title); - thisEvent.id = event->id; - if(thisEvent.id == 0) - thisEvent.id = 1; - bg = Colour::SELECTHIGHLIGHT; // highlight cell - fg = Colour::DARKTEXT; - } - else - { - if (currentRow && thisEvent.id == 0) - { - if (end <= UINT(selTime) && end > UINT(thisEvent.time)) - thisEvent.time = end; - if (event->time > UINT(selTime) && event->time < thisEvent.time + thisEvent.duration) - thisEvent.duration = event->time - thisEvent.time; - } - } - paintCell(event, y, bg, fg); - } + if (event) + { + UINT end = event->time + event->duration; // programme end time + if(event->time >= UINT(ltime) + (WINDOW_WIDTH * 60)) // programme starts after RHS of window + continue; // that's enough of this channel's events + if(end <= UINT(ltime)) // programme ends before LHS of window + continue; // this event is before the window - let's try the next event + // this event is one we are interested in + bg = (swapColour)?Colour::PROGRAMMEA:Colour::PROGRAMMEB; // alternate cell colour + swapColour = !swapColour; // it wil be the other colour next time + if(event->time <= UINT(selTime) && end > UINT(selTime) && currentRow) + { + // this is the selected programme + thisEvent.setdescription(event->description); + thisEvent.duration = event->duration; + thisEvent.time = event->time; + thisEvent.settitle(event->title); + thisEvent.id = event->id; + if(thisEvent.id == 0) + thisEvent.id = 1; + bg = Colour::SELECTHIGHLIGHT; // highlight cell + fg = Colour::DARKTEXT; + } + else + { + if (currentRow && thisEvent.id == 0) + { + if (end <= UINT(selTime) && end > UINT(thisEvent.time)) + thisEvent.time = end; + if (event->time > UINT(selTime) && event->time < thisEvent.time + thisEvent.duration) + thisEvent.duration = event->time - thisEvent.time; + } + } + paintCell(event, y, bg, fg); + } } } else { - // no event list for this channel. Already painted noevent colour so just highlight if selected + // no event list for this channel. Already painted noevent colour so just highlight if selected if (currentRow) { bg = Colour::SELECTHIGHLIGHT; // highlight cell @@ -456,9 +456,9 @@ void VEpg::drawgrid() // redraws grid and select programme else { bg = Colour::NOPROGRAMME; - fg = Colour::LIGHTTEXT; - noevent.settitle("No programme details"); - paintCell(&noevent, y, bg, fg); + fg = Colour::LIGHTTEXT; + noevent.settitle(tr("No programme details")); + paintCell(&noevent, y, bg, fg); } } y += Surface::getFontHeight() + 1; -- 2.39.5