]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/vlm.hpp
QT4_vlm: really fix #3938.
[vlc] / modules / gui / qt4 / dialogs / vlm.hpp
index 11a600a37fbe884b3016580fafe1815dc86b3a9c..6feee5893d16528f295a00f796053d93402c6ff9 100644 (file)
@@ -2,7 +2,7 @@
  * vlm.hpp : VLM Management
  ****************************************************************************
  * Copyright ( C ) 2006 the VideoLAN team
- * $Id: vlm.hpp 21875 2007-09-08 16:01:33Z jb $
+ * $Id$
  *
  * Authors: Jean-François Massol <jf.massol@gmail.com>
  *          Jean-Baptiste Kempf <jb@videolan.org>
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#ifndef _VLM_DIALOG_H_
-#define _VLM_DIALOG_H_
+#ifndef QVLC_VLM_DIALOG_H_
+#define QVLC_VLM_DIALOG_H_ 1
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef ENABLE_VLM
+
+#include <vlc_vlm.h>
 
 #include "ui/vlm.h"
 #include "util/qvlcframe.hpp"
+#include "util/singleton.hpp"
+#include <QDateTime>
 
 enum{
     QVLM_Broadcast,
@@ -36,6 +44,13 @@ enum{
     QVLM_VOD
 };
 
+enum{
+    ControlBroadcastPlay,
+    ControlBroadcastPause,
+    ControlBroadcastStop,
+    ControlBroadcastSeek
+};
+
 class QComboBox;
 class QVBoxLayout;
 class QStackedWidget;
@@ -47,71 +62,174 @@ class QToolButton;
 class QGroupBox;
 class QPushButton;
 class QHBoxLayout;
-class QDateEdit;
-class QTimeEdit;
+class QDateTimeEdit;
 class QSpinBox;
-class VLMObject;
+class VLMAWidget;
+class VLMWrapper;
+
 
-class VLMDialog : public QVLCFrame
+class VLMDialog : public QVLCDialog, public Singleton<VLMDialog>
 {
-    Q_OBJECT;
+    Q_OBJECT
+
 public:
-    static VLMDialog * getInstance( intf_thread_t *p_intf )
-    {
-        if( !instance)
-             instance = new VLMDialog( p_intf );
-        return instance;
-    };
-    virtual ~VLMDialog();
+    void toggleVisible();
 
+    VLMWrapper *vlmWrapper;
+    vlm_t *p_vlm;
 private:
     VLMDialog( intf_thread_t * );
-    static VLMDialog *instance;
+    virtual ~VLMDialog();
+
     Ui::Vlm ui;
 
-    QList<VLMObject *> vlmItems;
+    QString inputOptions;
+
+    QList<VLMAWidget *> vlmItems;
     int currentIndex;
 
     QVBoxLayout *vlmItemLayout;
     QWidget *vlmItemWidget;
-  
+
     QComboBox *mediatype;
-    QTimeEdit *time;
-    QDateEdit *date;
-    QSpinBox *scherepeatnumber;
-    bool isNameGenuine( QString );
+    QDateTimeEdit *time, *date, *repeatTime;
+    QSpinBox *scherepeatnumber, *repeatDays;
+    bool isNameGenuine( const QString& );
+    void mediasPopulator();
 public slots:
-    void removeVLMItem( VLMObject * );
-    void startModifyVLMItem( VLMObject * );
+    void removeVLMItem( VLMAWidget * );
+    void startModifyVLMItem( VLMAWidget * );
 private slots:
     void addVLMItem();
     void clearWidgets();
     void saveModifications();
     void showScheduleWidget( int );
     void selectVLMItem( int );
+    void selectInput();
+    void selectOutput();
+    bool exportVLMConf();
+    bool importVLMConf();
+
+    friend class    Singleton<VLMDialog>;
 };
 
-class VLMObject : public QGroupBox 
+class VLMWrapper
+{
+public:
+    VLMWrapper( vlm_t * );
+    virtual ~VLMWrapper();
+
+    static void AddBroadcast( const QString&, const QString&,
+                              const QString&, const QString&,
+                              bool b_enabled = true, bool b_loop = false );
+    static void EditBroadcast( const QString&, const QString&,
+                               const QString&, const QString&,
+                               bool b_enabled = true, bool b_loop = false );
+    static void EditSchedule( const QString&, const QString&,
+                              const QString&, const QString&,
+                              QDateTime _schetime, QDateTime _schedate,
+                              int _scherepeatnumber, int _repeatDays,
+                              bool b_enabled = true, const QString& mux = "" );
+    static void AddVod( const QString&, const QString&,
+                        const QString&, const QString&,
+                        bool b_enabled = true, const QString& mux = "" );
+    static void EditVod( const QString&, const QString&,
+                         const QString&, const QString&,
+                         bool b_enabled = true, const QString& mux = "" );
+    static void AddSchedule( const QString&, const QString&,
+                             const QString&, const QString&,
+                             QDateTime _schetime, QDateTime _schedate,
+                             int _scherepeatnumber, int _repeatDays,
+                             bool b_enabled = true, const QString& mux = "" );
+
+    static void ControlBroadcast( const QString&, int, unsigned int seek = 0 );
+    static void EnableItem( const QString&, bool );
+
+    /* We don't have yet the accessors in the core, so the following is commented */
+    //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
+   /* vlm_media_t *GetMedia( int i )
+    { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
+
+private:
+    static vlm_t *p_vlm;
+};
+
+class VLMAWidget : public QGroupBox
 {
     Q_OBJECT
     friend class VLMDialog;
 public:
-    VLMObject( int type, QString name, QString input, QString output, bool _enable, VLMDialog *parent );
-private:
+    VLMAWidget( const QString& name, const QString& input,
+                const QString& inputOptions, const QString& output,
+                bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
+    virtual void update() = 0;
+protected:
+    QLabel *nameLabel;
     QString name;
     QString input;
+    QString inputOptions;
     QString output;
-    bool b_looped;
     bool b_enabled;
+    int type;
     VLMDialog *parent;
-protected:
-    virtual void enterEvent( QEvent * );
+    QGridLayout *objLayout;
+private slots:
+    virtual void modify();
+    virtual void del();
+    virtual void toggleEnabled( bool );
+};
+
+class VLMBroadcast : public VLMAWidget
+{
+    Q_OBJECT
+    friend class VLMDialog;
+public:
+    VLMBroadcast( const QString& name, const QString& input,
+                  const QString& inputOptions, const QString& output,
+                  bool _enable, bool _loop, VLMDialog *parent );
+    void update();
+private:
+    bool b_looped;
+    bool b_playing;
+    QToolButton *loopButton, *playButton;
 private slots:
-    void modify();
     void stop();
-    void del();
     void togglePlayPause();
     void toggleLoop();
 };
 
+class VLMVod : public VLMAWidget
+{
+    Q_OBJECT
+    friend class VLMDialog;
+public:
+    VLMVod( const QString& name, const QString& input,
+            const QString& inputOptions, const QString& output,
+            bool _enable, const QString& _mux, VLMDialog *parent );
+    void update();
+private:
+    QString mux;
+    QLabel *muxLabel;
+};
+
+class VLMSchedule : public VLMAWidget
+{
+    Q_OBJECT
+    friend class VLMDialog;
+public:
+    VLMSchedule( const QString& name, const QString& input,
+                 const QString& inputOptions, const QString& output,
+                 QDateTime schetime, QDateTime schedate, int repeatnumber,
+                 int repeatdays, bool enabled, VLMDialog *parent );
+    void update();
+private:
+    QDateTime schetime;
+    QDateTime schedate;
+    int rNumber;
+    int rDays;
+};
+
 #endif
+
+#endif
+