[vlc-commits] Qt: reset EPG data when input type changes
Francois Cartegnie
git at videolan.org
Sat Mar 5 16:25:47 CET 2011
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar 4 22:41:35 2011 +0100| [193f5024d3727b6b458362b1b25771db1bfdd0e3] | committer: Francois Cartegnie
Qt: reset EPG data when input type changes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=193f5024d3727b6b458362b1b25771db1bfdd0e3
---
modules/gui/qt4/components/epg/EPGWidget.cpp | 22 +++++++++++++++++++++-
modules/gui/qt4/components/epg/EPGWidget.hpp | 5 ++++-
modules/gui/qt4/dialogs/epg.cpp | 9 ++++++---
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp
index 9032b99..311e29c 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.cpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.cpp
@@ -36,6 +36,7 @@
EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
{
+ b_input_type_known = false;
m_rulerWidget = new EPGRuler( this );
m_epgView = new EPGView( this );
m_channelsWidget = new EPGChannels( this, m_epgView );
@@ -71,6 +72,20 @@ EPGWidget::~EPGWidget()
delete item;
}
+void EPGWidget::reset()
+{
+ foreach( const QString &str, m_events.uniqueKeys() )
+ foreach( EPGEvent *item, m_events.values( str ) )
+ {
+ m_epgView->delEvent( item );
+ m_events.remove( str, item );
+ delete item;
+ }
+ m_epgView->updateDuration();
+ m_epgView->updateStartTime();
+ m_channelsWidget->update();
+}
+
void EPGWidget::setZoom( int level )
{
double scale = (double)level / 20;
@@ -78,13 +93,18 @@ void EPGWidget::setZoom( int level )
m_rulerWidget->setScale( scale );
}
-void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg )
+void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
{
QStringList channelsList;
EPGEvent* item;
/* FIXME: dvb time might be from the next timezone */
QDateTime timeReference = QDateTime::currentDateTime();
+ /* flush our EPG data if input type has changed */
+ if ( b_input_type_known && i_input_type != i_event_source_type ) reset();
+ i_event_source_type = i_input_type;
+ b_input_type_known = true;
+
/* flag all entries as non updated */
foreach( const QString &str, m_events.uniqueKeys() )
foreach( item, m_events.values( str ) )
diff --git a/modules/gui/qt4/components/epg/EPGWidget.hpp b/modules/gui/qt4/components/epg/EPGWidget.hpp
index e47f195..445dc19 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.hpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.hpp
@@ -43,10 +43,11 @@ class EPGWidget : public QWidget
public:
explicit EPGWidget( QWidget* parent = 0 );
~EPGWidget();
+ void reset();
public slots:
void setZoom( int level );
- void updateEPG( vlc_epg_t **pp_epg, int i_epg );
+ void updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type );
private:
EPGRuler* m_rulerWidget;
@@ -54,6 +55,8 @@ private:
EPGChannels *m_channelsWidget;
QMultiMap<QString, EPGEvent*> m_events;
+ uint8_t i_event_source_type;
+ bool b_input_type_known;
signals:
void itemSelectionChanged( EPGEvent * );
diff --git a/modules/gui/qt4/dialogs/epg.cpp b/modules/gui/qt4/dialogs/epg.cpp
index 008b21e..55113b6 100644
--- a/modules/gui/qt4/dialogs/epg.cpp
+++ b/modules/gui/qt4/dialogs/epg.cpp
@@ -73,6 +73,7 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
CONNECT( epg, itemSelectionChanged( EPGEvent *), this, showEvent( EPGEvent *) );
CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() );
+ CONNECT( THEMIM, inputChanged( input_thread_t * ), this, updateInfos() );
QDialogButtonBox *buttonsBox = new QDialogButtonBox( this );
@@ -121,8 +122,10 @@ void EpgDialog::showEvent( EPGEvent *event )
void EpgDialog::updateInfos()
{
if( !THEMIM->getInput() ) return;
-
- msg_Dbg( p_intf, "Found %i EPG items", input_GetItem( THEMIM->getInput())->i_epg);
- epg->updateEPG( input_GetItem( THEMIM->getInput())->pp_epg, input_GetItem( THEMIM->getInput())->i_epg );
+ int i_nbitems = input_GetItem( THEMIM->getInput())->i_epg;
+ if ( i_nbitems > 0 ) msg_Dbg( p_intf, "Found %i EPG items", i_nbitems );
+ epg->updateEPG( input_GetItem( THEMIM->getInput())->pp_epg,
+ input_GetItem( THEMIM->getInput())->i_epg,
+ input_GetItem( THEMIM->getInput())->i_type);
}
More information about the vlc-commits
mailing list