X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fepg%2FEPGWidget.cpp;h=948b83c090c2fe5eef161e16a82404e0766d4602;hb=16967781bf90e39fab994a82414454ba3f87f122;hp=59b52290eeb90148a628cd36782738e7a683b9b4;hpb=540bcfd77ea662eee554aeae27b9621c854659db;p=vlc diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp index 59b52290ee..948b83c090 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,39 @@ 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 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; } } @@ -146,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(); }