]> git.sesse.net Git - vlc/commitdiff
Qt/EPG: Set the EPGView start time correctly.
authorAdrien Maglo <magsoft@videolan.org>
Sun, 20 Jun 2010 20:35:05 +0000 (22:35 +0200)
committerAdrien Maglo <magsoft@videolan.org>
Sun, 20 Jun 2010 20:36:17 +0000 (22:36 +0200)
modules/gui/qt4/components/epg/EPGView.cpp
modules/gui/qt4/components/epg/EPGView.hpp
modules/gui/qt4/components/epg/EPGWidget.cpp

index d1d95348de8b0ebdc769d0092468d9a16d692a01..cb6690c7a24b1e04fa4130f24072dc820d4bf830 100644 (file)
@@ -52,21 +52,33 @@ void EPGView::setScale( double scaleFactor )
     setMatrix( matrix );
 }
 
-void EPGView::setStartTime( const QDateTime& startTime )
+void EPGView::updateStartTime()
 {
     QList<QGraphicsItem*> itemList = items();
 
-    m_startTime = startTime;
+    /* Set the new start time. */
+    for ( int i = 0; i < itemList.count(); ++i )
+    {
+        EPGItem* item = qgraphicsitem_cast<EPGItem*>( itemList.at( i ) );
+        if ( !item )
+            continue;
+        if( i == 0 )
+            m_startTime = item->start();
+        if ( item->start() < m_startTime )
+            m_startTime = item->start();
+    }
 
+    /* Update the position of all items. */
     for ( int i = 0; i < itemList.count(); ++i )
     {
         EPGItem* item = qgraphicsitem_cast<EPGItem*>( itemList.at( i ) );
-        if ( !item ) continue;
+        if ( !item )
+            continue;
         item->updatePos();
     }
 
-    // Our start time has changed
-    emit startTimeChanged( startTime );
+    // Our start time may have changed.
+    emit startTimeChanged( m_startTime );
 }
 
 const QDateTime& EPGView::startTime()
index 0655ce5b3fd164d4f88ddac5d0f591848ca2f3f0..6c26be11f202a0409c2a988a95b1e56acd3bf61c 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     void            setScale( double scaleFactor );
 
-    void            setStartTime( const QDateTime& startTime );
+    void            updateStartTime();
     const QDateTime& startTime();
 
     void            addEvent( EPGEvent* event );
index b614846a2a55ccc57f7e13aa1444b8184428425a..948b83c090c2fe5eef161e16a82404e0766d4602 100644 (file)
@@ -108,9 +108,6 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg )
             if ( !alreadyIn )
             {
                 m_events.insert( channelName, item );
-                if ( item->start < m_epgView->startTime() )
-                    m_epgView->setStartTime( item->start );
-
                 m_epgView->addEvent( item );
             }
             else
@@ -135,7 +132,8 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg )
         ++i;
     }
 
-    // Update the global duration
+    // Update the global duration and start time.
     m_epgView->updateDuration();
+    m_epgView->updateStartTime();
 }