From 08823609eadfa901447e58ade45a862a0964d2ed Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Thu, 28 Jan 2010 03:20:28 +0100 Subject: [PATCH] Qt: EPG, propagate the infos when clicking on an Item --- 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 c18ae55d7e..e1da384016 100644 --- a/modules/gui/qt4/components/epg/EPGItem.cpp +++ b/modules/gui/qt4/components/epg/EPGItem.cpp @@ -26,9 +26,12 @@ #include #include #include +#include +#include #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 376ba6d7ba..fd531caefe 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 a87201d8cd..e262b82dcc 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 3e4bb19b54..2fd66fc146 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 dfa81b1bc0..55bf2f82e3 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 44221768f9..10e7b4e33f 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() -- 2.39.5