]> git.sesse.net Git - vlc/commitdiff
Qt: EPG, propagate the infos when clicking on an Item
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 28 Jan 2010 02:20:28 +0000 (03:20 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 28 Jan 2010 02:30:04 +0000 (03:30 +0100)
modules/gui/qt4/components/epg/EPGItem.cpp
modules/gui/qt4/components/epg/EPGItem.hpp
modules/gui/qt4/components/epg/EPGView.cpp
modules/gui/qt4/components/epg/EPGView.hpp
modules/gui/qt4/components/epg/EPGWidget.cpp
modules/gui/qt4/dialogs/epg.cpp

index c18ae55d7e89fbad3225a1affbd702a27576e743..e1da38401648bea4b0f9a1200f8431f819c70943 100644 (file)
 #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 );
+}
index 376ba6d7ba018595121fcf901cc8db56cfca019f..fd531caefe048d9e887d5c38422c0efa3734ea51 100644 (file)
@@ -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;
index a87201d8cd88bdcd5e30133489b888474915f1e4..e262b82dcc8789895efc2d2e7c65a5e815b20283 100644 (file)
@@ -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 );
+}
index 3e4bb19b545d8a687a93175935229f06e8cb17e0..2fd66fc1465fc793fb812606b80ea38bf3287450 100644 (file)
@@ -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
index dfa81b1bc01bf3496b1322ac05597ea4d9c038ea..55bf2f82e349dd567f57c2f4ff3314f48fc455fc 100644 (file)
@@ -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 )
index 44221768f9a148557271cb69b4ffc1930ed75f65..10e7b4e33f0205bbfce4e530cf9469143be70030 100644 (file)
@@ -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()