Commit 193f5024 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: reset EPG data when input type changes

parent 9cac200d
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent ) EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
{ {
b_input_type_known = false;
m_rulerWidget = new EPGRuler( this ); m_rulerWidget = new EPGRuler( this );
m_epgView = new EPGView( this ); m_epgView = new EPGView( this );
m_channelsWidget = new EPGChannels( this, m_epgView ); m_channelsWidget = new EPGChannels( this, m_epgView );
...@@ -71,6 +72,20 @@ EPGWidget::~EPGWidget() ...@@ -71,6 +72,20 @@ EPGWidget::~EPGWidget()
delete item; 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 ) void EPGWidget::setZoom( int level )
{ {
double scale = (double)level / 20; double scale = (double)level / 20;
...@@ -78,13 +93,18 @@ void EPGWidget::setZoom( int level ) ...@@ -78,13 +93,18 @@ void EPGWidget::setZoom( int level )
m_rulerWidget->setScale( scale ); 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; QStringList channelsList;
EPGEvent* item; EPGEvent* item;
/* FIXME: dvb time might be from the next timezone */ /* FIXME: dvb time might be from the next timezone */
QDateTime timeReference = QDateTime::currentDateTime(); 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 */ /* flag all entries as non updated */
foreach( const QString &str, m_events.uniqueKeys() ) foreach( const QString &str, m_events.uniqueKeys() )
foreach( item, m_events.values( str ) ) foreach( item, m_events.values( str ) )
......
...@@ -43,10 +43,11 @@ class EPGWidget : public QWidget ...@@ -43,10 +43,11 @@ class EPGWidget : public QWidget
public: public:
explicit EPGWidget( QWidget* parent = 0 ); explicit EPGWidget( QWidget* parent = 0 );
~EPGWidget(); ~EPGWidget();
void reset();
public slots: public slots:
void setZoom( int level ); 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: private:
EPGRuler* m_rulerWidget; EPGRuler* m_rulerWidget;
...@@ -54,6 +55,8 @@ private: ...@@ -54,6 +55,8 @@ private:
EPGChannels *m_channelsWidget; EPGChannels *m_channelsWidget;
QMultiMap<QString, EPGEvent*> m_events; QMultiMap<QString, EPGEvent*> m_events;
uint8_t i_event_source_type;
bool b_input_type_known;
signals: signals:
void itemSelectionChanged( EPGEvent * ); void itemSelectionChanged( EPGEvent * );
......
...@@ -73,6 +73,7 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf ) ...@@ -73,6 +73,7 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
CONNECT( epg, itemSelectionChanged( EPGEvent *), this, showEvent( EPGEvent *) ); CONNECT( epg, itemSelectionChanged( EPGEvent *), this, showEvent( EPGEvent *) );
CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() ); CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() );
CONNECT( THEMIM, inputChanged( input_thread_t * ), this, updateInfos() );
QDialogButtonBox *buttonsBox = new QDialogButtonBox( this ); QDialogButtonBox *buttonsBox = new QDialogButtonBox( this );
...@@ -121,8 +122,10 @@ void EpgDialog::showEvent( EPGEvent *event ) ...@@ -121,8 +122,10 @@ void EpgDialog::showEvent( EPGEvent *event )
void EpgDialog::updateInfos() void EpgDialog::updateInfos()
{ {
if( !THEMIM->getInput() ) return; if( !THEMIM->getInput() ) return;
int i_nbitems = input_GetItem( THEMIM->getInput())->i_epg;
msg_Dbg( p_intf, "Found %i EPG items", 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 ); epg->updateEPG( input_GetItem( THEMIM->getInput())->pp_epg,
input_GetItem( THEMIM->getInput())->i_epg,
input_GetItem( THEMIM->getInput())->i_type);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment