From 3484582d7784ec3b9e0bcc17e5896089e234aee6 Mon Sep 17 00:00:00 2001 From: Ludovic Fauvet Date: Wed, 27 Jan 2010 00:45:01 +0100 Subject: [PATCH] Initial commit for EPG class for EPG Viewing --- modules/gui/qt4/components/epg/EPGEvent.hpp | 49 ++++++ modules/gui/qt4/components/epg/EPGItem.cpp | 143 ++++++++++++++++++ modules/gui/qt4/components/epg/EPGItem.hpp | 69 +++++++++ modules/gui/qt4/components/epg/EPGRuler.cpp | 96 ++++++++++++ modules/gui/qt4/components/epg/EPGRuler.hpp | 54 +++++++ modules/gui/qt4/components/epg/EPGView.cpp | 135 +++++++++++++++++ modules/gui/qt4/components/epg/EPGView.hpp | 65 ++++++++ modules/gui/qt4/components/epg/EPGWidget.cpp | 150 +++++++++++++++++++ modules/gui/qt4/components/epg/EPGWidget.hpp | 66 ++++++++ 9 files changed, 827 insertions(+) create mode 100644 modules/gui/qt4/components/epg/EPGEvent.hpp create mode 100644 modules/gui/qt4/components/epg/EPGItem.cpp create mode 100644 modules/gui/qt4/components/epg/EPGItem.hpp create mode 100644 modules/gui/qt4/components/epg/EPGRuler.cpp create mode 100644 modules/gui/qt4/components/epg/EPGRuler.hpp create mode 100644 modules/gui/qt4/components/epg/EPGView.cpp create mode 100644 modules/gui/qt4/components/epg/EPGView.hpp create mode 100644 modules/gui/qt4/components/epg/EPGWidget.cpp create mode 100644 modules/gui/qt4/components/epg/EPGWidget.hpp diff --git a/modules/gui/qt4/components/epg/EPGEvent.hpp b/modules/gui/qt4/components/epg/EPGEvent.hpp new file mode 100644 index 0000000000..87e5d0ba90 --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGEvent.hpp @@ -0,0 +1,49 @@ +/***************************************************************************** + * EPGEvent.h : EPGEvent + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef EPGEVENT_H +#define EPGEVENT_H + +#include +#include + +class EPGEvent +{ +public: + EPGEvent( const QString& eventName ) + : current( false ), updated( true ) + { + name = eventName; + } + + QDateTime start; + int duration; + QString name; + QString description; + QString shortDescription; + QString channelName; + bool current; + bool updated; +}; + +#endif // EPGEVENT_H diff --git a/modules/gui/qt4/components/epg/EPGItem.cpp b/modules/gui/qt4/components/epg/EPGItem.cpp new file mode 100644 index 0000000000..ecacbe83ed --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGItem.cpp @@ -0,0 +1,143 @@ +/***************************************************************************** + * EPGItem.cpp: EPGItem + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include +#include +#include +#include + +#include "EPGItem.hpp" +#include "EPGView.hpp" + +EPGItem::EPGItem( EPGView *view ) + : m_view( view ) +{ + m_current = false; + + m_boundingRect.setHeight( TRACKS_HEIGHT ); +} + +QRectF EPGItem::boundingRect() const +{ + return m_boundingRect; +} + +void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*) +{ + // Draw in view's coordinates + painter->setWorldMatrixEnabled( false ); + + // Draw high-quality items + //painter->setRenderHint( QPainter::Antialiasing ); + + // Get the transformations required to map the text on the viewport + QTransform viewPortTransform = m_view->viewportTransform(); + QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() ); + + painter->setPen( QPen( Qt::black ) ); + painter->setBrush( QBrush( Qt::blue ) ); + + painter->drawRect( mapped ); + + + /* Draw text */ + + // Setup the font + QFont f = painter->font(); + f.setPointSize( 9 ); + f.setBold( true ); + painter->setFont( f ); + + // Get the font metrics + QFontMetrics fm = painter->fontMetrics(); + + // Adjust the drawing rect + mapped.adjust( 2, 2, -2, -2 ); + + painter->setPen( Qt::white ); + painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft, fm.elidedText( m_name, Qt::ElideRight, mapped.width() ) ); + + + f.setBold( false ); + f.setItalic( true ); + f.setPointSize( 8 ); + painter->setFont( f ); + + QTextOption textoption; + textoption.setWrapMode( QTextOption::WordWrap ); + textoption.setAlignment( Qt::AlignTop | Qt::AlignLeft ); + + painter->drawText( mapped.adjusted( 0, 20, 0, 0 ), + m_shortDescription, + textoption ); +} + +const QDateTime& EPGItem::start() const +{ + return m_start; +} + +int EPGItem::duration() const +{ + return m_duration; +} + +void EPGItem::setChannel( int channelNb ) +{ + qDebug() << "Channel" << channelNb; + m_channelNb = channelNb; + setPos( pos().x(), m_channelNb * TRACKS_HEIGHT ); +} + +void EPGItem::setStart( const QDateTime& start ) +{ + m_start = start; + int x = m_view->startTime().secsTo( start ); + setPos( x, pos().y() ); +} + +void EPGItem::setDuration( int duration ) +{ + m_duration = duration; + m_boundingRect.setWidth( duration ); +} + +void EPGItem::setName( const QString& name ) +{ + m_name = name; +} + +void EPGItem::setDescription( const QString& description ) +{ + m_description = description; +} + +void EPGItem::setShortDescription( const QString& shortDescription ) +{ + m_shortDescription = shortDescription; +} + +void EPGItem::setCurrent( bool current ) +{ + m_current = current; +} diff --git a/modules/gui/qt4/components/epg/EPGItem.hpp b/modules/gui/qt4/components/epg/EPGItem.hpp new file mode 100644 index 0000000000..035e97bc7e --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGItem.hpp @@ -0,0 +1,69 @@ +/***************************************************************************** + * EPGItem.h : EPGItem + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef EPGITEM_H +#define EPGITEM_H + +#include +#include +#include +#include +#include + +class EPGView; + +class EPGItem : public QObject, public QGraphicsItem +{ +public: + EPGItem( EPGView *view ); + virtual ~EPGItem() { } + + virtual QRectF boundingRect() const; + virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ); + + const QDateTime& start() const; + + int duration() const; + + void setChannel( int channelNb ); + void setStart( const QDateTime& start ); + void setDuration( int duration ); + void setName( const QString& name ); + void setDescription( const QString& description ); + void setShortDescription( const QString& shortDescription ); + void setCurrent( bool current ); + +private: + EPGView *m_view; + QRectF m_boundingRect; + int m_channelNb; + + QDateTime m_start; + int m_duration; + QString m_name; + QString m_description; + QString m_shortDescription; + bool m_current; +}; + +#endif // EPGITEM_H diff --git a/modules/gui/qt4/components/epg/EPGRuler.cpp b/modules/gui/qt4/components/epg/EPGRuler.cpp new file mode 100644 index 0000000000..7cadd6ef55 --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGRuler.cpp @@ -0,0 +1,96 @@ +/***************************************************************************** + * EPGRuler.coo: EPGRuler + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "EPGRuler.hpp" + +#include +#include +#include +#include + +EPGRuler::EPGRuler( QWidget* parent ) + : QWidget( parent ) +{ + setContentsMargins( 0, 0, 0, 0 ); + setMinimumHeight( 30 ); + setMaximumHeight( 30 ); + m_offset = 0; +} + +void EPGRuler::setScale( double scale ) +{ + m_scale = scale; + update(); +} + +void EPGRuler::setStartTime( const QDateTime& startTime ) +{ + m_startTime = startTime; + update(); +} + +void EPGRuler::setDuration( int duration ) +{ + m_duration = duration; + update(); +} + +void EPGRuler::setOffset( int offset ) +{ + m_offset = offset; + update(); +} + +void EPGRuler::paintEvent( QPaintEvent *event ) +{ + Q_UNUSED( event ); + + QPainter p( this ); + + int secondsOffset = m_offset / m_scale; + + QDateTime localStartTime; + localStartTime = m_startTime.addSecs( secondsOffset ); + + QDateTime diff( localStartTime ); + diff.setTime( QTime( localStartTime.time().hour(), 0, 0, 0 ) ); + + int secondsToHour = localStartTime.secsTo( diff ); + + QDateTime current( localStartTime.addSecs( secondsToHour ) ); + + int spacing = ( m_scale * 60 ) * 60; + int posx = secondsToHour * m_scale; + + // Count the number of items to draw + int itemsToDraw = ( width() / spacing ) + 1; + + for ( ; itemsToDraw >= 0; --itemsToDraw ) + { + p.setFont( QFont( "Verdana", 8 ) ); + p.drawLine( posx, 15, posx, 30 ); + p.drawText( posx + 1, 12, 50, 15, Qt::AlignLeft, current.toString( "hh'h'" ) ); + posx += spacing; + current = current.addSecs( 60 * 60 ); + } +} diff --git a/modules/gui/qt4/components/epg/EPGRuler.hpp b/modules/gui/qt4/components/epg/EPGRuler.hpp new file mode 100644 index 0000000000..cb29fbc039 --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGRuler.hpp @@ -0,0 +1,54 @@ +/***************************************************************************** + * EPGRuler.h: EPGRuler + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef EPGRULER_H +#define EPGRULER_H + +#include +#include + +class EPGRuler : public QWidget +{ + Q_OBJECT + +public: + EPGRuler( QWidget* parent = 0 ); + virtual ~EPGRuler() { } + +public slots: + void setScale( double scale ); + void setStartTime( const QDateTime& startTime ); + void setDuration( int duration ); + void setOffset( int offset ); + +protected: + virtual void paintEvent( QPaintEvent *event ); + +private: + qreal m_scale; + int m_duration; + int m_offset; + QDateTime m_startTime; +}; + +#endif // EPGRULER_H diff --git a/modules/gui/qt4/components/epg/EPGView.cpp b/modules/gui/qt4/components/epg/EPGView.cpp new file mode 100644 index 0000000000..95d2c3ad96 --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGView.cpp @@ -0,0 +1,135 @@ +/***************************************************************************** + * EPGView.cpp: EPGView + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include +#include "EPGView.hpp" +#include "EPGItem.hpp" +#include + +EPGView::EPGView( QWidget *parent ) : QGraphicsView( parent ) +{ + setContentsMargins( 0, 0, 0, 0 ); + setFrameStyle( QFrame::NoFrame ); + setAlignment( Qt::AlignLeft | Qt::AlignTop ); + + m_startTime = QDateTime::currentDateTime(); + + //tmp + setSceneRect( 0, 0, 20000, 200 ); + + QGraphicsScene *EPGscene = new QGraphicsScene( this ); + + setScene( EPGscene ); +} + +void EPGView::setScale( double scaleFactor ) +{ + m_scaleFactor = scaleFactor; + QMatrix matrix; + matrix.scale( scaleFactor, 1 ); + setMatrix( matrix ); +} + +void EPGView::setStartTime( const QDateTime& startTime ) +{ + QList itemList = items(); + + int diff = startTime.secsTo( m_startTime ); + + for ( int i = 0; i < itemList.count(); ++i ) + { + EPGItem* item = static_cast( itemList.at( i ) ); + item->setStart( item->start().addSecs( diff ) ); + } + + m_startTime = startTime; + + // Our start time has changed + emit startTimeChanged( startTime ); +} + +const QDateTime& EPGView::startTime() +{ + return m_startTime; +} + +void EPGView::addEvent( EPGEvent* event ) +{ + if ( !m_channels.contains( event->channelName ) ) + m_channels.append( event->channelName ); + + EPGItem* item = new EPGItem( this ); + item->setChannel( m_channels.indexOf( event->channelName ) ); + item->setStart( event->start ); + item->setDuration( event->duration ); + item->setName( event->name ); + item->setDescription( event->description ); + item->setShortDescription( event->shortDescription ); + item->setCurrent( event->current ); + + scene()->addItem( item ); +} + +void EPGView::updateEvent( EPGEvent* event ) +{ + qDebug() << "Update event: " << event->name; +} + +void EPGView::delEvent( EPGEvent* event ) +{ + qDebug() << "Del event: " << event->name; +} + +void EPGView::drawBackground( QPainter *painter, const QRectF &rect ) +{ + painter->setPen( QPen( QColor( 72, 72, 72 ) ) ); + + QPointF p = mapToScene( width(), 0 ); + + int y = 0; + for ( int i = 0; i < m_channels.count() + 1; ++i ) + { + painter->drawLine( 0, + y * TRACKS_HEIGHT, + p.x(), + y * TRACKS_HEIGHT ); + ++y; + } +} + +void EPGView::updateDuration() +{ + QDateTime lastItem; + QList list = items(); + + for ( int i = 0; i < list.count(); ++i ) + { + EPGItem* item = static_cast( list.at( i ) ); + QDateTime itemEnd = item->start().addSecs( item->duration() ); + + if ( itemEnd > lastItem ) + lastItem = itemEnd; + } + m_duration = m_startTime.secsTo( lastItem ); + emit durationChanged( m_duration ); +} diff --git a/modules/gui/qt4/components/epg/EPGView.hpp b/modules/gui/qt4/components/epg/EPGView.hpp new file mode 100644 index 0000000000..d40536ee69 --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGView.hpp @@ -0,0 +1,65 @@ +/***************************************************************************** + * EPGView.h : EPGView + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef EPGVIEW_H +#define EPGVIEW_H + +#include +#include +#include + +#include "EPGEvent.hpp" + +#define TRACKS_HEIGHT 75 + +class EPGView : public QGraphicsView +{ +Q_OBJECT + +public: + explicit EPGView( QWidget *parent = 0 ); + + void setScale( double scaleFactor ); + + void setStartTime( const QDateTime& startTime ); + const QDateTime& startTime(); + + void addEvent( EPGEvent* event ); + void updateEvent( EPGEvent* event ); + void delEvent( EPGEvent* event ); + void updateDuration(); + +signals: + void startTimeChanged( const QDateTime& startTime ); + void durationChanged( int seconds ); + +protected: + virtual void drawBackground( QPainter *painter, const QRectF &rect ); + + QList m_channels; + QDateTime m_startTime; + int m_scaleFactor; + int m_duration; +}; + +#endif // EPGVIEW_H diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp new file mode 100644 index 0000000000..3c8b4eac2b --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGWidget.cpp @@ -0,0 +1,150 @@ +/***************************************************************************** + * EPGWidget.h : EPGWidget + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include +#include +#include + +#include "EPGWidget.hpp" + +ChannelsWidget::ChannelsWidget( QWidget *parent ) : QWidget( parent ) +{ + setContentsMargins( 0, 0, 0, 0 ); + setMaximumWidth( 50 ); +} + +EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent ) +{ + QGridLayout* layout = new QGridLayout( this ); + + m_rulerWidget = new EPGRuler( this ); + m_channelsWidget = new ChannelsWidget( this ); + m_epgView = new EPGView( this ); + m_description = new QLabel( "Hello world
blablabla" ); + + m_channelsWidget->setMinimumWidth( 40 ); + m_description->setAlignment( Qt::AlignTop | Qt::AlignLeft ); + m_description->setMinimumHeight( 70 ); + + m_epgView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + setZoom( 1 ); + + layout->addWidget( m_rulerWidget, 0, 1 ); + layout->addWidget( m_channelsWidget, 1, 0 ); + layout->addWidget( m_epgView, 1, 1 ); + layout->addWidget( m_description, 2, 1 ); + layout->setSpacing( 0 ); + setLayout( layout ); + + connect( m_epgView, SIGNAL( startTimeChanged(QDateTime) ), + m_rulerWidget, SLOT( setStartTime(QDateTime) ) ); + connect( m_epgView, SIGNAL( durationChanged(int) ), + m_rulerWidget, SLOT( setDuration(int) ) ); + connect( m_epgView->horizontalScrollBar(), SIGNAL( valueChanged(int) ), + m_rulerWidget, SLOT( setOffset(int) ) ); +} + +void EPGWidget::setZoom( int level ) +{ + double scale = (double)level / 20; + m_epgView->setScale( scale ); + m_rulerWidget->setScale( scale ); +} + +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]; + QString channelName = QString( p_epg->psz_name ); + + 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 = QString( p_event->psz_name ); + + QList events = m_events.values( channelName ); + + for ( int k = 0; k < events.count(); ++k ) + { + if ( events.at( k )->name == eventName && + events.at( k )->channelName == channelName ) + { + item = events.at( k ); + item->updated = true; + item->description = QString( p_event->psz_description ); + item->shortDescription = QString( p_event->psz_short_description ); + item->start = QDateTime::fromTime_t( p_event->i_start ); + 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 ); + break; + } + } + + if ( !item ) + { + item = new EPGEvent( eventName ); + item->description = QString( p_event->psz_description ); + item->shortDescription = QString( p_event->psz_short_description ); + item->start = QDateTime::fromTime_t( p_event->i_start ); + 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 ); + } + } + } + + // Remove old items + QMap::iterator i = m_events.begin(); + while ( i != m_events.end() ) + { + EPGEvent* item = i.value(); + if ( !item->updated ) + { + m_epgView->delEvent( item ); + delete item; + i = m_events.erase( i ); + } + else + item->updated = false; + + ++i; + } + + // Update the global duration + m_epgView->updateDuration(); +} + diff --git a/modules/gui/qt4/components/epg/EPGWidget.hpp b/modules/gui/qt4/components/epg/EPGWidget.hpp new file mode 100644 index 0000000000..82f857433b --- /dev/null +++ b/modules/gui/qt4/components/epg/EPGWidget.hpp @@ -0,0 +1,66 @@ +/***************************************************************************** + * EPGWidget.h : EPGWidget + **************************************************************************** + * Copyright © 2009-2010 VideoLAN + * $Id$ + * + * Authors: Ludovic Fauvet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef EPGWIDGET_H +#define EPGWIDGET_H + +#include +#include +#include +#include +#include + +#include "EPGView.hpp" +#include "EPGEvent.hpp" +#include "EPGRuler.hpp" + +#include +#include + +class ChannelsWidget : public QWidget +{ +Q_OBJECT +public: + explicit ChannelsWidget( QWidget* parent = 0 ); +}; + +class EPGWidget : public QWidget +{ +Q_OBJECT +public: + explicit EPGWidget( QWidget* parent = 0 ); + +public slots: + void setZoom( int level ); + void updateEPG( vlc_epg_t **pp_epg, int i_epg ); + +private: + ChannelsWidget* m_channelsWidget; + EPGRuler* m_rulerWidget; + EPGView* m_epgView; + QLabel* m_description; + + QMultiMap m_events; +}; + +#endif // EPGWIDGET_H -- 2.39.2