1 /*****************************************************************************
2 * EPGChannels.cpp: EPGChannels
3 ****************************************************************************
4 * Copyright © 2009-2010 VideoLAN
6 * Authors: Adrien Maglo <magsoft@videolan.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #include "EPGChannels.hpp"
24 #include "EPGView.hpp"
28 #include <QPaintEvent>
30 EPGChannels::EPGChannels( QWidget *parent, EPGView *m_epgView )
31 : QWidget( parent ), m_epgView( m_epgView ), m_offset( 0 )
33 setContentsMargins( 0, 0, 0, 0 );
36 void EPGChannels::setOffset( int offset )
42 void EPGChannels::paintEvent( QPaintEvent *event )
48 /* Draw the top and the bottom lines. */
49 p.drawLine( 0, 0, width() - 1, 0 );
51 p.setFont( QFont( "Verdana", 8 ) );
53 QList<QString> channels = m_epgView->getChannelList();
55 for( int i = 0; i < channels.count(); ++i )
57 p.drawText( 0, - m_offset + ( i + 0.5 ) * TRACKS_HEIGHT - 4,
58 width(), 20, Qt::AlignLeft, channels[i] );
60 int i_width = fontMetrics().width( channels[i] );
61 if( width() < i_width )
62 setMinimumWidth( i_width );