Commit c93ea88c authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: EPG: add channels line background

parent 0bf8724d
......@@ -191,7 +191,12 @@ void EPGItem::updatePos()
void EPGItem::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
{
event->accept();
update();
scene()->update();
}
void EPGItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
{ /* required to redraw our background without flaws */
hoverEnterEvent( event );
}
void EPGItem::focusInEvent( QFocusEvent * event )
......
......@@ -59,6 +59,7 @@ public:
protected:
virtual void focusInEvent( QFocusEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * );
private:
EPGView *m_view;
......
......@@ -31,6 +31,16 @@
#include <QtDebug>
#include <QGraphicsTextItem>
EPGGraphicsScene::EPGGraphicsScene( QObject *parent ) : QGraphicsScene( parent )
{}
void EPGGraphicsScene::drawBackground( QPainter *painter, const QRectF &rect)
{
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::EPGView( QWidget *parent ) : QGraphicsView( parent )
{
setContentsMargins( 0, 0, 0, 0 );
......@@ -39,7 +49,7 @@ EPGView::EPGView( QWidget *parent ) : QGraphicsView( parent )
m_startTime = QDateTime::currentDateTime();
QGraphicsScene *EPGscene = new QGraphicsScene( this );
EPGGraphicsScene *EPGscene = new EPGGraphicsScene( this );
setScene( EPGscene );
}
......
......@@ -27,6 +27,7 @@
#include "EPGItem.hpp"
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QList>
#include <QMap>
#include <QMutex>
......@@ -37,6 +38,15 @@
typedef QMap<QDateTime, EPGItem *> EPGEventByTimeQMap;
typedef QMap<QString, EPGEventByTimeQMap* > EPGTimeMapByChannelQMap;
class EPGGraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
explicit EPGGraphicsScene( QObject *parent = 0 );
protected:
void drawBackground ( QPainter *, const QRectF &);
};
class EPGView : public QGraphicsView
{
Q_OBJECT
......
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