[vlc-devel] commit: Qt: EPG, propagate the infos when clicking on an Item ( Jean-Baptiste Kempf )

git version control git at videolan.org
Thu Jan 28 03:30:01 CET 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Jan 28 03:20:28 2010 +0100| [08823609eadfa901447e58ade45a862a0964d2ed] | committer: Jean-Baptiste Kempf 

Qt: EPG, propagate the infos when clicking on an Item

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=08823609eadfa901447e58ade45a862a0964d2ed
---

 modules/gui/qt4/components/epg/EPGItem.cpp   |   12 ++++++++++++
 modules/gui/qt4/components/epg/EPGItem.hpp   |    3 +++
 modules/gui/qt4/components/epg/EPGView.cpp   |    5 +++++
 modules/gui/qt4/components/epg/EPGView.hpp   |    5 ++++-
 modules/gui/qt4/components/epg/EPGWidget.cpp |    3 +++
 modules/gui/qt4/dialogs/epg.cpp              |    5 ++++-
 6 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGItem.cpp b/modules/gui/qt4/components/epg/EPGItem.cpp
index c18ae55..e1da384 100644
--- a/modules/gui/qt4/components/epg/EPGItem.cpp
+++ b/modules/gui/qt4/components/epg/EPGItem.cpp
@@ -26,9 +26,12 @@
 #include <QFontMetrics>
 #include <QDebug>
 #include <QDateTime>
+#include <QFocusEvent>
+#include <QGraphicsScene>
 
 #include "EPGItem.hpp"
 #include "EPGView.hpp"
+#include "EPGEvent.hpp"
 
 EPGItem::EPGItem( EPGView *view )
     : m_view( view )
@@ -36,6 +39,7 @@ EPGItem::EPGItem( EPGView *view )
     m_current = false;
 
     m_boundingRect.setHeight( TRACKS_HEIGHT );
+    setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
 }
 
 QRectF EPGItem::boundingRect() const
@@ -142,3 +146,11 @@ void EPGItem::setCurrent( bool current )
 {
     m_current = current;
 }
+
+void EPGItem::focusInEvent( QFocusEvent * event )
+{
+    EPGEvent *evEPG = new EPGEvent( m_name );
+    evEPG->description = m_description;
+    evEPG->shortDescription = m_shortDescription;
+    m_view->eventFocused( evEPG );
+}
diff --git a/modules/gui/qt4/components/epg/EPGItem.hpp b/modules/gui/qt4/components/epg/EPGItem.hpp
index 376ba6d..fd531ca 100644
--- a/modules/gui/qt4/components/epg/EPGItem.hpp
+++ b/modules/gui/qt4/components/epg/EPGItem.hpp
@@ -53,6 +53,9 @@ public:
     void setShortDescription( const QString& shortDescription );
     void setCurrent( bool current );
 
+protected:
+    virtual void focusInEvent( QFocusEvent * event );
+
 private:
     EPGView     *m_view;
     QRectF      m_boundingRect;
diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp
index a87201d..e262b82 100644
--- a/modules/gui/qt4/components/epg/EPGView.cpp
+++ b/modules/gui/qt4/components/epg/EPGView.cpp
@@ -135,3 +135,8 @@ void EPGView::updateDuration()
     m_duration = m_startTime.secsTo( lastItem );
     emit durationChanged( m_duration );
 }
+
+void EPGView::eventFocused( EPGEvent *ev )
+{
+    emit eventFocusedChanged( ev );
+}
diff --git a/modules/gui/qt4/components/epg/EPGView.hpp b/modules/gui/qt4/components/epg/EPGView.hpp
index 3e4bb19..2fd66fc 100644
--- a/modules/gui/qt4/components/epg/EPGView.hpp
+++ b/modules/gui/qt4/components/epg/EPGView.hpp
@@ -52,7 +52,7 @@ public:
 signals:
     void            startTimeChanged( const QDateTime& startTime );
     void            durationChanged( int seconds );
-
+    void            eventFocusedChanged( EPGEvent * );
 protected:
     virtual void    drawBackground( QPainter *painter, const QRectF &rect );
 
@@ -60,6 +60,9 @@ protected:
     QDateTime       m_startTime;
     int             m_scaleFactor;
     int             m_duration;
+
+public slots:
+    void eventFocused( EPGEvent * );
 };
 
 #endif // EPGVIEW_H
diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp
index dfa81b1..55bf2f8 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.cpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.cpp
@@ -32,6 +32,7 @@ ChannelsWidget::ChannelsWidget( QWidget *parent ) : QWidget( parent )
 {
     setContentsMargins( 0, 0, 0, 0 );
     setMaximumWidth( 50 );
+    setFocusPolicy( Qt::ClickFocus );
 }
 
 EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
@@ -59,6 +60,8 @@ EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
              m_rulerWidget, SLOT( setDuration(int) ) );
     connect( m_epgView->horizontalScrollBar(), SIGNAL( valueChanged(int) ),
              m_rulerWidget, SLOT( setOffset(int) ) );
+    connect( m_epgView, SIGNAL( eventFocusedChanged(EPGEvent*)),
+             this, SIGNAL(itemSelectionChanged(EPGEvent*)) );
 }
 
 void EPGWidget::setZoom( int level )
diff --git a/modules/gui/qt4/dialogs/epg.cpp b/modules/gui/qt4/dialogs/epg.cpp
index 4422176..10e7b4e 100644
--- a/modules/gui/qt4/dialogs/epg.cpp
+++ b/modules/gui/qt4/dialogs/epg.cpp
@@ -92,7 +92,10 @@ void EpgDialog::showEvent( EPGEvent *event )
     if( !event ) return;
 
     title->setText( event->name );
-    description->setText( event->description );
+    if( !event->description.isEmpty() )
+        description->setText( event->description );
+    else
+        description->setText( event->shortDescription );
 }
 
 void EpgDialog::update()




More information about the vlc-devel mailing list