From 16967781bf90e39fab994a82414454ba3f87f122 Mon Sep 17 00:00:00 2001 From: Adrien Maglo Date: Sun, 20 Jun 2010 22:35:05 +0200 Subject: [PATCH] Qt/EPG: Set the EPGView start time correctly. --- modules/gui/qt4/components/epg/EPGView.cpp | 22 +++++++++++++++++----- modules/gui/qt4/components/epg/EPGView.hpp | 2 +- modules/gui/qt4/components/epg/EPGWidget.cpp | 6 ++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp index d1d95348de..cb6690c7a2 100644 --- a/modules/gui/qt4/components/epg/EPGView.cpp +++ b/modules/gui/qt4/components/epg/EPGView.cpp @@ -52,21 +52,33 @@ void EPGView::setScale( double scaleFactor ) setMatrix( matrix ); } -void EPGView::setStartTime( const QDateTime& startTime ) +void EPGView::updateStartTime() { QList itemList = items(); - m_startTime = startTime; + /* Set the new start time. */ + for ( int i = 0; i < itemList.count(); ++i ) + { + EPGItem* item = qgraphicsitem_cast( 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( 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() diff --git a/modules/gui/qt4/components/epg/EPGView.hpp b/modules/gui/qt4/components/epg/EPGView.hpp index 0655ce5b3f..6c26be11f2 100644 --- a/modules/gui/qt4/components/epg/EPGView.hpp +++ b/modules/gui/qt4/components/epg/EPGView.hpp @@ -41,7 +41,7 @@ public: void setScale( double scaleFactor ); - void setStartTime( const QDateTime& startTime ); + void updateStartTime(); const QDateTime& startTime(); void addEvent( EPGEvent* event ); diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp index b614846a2a..948b83c090 100644 --- a/modules/gui/qt4/components/epg/EPGWidget.cpp +++ b/modules/gui/qt4/components/epg/EPGWidget.cpp @@ -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(); } -- 2.11.4.GIT