[mythtv] [Patch] a little red line indicating now in mythepg

Christian Hoenig mythtv-dev@snowman.net
Tue, 19 Nov 2002 00:13:39 +0100


--Boundary-00=_jQX29EVPvCVlz/X
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi, 

This patch (for libs/libsmyth/guidegrid.cpp from 0.7) adds a little red line 
to the timescale in mythepg indicating "now". Problem with this patch is, 
that the red bar is shown everyday at the hours and minutes like now. (Am i 
clear? ;-).

Maybe you are interested.

take care, have fun
/christian

PS.: Like always this is only tested on my system, so go and test it on yours 
:-).


--Boundary-00=_jQX29EVPvCVlz/X
Content-Type: text/x-diff;
  charset="us-ascii";
  name="guidegrid.cpp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="guidegrid.cpp.diff"

--- /tmp/mythtv-0.7/libs/libmyth/guidegrid.cpp	2002-11-04 20:33:43.000000000 +0100
+++ guidegrid.cpp	2002-11-19 00:06:41.000000000 +0100
@@ -520,6 +520,9 @@
     tmp.setFont(*m_timeFont);
 
     int xdifference = (int)(tr.width() / DISPLAY_TIMES); 
+	
+	QTime now = now.currentTime();
+	int nowpos = -1;
 
     for (int x = 0; x < DISPLAY_TIMES; x++)
     {
@@ -543,11 +546,27 @@
             int xpos = (x * xdifference) + (xdifference * 6 - width) / 2; 
             tmp.drawText(xpos, (tr.bottom() - height) / 2 + height, 
                          tinfo->usertime);
-        }
+	
+			int t;		 
+			if (nowpos < 0 && (t = now.secsTo(QTime(tinfo->hour, tinfo->min))) < 0)
+				nowpos = x + (t/-60/5);
+	    }
     }
 
     tmp.drawLine(0, tr.height() - 1, tr.right(), tr.height() - 1);
+		
+	if (nowpos >= 0)	
+	{
+		QPen old = tmp.pen();
+		QPen n = tmp.pen();
+		n.setColor(QColor(255, 0, 0));
+		tmp.setPen(n);
 
+		tmp.drawLine((nowpos) * xdifference, 0, (nowpos) * xdifference, 
+                         tr.bottom());
+		tmp.setPen(old);
+ 	}
+    
     tmp.end();
 
     p->drawPixmap(tr.topLeft(), pix);

--Boundary-00=_jQX29EVPvCVlz/X--