[vlc-commits] Qt: EPGRuler: simplify color change case.

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 18:39:45 2013 +0100| [1f03651994e8cbe4c34861936dac84260083772e] | committer: Francois Cartegnie

Qt: EPGRuler: simplify color change case.

fixes behavior when hour == day change

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

 modules/gui/qt4/components/epg/EPGRuler.cpp |   28 ++++++++-------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGRuler.cpp b/modules/gui/qt4/components/epg/EPGRuler.cpp
index 1762672..ee32292 100644
--- a/modules/gui/qt4/components/epg/EPGRuler.cpp
+++ b/modules/gui/qt4/components/epg/EPGRuler.cpp
@@ -75,7 +75,6 @@ void EPGRuler::paintEvent( QPaintEvent *event )
 
     QDateTime localStartTime;
     localStartTime = m_startTime.addSecs( m_offset / m_scale );
-    const QString currentDate = localStartTime.date().toString();
 
     QDateTime diff( localStartTime );
     diff.setTime( QTime( localStartTime.time().hour(), 0, 0, 0 ) );
@@ -88,31 +87,20 @@ void EPGRuler::paintEvent( QPaintEvent *event )
     QDateTime current( localStartTime.addSecs( secondsToHour ) );
     current = current.addSecs( -3600 );
 
-    QPalette::ColorRole fillColorRole;
-    if ( localStartTime.date().daysTo( current.date() ) % 2 == 0 )
-        fillColorRole = QPalette::Window;
-    else
-        fillColorRole = QPalette::Dark;
-    QColor fillColor = palette().color( fillColorRole );
-
+    QColor fillColor;
     while ( here.rx() < width() + spacing )
     {
         QRect area( QPoint( previous.x() + 1, margin.height() ), here );
         area.adjust( 0, 0, 0, header.height() );
         QString timeString = current.toString( "hh'h'" );
-        localStartTime.date().daysTo( current.date() );
-        if ( current.time().hour() == 0 &&
-             current.date().toString() != currentDate )
-        {
-            /* Show Day */
+        /* Show Day */
+        if ( current.time().hour() == 0 )
             timeString += current.date().toString( " ddd dd" );
-            /* And switch colors */
-            if ( fillColorRole == QPalette::Dark )
-                fillColorRole = QPalette::Window;
-            else
-                fillColorRole = QPalette::Dark;
-            fillColor = palette().color( fillColorRole );
-        }
+
+        if ( m_startTime.date().daysTo( current.date() ) % 2 == 0 )
+            fillColor = palette().color( QPalette::Window );
+        else
+            fillColor = palette().color( QPalette::Dark );
         p.fillRect( area, fillColor );
         p.drawLine( area.topRight(), area.bottomRight() );
         p.drawText( area, Qt::AlignLeft, timeString );



More information about the vlc-commits mailing list