Commit 29fee926 authored by Adrien Maglo's avatar Adrien Maglo

Remove the channel list overlaid above the EPGView widget.

Add a channel list widget at the left of the EPGView widget.
Remove the splitter on the EPG window.
parent 0b9fa694
......@@ -53,6 +53,7 @@ nodist_SOURCES_qt4 = \
components/interface_widgets.moc.cpp \
components/controller.moc.cpp \
components/controller_widget.moc.cpp \
components/epg/EPGChannels.moc.cpp \
components/epg/EPGRuler.moc.cpp \
components/epg/EPGView.moc.cpp \
components/epg/EPGWidget.moc.cpp \
......@@ -251,6 +252,7 @@ SOURCES_qt4 = qt4.cpp \
components/interface_widgets.cpp \
components/controller.cpp \
components/controller_widget.cpp \
components/epg/EPGChannels.cpp \
components/epg/EPGItem.cpp \
components/epg/EPGRuler.cpp \
components/epg/EPGView.cpp \
......@@ -307,6 +309,7 @@ noinst_HEADERS = \
components/interface_widgets.hpp \
components/controller.hpp \
components/controller_widget.hpp \
components/epg/EPGChannels.hpp \
components/epg/EPGEvent.hpp \
components/epg/EPGItem.hpp \
components/epg/EPGRuler.hpp \
......
/*****************************************************************************
* EPGChannels.cpp: EPGChannels
****************************************************************************
* Copyright © 2009-2010 VideoLAN
*
* Authors: Adrien Maglo <magsoft@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.
*****************************************************************************/
#include "EPGChannels.hpp"
#include "EPGView.hpp"
#include <QPainter>
#include <QFont>
#include <QPaintEvent>
EPGChannels::EPGChannels( QWidget *parent, EPGView *m_epgView )
: QWidget( parent ), m_epgView( m_epgView ), m_offset( 0 )
{
setContentsMargins( 0, 0, 0, 0 );
}
void EPGChannels::setOffset( int offset )
{
m_offset = offset;
update();
}
void EPGChannels::paintEvent( QPaintEvent *event )
{
Q_UNUSED( event );
QPainter p( this );
/* Draw the top and the bottom lines. */
p.drawLine( 0, 0, width() - 1, 0 );
p.drawLine( 0, height() - 1, width(), height() - 1 );
p.setFont( QFont( "Verdana", 8 ) );
QList<QString> channels = m_epgView->getChannelList();
for( int i = 0; i < channels.count(); ++i )
{
p.drawText( 0, - m_offset + ( i + 0.5 ) * TRACKS_HEIGHT - 4,
width(), 20, Qt::AlignLeft, channels[i] );
int i_width = fontMetrics().width( channels[i] );
if( width() < i_width )
setMinimumWidth( i_width );
}
}
/*****************************************************************************
* EPGChannels.hpp : EPGChannels
****************************************************************************
* Copyright © 2009-2010 VideoLAN
*
* Authors: Adrien Maglo <magsoft@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.
*****************************************************************************/
#ifndef EPGCHANNELS_HPP
#define EPGCHANNELS_HPP
#include <QWidget>
class EPGView;
class EPGChannels : public QWidget
{
Q_OBJECT
public:
EPGChannels( QWidget *parent, EPGView *m_epgView );
virtual ~EPGChannels() { }
public slots:
void setOffset( int offset );
protected:
virtual void paintEvent( QPaintEvent *event );
private:
EPGView *m_epgView;
int m_offset;
};
#endif // EPGCHANNELS_HPP
......@@ -34,33 +34,14 @@
EPGView::EPGView( QWidget *parent ) : QGraphicsView( parent )
{
setContentsMargins( 0, 0, 0, 0 );
setFrameStyle( QFrame::NoFrame );
setFrameStyle( QFrame::Box );
setAlignment( Qt::AlignLeft | Qt::AlignTop );
setViewportUpdateMode( QGraphicsView::FullViewportUpdate );
m_startTime = QDateTime::currentDateTime();
QGraphicsScene *EPGscene = new QGraphicsScene( this );
setScene( EPGscene );
connect( horizontalScrollBar(), SIGNAL( valueChanged(int) ),
this, SLOT( updateOverlayPosition(int) ) );
m_overlay = EPGscene->addRect( 0, 0, 100, 1, QPen(), QBrush( QColor( 40, 86, 255, 220 ) ) );
m_overlay->setFlag( QGraphicsItem::ItemIgnoresTransformations );
m_overlay->setZValue( 100 );
sceneRectChanged( scene()->sceneRect() );
connect( scene(), SIGNAL( sceneRectChanged(QRectF) ),
this, SLOT( sceneRectChanged(QRectF) ) );
}
void EPGView::updateOverlayPosition( int value )
{
int pos = value * matrix().inverted().m11();
m_overlay->setPos( pos, 0 );
}
void EPGView::setScale( double scaleFactor )
......@@ -98,13 +79,7 @@ const QDateTime& EPGView::startTime()
void EPGView::addEvent( EPGEvent* event )
{
if ( !m_channels.contains( event->channelName ) )
{
m_channels.append( event->channelName );
QGraphicsTextItem* channelTitle = new QGraphicsTextItem( event->channelName, m_overlay );
channelTitle->setZValue( 101 );
channelTitle->setPos( 0, m_channels.indexOf( event->channelName ) * TRACKS_HEIGHT );
channelTitle->setTextWidth( 100 );
}
EPGItem* item = new EPGItem( this );
item->setChannel( m_channels.indexOf( event->channelName ) );
......@@ -134,14 +109,10 @@ void EPGView::drawBackground( QPainter *painter, const QRectF &rect )
QPointF p = mapToScene( width(), 0 );
int y = 0;
for ( int i = 0; i < m_channels.count() + 1; ++i )
for ( int i = 0; i < m_channels.count(); ++i )
{
painter->drawLine( 0,
y * TRACKS_HEIGHT,
p.x(),
y * TRACKS_HEIGHT );
++y;
painter->drawLine( 0, ( i + 1 ) * TRACKS_HEIGHT,
p.x(), ( i + 1 ) * TRACKS_HEIGHT );
}
}
......@@ -163,12 +134,12 @@ void EPGView::updateDuration()
emit durationChanged( m_duration );
}
void EPGView::eventFocused( EPGEvent *ev )
QList<QString> EPGView::getChannelList()
{
emit eventFocusedChanged( ev );
return m_channels;
}
void EPGView::sceneRectChanged( const QRectF& rect )
void EPGView::eventFocused( EPGEvent *ev )
{
m_overlay->setRect( 0, 0, m_overlay->rect().width(), rect.height() );
emit eventFocusedChanged( ev );
}
......@@ -49,6 +49,8 @@ public:
void delEvent( EPGEvent* event );
void updateDuration();
QList<QString> getChannelList();
signals:
void startTimeChanged( const QDateTime& startTime );
void durationChanged( int seconds );
......@@ -61,14 +63,8 @@ protected:
int m_scaleFactor;
int m_duration;
private:
QGraphicsRectItem* m_overlay;
public slots:
void eventFocused( EPGEvent * );
private slots:
void updateOverlayPosition( int value );
void sceneRectChanged( const QRectF& rect );
};
#endif // EPGVIEW_H
......@@ -37,13 +37,17 @@ EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
{
m_rulerWidget = new EPGRuler( this );
m_epgView = new EPGView( this );
m_channelsWidget = new EPGChannels( this, m_epgView );
m_channelsWidget->setMinimumWidth( 100 );
m_epgView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
setZoom( 1 );
QVBoxLayout* layout = new QVBoxLayout( this );
layout->addWidget( m_rulerWidget );
layout->addWidget( m_epgView );
QGridLayout* layout = new QGridLayout( this );
layout->addWidget( m_rulerWidget, 0, 1 );
layout->addWidget( m_channelsWidget, 1, 0 );
layout->addWidget( m_epgView, 1, 1 );
layout->setSpacing( 0 );
setLayout( layout );
......@@ -53,6 +57,8 @@ EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
m_rulerWidget, SLOT( setDuration(int) ) );
connect( m_epgView->horizontalScrollBar(), SIGNAL( valueChanged(int) ),
m_rulerWidget, SLOT( setOffset(int) ) );
connect( m_epgView->verticalScrollBar(), SIGNAL( valueChanged(int) ),
m_channelsWidget, SLOT( setOffset(int) ) );
connect( m_epgView, SIGNAL( eventFocusedChanged(EPGEvent*)),
this, SIGNAL(itemSelectionChanged(EPGEvent*)) );
}
......
......@@ -27,6 +27,7 @@
#include "EPGView.hpp"
#include "EPGEvent.hpp"
#include "EPGRuler.hpp"
#include "EPGChannels.hpp"
#include <vlc_common.h>
#include <vlc_epg.h>
......@@ -49,6 +50,7 @@ public slots:
private:
EPGRuler* m_rulerWidget;
EPGView* m_epgView;
EPGChannels *m_channelsWidget;
QMultiMap<QString, EPGEvent*> m_events;
......
......@@ -33,6 +33,7 @@
#include <QLabel>
#include <QGroupBox>
#include <QPushButton>
#include <QTextEdit>
#include "qt4.hpp"
#include "input_manager.hpp"
......@@ -43,20 +44,18 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 0 );
QSplitter *splitter = new QSplitter( this );
epg = new EPGWidget( this );
splitter->addWidget( epg );
splitter->setOrientation(Qt::Vertical);
QGroupBox *descBox = new QGroupBox( qtr( "Description" ), this );
QVBoxLayout *boxLayout = new QVBoxLayout( descBox );
description = new QLabel( this );
description = new QTextEdit( this );
description->setReadOnly( true );
description->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel );
description->setAutoFillBackground( true );
description->setWordWrap( true );
description->setAlignment( Qt::AlignLeft | Qt::AlignTop );
description->setFixedHeight( 100 );
QPalette palette;
palette.setBrush(QPalette::Active, QPalette::Window, palette.brush( QPalette::Base ) );
......@@ -65,11 +64,10 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
title = new QLabel( qtr( "Title" ), this );
boxLayout->addWidget( title );
boxLayout->addWidget( description, 10 );
boxLayout->addWidget( description );
splitter->addWidget( epg );
splitter->addWidget( descBox );
layout->addWidget( splitter );
layout->addWidget( epg, 10 );
layout->addWidget( descBox );
CONNECT( epg, itemSelectionChanged( EPGEvent *), this, showEvent( EPGEvent *) );
CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() );
......
......@@ -28,8 +28,10 @@
#include "util/singleton.hpp"
class QLabel;
class QTextEdit;
class EPGEvent;
class EPGWidget;
class EpgDialog : public QVLCFrame, public Singleton<EpgDialog>
{
Q_OBJECT
......@@ -38,7 +40,7 @@ private:
virtual ~EpgDialog();
EPGWidget *epg;
QLabel *description;
QTextEdit *description;
QLabel *title;
friend class Singleton<EpgDialog>;
......
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