[vlc-commits] commit: Qt/EPG: update and synchronise as in master (Adrien Maglo )

git at videolan.org git at videolan.org
Sun Jun 20 22:24:08 CEST 2010


vlc/vlc-1.1 | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Jun 18 19:57:49 2010 +0200| [ab097340c02ea3e0ac2b143027c110a2a7db4082] | committer: Jean-Baptiste Kempf 

Qt/EPG: update and synchronise as in master

(cherry picked from commit c57d47dbe87f236784e975743ae1fe32e18fdcdc)
(cherry picked from commit 753a7d15e9d2dedf650789245dc7d0b5b1765c65)
(cherry picked from commit 1ef8da27660e7a46070a7b104b9b5b1f96daf5a7)
(cherry picked from commit 44676a0590c2b96d13ea5a700b5878166b6f432a)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/components/epg/EPGEvent.hpp  |   16 +++++++++-
 modules/gui/qt4/components/epg/EPGItem.cpp   |   18 ++++++----
 modules/gui/qt4/components/epg/EPGView.cpp   |   13 +++----
 modules/gui/qt4/components/epg/EPGView.hpp   |    3 +-
 modules/gui/qt4/components/epg/EPGWidget.cpp |   43 +++++++++----------------
 5 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGEvent.hpp b/modules/gui/qt4/components/epg/EPGEvent.hpp
index 1296f7b..c246abe 100644
--- a/modules/gui/qt4/components/epg/EPGEvent.hpp
+++ b/modules/gui/qt4/components/epg/EPGEvent.hpp
@@ -25,17 +25,29 @@
 #define EPGEVENT_H
 
 class QString;
+class EPGItem;
 #include <QDateTime>
 
 class EPGEvent
 {
 public:
     EPGEvent( const QString& eventName )
-        : current( false ), updated( true )
+        : current( false ), updated( true ), item( NULL )
     {
         name = eventName;
     }
 
+    bool operator==( const EPGEvent & other ) const
+    {
+        return start == other.start
+               && duration == other.duration
+               && name == other.name
+               && description == other.description
+               && shortDescription == other.shortDescription
+               && channelName == other.channelName
+               && current == other.current;
+    }
+
     QDateTime   start;
     int         duration;
     QString     name;
@@ -44,6 +56,8 @@ public:
     QString     channelName;
     bool        current;
     bool        updated;
+
+    EPGItem     *item;
 };
 
 #endif // EPGEVENT_H
diff --git a/modules/gui/qt4/components/epg/EPGItem.cpp b/modules/gui/qt4/components/epg/EPGItem.cpp
index 15bdf46..ec2d1f9 100644
--- a/modules/gui/qt4/components/epg/EPGItem.cpp
+++ b/modules/gui/qt4/components/epg/EPGItem.cpp
@@ -59,15 +59,19 @@ void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem*, QWidget
     QTransform viewPortTransform = m_view->viewportTransform();
     QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() );
 
-    painter->setPen( QPen( Qt::black ) );
-
     if ( m_current )
-        painter->setBrush( QBrush( QColor( 100, 100, 100 ) ) );
+    {
+        painter->setBrush( QBrush( QColor( 244, 102, 146 ) ) );
+        painter->setPen( QPen( QColor( 244, 102, 146 ) ) );
+    }
     else
-        painter->setBrush( QBrush( QColor( 150, 150, 150 ) ) );
-
-    painter->drawRect( mapped );
+    {
+        painter->setBrush( QBrush( QColor( 201, 217, 242 ) ) );
+        painter->setPen( QPen( QColor( 201, 217, 242 ) ) );
+    }
 
+    mapped.adjust( 1, 2, -1, -2 );
+    painter->drawRoundedRect( mapped, 10, 10 );
 
     /* Draw text */
 
@@ -80,7 +84,7 @@ void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem*, QWidget
     // Adjust the drawing rect
     mapped.adjust( 6, 6, -6, -6 );
 
-    painter->setPen( Qt::white );
+    painter->setPen( Qt::black );
     /* Draw the title. */
     painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft, fm.elidedText( m_name, Qt::ElideRight, mapped.width() ) );
 
diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp
index aa2a614..d1d9534 100644
--- a/modules/gui/qt4/components/epg/EPGView.cpp
+++ b/modules/gui/qt4/components/epg/EPGView.cpp
@@ -62,7 +62,7 @@ void EPGView::setStartTime( const QDateTime& startTime )
     {
         EPGItem* item = qgraphicsitem_cast<EPGItem*>( itemList.at( i ) );
         if ( !item ) continue;
-        item->setStart( item->start() );
+        item->updatePos();
     }
 
     // Our start time has changed
@@ -88,17 +88,16 @@ void EPGView::addEvent( EPGEvent* event )
     item->setShortDescription( event->shortDescription );
     item->setCurrent( event->current );
 
-    scene()->addItem( item );
-}
+    event->item = item;
 
-void EPGView::updateEvent( EPGEvent* event )
-{
-    //qDebug() << "Update event: " << event->name;
+    scene()->addItem( item );
 }
 
 void EPGView::delEvent( EPGEvent* event )
 {
-    //qDebug() << "Del event: " << event->name;
+    if( event->item != NULL )
+        scene()->removeItem( event->item );
+    event->item = NULL;
 }
 
 void EPGView::updateDuration()
diff --git a/modules/gui/qt4/components/epg/EPGView.hpp b/modules/gui/qt4/components/epg/EPGView.hpp
index 8cad5bd..0655ce5 100644
--- a/modules/gui/qt4/components/epg/EPGView.hpp
+++ b/modules/gui/qt4/components/epg/EPGView.hpp
@@ -29,7 +29,7 @@
 #include <QGraphicsView>
 #include <QList>
 
-#define TRACKS_HEIGHT 75
+#define TRACKS_HEIGHT 60
 
 class QDateTime;
 class EPGView : public QGraphicsView
@@ -45,7 +45,6 @@ public:
     const QDateTime& startTime();
 
     void            addEvent( EPGEvent* event );
-    void            updateEvent( EPGEvent* event );
     void            delEvent( EPGEvent* event );
     void            updateDuration();
 
diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp
index 59b5229..b614846 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.cpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.cpp
@@ -72,7 +72,6 @@ void EPGWidget::setZoom( int level )
 
 void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg )
 {
-    m_epgView->setStartTime( QDateTime::currentDateTime() );
     for ( int i = 0; i < i_epg; ++i )
     {
         vlc_epg_t *p_epg = pp_epg[i];
@@ -80,52 +79,42 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg )
 
         for ( int j = 0; j < p_epg->i_event; ++j )
         {
-            EPGEvent *item = NULL;
             vlc_epg_event_t *p_event = p_epg->pp_event[j];
             QString eventName = qfu( p_event->psz_name );
             QDateTime eventStart = QDateTime::fromTime_t( p_event->i_start );
 
             QList<EPGEvent*> events = m_events.values( channelName );
 
+            EPGEvent *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;
+
+            bool alreadyIn = false;
+
             for ( int k = 0; k < events.count(); ++k )
             {
-                if ( events.at( k )->name == eventName &&
-                     events.at( k )->channelName == channelName &&
-                     events.at( k )->start == eventStart )
+                if ( *events.at( k ) == *item )
                 {
-                    /* Update the event. */
-                    item = events.at( k );
-                    item->updated = true;
-                    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->current = ( p_epg->p_current == p_event ) ? true : false;
-
-                    if ( item->start < m_epgView->startTime() )
-                        m_epgView->setStartTime( item->start );
-
-                    m_epgView->updateEvent( item );
+                    alreadyIn = true;
+                    events.at( k )->updated = true;
                     break;
                 }
             }
 
-            if ( !item )
+            if ( !alreadyIn )
             {
-                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;
                 m_events.insert( channelName, item );
-
                 if ( item->start < m_epgView->startTime() )
                     m_epgView->setStartTime( item->start );
 
                 m_epgView->addEvent( item );
             }
+            else
+                delete item;
         }
     }
 



More information about the vlc-commits mailing list