Commit 64369374 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: EPG: Always update data on EPG refresh and highlight simultaneous

programs
parent cb9b7a6c
...@@ -53,6 +53,11 @@ public: ...@@ -53,6 +53,11 @@ public:
return start_.addSecs( duration ) < ref; return start_.addSecs( duration ) < ref;
} }
bool plays_at( const QDateTime & ref ) const
{
return (start <= ref) && !ends_before( ref );
}
QDateTime start; QDateTime start;
int duration; int duration;
QString name; QString name;
......
...@@ -40,6 +40,7 @@ EPGItem::EPGItem( EPGView *view ) ...@@ -40,6 +40,7 @@ EPGItem::EPGItem( EPGView *view )
: m_view( view ) : m_view( view )
{ {
m_current = false; m_current = false;
m_simultaneous = false;
m_boundingRect.setHeight( TRACKS_HEIGHT ); m_boundingRect.setHeight( TRACKS_HEIGHT );
setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable); setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
setAcceptHoverEvents( true ); setAcceptHoverEvents( true );
...@@ -66,8 +67,8 @@ void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, ...@@ -66,8 +67,8 @@ void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option,
QTransform viewPortTransform = m_view->viewportTransform(); QTransform viewPortTransform = m_view->viewportTransform();
QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() ); QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() );
if ( m_current ) if ( m_current || m_simultaneous )
gradientColor.setRgb( 244, 125, 0 ); gradientColor.setRgb( 244, 125, 0 , m_simultaneous ? 192 : 255 );
else else
gradientColor.setRgb( 201, 217, 242 ); gradientColor.setRgb( 201, 217, 242 );
...@@ -147,6 +148,7 @@ void EPGItem::setData( EPGEvent *event ) ...@@ -147,6 +148,7 @@ void EPGItem::setData( EPGEvent *event )
setDuration( event->duration ); setDuration( event->duration );
updatePos(); updatePos();
setToolTip( m_name ); setToolTip( m_name );
update();
} }
void EPGItem::setDuration( int duration ) void EPGItem::setDuration( int duration )
......
...@@ -61,6 +61,7 @@ private: ...@@ -61,6 +61,7 @@ private:
QRectF m_boundingRect; QRectF m_boundingRect;
int m_channelNb; int m_channelNb;
/*FIXME: Bad object design. We shouldn't need to clone this EPGEvent data */
QDateTime m_start; QDateTime m_start;
int m_duration; int m_duration;
QString m_name; QString m_name;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#endif #endif
#include "EPGWidget.hpp" #include "EPGWidget.hpp"
#include "EPGItem.hpp"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QScrollBar> #include <QScrollBar>
...@@ -97,7 +98,7 @@ void EPGWidget::setZoom( int level ) ...@@ -97,7 +98,7 @@ void EPGWidget::setZoom( int level )
void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type ) void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
{ {
QStringList channelsList; QStringList channelsList;
EPGEvent* item; EPGEvent* epgEvent;
/* if we have epg time available take new minimum time */ /* if we have epg time available take new minimum time */
if ( i_epg > 0 && pp_epg[0]->i_event > 0 ) if ( i_epg > 0 && pp_epg[0]->i_event > 0 )
...@@ -110,8 +111,11 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type ) ...@@ -110,8 +111,11 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
/* flag all entries as non updated */ /* flag all entries as non updated */
foreach( const QString &str, m_events.uniqueKeys() ) foreach( const QString &str, m_events.uniqueKeys() )
foreach( item, m_events.values( str ) ) foreach( epgEvent, m_events.values( str ) )
item->updated = false; {
epgEvent->updated = false;
epgEvent->current = false;
}
for ( int i = 0; i < i_epg; ++i ) for ( int i = 0; i < i_epg; ++i )
{ {
...@@ -129,19 +133,19 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type ) ...@@ -129,19 +133,19 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
/* FIXME: EPGView timechanged signal is duplicate */ /* FIXME: EPGView timechanged signal is duplicate */
QList<EPGEvent*> events = m_events.values( channelName ); QList<EPGEvent*> events = m_events.values( channelName );
item = new EPGEvent( eventName ); epgEvent = new EPGEvent( eventName );
item->description = qfu( p_event->psz_description ); epgEvent->description = qfu( p_event->psz_description );
item->shortDescription = qfu( p_event->psz_short_description ); epgEvent->shortDescription = qfu( p_event->psz_short_description );
item->start = eventStart; epgEvent->start = eventStart;
item->duration = p_event->i_duration; epgEvent->duration = p_event->i_duration;
item->channelName = channelName; epgEvent->channelName = channelName;
item->current = ( p_epg->p_current == p_event ) ? true : false; epgEvent->current = ( p_epg->p_current == p_event ) ? true : false;
bool alreadyIn = false; bool alreadyIn = false;
for ( int k = 0; k < events.count(); ++k ) for ( int k = 0; k < events.count(); ++k )
{ {
if ( *events.at( k ) == *item ) if ( *events.at( k ) == *epgEvent )
{ {
alreadyIn = true; alreadyIn = true;
events.at( k )->updated = true; events.at( k )->updated = true;
...@@ -151,11 +155,11 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type ) ...@@ -151,11 +155,11 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
if ( !alreadyIn ) if ( !alreadyIn )
{ {
m_events.insert( channelName, item ); m_events.insert( channelName, epgEvent );
m_epgView->addEvent( item ); m_epgView->addEvent( epgEvent );
} }
else /* the new item is unused */ else /* the new epgEvent is unused */
delete item; delete epgEvent;
} }
} }
...@@ -164,23 +168,28 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type ) ...@@ -164,23 +168,28 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
QMultiMap<QString, EPGEvent*>::iterator i = m_events.begin(); QMultiMap<QString, EPGEvent*>::iterator i = m_events.begin();
while ( i != m_events.end() ) while ( i != m_events.end() )
{ {
item = i.value(); epgEvent = i.value();
if ( channelsList.contains( item->channelName ) && !item->updated ) if ( channelsList.contains( epgEvent->channelName ) && !epgEvent->updated )
{ {
m_epgView->delEvent( item ); m_epgView->delEvent( epgEvent );
delete item; delete epgEvent;
i = m_events.erase( i ); i = m_events.erase( i );
} }
else else
{/* If it's known but not in current libvlc data, try to expire it */ {/* If it's known but not in current libvlc data, try to expire it */
if ( item->ends_before( timeReference ) ) if ( epgEvent->ends_before( timeReference ) )
{ {
m_epgView->delEvent( item ); m_epgView->delEvent( epgEvent );
delete item; delete epgEvent;
i = m_events.erase( i ); i = m_events.erase( i );
} }
else else
{
++i; ++i;
epgEvent->simultaneous = ( !epgEvent->current
&& epgEvent->plays_at( QDateTime::currentDateTime() ) );
epgEvent->item->setData( epgEvent ); /* update data */
}
} }
} }
......
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