summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/playlistwidget.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp399
1 files changed, 256 insertions, 143 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 202f351..7862d8d 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -8,53 +8,60 @@
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54
20 21
21#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
23#include <qpe/fileselector.h> 24#include <qpe/fileselector.h>
24#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
25 26
26#include <qpe/applnk.h> 27#include <qpe/applnk.h>
27#include <qpe/config.h> 28#include <qpe/config.h>
28#include <qpe/global.h> 29#include <qpe/global.h>
29#include <qpe/resource.h> 30#include <qpe/resource.h>
30#include <qaction.h> 31#include <qaction.h>
31#include <qimage.h> 32#include <qimage.h>
32#include <qfile.h> 33#include <qfile.h>
33#include <qlayout.h> 34#include <qlayout.h>
34#include <qlabel.h> 35#include <qlabel.h>
35#include <qlist.h> 36#include <qlist.h>
36#include <qlistbox.h> 37#include <qlistbox.h>
37#include <qmainwindow.h> 38#include <qmainwindow.h>
38#include <qmessagebox.h> 39#include <qmessagebox.h>
39#include <qtoolbutton.h> 40#include <qtoolbutton.h>
40#include <qtabwidget.h> 41#include <qtabwidget.h>
41#include <qlistview.h> 42#include <qlistview.h>
42#include <qpoint.h> 43#include <qpoint.h>
44#include <qlineedit.h>
45#include <qpushbutton.h>
46
43//#include <qtimer.h> 47//#include <qtimer.h>
44 48
45#include "playlistselection.h" 49#include "playlistselection.h"
46#include "playlistwidget.h" 50#include "playlistwidget.h"
47#include "mediaplayerstate.h" 51#include "mediaplayerstate.h"
48 52
53#include "fileBrowser.h"
54#include "inputDialog.h"
55
49#include <stdlib.h> 56#include <stdlib.h>
50 57
51#define BUTTONS_ON_TOOLBAR 58#define BUTTONS_ON_TOOLBAR
52#define SIDE_BUTTONS 59#define SIDE_BUTTONS
53#define CAN_SAVE_LOAD_PLAYLISTS 60#define CAN_SAVE_LOAD_PLAYLISTS
54 61
55extern MediaPlayerState *mediaPlayerState; 62extern MediaPlayerState *mediaPlayerState;
56 63
57// class myFileSelector { 64// class myFileSelector {
58 65
59// }; 66// };
60class PlayListWidgetPrivate { 67class PlayListWidgetPrivate {
@@ -110,57 +117,71 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
110 setToolBarsMovable( FALSE ); 117 setToolBarsMovable( FALSE );
111 118
112 // Create Toolbar 119 // Create Toolbar
113 QPEToolBar *toolbar = new QPEToolBar( this ); 120 QPEToolBar *toolbar = new QPEToolBar( this );
114 toolbar->setHorizontalStretchable( TRUE ); 121 toolbar->setHorizontalStretchable( TRUE );
115 122
116 // Create Menubar 123 // Create Menubar
117 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 124 QPEMenuBar *menu = new QPEMenuBar( toolbar );
118 menu->setMargin( 0 ); 125 menu->setMargin( 0 );
119 126
120 QPEToolBar *bar = new QPEToolBar( this ); 127 QPEToolBar *bar = new QPEToolBar( this );
121 bar->setLabel( tr( "Play Operations" ) ); 128 bar->setLabel( tr( "Play Operations" ) );
122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),"mpegplayer/add_to_playlist",this , SLOT(addSelected()) ); 129// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list",
123 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); 130// this , SLOT( addSelected()) );
124 d->tbPlay = new ToolButton( bar, tr( "Play" ),"mpegplayer/play", mediaPlayerState, SLOT( setPlaying(bool)), TRUE ); 131 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close");
125 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 132 tbDeletePlaylist->setFlat(TRUE);
126 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 133 tbDeletePlaylist->setFixedSize(20,20);
134 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
135
136 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
137 this , SLOT(addSelected()) );
138 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
139 this , SLOT(removeSelected()) );
140// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
141 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
142 this , SLOT( btnPlay(bool) ), TRUE );
143 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle",
144 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
145 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop",
146 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
147 tbDeletePlaylist->hide();
127 148
128 QPopupMenu *pmPlayList = new QPopupMenu( this ); 149 QPopupMenu *pmPlayList = new QPopupMenu( this );
129 menu->insertItem( tr( "File" ), pmPlayList ); 150 menu->insertItem( tr( "File" ), pmPlayList );
130 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 151 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
131 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 152 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
132 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 153 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
133 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 154 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
134 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 155 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
135 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); 156 // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) );
136 157
137 QPopupMenu *pmView = new QPopupMenu( this ); 158 QPopupMenu *pmView = new QPopupMenu( this );
138 menu->insertItem( tr( "View" ), pmView ); 159 menu->insertItem( tr( "View" ), pmView );
139 160
140 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 161 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
141 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 162 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
142 fullScreenButton->addTo(pmView); 163 fullScreenButton->addTo(pmView);
143 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); 164 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
144 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 165 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
145 scaleButton->addTo(pmView); 166 scaleButton->addTo(pmView);
146 167
147 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 168 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
148 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 169 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
149 170
150 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 171 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
151 172
152 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 173 tabWidget = new QTabWidget( hbox6, "tabWidget" );
153 tabWidget->setTabShape(QTabWidget::Triangular); 174 tabWidget->setTabShape(QTabWidget::Triangular);
154 175
155 QWidget *pTab; 176 QWidget *pTab;
156 pTab = new QWidget( tabWidget, "pTab" ); 177 pTab = new QWidget( tabWidget, "pTab" );
157 playlistView = new QListView( pTab, "Videoview" ); 178 playlistView = new QListView( pTab, "Videoview" );
158 playlistView->setMinimumSize(236,260); 179 playlistView->setMinimumSize(236,260);
159 tabWidget->insertTab( pTab,"Playlist"); 180 tabWidget->insertTab( pTab,"Playlist");
160 181
161 // Add the playlist area 182 // Add the playlist area
162 183
163 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 184 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
164 d->playListFrame = vbox3; 185 d->playListFrame = vbox3;
165 d->playListFrame ->setMinimumSize(235,260); 186 d->playListFrame ->setMinimumSize(235,260);
166 187
@@ -219,53 +240,57 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
219 QListIterator<DocLnk> Vdit( vFiles.children() ); 240 QListIterator<DocLnk> Vdit( vFiles.children() );
220 for ( ; Vdit.current(); ++Vdit ) { 241 for ( ; Vdit.current(); ++Vdit ) {
221 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 242 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
222 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; 243 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
223 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 244 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
224 else storage="RAM"; 245 else storage="RAM";
225 QListViewItem * newItem; 246 QListViewItem * newItem;
226 if ( QFile( Vdit.current()->file()).exists() ) { 247 if ( QFile( Vdit.current()->file()).exists() ) {
227 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 248 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
228 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 249 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
229 } 250 }
230 } 251 }
231 // add the library area
232 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
233 252
234// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 253//playlists list
235// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 254 QWidget *LTab;
255 LTab = new QWidget( tabWidget, "LTab" );
256 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
257 playLists->setMinimumSize(233,260);;
258 tabWidget->insertTab(LTab,"Lists");
259 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
260// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
236 261
237 connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
238 connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
239 262
240 connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), 263// add the library area
241 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); 264 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
242 connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
243 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
244 265
245 266
246 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 267 connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
247 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 268 this, SLOT( fauxPlay( QListViewItem *) ) );
248 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 269 connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
249 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 270 this, SLOT( fauxPlay( QListViewItem *)) );
250 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
251 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
252 271
253// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); 272// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
254// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); 273// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
255// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) );
256 274
257 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 275 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
276 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
258 277
259 connect( d->selectedFiles, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 278 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
279 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
280 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
281 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
282 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
283
284 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
260// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 285// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
261 286
262 setCentralWidget( vbox5 ); 287 setCentralWidget( vbox5 );
263 288
264 Config cfg( "MediaPlayer" ); 289 Config cfg( "MediaPlayer" );
265 readConfig( cfg ); 290 readConfig( cfg );
266 291
267 initializeStates(); 292 initializeStates();
268} 293}
269 294
270 295
271PlayListWidget::~PlayListWidget() { 296PlayListWidget::~PlayListWidget() {
@@ -278,40 +303,42 @@ PlayListWidget::~PlayListWidget() {
278} 303}
279 304
280 305
281void PlayListWidget::initializeStates() { 306void PlayListWidget::initializeStates() {
282 307
283 d->tbPlay->setOn( mediaPlayerState->playing() ); 308 d->tbPlay->setOn( mediaPlayerState->playing() );
284 d->tbLoop->setOn( mediaPlayerState->looping() ); 309 d->tbLoop->setOn( mediaPlayerState->looping() );
285 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 310 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
286// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 311// d->tbFull->setOn( mediaPlayerState->fullscreen() );
287// d->tbScale->setOn( mediaPlayerState->scaled() ); 312// d->tbScale->setOn( mediaPlayerState->scaled() );
288// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 313// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
289// setPlaylist( mediaPlayerState->playlist() ); 314// setPlaylist( mediaPlayerState->playlist() );
315 setPlaylist( true);
316 d->selectedFiles->first();
317
290} 318}
291 319
292 320
293void PlayListWidget::readConfig( Config& cfg ) { 321void PlayListWidget::readConfig( Config& cfg ) {
294 cfg.setGroup("PlayList"); 322 cfg.setGroup("PlayList");
295 323
296 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 324 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
297 325
298 for ( int i = 0; i < noOfFiles; i++ ) { 326 for ( int i = 0; i < noOfFiles; i++ ) {
299 QString entryName; 327 QString entryName;
300 entryName.sprintf( "File%i", i + 1 ); 328 entryName.sprintf( "File%i", i + 1 );
301 QString linkFile = cfg.readEntry( entryName ); 329 QString linkFile = cfg.readEntry( entryName );
302 DocLnk lnk( linkFile ); 330 DocLnk lnk( linkFile );
303 if ( lnk.isValid() ) 331 if ( lnk.isValid() )
304 d->selectedFiles->addToSelection( lnk ); 332 d->selectedFiles->addToSelection( lnk );
305
306 } 333 }
307} 334}
308 335
309 336
310void PlayListWidget::writeConfig( Config& cfg ) const { 337void PlayListWidget::writeConfig( Config& cfg ) const {
311 cfg.setGroup("PlayList"); 338 cfg.setGroup("PlayList");
312 339
313 int noOfFiles = 0; 340 int noOfFiles = 0;
314 341
315 d->selectedFiles->first(); 342 d->selectedFiles->first();
316 do { 343 do {
317 const DocLnk *lnk = d->selectedFiles->current(); 344 const DocLnk *lnk = d->selectedFiles->current();
@@ -325,51 +352,44 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
325 // the way writing lnks doesn't really check for out 352 // the way writing lnks doesn't really check for out
326 // of disk space, but check it anyway. 353 // of disk space, but check it anyway.
327 if ( !lnk->writeLink() ) { 354 if ( !lnk->writeLink() ) {
328 QMessageBox::critical( 0, tr("Out of space"), 355 QMessageBox::critical( 0, tr("Out of space"),
329 tr( "There was a problem saving " 356 tr( "There was a problem saving "
330 "the playlist.\n" 357 "the playlist.\n"
331 "Your playlist " 358 "Your playlist "
332 "may be missing some entries\n" 359 "may be missing some entries\n"
333 "the next time you start it." ) 360 "the next time you start it." )
334 ); 361 );
335 } 362 }
336 } 363 }
337 noOfFiles++; 364 noOfFiles++;
338 } 365 }
339 } while ( d->selectedFiles->next() ); 366 } while ( d->selectedFiles->next() );
340 367
341 cfg.writeEntry("NumberOfFiles", noOfFiles ); 368 cfg.writeEntry("NumberOfFiles", noOfFiles );
369
370
342} 371}
343 372
344 373
345void PlayListWidget::addToSelection( const DocLnk& lnk ) { 374void PlayListWidget::addToSelection( const DocLnk& lnk ) {
346 d->setDocumentUsed = FALSE; 375 qDebug("add");
376 d->setDocumentUsed = FALSE;
347 if ( mediaPlayerState->playlist() ) 377 if ( mediaPlayerState->playlist() )
348 d->selectedFiles->addToSelection( lnk ); 378 d->selectedFiles->addToSelection( lnk );
349 else 379 else
350 mediaPlayerState->setPlaying( TRUE ); 380 mediaPlayerState->setPlaying( TRUE );
351} 381}
352 382
353 383
354void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) {
355 qDebug("add");
356// d->selectedFiles->addToSelection( lnk );
357 // }
358// else
359// mediaPlayerState->setPlaying( TRUE );
360//
361}
362
363
364void PlayListWidget::clearList() { 384void PlayListWidget::clearList() {
365 while ( first() ) 385 while ( first() )
366 d->selectedFiles->removeSelected(); 386 d->selectedFiles->removeSelected();
367} 387}
368 388
369 389
370void PlayListWidget::addAllToList() { 390void PlayListWidget::addAllToList() {
371 DocLnkSet files; 391 DocLnkSet files;
372 Global::findDocuments(&files, "video/*;audio/*"); 392 Global::findDocuments(&files, "video/*;audio/*");
373 QListIterator<DocLnk> dit( files.children() ); 393 QListIterator<DocLnk> dit( files.children() );
374 for ( ; dit.current(); ++dit ) 394 for ( ; dit.current(); ++dit )
375 d->selectedFiles->addToSelection( **dit ); 395 d->selectedFiles->addToSelection( **dit );
@@ -387,60 +407,64 @@ void PlayListWidget::addAllMusicToList() {
387 407
388void PlayListWidget::addAllVideoToList() { 408void PlayListWidget::addAllVideoToList() {
389 DocLnkSet files; 409 DocLnkSet files;
390 Global::findDocuments(&files, "video/*"); 410 Global::findDocuments(&files, "video/*");
391 QListIterator<DocLnk> dit( files.children() ); 411 QListIterator<DocLnk> dit( files.children() );
392 for ( ; dit.current(); ++dit ) 412 for ( ; dit.current(); ++dit )
393 d->selectedFiles->addToSelection( **dit ); 413 d->selectedFiles->addToSelection( **dit );
394} 414}
395 415
396 416
397void PlayListWidget::setDocument(const QString& fileref) { 417void PlayListWidget::setDocument(const QString& fileref) {
398 if ( fileref.isNull() ) { 418 if ( fileref.isNull() ) {
399 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 419 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
400 return; 420 return;
401 } 421 }
402 if ( mediaPlayerState->playlist() ) 422 if ( mediaPlayerState->playlist() )
403 addToSelection( DocLnk( fileref ) ); 423 addToSelection( DocLnk( fileref ) );
404 else { 424 else {
405 d->setDocumentUsed = TRUE; 425 d->setDocumentUsed = TRUE;
406 if ( d->current ) 426 if ( d->current )
407 delete d->current; 427 delete d->current;
408 d->current = new DocLnk( fileref ); 428 d->current = new DocLnk( fileref );
409 } 429 }
410 mediaPlayerState->setPlaying( FALSE ); 430 mediaPlayerState->setPlaying( FALSE );
411 mediaPlayerState->setPlaying( TRUE ); 431 mediaPlayerState->setPlaying( TRUE );
412} 432}
413 433
414 434
415void PlayListWidget::setActiveWindow() { 435void PlayListWidget::setActiveWindow() {
416 // When we get raised we need to ensure that it switches views 436 // When we get raised we need to ensure that it switches views
417 char origView = mediaPlayerState->view(); 437 char origView = mediaPlayerState->view();
418 mediaPlayerState->setView( 'l' ); // invalidate 438 mediaPlayerState->setView( 'l' ); // invalidate
419 mediaPlayerState->setView( origView ); // now switch back 439 mediaPlayerState->setView( origView ); // now switch back
420} 440}
421 441
422 442
423void PlayListWidget::useSelectedDocument() { 443void PlayListWidget::useSelectedDocument() {
424 d->setDocumentUsed = FALSE; 444 d->setDocumentUsed = FALSE;
425} 445}
426 446
427 447
428const DocLnk *PlayListWidget::current() { 448const DocLnk *PlayListWidget::current() {
429 if ( mediaPlayerState->playlist() ) 449
430 return d->selectedFiles->current(); 450// qDebug("in Playlist widget ::current");
451 if ( mediaPlayerState->playlist() ) {
452 return d->selectedFiles->current();
453 }
431 else if ( d->setDocumentUsed && d->current ) { 454 else if ( d->setDocumentUsed && d->current ) {
432 return d->current; 455 return d->current;
433 } else 456 } else {
434 return d->files->selected(); 457 return d->files->selected();
458 }
435} 459}
436 460
437 461
438bool PlayListWidget::prev() { 462bool PlayListWidget::prev() {
439 if ( mediaPlayerState->playlist() ) { 463 if ( mediaPlayerState->playlist() ) {
440 if ( mediaPlayerState->shuffled() ) { 464 if ( mediaPlayerState->shuffled() ) {
441 const DocLnk *cur = current(); 465 const DocLnk *cur = current();
442 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 466 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
443 for ( int i = 0; i < j; i++ ) { 467 for ( int i = 0; i < j; i++ ) {
444 if ( !d->selectedFiles->next() ) 468 if ( !d->selectedFiles->next() )
445 d->selectedFiles->first(); 469 d->selectedFiles->first();
446 } 470 }
@@ -492,158 +516,247 @@ bool PlayListWidget::first() {
492} 516}
493 517
494 518
495bool PlayListWidget::last() { 519bool PlayListWidget::last() {
496 if ( mediaPlayerState->playlist() ) 520 if ( mediaPlayerState->playlist() )
497 return d->selectedFiles->last(); 521 return d->selectedFiles->last();
498 else 522 else
499 return mediaPlayerState->looping(); 523 return mediaPlayerState->looping();
500} 524}
501 525
502 526
503void PlayListWidget::saveList() { 527void PlayListWidget::saveList() {
528
504 QString filename; 529 QString filename;
505// pseudo code 530 InputDialog *fileDlg;
506// filename = QLineEdit->getText(); 531 fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0);
507 Config cfg( filename + ".playlist" ); 532 fileDlg->exec();
508 writeConfig( cfg ); 533 if( fileDlg->result() == 1 ) {
534 filename = fileDlg->LineEdit1->text();//+".playlist";
535 qDebug("saving playlist "+filename+".playlist");
536
537// DocLnk *lnk;
538// lnk.setName( filename); //sets file name
539// // lnk.setComment(title);
540// lnk.setFile( filename+".playlist"); //sets File property
541// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D
542// lnk.setIcon("MPEGPlayer");
543// if(!lnk.writeLink())
544// qDebug("Writing doclink did not work");
545
546 Config cfg( filename +".playlist");
547 writeConfig( cfg );
548 }
549 DocLnk lnk;
550 lnk.setName( filename); //sets file name
551// lnk.setComment(title);
552 lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property
553 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
554 lnk.setIcon("MPEGPlayer");
555 if(!lnk.writeLink())
556 qDebug("Writing doclink did not work");
557
558 if(fileDlg)
559 delete fileDlg;
509} 560}
510 561
511 562
512void PlayListWidget::loadList() { 563void PlayListWidget::loadList( const DocLnk & lnk) {
513 QString filename; 564
514// pseudo code 565 clearList();
515// filename = FileSelector->openFile( "*.playlist" ); 566 Config cfg( lnk.file());
516 Config cfg( filename + ".playlist" ); 567 readConfig(cfg);
517 readConfig( cfg ); 568 tabWidget->setCurrentPage(0);
569 setCaption("OpiePlayer: "+lnk.name());
518} 570}
519 571
520 572
521void PlayListWidget::setPlaylist( bool shown ) { 573void PlayListWidget::setPlaylist( bool shown ) {
522 if ( shown ) 574 if ( shown )
523 d->playListFrame->show(); 575 d->playListFrame->show();
524 else 576 else
525 d->playListFrame->hide(); 577 d->playListFrame->hide();
526} 578}
527 579
528 580
529void PlayListWidget::setView( char view ) { 581void PlayListWidget::setView( char view ) {
530 if ( view == 'l' ) 582 if ( view == 'l' )
531 showMaximized(); 583 showMaximized();
532 else 584 else
533 hide(); 585 hide();
534} 586}
535 587
536void PlayListWidget::addSelected() { 588void PlayListWidget::addSelected() {
537// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); 589
538 int tabPage=tabWidget->currentPageIndex(); 590 switch (tabWidget->currentPageIndex()) {
539 switch (tabPage) { 591 case 0: //playlist
540 case 0: //playlist
541 break; 592 break;
542 case 1: { //audio 593 case 1: { //audio
543 addToSelection( audioView->selectedItem() ); 594 addToSelection( audioView->selectedItem() );
544 } 595 }
545 break; 596 break;
546 case 2: { // video 597 case 2: { // video
547 addToSelection( videoView->selectedItem() ); 598 addToSelection( videoView->selectedItem() );
548 } 599 }
549 break; 600 break;
550 }; 601 };
551} 602}
552 603
553void PlayListWidget::removeSelected() { 604void PlayListWidget::removeSelected() {
554 d->selectedFiles->removeSelected( ); 605 d->selectedFiles->removeSelected( );
555} 606}
556 607
557 608
558void PlayListWidget::playIt( QListViewItem *it) { 609void PlayListWidget::playIt( QListViewItem *it) {
559// d->setDocumentUsed = FALSE; 610// d->setDocumentUsed = FALSE;
560 mediaPlayerState->setPlaying(true); 611 mediaPlayerState->setPlaying(TRUE);
561} 612}
562 613
563void PlayListWidget::addToSelection( QListViewItem *it) { 614void PlayListWidget::addToSelection( QListViewItem *it) {
564 d->setDocumentUsed = FALSE; 615 d->setDocumentUsed = FALSE;
565 616
566 if(it) { 617 if(it) {
567 qDebug("add to selection"); 618// qDebug("add to selection");
568 int tabPage=tabWidget->currentPageIndex(); 619 switch (tabWidget->currentPageIndex()) {
569 switch (tabPage) { 620 case 1: {
570 case 1: { 621// qDebug("case 1");
622 QListIterator<DocLnk> dit( files.children() );
623 for ( ; dit.current(); ++dit ) {
624// qDebug(dit.current()->name());
625 if( dit.current()->name() == it->text(0)) {
626 d->selectedFiles->addToSelection( **dit );
627 }
628 }
629 }
630 break;
631 case 2: {
632// qDebug("case 2");
633 QListIterator<DocLnk> dit( vFiles.children() );
634 for ( ; dit.current(); ++dit ) {
635// qDebug(dit.current()->name());
636 if( dit.current()->name() == it->text(0)) {
637 d->selectedFiles->addToSelection( **dit );
638 }
639 }
640 }
641 break;
642 case 0:
643 break;
644 };
645 tabWidget->setCurrentPage(0);
646// mediaPlayerState->setPlaying( TRUE );
647 }
648}
649
650void PlayListWidget::tabChanged(QWidget *widg) {
651
652 switch ( tabWidget->currentPageIndex()) {
653 case 0:
654 {
655 if( !tbDeletePlaylist->isHidden())
656 tbDeletePlaylist->hide();
657 d->tbRemoveFromList->setEnabled(TRUE);
658 d->tbAddToList->setEnabled(FALSE);
659 }
660 break;
661 case 1:
662 {
663 if( !tbDeletePlaylist->isHidden())
664 tbDeletePlaylist->hide();
665 d->tbRemoveFromList->setEnabled(FALSE);
666 d->tbAddToList->setEnabled(TRUE);
667 }
668 break;
669 case 2:
670 {
671 if( !tbDeletePlaylist->isHidden())
672 tbDeletePlaylist->hide();
673 d->tbRemoveFromList->setEnabled(FALSE);
674 d->tbAddToList->setEnabled(TRUE);
675 }
676 break;
677 case 3:
678 {
679 if( tbDeletePlaylist->isHidden())
680 tbDeletePlaylist->show();
681 playLists->reread();
682 }
683 break;
684 };
685}
686
687/*
688 list is right clicked*/
689void PlayListWidget::fauxPlay(QListViewItem *it) {
690
691 switch (tabWidget->currentPageIndex()) {
692 case 0: //playlist
693 break;
694 case 1: { //audio
571 QListIterator<DocLnk> dit( files.children() ); 695 QListIterator<DocLnk> dit( files.children() );
572 for ( ; dit.current(); ++dit ) { 696 for ( ; dit.current(); ++dit ) {
697// qDebug(dit.current()->name());
573 if( dit.current()->name() == it->text(0)) { 698 if( dit.current()->name() == it->text(0)) {
574 d->selectedFiles->addToSelection( **dit ); 699 d->selectedFiles->addToSelection( **dit );
575 } 700 }
576 } 701 }
577 } 702 }
578 break; 703 break;
579 case 2: { 704 case 2: { // video
580 QListIterator<DocLnk> dit( vFiles.children() ); 705 QListIterator<DocLnk> dit( vFiles.children() );
581 for ( ; dit.current(); ++dit ) { 706 for ( ; dit.current(); ++dit ) {
582 qDebug(dit.current()->name()); 707// qDebug(dit.current()->name());
583 if( dit.current()->name() == it->text(0)) { 708 if( dit.current()->name() == it->text(0)) {
584 d->selectedFiles->addToSelection( **dit ); 709 d->selectedFiles->addToSelection( **dit );
585 } 710 }
586 } 711 }
587 } 712 }
588 break; 713 break;
589 case 0:
590 break;
591 }; 714 };
592 tabWidget->setCurrentPage(0); 715 mediaPlayerState->setPlaying( TRUE );
593// mediaPlayerState->setPlaying( TRUE ); 716// tabWidget->setCurrentPage(0);
594 } 717 d->selectedFiles->removeSelected();
595} 718}
596 719
597void PlayListWidget::tabChanged(QWidget *widg) { 720/*
598 721 play button is pressed*/
599 int tabPage=tabWidget->currentPageIndex(); 722void PlayListWidget::btnPlay(bool b) { // this is fugly
600 switch (tabPage) { 723 switch ( tabWidget->currentPageIndex()) {
601 case 0: 724 case 0:
602 { 725 {
603 d->tbRemoveFromList->setEnabled(TRUE); 726 mediaPlayerState->setPlaying(b);
604 d->tbAddToList->setEnabled(FALSE);
605 } 727 }
606 break; 728 break;
607 case 1: 729 case 1:
608 { 730 {
609 d->tbRemoveFromList->setEnabled(FALSE); 731 addToSelection( audioView->selectedItem() );
610 d->tbAddToList->setEnabled(TRUE); 732 mediaPlayerState->setPlaying(b);
611 } 733 d->selectedFiles->removeSelected( );
612 break; 734 tabWidget->setCurrentPage(1);
613 case 2: 735 }
614 { 736 break;
615 d->tbRemoveFromList->setEnabled(FALSE); 737 case 2:
616 d->tbAddToList->setEnabled(TRUE); 738 {
617 } 739 addToSelection( videoView->selectedItem() );
618 break; 740 mediaPlayerState->setPlaying(b);
619 }; 741 d->selectedFiles->removeSelected( );
620} 742 tabWidget->setCurrentPage(2);
621 743 }
622// void PlayListWidget::cancelMenuTimer() { 744 break;
623// if( menuTimer->isActive() ) 745 };
624// menuTimer->stop();
625// }
626
627// void PlayListWidget::showFileMenu() {
628
629// }
630
631// void PlayListWidget::contentsMousePressEvent( QMouseEvent * e )
632// {
633// // QListView::contentsMousePressEvent( e );
634// menuTimer->start( 750, TRUE );
635// }
636 746
747}
637 748
638// void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) 749void PlayListWidget::deletePlaylist() {
639// { 750 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
640// // QListView::contentsMouseReleaseEvent( e ); 751 (tr("You really want to delete\nthis playlist?")),
641// menuTimer->stop(); 752 (tr("Yes")), (tr("No")), 0 )){
642// } 753 case 0: // Yes clicked,
643// // void PlayListWidget::setFullScreen() { 754 QFile().remove(playLists->selected()->file());
644// mediaPlayerState->toggleFullscreen( ); 755 QFile().remove(playLists->selected()->linkFile());
645// } 756 playLists->reread();
757 break;
758 case 1: // Cancel
759 break;
760 };
646 761
647// void PlayListWidget::setScaled() { 762}
648// mediaPlayerState->toggleScaled();
649// }