]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.cpp
1c457ad0464ff9e3437b16b2d5cd2c9be5981e6d
[vlc] / modules / gui / qt4 / dialogs / vlm.cpp
1 /*****************************************************************************
2  * sout.cpp : stream output dialog ( old-style )
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id: sout.cpp 21875 2007-09-08 16:01:33Z jb $
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Jean-François Massol <jf.massol -at- gmail.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * ( at your option ) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #include "dialogs/vlm.hpp"
27 #include <vlc_streaming.h>
28
29 #include <QString>
30 #include <QFileDialog>
31 #include <QComboBox>
32 #include <QVBoxLayout>
33 #include <QStackedWidget>
34 #include <QLabel>
35 #include <QWidget>
36 #include <QGridLayout>
37 #include <QLineEdit>
38 #include <QCheckBox>
39 #include <QToolButton>
40 #include <QGroupBox>
41 #include <QPushButton>
42 #include <QHBoxLayout>
43 #include <QTimeEdit>
44 #include <QDateEdit>
45 #include <QSpinBox>
46 #include <QHeaderView>
47
48 VLMDialog *VLMDialog::instance = NULL;
49
50
51 VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
52 {
53     // UI stuff
54     ui.setupUi( this );
55
56 #define ADDMEDIATYPES( str, type ) ui.mediaType->addItem( qtr( str ), QVariant( type ) );
57     ADDMEDIATYPES( "Broadcast", QVLM_Broadcast );
58     ADDMEDIATYPES( "Video On Demand ( VOD )", QVLM_VOD );
59     ADDMEDIATYPES( "Schedule", QVLM_Schedule );
60 #undef ADDMEDIATYPES
61     
62   /*  ui.mediasDB->horizontalHeader()->setResizeMode( 0, QHeaderView::ResizeToContents );
63     ui.mediasDB->horizontalHeader()->resizeSection( 1, 160 );
64     ui.mediasDB->horizontalHeader()->resizeSection( 2, 120 );
65     ui.mediasDB->horizontalHeader()->resizeSection( 3, 120 );
66     ui.mediasDB->horizontalHeader()->setStretchLastSection ( true );*/
67
68     QGridLayout *bcastlayout = new QGridLayout( ui.pBcast );
69     QLabel *bcastname = new QLabel( qtr( "Name:" ) );
70     bcastnameledit = new QLineEdit;
71     bcastenable = new QCheckBox( qtr( "Enable" ) );
72     bcastenable->setCheckState( Qt::Checked );
73     QLabel *bcastinput = new QLabel( qtr( "Input:" ) );
74     bcastinputledit = new QLineEdit;
75     bcastinputtbutton = new QToolButton;
76     QLabel *bcastoutput = new QLabel( qtr( "Output:" ) );
77     bcastoutputledit = new QLineEdit;
78     bcastoutputtbutton = new QToolButton;
79     QGroupBox *bcastcontrol = new QGroupBox( qtr( "Controls" ) );
80     QHBoxLayout *bcastgbox = new QHBoxLayout( bcastcontrol );
81     bcastplay = new QPushButton( qtr( "Play" ) );
82     bcastpause = new QPushButton( qtr( "Pause" ) );
83     bcaststop = new QPushButton( qtr( "Stop" ) );
84
85     bcastgbox->addWidget( bcastplay );
86     bcastgbox->addWidget( bcastpause );
87     bcastgbox->addWidget( bcaststop );
88
89     bcastlayout->addWidget( bcastname, 0, 0 );
90     bcastlayout->addWidget( bcastnameledit, 0, 1 );
91     bcastlayout->addWidget( bcastenable, 0, 2 );
92     bcastlayout->addWidget( bcastinput, 1, 0 );
93     bcastlayout->addWidget( bcastinputledit, 1, 1 );
94     bcastlayout->addWidget( bcastinputtbutton, 1, 2 );
95     bcastlayout->addWidget( bcastoutput, 2, 0 );
96     bcastlayout->addWidget( bcastoutputledit, 2, 1 );
97     bcastlayout->addWidget( bcastoutputtbutton, 2, 2 );
98     bcastlayout->addWidget( bcastcontrol, 3, 0, 1, 3 );
99     QSpacerItem *spacerItem = new QSpacerItem(10, 5,
100                         QSizePolicy::Expanding, QSizePolicy::MinimumExpanding );
101     bcastlayout->addItem(spacerItem, 4, 0, 1, 1);
102
103
104     QGridLayout *vodlayout = new QGridLayout( ui.pVod );
105     QLabel *vodname = new QLabel( qtr( "Name :" ) );
106     vodnameledit = new QLineEdit;
107     vodenable = new QCheckBox( qtr( "Enable" ) );
108     QLabel *vodinput = new QLabel( qtr( "Input :" ) );
109     vodinputledit = new QLineEdit;
110     vodinputtbutton = new QToolButton;
111     QLabel *vodoutput = new QLabel( qtr( "Output :" ) );
112     vodoutputledit = new QLineEdit;
113     vodoutputtbutton = new QToolButton;
114
115     vodlayout->addWidget( vodname, 0, 0 );
116     vodlayout->addWidget( vodnameledit, 0, 1 );
117     vodlayout->addWidget( vodenable, 0, 2 );
118     vodlayout->addWidget( vodinput, 1, 0 );
119     vodlayout->addWidget( vodinputledit, 1, 1 );
120     vodlayout->addWidget( vodinputtbutton, 1, 2 );
121     vodlayout->addWidget( vodoutput, 2, 0 );
122     vodlayout->addWidget( vodoutputledit, 2, 1 );
123     vodlayout->addWidget( vodoutputtbutton, 2, 2 );
124     QSpacerItem *spacerVod = new QSpacerItem(10, 5, 
125                         QSizePolicy::Expanding, QSizePolicy::MinimumExpanding );
126     vodlayout->addItem( spacerVod, 4, 0, 1, 1);
127
128
129     QGridLayout *schelayout = new QGridLayout( ui.pSched );
130     QLabel *schename = new QLabel( qtr( "Name:" ) );
131     schenameledit = new QLineEdit;
132     scheenable = new QCheckBox( qtr( "Enable" ) );
133     QLabel *scheinput = new QLabel( qtr( "Input:" ) );
134     scheinputledit = new QLineEdit;
135     scheinputtbutton = new QToolButton;
136     QLabel *scheoutput = new QLabel( qtr( "Output:" ) );
137     scheoutputledit = new QLineEdit;
138     scheoutputtbutton = new QToolButton;
139
140     QGroupBox *schecontrol = new QGroupBox( qtr( "Time Control" ), ui.pSched );
141     QGridLayout *schetimelayout = new QGridLayout( schecontrol );
142     QLabel *schetimelabel = new QLabel( qtr( "Hours/Minutes/Seconds:" ) );
143     QLabel *schedatelabel = new QLabel( qtr( "Day Month Year:" ) );
144     QLabel *schetimerepeat = new QLabel( qtr( "Repeat:" ) );
145     time = new QTimeEdit( QTime::currentTime() );
146     time->setAlignment( Qt::AlignRight );
147     date = new QDateEdit( QDate::currentDate() );
148     date->setAlignment( Qt::AlignRight );
149 #ifdef WIN32
150     date->setDisplayFormat( "dd MM yyyy" );
151 #else
152     date->setDisplayFormat( "dd MMMM yyyy" );
153 #endif
154     scherepeatnumber = new QSpinBox;
155     scherepeatnumber->setAlignment( Qt::AlignRight );
156     schecontrol->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
157
158     schetimelayout->addWidget( schetimelabel, 0, 0 );
159     schetimelayout->addWidget( time, 0, 1 );
160     schetimelayout->addWidget( schedatelabel, 1, 0 );
161     schetimelayout->addWidget( date, 1, 1 );
162     schetimelayout->addWidget( schetimerepeat, 2, 0 );
163     schetimelayout->addWidget( scherepeatnumber, 2, 1 );
164     schelayout->addWidget( schename, 0, 0 );
165     schelayout->addWidget( schenameledit, 0, 1 );
166     schelayout->addWidget( scheenable, 0, 2 );
167     schelayout->addWidget( scheinput, 1, 0 );
168     schelayout->addWidget( scheinputledit, 1, 1 );
169     schelayout->addWidget( scheinputtbutton, 1, 2 );
170     schelayout->addWidget( scheoutput, 2, 0 );
171     schelayout->addWidget( scheoutputledit, 2, 1 );
172     schelayout->addWidget( scheoutputtbutton, 2, 2 );
173     schelayout->addWidget( schecontrol, 3, 0, 1, 3 );
174
175     QPushButton *closeButton = new QPushButton( qtr( "Close" ) );
176     QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
177     ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
178     ui.buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
179
180     ui.mediaStacked->setCurrentIndex( QVLM_Broadcast );
181     CONNECT( ui.mediaType, currentIndexChanged( int ),
182              ui.mediaStacked, setCurrentIndex( int ) );
183
184     BUTTONACT( closeButton, finish() );
185     BUTTONACT( cancelButton, cancel() );
186
187     BUTTONACT( ui.addButton, addVLMItem() );
188     BUTTONACT( ui.clearButton, clearVLMItem() );
189 }
190
191 VLMDialog::~VLMDialog(){}
192
193 void VLMDialog::cancel()
194 {
195     hide();
196
197 }
198
199 void VLMDialog::finish()
200 {
201    // for( int i = 0; i < ui.mediasDB->topLevelItemCount(); i++ );
202     hide();
203 }
204
205 void VLMDialog::addVLMItem()
206 {
207    // int row =  ui.mediasDB->rowCount() -1 ;
208     int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
209     QString str;
210     QString name;
211
212     switch( type )
213     {
214     case QVLM_Broadcast:
215         str = "broadcast";
216         name = bcastnameledit->text();        
217     break;
218     case QVLM_VOD:
219         str = "vod";
220         name = vodnameledit->text();
221         break;
222     case QVLM_Schedule:
223         str = "schedule";
224         name = schenameledit->text();
225         break;
226     default:
227         break;
228     }
229
230     QGroupBox *groupItem = new QGroupBox( name );
231     
232     /*QTableWidgetItem *newItem = new QTableWidgetItem( str );
233     ui.mediasDB->setItem( row, 0,  newItem );
234     QTableWidgetItem *newItem2 = new QTableWidgetItem( name );
235     ui.mediasDB->setItem( row, 1,  newItem2 );*/
236
237 }
238
239 void VLMDialog::removeVLMItem()
240 {
241     
242 }
243
244
245 void VLMDialog::clearVLMItem()
246 {
247     
248 }