epg.cpp 3.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*****************************************************************************
 * Epg.cpp : Epg Viewer dialog
 ****************************************************************************
 * Copyright © 2010 VideoLAN and AUTHORS
 *
 * Authors:    Jean-Baptiste Kempf <jb@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "dialogs/epg.hpp"

#include "components/epg/EPGWidget.hpp"

31
#include <QVBoxLayout>
32 33 34
#include <QSplitter>
#include <QLabel>
#include <QGroupBox>
35
#include <QPushButton>
36
#include <QTextEdit>
37

38 39 40
#include "qt4.hpp"
#include "input_manager.hpp"

41 42
EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
{
Christophe Mutricy's avatar
Christophe Mutricy committed
43
    setWindowTitle( qtr( "Program Guide" ) );
44

45 46
    QVBoxLayout *layout = new QVBoxLayout( this );
    layout->setMargin( 0 );
47
    epg = new EPGWidget( this );
48

49 50
    QGroupBox *descBox = new QGroupBox( qtr( "Description" ), this );

51
    QVBoxLayout *boxLayout = new QVBoxLayout( descBox );
52

53 54
    description = new QTextEdit( this );
    description->setReadOnly( true );
55 56
    description->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel );
    description->setAutoFillBackground( true );
57
    description->setAlignment( Qt::AlignLeft | Qt::AlignTop );
58
    description->setFixedHeight( 100 );
59 60 61 62 63

    QPalette palette;
    palette.setBrush(QPalette::Active, QPalette::Window, palette.brush( QPalette::Base ) );
    description->setPalette( palette );

64
    title = new QLabel( qtr( "Title" ), this );
65
    title->setWordWrap( true );
66 67

    boxLayout->addWidget( title );
68
    boxLayout->addWidget( description );
69

70 71
    layout->addWidget( epg, 10 );
    layout->addWidget( descBox );
72

73
    CONNECT( epg, itemSelectionChanged( EPGEvent *), this, showEvent( EPGEvent *) );
74
    CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() );
75

Christophe Mutricy's avatar
Christophe Mutricy committed
76
    QPushButton *update = new QPushButton( qtr( "Update" ) ); //Temporary to test
77
    layout->addWidget( update, 0, Qt::AlignRight );
78
    BUTTONACT( update, updateInfos() );
79

80 81 82 83
    QPushButton *close = new QPushButton( qtr( "&Close" ) );
    layout->addWidget( close, 0, Qt::AlignRight );
    BUTTONACT( close, close() );

84 85
    updateInfos();
    readSettings( "EPGDialog", QSize( 650, 450 ) );
86 87 88 89
}

EpgDialog::~EpgDialog()
{
90
    writeSettings( "EPGDialog" );
91 92
}

93 94 95 96
void EpgDialog::showEvent( EPGEvent *event )
{
    if( !event ) return;

97 98 99 100 101 102 103 104 105 106
    QString titleDescription, textDescription;
    if( event->description.isEmpty() )
        textDescription = event->shortDescription;
    else
    {
        textDescription = event->description;
        if( !event->shortDescription.isEmpty() )
            titleDescription = " - " + event->shortDescription;
    }

107 108 109
    QDateTime end = event->start.addSecs( event->duration );
    title->setText( event->start.toString( "hh:mm" ) + " - "
                    + end.toString( "hh:mm" ) + " : "
110
                    + event->name + titleDescription );
111

112
    description->setText( textDescription );
113
}
114

115
void EpgDialog::updateInfos()
116 117 118 119 120 121 122
{
    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 );

}