]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.hpp
Qt: includes barrier fix.
[vlc] / modules / gui / qt4 / dialogs / vlm.hpp
1 /*****************************************************************************
2  * vlm.hpp : VLM Management
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id$
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 QVLC_VLM_DIALOG_H_
26 #define QVLC_VLM_DIALOG_H_ 1
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #ifdef ENABLE_VLM
33
34 #include <vlc_vlm.h>
35
36 #include "ui/vlm.h"
37 #include "util/qvlcframe.hpp"
38 #include <QDateTime>
39
40 enum{
41     QVLM_Broadcast,
42     QVLM_Schedule,
43     QVLM_VOD
44 };
45
46 enum{
47     ControlBroadcastPlay,
48     ControlBroadcastPause,
49     ControlBroadcastStop,
50     ControlBroadcastSeek
51 };
52
53 class QComboBox;
54 class QVBoxLayout;
55 class QStackedWidget;
56 class QLabel;
57 class QGridLayout;
58 class QLineEdit;
59 class QCheckBox;
60 class QToolButton;
61 class QGroupBox;
62 class QPushButton;
63 class QHBoxLayout;
64 class QDateTimeEdit;
65 class QSpinBox;
66 class VLMAWidget;
67 class VLMWrapper;
68
69
70 class VLMDialog : public QVLCDialog
71 {
72     Q_OBJECT;
73 public:
74     static VLMDialog * getInstance( intf_thread_t *p_intf )
75     {
76         if( !instance)
77              instance = new VLMDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
78         return instance;
79     };
80     virtual ~VLMDialog();
81     void toggleVisible();
82
83     VLMWrapper *vlmWrapper;
84     vlm_t *p_vlm;
85 private:
86     VLMDialog( QWidget *, intf_thread_t * );
87     static VLMDialog *instance;
88     Ui::Vlm ui;
89
90     QList<VLMAWidget *> vlmItems;
91     int currentIndex;
92
93     QVBoxLayout *vlmItemLayout;
94     QWidget *vlmItemWidget;
95
96     QComboBox *mediatype;
97     QDateTimeEdit *time, *date, *repeatTime;
98     QSpinBox *scherepeatnumber, *repeatDays;
99     bool isNameGenuine( const QString& );
100     void mediasPopulator();
101 public slots:
102     void removeVLMItem( VLMAWidget * );
103     void startModifyVLMItem( VLMAWidget * );
104 private slots:
105     void addVLMItem();
106     void clearWidgets();
107     void saveModifications();
108     void showScheduleWidget( int );
109     void selectVLMItem( int );
110     void selectInput();
111     void selectOutput();
112     bool exportVLMConf();
113     bool importVLMConf();
114 };
115
116 class VLMWrapper
117 {
118 public:
119     VLMWrapper( vlm_t * );
120     virtual ~VLMWrapper();
121
122     static void AddBroadcast( const QString&, const QString&, const QString&,
123                        bool b_enabled = true,
124                        bool b_loop = false );
125     static void EditBroadcast( const QString&, const QString&, const QString&,
126                        bool b_enabled = true,
127                        bool b_loop = false );
128     static void EditSchedule( const QString&, const QString&, const QString&,
129                        QDateTime _schetime, QDateTime _schedate,
130                        int _scherepeatnumber, int _repeatDays,
131                        bool b_enabled = true, const QString& mux = "" );
132     static void AddVod( const QString&, const QString&, const QString&,
133                        bool b_enabled = true, const QString& mux = "" );
134     static void EditVod( const QString&, const QString&, const QString&,
135                        bool b_enabled = true, const QString& mux = "" );
136     static void AddSchedule( const QString&, const QString&, const QString&,
137                        QDateTime _schetime, QDateTime _schedate,
138                        int _scherepeatnumber, int _repeatDays,
139                        bool b_enabled = true, const QString& mux = "" );
140
141     static void ControlBroadcast( const QString&, int, unsigned int seek = 0 );
142     static void EnableItem( const QString&, bool );
143
144     /* We don't have yet the accessors in the core, so the following is commented */
145     //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
146    /* vlm_media_t *GetMedia( int i )
147     { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
148
149 private:
150     static vlm_t *p_vlm;
151 };
152
153 class VLMAWidget : public QGroupBox
154 {
155     Q_OBJECT
156     friend class VLMDialog;
157 public:
158     VLMAWidget( const QString& name, const QString& input, const QString& output,
159             bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
160     virtual void update() = 0;
161 protected:
162     QLabel *nameLabel;
163     QString name;
164     QString input;
165     QString output;
166     bool b_enabled;
167     int type;
168     VLMDialog *parent;
169     QGridLayout *objLayout;
170 private slots:
171     virtual void modify();
172     virtual void del();
173     virtual void toggleEnabled( bool );
174 };
175
176 class VLMBroadcast : public VLMAWidget
177 {
178     Q_OBJECT
179     friend class VLMDialog;
180 public:
181     VLMBroadcast( const QString& name, const QString& input, const QString& output,
182             bool _enable, bool _loop, VLMDialog *parent );
183     void update();
184 private:
185     bool b_looped;
186     bool b_playing;
187     QToolButton *loopButton, *playButton;
188 private slots:
189     void stop();
190     void togglePlayPause();
191     void toggleLoop();
192 };
193
194 class VLMVod : public VLMAWidget
195 {
196     Q_OBJECT
197     friend class VLMDialog;
198 public:
199     VLMVod( const QString& name, const QString& input, const QString& output,
200             bool _enable, const QString& _mux, VLMDialog *parent );
201     void update();
202 private:
203     QString mux;
204     QLabel *muxLabel;
205 };
206
207 class VLMSchedule : public VLMAWidget
208 {
209     Q_OBJECT
210     friend class VLMDialog;
211 public:
212     VLMSchedule( const QString& name, const QString& input, const QString& output,
213             QDateTime schetime, QDateTime schedate, int repeatnumber,
214             int repeatdays, bool enabled, VLMDialog *parent );
215     void update();
216 private:
217     QDateTime schetime;
218     QDateTime schedate;
219     int rNumber;
220     int rDays;
221 };
222
223 #endif
224
225 #endif
226