]> git.sesse.net Git - vlc/commitdiff
Remove the channel list overlaid above the EPGView widget.
authorAdrien Maglo <magsoft@videolan.org>
Sat, 12 Jun 2010 19:25:20 +0000 (21:25 +0200)
committerAdrien Maglo <magsoft@videolan.org>
Sat, 12 Jun 2010 19:46:22 +0000 (21:46 +0200)
Add a channel list widget at the left of the EPGView widget.
Remove the splitter on the EPG window.

modules/gui/qt4/Modules.am
modules/gui/qt4/components/epg/EPGChannels.cpp [new file with mode: 0644]
modules/gui/qt4/components/epg/EPGChannels.hpp [new file with mode: 0644]
modules/gui/qt4/components/epg/EPGView.cpp
modules/gui/qt4/components/epg/EPGView.hpp
modules/gui/qt4/components/epg/EPGWidget.cpp
modules/gui/qt4/components/epg/EPGWidget.hpp
modules/gui/qt4/dialogs/epg.cpp
modules/gui/qt4/dialogs/epg.hpp

index 936a6027cdd14c47f5a1b22d8813164983b7f043..0b8cb905ed7393c4e3ed1cc6dd4454dc6f68e0a3 100644 (file)
@@ -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 \
diff --git a/modules/gui/qt4/components/epg/EPGChannels.cpp b/modules/gui/qt4/components/epg/EPGChannels.cpp
new file mode 100644 (file)
index 0000000..9120a55
--- /dev/null
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * 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 );
+    }
+}
diff --git a/modules/gui/qt4/components/epg/EPGChannels.hpp b/modules/gui/qt4/components/epg/EPGChannels.hpp
new file mode 100644 (file)
index 0000000..614a704
--- /dev/null
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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
index 5af6f93382f12fa5a989d71a07cfe0f52c5af450..e4af52f6f2f3cb6ffdc87121152c9a5a78b00ec6 100644 (file)
 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 );
 }
index ef8d76debd831a33f370fbc1b16024466af08a14..00b9b77002e8221e65cc2e86563838a1519bf418 100644 (file)
@@ -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
index d5f235dbd1d0c0ca84af3747c64e3ff95c023f83..d62114aa7d48bdafe06b8e77916166cb0b4cbe21 100644 (file)
@@ -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*)) );
 }
index 41bcba7bae1ad5f93dc658227ebe3858d8caf9e6..ad03eac465e2cadb942a9b8fc53473f2d7e8b92d 100644 (file)
@@ -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;
 
index d54da54c0d1ae2ac29024dd0505a42301e531a4c..7c112d3b0ef46e1f4df052f2124a8b4878e31137 100644 (file)
@@ -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() );
index 9213182080e99c57bcaff5b8d1de43ed11751deb..f81e39daba913892de7237611a4bf0d424cef890 100644 (file)
 #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>;