[vlc-commits] Qt: EPG: add channels line background
Francois Cartegnie
git at videolan.org
Wed Mar 23 22:10:58 CET 2011
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar 23 21:30:29 2011 +0100| [c93ea88c464a43cd694d0642bf026e5fe67caf2b] | committer: Francois Cartegnie
Qt: EPG: add channels line background
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c93ea88c464a43cd694d0642bf026e5fe67caf2b
---
modules/gui/qt4/components/epg/EPGItem.cpp | 7 ++++++-
modules/gui/qt4/components/epg/EPGItem.hpp | 1 +
modules/gui/qt4/components/epg/EPGView.cpp | 12 +++++++++++-
modules/gui/qt4/components/epg/EPGView.hpp | 10 ++++++++++
4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt4/components/epg/EPGItem.cpp b/modules/gui/qt4/components/epg/EPGItem.cpp
index 5c61a85..de5c9b6 100644
--- a/modules/gui/qt4/components/epg/EPGItem.cpp
+++ b/modules/gui/qt4/components/epg/EPGItem.cpp
@@ -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 )
diff --git a/modules/gui/qt4/components/epg/EPGItem.hpp b/modules/gui/qt4/components/epg/EPGItem.hpp
index e1ec959..60cc63d 100644
--- a/modules/gui/qt4/components/epg/EPGItem.hpp
+++ b/modules/gui/qt4/components/epg/EPGItem.hpp
@@ -59,6 +59,7 @@ public:
protected:
virtual void focusInEvent( QFocusEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * );
+ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * );
private:
EPGView *m_view;
diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp
index 15edd62..53cd25d 100644
--- a/modules/gui/qt4/components/epg/EPGView.cpp
+++ b/modules/gui/qt4/components/epg/EPGView.cpp
@@ -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 );
}
diff --git a/modules/gui/qt4/components/epg/EPGView.hpp b/modules/gui/qt4/components/epg/EPGView.hpp
index f26359d..e49a6e2 100644
--- a/modules/gui/qt4/components/epg/EPGView.hpp
+++ b/modules/gui/qt4/components/epg/EPGView.hpp
@@ -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
More information about the vlc-commits
mailing list