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