vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Mar 23 18:13:03 2011 +0100| [a145b0c4b33c84ff1948e2e258838c8aef54eb6a] | committer: Francois Cartegnie
Qt: EPG: remove overlapped entries. EPG entries can have varying start or end time. More efficient than looking for non-updated items. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a145b0c4b33c84ff1948e2e258838c8aef54eb6a --- modules/gui/qt4/components/epg/EPGView.cpp | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp index 98738c8..10d58c1 100644 --- a/modules/gui/qt4/components/epg/EPGView.cpp +++ b/modules/gui/qt4/components/epg/EPGView.cpp @@ -89,6 +89,26 @@ const QDateTime& EPGView::baseTime() return m_baseTime; } +static void cleanOverlapped( EPGEventByTimeQMap *epgItemByTime, EPGItem *epgItem, QGraphicsScene *scene ) +{ + /* Clean overlapped programs */ + foreach(const QDateTime existingTimes, epgItemByTime->keys()) + { + if ( existingTimes != epgItem->start() ) + { + EPGItem *otherEPGItem = epgItemByTime->value( existingTimes ); + if ( otherEPGItem->playsAt( epgItem->start().addSecs( 1 ) ) + || /* add/minus one sec because next one can start at prev end min */ + otherEPGItem->playsAt( epgItem->end().addSecs( -1 ) ) ) + { + epgItemByTime->remove( otherEPGItem->start() ); + scene->removeItem( otherEPGItem ); + delete otherEPGItem; + } + } + } +} + bool EPGView::addEPGEvent( vlc_epg_event_t *data, QString channelName, bool b_current ) { /* Init our nested map if required */ @@ -120,11 +140,13 @@ bool EPGView::addEPGEvent( vlc_epg_event_t *data, QString channelName, bool b_cu epgItem = epgItemByTime->value( eventStart ); epgItem->setData( data ); /* updates our entry */ epgItem->setCurrent( b_current ); + cleanOverlapped( epgItemByTime, epgItem, scene() ); mutex.unlock(); return false; } else { /* Insert a new program entry */ epgItem = new EPGItem( data, this ); + cleanOverlapped( epgItemByTime, epgItem, scene() ); /* Effectively insert our new program */ epgItem->setCurrent( b_current ); epgItemByTime->insert( eventStart, epgItem ); _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
