[vlc-commits] commit: epg: add an overlay containing the channels list (Ludovic Fauvet )

git at videolan.org git at videolan.org
Thu Jun 3 12:36:33 CEST 2010


vlc/vlc-1.1 | branch: master | Ludovic Fauvet <etix at l0cal.com> | Wed Jun  2 11:00:29 2010 +0200| [79cf82b162987aa30748525205399ae003251a1a] | committer: Jean-Baptiste Kempf 

epg: add an overlay containing the channels list

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 4f30340a1ea3b3caa4d2d4d07318a7a8a9a2a3f9)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=79cf82b162987aa30748525205399ae003251a1a
---

 modules/gui/qt4/components/epg/EPGView.cpp |   39 ++++++++++++++++++++++++++-
 modules/gui/qt4/components/epg/EPGView.hpp |    6 ++++
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp
index cf3c91a..5af6f93 100644
--- a/modules/gui/qt4/components/epg/EPGView.cpp
+++ b/modules/gui/qt4/components/epg/EPGView.cpp
@@ -26,19 +26,41 @@
 
 #include <QDateTime>
 #include <QMatrix>
+#include <QPaintEvent>
+#include <QScrollBar>
 #include <QtDebug>
+#include <QGraphicsTextItem>
 
 EPGView::EPGView( QWidget *parent ) : QGraphicsView( parent )
 {
     setContentsMargins( 0, 0, 0, 0 );
     setFrameStyle( QFrame::NoFrame );
     setAlignment( Qt::AlignLeft | Qt::AlignTop );
+    setViewportUpdateMode( QGraphicsView::FullViewportUpdate );
 
     m_startTime = QDateTime::currentDateTime();
 
     QGraphicsScene *EPGscene = new QGraphicsScene( this );
 
     setScene( EPGscene );
+
+    connect( horizontalScrollBar(), SIGNAL( valueChanged(int) ),
+             this, SLOT( updateOverlayPosition(int) ) );
+
+    m_overlay = EPGscene->addRect( 0, 0, 100, 1, QPen(), QBrush( QColor( 40, 86, 255, 220 ) ) );
+    m_overlay->setFlag( QGraphicsItem::ItemIgnoresTransformations );
+    m_overlay->setZValue( 100 );
+
+    sceneRectChanged( scene()->sceneRect() );
+
+    connect( scene(), SIGNAL( sceneRectChanged(QRectF) ),
+             this, SLOT( sceneRectChanged(QRectF) ) );
+}
+
+void EPGView::updateOverlayPosition( int value )
+{
+    int pos = value * matrix().inverted().m11();
+    m_overlay->setPos( pos, 0 );
 }
 
 void EPGView::setScale( double scaleFactor )
@@ -57,7 +79,8 @@ void EPGView::setStartTime( const QDateTime& startTime )
 
     for ( int i = 0; i < itemList.count(); ++i )
     {
-        EPGItem* item = static_cast<EPGItem*>( itemList.at( i ) );
+        EPGItem* item = dynamic_cast<EPGItem*>( itemList.at( i ) );
+        if ( !item ) continue;
         item->setStart( item->start().addSecs( diff ) );
     }
 
@@ -75,7 +98,13 @@ const QDateTime& EPGView::startTime()
 void EPGView::addEvent( EPGEvent* event )
 {
     if ( !m_channels.contains( event->channelName ) )
+    {
         m_channels.append( event->channelName );
+        QGraphicsTextItem* channelTitle = new QGraphicsTextItem( event->channelName, m_overlay );
+        channelTitle->setZValue( 101 );
+        channelTitle->setPos( 0, m_channels.indexOf( event->channelName ) * TRACKS_HEIGHT );
+        channelTitle->setTextWidth( 100 );
+    }
 
     EPGItem* item = new EPGItem( this );
     item->setChannel( m_channels.indexOf( event->channelName ) );
@@ -123,7 +152,8 @@ void EPGView::updateDuration()
 
     for ( int i = 0; i < list.count(); ++i )
     {
-        EPGItem* item = static_cast<EPGItem*>( list.at( i ) );
+        EPGItem* item = dynamic_cast<EPGItem*>( list.at( i ) );
+        if ( !item ) continue;
         QDateTime itemEnd = item->start().addSecs( item->duration() );
 
         if ( itemEnd > lastItem )
@@ -137,3 +167,8 @@ void EPGView::eventFocused( EPGEvent *ev )
 {
     emit eventFocusedChanged( ev );
 }
+
+void EPGView::sceneRectChanged( const QRectF& rect )
+{
+    m_overlay->setRect( 0, 0, m_overlay->rect().width(), rect.height() );
+}
diff --git a/modules/gui/qt4/components/epg/EPGView.hpp b/modules/gui/qt4/components/epg/EPGView.hpp
index 2fd66fc..ef8d76d 100644
--- a/modules/gui/qt4/components/epg/EPGView.hpp
+++ b/modules/gui/qt4/components/epg/EPGView.hpp
@@ -61,8 +61,14 @@ protected:
     int             m_scaleFactor;
     int             m_duration;
 
+private:
+    QGraphicsRectItem* m_overlay;
+
 public slots:
     void eventFocused( EPGEvent * );
+private slots:
+    void updateOverlayPosition( int value );
+    void sceneRectChanged( const QRectF& rect );
 };
 
 #endif // EPGVIEW_H



More information about the vlc-commits mailing list