[vlc-commits] Qt: EPG: Always update data on EPG refresh and highlight simultaneous

Francois Cartegnie git at videolan.org
Sat Mar 5 16:25:48 CET 2011


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Mar  5 15:17:11 2011 +0100| [6436937420a8f53f174f91802cb53e517bc55b73] | committer: Francois Cartegnie

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6436937420a8f53f174f91802cb53e517bc55b73
---

 modules/gui/qt4/components/epg/EPGEvent.hpp  |    5 ++
 modules/gui/qt4/components/epg/EPGItem.cpp   |    6 ++-
 modules/gui/qt4/components/epg/EPGItem.hpp   |    1 +
 modules/gui/qt4/components/epg/EPGWidget.cpp |   53 +++++++++++++++-----------
 4 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGEvent.hpp b/modules/gui/qt4/components/epg/EPGEvent.hpp
index 54e4713..cd0be06 100644
--- a/modules/gui/qt4/components/epg/EPGEvent.hpp
+++ b/modules/gui/qt4/components/epg/EPGEvent.hpp
@@ -53,6 +53,11 @@ public:
         return start_.addSecs( duration ) < ref;
     }
 
+    bool plays_at( const QDateTime & ref ) const
+    {
+        return (start <= ref) && !ends_before( ref );
+    }
+
     QDateTime   start;
     int         duration;
     QString     name;
diff --git a/modules/gui/qt4/components/epg/EPGItem.cpp b/modules/gui/qt4/components/epg/EPGItem.cpp
index 16767f2..62b0366 100644
--- a/modules/gui/qt4/components/epg/EPGItem.cpp
+++ b/modules/gui/qt4/components/epg/EPGItem.cpp
@@ -40,6 +40,7 @@ EPGItem::EPGItem( EPGView *view )
     : m_view( view )
 {
     m_current = false;
+    m_simultaneous = false;
     m_boundingRect.setHeight( TRACKS_HEIGHT );
     setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
     setAcceptHoverEvents( true );
@@ -66,8 +67,8 @@ void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option,
     QTransform viewPortTransform = m_view->viewportTransform();
     QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() );
 
-    if ( m_current )
-        gradientColor.setRgb( 244, 125, 0 );
+    if ( m_current || m_simultaneous )
+        gradientColor.setRgb( 244, 125, 0 , m_simultaneous ? 192 : 255 );
     else
         gradientColor.setRgb( 201, 217, 242 );
 
@@ -147,6 +148,7 @@ void EPGItem::setData( EPGEvent *event )
     setDuration( event->duration );
     updatePos();
     setToolTip( m_name );
+    update();
 }
 
 void EPGItem::setDuration( int duration )
diff --git a/modules/gui/qt4/components/epg/EPGItem.hpp b/modules/gui/qt4/components/epg/EPGItem.hpp
index 76a853f..3f39cd6 100644
--- a/modules/gui/qt4/components/epg/EPGItem.hpp
+++ b/modules/gui/qt4/components/epg/EPGItem.hpp
@@ -61,6 +61,7 @@ private:
     QRectF      m_boundingRect;
     int         m_channelNb;
 
+    /*FIXME: Bad object design. We shouldn't need to clone this EPGEvent data */
     QDateTime   m_start;
     int         m_duration;
     QString     m_name;
diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp
index 4265b2f..aebfd86 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.cpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.cpp
@@ -26,6 +26,7 @@
 #endif
 
 #include "EPGWidget.hpp"
+#include "EPGItem.hpp"
 
 #include <QVBoxLayout>
 #include <QScrollBar>
@@ -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 )
 {
     QStringList channelsList;
-    EPGEvent* item;
+    EPGEvent* epgEvent;
 
     /* if we have epg time available take new minimum time */
     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 )
 
     /* flag all entries as non updated */
     foreach( const QString &str, m_events.uniqueKeys() )
-        foreach( item, m_events.values( str ) )
-            item->updated = false;
+        foreach( epgEvent, m_events.values( str ) )
+        {
+            epgEvent->updated = false;
+            epgEvent->current = false;
+        }
 
     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 )
             /* FIXME: EPGView timechanged signal is duplicate */
             QList<EPGEvent*> events = m_events.values( channelName );
 
-            item = new EPGEvent( eventName );
-            item->description = qfu( p_event->psz_description );
-            item->shortDescription = qfu( p_event->psz_short_description );
-            item->start = eventStart;
-            item->duration = p_event->i_duration;
-            item->channelName = channelName;
-            item->current = ( p_epg->p_current == p_event ) ? true : false;
+            epgEvent = new EPGEvent( eventName );
+            epgEvent->description = qfu( p_event->psz_description );
+            epgEvent->shortDescription = qfu( p_event->psz_short_description );
+            epgEvent->start = eventStart;
+            epgEvent->duration = p_event->i_duration;
+            epgEvent->channelName = channelName;
+            epgEvent->current = ( p_epg->p_current == p_event ) ? true : false;
 
             bool alreadyIn = false;
 
             for ( int k = 0; k < events.count(); ++k )
             {
-                if ( *events.at( k ) == *item )
+                if ( *events.at( k ) == *epgEvent )
                 {
                     alreadyIn = 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 )
 
             if ( !alreadyIn )
             {
-                m_events.insert( channelName, item );
-                m_epgView->addEvent( item );
+                m_events.insert( channelName, epgEvent );
+                m_epgView->addEvent( epgEvent );
             }
-            else /* the new item is unused */
-                delete item;
+            else /* the new epgEvent is unused */
+                delete epgEvent;
         }
     }
 
@@ -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();
     while ( i != m_events.end() )
     {
-        item = i.value();
-        if ( channelsList.contains( item->channelName ) && !item->updated )
+        epgEvent = i.value();
+        if ( channelsList.contains( epgEvent->channelName ) && !epgEvent->updated )
         {
-            m_epgView->delEvent( item );
-            delete item;
+            m_epgView->delEvent( epgEvent );
+            delete epgEvent;
             i = m_events.erase( i );
         }
         else
         {/* 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 );
-                delete item;
+                m_epgView->delEvent( epgEvent );
+                delete epgEvent;
                 i = m_events.erase( i );
             }
             else
+            {
                 ++i;
+                epgEvent->simultaneous = ( !epgEvent->current
+                            && epgEvent->plays_at( QDateTime::currentDateTime() ) );
+                epgEvent->item->setData( epgEvent ); /* update data */
+            }
         }
     }
 



More information about the vlc-commits mailing list