1 /*****************************************************************************
2 * EPGWidget.h : EPGWidget
3 ****************************************************************************
4 * Copyright © 2009-2010 VideoLAN
7 * Authors: Ludovic Fauvet <etix@l0cal.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
28 #include "EPGWidget.hpp"
30 #include <QVBoxLayout>
33 #include <QStringList>
36 EPGWidget::EPGWidget( QWidget
*parent
) : QWidget( parent
)
38 b_input_type_known
= false;
39 m_rulerWidget
= new EPGRuler( this );
40 m_epgView
= new EPGView( this );
41 m_channelsWidget
= new EPGChannels( this, m_epgView
);
43 m_channelsWidget
->setMinimumWidth( 100 );
45 m_epgView
->setSizePolicy( QSizePolicy::Expanding
, QSizePolicy::Expanding
);
48 QGridLayout
* layout
= new QGridLayout( this );
49 layout
->addWidget( m_rulerWidget
, 0, 1 );
50 layout
->addWidget( m_channelsWidget
, 1, 0 );
51 layout
->addWidget( m_epgView
, 1, 1 );
52 layout
->setSpacing( 0 );
55 connect( m_epgView
, SIGNAL( startTimeChanged(QDateTime
) ),
56 m_rulerWidget
, SLOT( setStartTime(QDateTime
) ) );
57 connect( m_epgView
, SIGNAL( durationChanged(int) ),
58 m_rulerWidget
, SLOT( setDuration(int) ) );
59 connect( m_epgView
->horizontalScrollBar(), SIGNAL( valueChanged(int) ),
60 m_rulerWidget
, SLOT( setOffset(int) ) );
61 connect( m_epgView
->verticalScrollBar(), SIGNAL( valueChanged(int) ),
62 m_channelsWidget
, SLOT( setOffset(int) ) );
63 connect( m_epgView
, SIGNAL( itemFocused(EPGItem
*)),
64 this, SIGNAL(itemSelectionChanged(EPGItem
*)) );
65 CONNECT( m_epgView
, channelAdded(QString
), m_channelsWidget
, addChannel(QString
) );
66 CONNECT( m_epgView
, channelRemoved(QString
), m_channelsWidget
, removeChannel(QString
) );
69 void EPGWidget::reset()
72 m_epgView
->updateDuration();
73 m_epgView
->updateStartTime();
76 void EPGWidget::setZoom( int level
)
78 double scale
= (double)level
/ 20;
79 m_epgView
->setScale( scale
);
80 m_rulerWidget
->setScale( scale
);
83 void EPGWidget::updateEPG( vlc_epg_t
**pp_epg
, int i_epg
, uint8_t i_input_type
)
85 /* flush our EPG data if input type has changed */
86 if ( b_input_type_known
&& i_input_type
!= i_event_source_type
) m_epgView
->reset();
87 i_event_source_type
= i_input_type
;
88 b_input_type_known
= true;
90 m_epgView
->cleanup(); /* expire items and flags */
92 for ( int i
= 0; i
< i_epg
; ++i
)
94 vlc_epg_t
*p_epg
= pp_epg
[i
];
96 /* Read current epg events from libvlc and try to insert them */
97 for ( int j
= 0; j
< p_epg
->i_event
; ++j
)
99 vlc_epg_event_t
*p_event
= p_epg
->pp_event
[j
];
100 m_epgView
->addEPGEvent( p_event
, qfu( p_epg
->psz_name
),
101 ( p_epg
->p_current
== p_event
) );
105 // Update the global duration and start time.
106 m_epgView
->updateDuration();
107 m_epgView
->updateStartTime();