]> git.vomp.tv Git - vompclient.git/commitdiff
Internationalise EPG, add timed input code to vchannelselect
authorChris Tallon <chris@vomp.tv>
Tue, 6 Dec 2005 22:48:36 +0000 (22:48 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 6 Dec 2005 22:48:36 +0000 (22:48 +0000)
vchannelselect.cc
vchannelselect.h
vepg.cc

index 24ce79e7f06bda9594a4103f770c89f6905be914..14b4e0146b50bf8a4c680b2f0decc2c47789eb2b 100644 (file)
@@ -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);
+  }
+}
index cb95c6efd6a481ea036a04f5c24c41658dd3cc97..a1cc793c55706471e5783766424c55c3cdd1b360 100644 (file)
 #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 014a90c0d3791780e38f8f8ca352ae3a836fc58f..0f16515c2ed5e6852dd0e2c7e759082a0b9379a6 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -175,35 +175,35 @@ void VEpg::draw()
   w.setSurfaceOffset(keyx + 50, keyy + 20);\r
   w.draw();\r
 \r
-  drawText("OK", keyx + 18, keyy + 20, Colour::LIGHTTEXT);\r
+  drawText(tr("OK"), keyx + 18, keyy + 20, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 72, keyy + 4, 104, Surface::getFontHeight() + 2, surface->rgba(200, 0, 0, 255));\r
-  drawText("Page up", keyx + 74, keyy + 5, Colour::LIGHTTEXT);\r
+  drawText(tr("Page up"), keyx + 74, keyy + 5, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 72, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, surface->rgba(0, 200, 0, 255));\r
-  drawText("Page down", keyx + 74, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT);\r
+  drawText(tr("Page down"), keyx + 74, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 180, keyy + 4, 104, Surface::getFontHeight() + 2, surface->rgba(200, 200, 0, 255));\r
-  drawText("-24 hours", keyx + 182, keyy + 5, Colour::LIGHTTEXT);\r
+  drawText(tr("-24 hours"), keyx + 182, keyy + 5, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 180, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, surface->rgba( 0, 0, 200, 255));\r
-  drawText("+24 hours", keyx + 182, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT);\r
+  drawText(tr("+24 hours"), keyx + 182, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 290, keyy + 4, 180, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255));\r
-  drawText("Guide / Back: Close", keyx + 292 , keyy + 5, Colour::LIGHTTEXT);\r
+  drawText(tr("Guide / Back: Close"), keyx + 292 , keyy + 5, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 290, keyy + Surface::getFontHeight() + 8, 180, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255));\r
   Colour red = Colour(130, 0, 0);\r
-  drawText("Rec: Set timer", keyx + 292, keyy + Surface::getFontHeight() + 9, red);\r
+  drawText(tr("Rec: Set timer"), keyx + 292, keyy + Surface::getFontHeight() + 9, red);\r
 \r
   surface->fillblt(keyx + 474, keyy + 4, 128, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255));\r
   w.nextSymbol = WSymbol::PLAY;\r
   w.setSurfaceOffset(keyx + 476, keyy + 5);\r
   w.draw();\r
-  drawText("Sel channel", keyx + 496, keyy + 5, Colour::LIGHTTEXT);\r
+  drawText(tr("Sel channel"), keyx + 496, keyy + 5, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 474, keyy + Surface::getFontHeight() + 8, 128, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255));\r
-  drawText("Go: Preview", keyx + 476, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT);\r
+  drawText(tr("Go: Preview"), keyx + 476, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT);\r
 }\r
 \r
 int VEpg::handleCommand(int command)\r
@@ -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?\r
   Event* event;\r
   Event noevent; // an event to use if there are gaps in the epg\r
-  thisEvent.setdescription("There are no programme details available for this period");\r
+  thisEvent.setdescription(tr("There are no programme details available for this period"));\r
   thisEvent.duration = WINDOW_WIDTH * 60;\r
   thisEvent.time = ltime;\r
-  thisEvent.settitle("No programme details");\r
+  thisEvent.settitle(tr("No programme details"));\r
   thisEvent.id = 0;\r
   bool swapColour = FALSE; // alternate cell colour\r
   bool currentRow = FALSE;\r
@@ -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\r
     if (currentRow)\r
     {\r
-      thisEvent.setdescription("There are no programme details available for this period");\r
+      thisEvent.setdescription(tr("There are no programme details available for this period"));\r
       thisEvent.duration = WINDOW_WIDTH * 60;\r
       thisEvent.time = ltime;\r
-      thisEvent.settitle("No programme details");\r
+      thisEvent.settitle(tr("No programme details"));\r
       thisEvent.id = 0;\r
     }\r
     if (eventLista[listIndex])\r
@@ -405,48 +405,48 @@ void VEpg::drawgrid() // redraws grid and select programme
       sort(eventLista[listIndex]->begin(), eventLista[listIndex]->end(), EventSorter());\r
       for(e = 0; e < (eventLista[listIndex])->size(); e++) // step through events for this channel\r
       {\r
-  fg = Colour::LIGHTTEXT;\r
+        fg = Colour::LIGHTTEXT;\r
         event = (*eventLista[listIndex])[e];\r
-  if (event)\r
-  {\r
-    UINT end = event->time + event->duration; // programme end time\r
-    if(event->time >= UINT(ltime) + (WINDOW_WIDTH * 60)) // programme starts after RHS of window\r
-      continue; // that's enough of this channel's events\r
-    if(end <= UINT(ltime)) // programme ends before LHS of window\r
-      continue; // this event is before the window - let's try the next event\r
-    // this event is one we are interested in\r
-    bg = (swapColour)?Colour::PROGRAMMEA:Colour::PROGRAMMEB; // alternate cell colour\r
-    swapColour = !swapColour; // it wil be the other colour next time\r
-    if(event->time <= UINT(selTime) && end > UINT(selTime) && currentRow)\r
-    {\r
-    // this is the selected programme\r
-      thisEvent.setdescription(event->description);\r
-      thisEvent.duration = event->duration;\r
-      thisEvent.time = event->time;\r
-      thisEvent.settitle(event->title);\r
-      thisEvent.id = event->id;\r
-      if(thisEvent.id == 0)\r
-        thisEvent.id = 1;\r
-      bg = Colour::SELECTHIGHLIGHT; // highlight cell\r
-      fg = Colour::DARKTEXT;\r
-    }\r
-    else\r
-    {\r
-      if (currentRow && thisEvent.id == 0)\r
-      {\r
-        if (end <= UINT(selTime) && end > UINT(thisEvent.time))\r
-          thisEvent.time = end;\r
-        if (event->time > UINT(selTime) && event->time < thisEvent.time + thisEvent.duration)\r
-          thisEvent.duration = event->time - thisEvent.time;\r
-      }\r
-    }\r
-    paintCell(event, y, bg, fg);\r
-  }\r
+        if (event)\r
+        {\r
+          UINT end = event->time + event->duration; // programme end time\r
+          if(event->time >= UINT(ltime) + (WINDOW_WIDTH * 60)) // programme starts after RHS of window\r
+            continue; // that's enough of this channel's events\r
+          if(end <= UINT(ltime)) // programme ends before LHS of window\r
+            continue; // this event is before the window - let's try the next event\r
+          // this event is one we are interested in\r
+          bg = (swapColour)?Colour::PROGRAMMEA:Colour::PROGRAMMEB; // alternate cell colour\r
+          swapColour = !swapColour; // it wil be the other colour next time\r
+          if(event->time <= UINT(selTime) && end > UINT(selTime) && currentRow)\r
+          {\r
+            // this is the selected programme\r
+            thisEvent.setdescription(event->description);\r
+            thisEvent.duration = event->duration;\r
+            thisEvent.time = event->time;\r
+            thisEvent.settitle(event->title);\r
+            thisEvent.id = event->id;\r
+            if(thisEvent.id == 0)\r
+              thisEvent.id = 1;\r
+            bg = Colour::SELECTHIGHLIGHT; // highlight cell\r
+            fg = Colour::DARKTEXT;\r
+          }\r
+          else\r
+          {\r
+            if (currentRow && thisEvent.id == 0)\r
+            {\r
+              if (end <= UINT(selTime) && end > UINT(thisEvent.time))\r
+                thisEvent.time = end;\r
+              if (event->time > UINT(selTime) && event->time < thisEvent.time + thisEvent.duration)\r
+                thisEvent.duration = event->time - thisEvent.time;\r
+            }\r
+          }\r
+          paintCell(event, y, bg, fg);\r
+        }\r
       }\r
     }\r
     else\r
     {\r
-    // no event list for this channel. Already painted noevent colour so just highlight if selected\r
+      // no event list for this channel. Already painted noevent colour so just highlight if selected\r
       if (currentRow)\r
       {\r
         bg = Colour::SELECTHIGHLIGHT; // highlight cell\r
@@ -456,9 +456,9 @@ void VEpg::drawgrid() // redraws grid and select programme
       else\r
       {\r
         bg = Colour::NOPROGRAMME;\r
-  fg = Colour::LIGHTTEXT;\r
-        noevent.settitle("No programme details");\r
-  paintCell(&noevent, y, bg, fg);\r
+        fg = Colour::LIGHTTEXT;\r
+        noevent.settitle(tr("No programme details"));\r
+        paintCell(&noevent, y, bg, fg);\r
       }\r
     }\r
     y += Surface::getFontHeight() + 1;\r