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 @@
#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 );
}
......@@ -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;
......
......@@ -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 );
}
......@@ -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
......@@ -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 )
......
......@@ -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()
......
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