]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.hpp
Qt4 - VLM: simplifications.
[vlc] / modules / gui / qt4 / dialogs / vlm.hpp
1 /*****************************************************************************
2  * vlm.hpp : VLM Management
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id: vlm.hpp 21875 2007-09-08 16:01:33Z jb $
6  *
7  * Authors: Jean-François Massol <jf.massol@gmail.com>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * ( at your option ) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef _VLM_DIALOG_H_
26 #define _VLM_DIALOG_H_
27
28 #include <vlc/vlc.h>
29 #include <vlc_vlm.h>
30
31 #include "ui/vlm.h"
32 #include "util/qvlcframe.hpp"
33
34 enum{
35     QVLM_Broadcast,
36     QVLM_Schedule,
37     QVLM_VOD
38 };
39
40 enum{
41     ControlBroadcastPlay,
42     ControlBroadcastPause,
43     ControlBroadcastStop,
44     ControlBroadcastSeek
45 };
46
47 class QComboBox;
48 class QVBoxLayout;
49 class QStackedWidget;
50 class QLabel;
51 class QGridLayout;
52 class QLineEdit;
53 class QCheckBox;
54 class QToolButton;
55 class QGroupBox;
56 class QPushButton;
57 class QHBoxLayout;
58 class QDateTimeEdit;
59 class QSpinBox;
60 class VLMAWidget;
61 class VLMWrapper;
62
63
64 class VLMDialog : public QVLCFrame
65 {
66     Q_OBJECT;
67 public:
68     static VLMDialog * getInstance( intf_thread_t *p_intf )
69     {
70         if( !instance)
71              instance = new VLMDialog( p_intf );
72         return instance;
73     };
74     virtual ~VLMDialog();
75
76     VLMWrapper *vlmWrapper;
77 vlm_t *p_vlm;
78 private:
79     VLMDialog( intf_thread_t * );
80     static VLMDialog *instance;
81     Ui::Vlm ui;
82
83     QList<VLMAWidget *> vlmItems;
84     int currentIndex;
85
86     QVBoxLayout *vlmItemLayout;
87     QWidget *vlmItemWidget;
88   
89     QComboBox *mediatype;
90     QDateTimeEdit *time, *date, *repeatTime;
91     QSpinBox *scherepeatnumber, *repeatDays;
92     bool isNameGenuine( QString );
93 public slots:
94     void removeVLMItem( VLMAWidget * );
95     void startModifyVLMItem( VLMAWidget * );
96 private slots:
97     void addVLMItem();
98     void clearWidgets();
99     void saveModifications();
100     void showScheduleWidget( int );
101     void selectVLMItem( int );
102 };
103
104 class VLMWrapper
105 {
106 public:
107     VLMWrapper( vlm_t * );
108     virtual ~VLMWrapper();
109
110     static void AddBroadcast( const QString, const QString, const QString,
111                        bool b_enabled = true,
112                        bool b_loop = false );
113     static void EditBroadcast( const QString, const QString, const QString,
114                        bool b_enabled = true,
115                        bool b_loop = false );
116     static void AddVod( const QString, const QString, const QString,
117                        bool b_enabled = true, QString mux = "" );
118     static void EditVod( const QString, const QString, const QString,
119                        bool b_enabled = true, QString mux = "" );
120
121     static void ControlBroadcast( const QString, int, unsigned int seek = 0 );
122
123     /* We don't have yet the accessors in the core, so the following is commented */
124     //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
125    /* vlm_media_t *GetMedia( int i )
126     { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
127
128 private:
129     static vlm_t *p_vlm;
130 };
131
132 class VLMAWidget : public QGroupBox 
133 {
134     Q_OBJECT
135     friend class VLMDialog;
136 public:
137     VLMAWidget( QString name, QString input, QString output,
138             bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
139     virtual void update() = 0;
140 protected:
141     QLabel *nameLabel;
142     QString name;
143     QString input;
144     QString output;
145     bool b_enabled;
146     int type;
147     VLMDialog *parent;
148     virtual void enterEvent( QEvent * );
149     QGridLayout *objLayout;
150 private slots:
151     virtual void modify();
152     virtual void del();
153 };
154
155 class VLMBroadcast : public VLMAWidget
156 {
157     Q_OBJECT
158     friend class VLMDialog;
159 public:
160     VLMBroadcast( QString name, QString input, QString output,
161             bool _enable, bool _loop, VLMDialog *parent );
162     void update();
163 private:
164     bool b_looped;
165     bool b_playing;
166     QToolButton *loopButton, *playButton;
167 private slots:
168     void stop();
169     void togglePlayPause();
170     void toggleLoop();
171 };
172
173 class VLMVod : public VLMAWidget
174 {
175     Q_OBJECT
176     friend class VLMDialog;
177 public:
178     VLMVod( QString name, QString input, QString output,
179             bool _enable, QString _mux, VLMDialog *parent );
180     void update();
181 private:
182     QString mux;
183     QLabel *muxLabel;
184 };
185
186 class VLMSchedule : public VLMAWidget
187 {
188     friend class VLMDialog;
189 public:
190     VLMSchedule( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
191     void update();
192 private:
193     
194 };
195
196 #endif