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

Qt: reset EPG data when input type changes

parent 9cac200d
......@@ -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 ) )
......
......@@ -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 * );
......
......@@ -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);
}
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