Commit 08823609 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

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

parent e0a92345
...@@ -26,9 +26,12 @@ ...@@ -26,9 +26,12 @@
#include <QFontMetrics> #include <QFontMetrics>
#include <QDebug> #include <QDebug>
#include <QDateTime> #include <QDateTime>
#include <QFocusEvent>
#include <QGraphicsScene>
#include "EPGItem.hpp" #include "EPGItem.hpp"
#include "EPGView.hpp" #include "EPGView.hpp"
#include "EPGEvent.hpp"
EPGItem::EPGItem( EPGView *view ) EPGItem::EPGItem( EPGView *view )
: m_view( view ) : m_view( view )
...@@ -36,6 +39,7 @@ EPGItem::EPGItem( EPGView *view ) ...@@ -36,6 +39,7 @@ EPGItem::EPGItem( EPGView *view )
m_current = false; m_current = false;
m_boundingRect.setHeight( TRACKS_HEIGHT ); m_boundingRect.setHeight( TRACKS_HEIGHT );
setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
} }
QRectF EPGItem::boundingRect() const QRectF EPGItem::boundingRect() const
...@@ -142,3 +146,11 @@ void EPGItem::setCurrent( bool current ) ...@@ -142,3 +146,11 @@ void EPGItem::setCurrent( bool current )
{ {
m_current = 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 );
}
...@@ -53,6 +53,9 @@ public: ...@@ -53,6 +53,9 @@ public:
void setShortDescription( const QString& shortDescription ); void setShortDescription( const QString& shortDescription );
void setCurrent( bool current ); void setCurrent( bool current );
protected:
virtual void focusInEvent( QFocusEvent * event );
private: private:
EPGView *m_view; EPGView *m_view;
QRectF m_boundingRect; QRectF m_boundingRect;
......
...@@ -135,3 +135,8 @@ void EPGView::updateDuration() ...@@ -135,3 +135,8 @@ void EPGView::updateDuration()
m_duration = m_startTime.secsTo( lastItem ); m_duration = m_startTime.secsTo( lastItem );
emit durationChanged( m_duration ); emit durationChanged( m_duration );
} }
void EPGView::eventFocused( EPGEvent *ev )
{
emit eventFocusedChanged( ev );
}
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
signals: signals:
void startTimeChanged( const QDateTime& startTime ); void startTimeChanged( const QDateTime& startTime );
void durationChanged( int seconds ); void durationChanged( int seconds );
void eventFocusedChanged( EPGEvent * );
protected: protected:
virtual void drawBackground( QPainter *painter, const QRectF &rect ); virtual void drawBackground( QPainter *painter, const QRectF &rect );
...@@ -60,6 +60,9 @@ protected: ...@@ -60,6 +60,9 @@ protected:
QDateTime m_startTime; QDateTime m_startTime;
int m_scaleFactor; int m_scaleFactor;
int m_duration; int m_duration;
public slots:
void eventFocused( EPGEvent * );
}; };
#endif // EPGVIEW_H #endif // EPGVIEW_H
...@@ -32,6 +32,7 @@ ChannelsWidget::ChannelsWidget( QWidget *parent ) : QWidget( parent ) ...@@ -32,6 +32,7 @@ ChannelsWidget::ChannelsWidget( QWidget *parent ) : QWidget( parent )
{ {
setContentsMargins( 0, 0, 0, 0 ); setContentsMargins( 0, 0, 0, 0 );
setMaximumWidth( 50 ); setMaximumWidth( 50 );
setFocusPolicy( Qt::ClickFocus );
} }
EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent ) EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
...@@ -59,6 +60,8 @@ EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent ) ...@@ -59,6 +60,8 @@ EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
m_rulerWidget, SLOT( setDuration(int) ) ); m_rulerWidget, SLOT( setDuration(int) ) );
connect( m_epgView->horizontalScrollBar(), SIGNAL( valueChanged(int) ), connect( m_epgView->horizontalScrollBar(), SIGNAL( valueChanged(int) ),
m_rulerWidget, SLOT( setOffset(int) ) ); m_rulerWidget, SLOT( setOffset(int) ) );
connect( m_epgView, SIGNAL( eventFocusedChanged(EPGEvent*)),
this, SIGNAL(itemSelectionChanged(EPGEvent*)) );
} }
void EPGWidget::setZoom( int level ) void EPGWidget::setZoom( int level )
......
...@@ -92,7 +92,10 @@ void EpgDialog::showEvent( EPGEvent *event ) ...@@ -92,7 +92,10 @@ void EpgDialog::showEvent( EPGEvent *event )
if( !event ) return; if( !event ) return;
title->setText( event->name ); title->setText( event->name );
description->setText( event->description ); if( !event->description.isEmpty() )
description->setText( event->description );
else
description->setText( event->shortDescription );
} }
void EpgDialog::update() void EpgDialog::update()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment