~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/gui/qt4/components/epg/EPGChannels.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * EPGChannels.cpp: EPGChannels
 
3
 ****************************************************************************
 
4
 * Copyright © 2009-2010 VideoLAN
 
5
 *
 
6
 * Authors: Adrien Maglo <magsoft@videolan.org>
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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
 *****************************************************************************/
 
22
 
 
23
#include "EPGChannels.hpp"
 
24
#include "EPGView.hpp"
 
25
 
 
26
#include <QPainter>
 
27
#include <QFont>
 
28
#include <QPaintEvent>
 
29
 
 
30
EPGChannels::EPGChannels( QWidget *parent, EPGView *m_epgView )
 
31
    : QWidget( parent ), m_epgView( m_epgView ), m_offset( 0 )
 
32
{
 
33
    setContentsMargins( 0, 0, 0, 0 );
 
34
}
 
35
 
 
36
void EPGChannels::setOffset( int offset )
 
37
{
 
38
    m_offset = offset;
 
39
    update();
 
40
}
 
41
 
 
42
void EPGChannels::paintEvent( QPaintEvent *event )
 
43
{
 
44
    Q_UNUSED( event );
 
45
 
 
46
    QPainter p( this );
 
47
 
 
48
    /* Draw the top and the bottom lines. */
 
49
    p.drawLine( 0, 0, width() - 1, 0 );
 
50
    p.drawLine( 0, height() - 1, width(), height() - 1 );
 
51
 
 
52
    p.setFont( QFont( "Verdana", 8 ) );
 
53
 
 
54
    QList<QString> channels = m_epgView->getChannelList();
 
55
 
 
56
    for( int i = 0; i < channels.count(); ++i )
 
57
    {
 
58
        p.drawText( 0, - m_offset + ( i + 0.5 ) * TRACKS_HEIGHT - 4,
 
59
                    width(), 20, Qt::AlignLeft, channels[i] );
 
60
 
 
61
        int i_width = fontMetrics().width( channels[i] );
 
62
        if( width() < i_width )
 
63
            setMinimumWidth( i_width );
 
64
    }
 
65
}