]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/epg/EPGView.hpp
Qt: epg: don't hide EPG when there's still data.
[vlc] / modules / gui / qt4 / components / epg / EPGView.hpp
1 /*****************************************************************************
2  * EPGView.h : EPGView
3  ****************************************************************************
4  * Copyright © 2009-2010 VideoLAN
5  * $Id$
6  *
7  * Authors: Ludovic Fauvet <etix@l0cal.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef EPGVIEW_H
25 #define EPGVIEW_H
26
27 #include "EPGItem.hpp"
28
29 #include <QGraphicsView>
30 #include <QGraphicsScene>
31 #include <QList>
32 #include <QMap>
33 #include <QMutex>
34 #include <QDateTime>
35
36 #define TRACKS_HEIGHT 60
37
38 typedef QMap<QDateTime, EPGItem *> EPGEventByTimeQMap;
39 typedef QMap<QString, EPGEventByTimeQMap* > EPGTimeMapByChannelQMap;
40
41 class EPGGraphicsScene : public QGraphicsScene
42 {
43 Q_OBJECT
44 public:
45     explicit EPGGraphicsScene( QObject *parent = 0 );
46 protected:
47     void drawBackground ( QPainter *, const QRectF &);
48 };
49
50 class EPGView : public QGraphicsView
51 {
52 Q_OBJECT
53
54 public:
55     explicit EPGView( QWidget *parent = 0 );
56     ~EPGView();
57
58     void            setScale( double scaleFactor );
59
60     void            updateStartTime();
61     const QDateTime& startTime();
62     const QDateTime& baseTime();
63
64     bool            addEPGEvent( vlc_epg_event_t*, QString, bool );
65     void            removeEPGEvent( vlc_epg_event_t*, QString );
66     void            updateDuration();
67     void            reset();
68     void            cleanup();
69     bool            hasValidData();
70
71 signals:
72     void            startTimeChanged( const QDateTime& startTime );
73     void            durationChanged( int seconds );
74     void            itemFocused( EPGItem * );
75     void            channelAdded( QString );
76     void            channelRemoved( QString );
77 protected:
78
79     QDateTime       m_startTime;
80     QDateTime       m_baseTime;
81     int             m_scaleFactor;
82     int             m_duration;
83
84 public slots:
85     void            focusItem( EPGItem * );
86 private:
87     EPGTimeMapByChannelQMap epgitemsByChannel;
88     void updateChannels();
89     QMutex mutex;
90 };
91
92 #endif // EPGVIEW_H