[vlc-commits] Qt: EPGView: highlight day change

Francois Cartegnie git at videolan.org
Mon Mar 11 20:04:41 CET 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Mar 11 19:53:32 2013 +0100| [c793eb04f43c60882ec78c05dc760495c07f0060] | committer: Francois Cartegnie

Qt: EPGView: highlight day change

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c793eb04f43c60882ec78c05dc760495c07f0060
---

 modules/gui/qt4/components/epg/EPGView.cpp |   27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp
index 44f04e6..107e864 100644
--- a/modules/gui/qt4/components/epg/EPGView.cpp
+++ b/modules/gui/qt4/components/epg/EPGView.cpp
@@ -27,20 +27,41 @@
 #include <QDateTime>
 #include <QMatrix>
 #include <QPaintEvent>
+#include <QRectF>
 
 EPGGraphicsScene::EPGGraphicsScene( QObject *parent ) : QGraphicsScene( parent )
 {}
 
 void EPGGraphicsScene::drawBackground( QPainter *painter, const QRectF &rect)
 {
-    EPGView *epgView;
+    EPGView *epgView = qobject_cast<EPGView *>(parent());
+
+    /* day change */
+    QDateTime rectstarttime = epgView->startTime().addSecs( rect.left() );
+    QDateTime nextdaylimit = QDateTime( rectstarttime.date() );
+    QRectF area( rect );
+    while( area.left() < width() )
+    {
+        nextdaylimit = nextdaylimit.addDays( 1 );
+        area.setRight( epgView->startTime().secsTo( nextdaylimit ) );
+
+        if ( epgView->startTime().date().daysTo( nextdaylimit.date() ) % 2 != 0 )
+            painter->fillRect( area, palette().color( QPalette::Base ) );
+        else
+            painter->fillRect( area, palette().color( QPalette::AlternateBase ) );
+
+        area.setLeft( area.right() + 1 );
+    }
+
+    /* channels lines */
     painter->setPen( QPen( QColor( 224, 224, 224 ) ) );
     for( int y = rect.top() + TRACKS_HEIGHT ; y < rect.bottom() ; y += TRACKS_HEIGHT )
        painter->drawLine( QLineF( rect.left(), y, rect.right(), y ) );
-    epgView = qobject_cast<EPGView *>(parent());
+
+    /* current hour line */
     int x = epgView->startTime().secsTo( epgView->baseTime() );
     painter->setPen( QPen( QColor( 255, 192, 192 ) ) );
-        painter->drawLine( QLineF( x, rect.top(), x, rect.bottom() ) );
+    painter->drawLine( QLineF( x, rect.top(), x, rect.bottom() ) );
 }
 
 EPGView::EPGView( QWidget *parent ) : QGraphicsView( parent )



More information about the vlc-commits mailing list