Commit c793eb04 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: EPGView: highlight day change

parent 1f036519
......@@ -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 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment