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.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 5d0f6de..7ea95ab 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -308,384 +308,385 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
308 QWidget *LTab; 308 QWidget *LTab;
309 LTab = new QWidget( tabWidget, "LTab" ); 309 LTab = new QWidget( tabWidget, "LTab" );
310 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 310 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
311 311
312 QGridLayout *layoutL = new QGridLayout( LTab ); 312 QGridLayout *layoutL = new QGridLayout( LTab );
313 layoutL->setSpacing( 2); 313 layoutL->setSpacing( 2);
314 layoutL->setMargin( 2); 314 layoutL->setMargin( 2);
315 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 315 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
316// playLists->setMinimumSize(233,260); 316// playLists->setMinimumSize(233,260);
317 317
318 tabWidget->insertTab(LTab,tr("Lists")); 318 tabWidget->insertTab(LTab,tr("Lists"));
319 319
320 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 320 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
321 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 321 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
322 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 322 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
323 323
324 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 324 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
325 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 325 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
326 326
327 327
328///audioView 328///audioView
329 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 329 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
330 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 330 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
331 331
332 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 332 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
333 this,SLOT( playIt( QListViewItem *)) ); 333 this,SLOT( playIt( QListViewItem *)) );
334 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 334 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
335 335
336 336
337//videoView 337//videoView
338 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 338 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
339 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 339 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
340 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 340 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
341 this,SLOT( playIt( QListViewItem *)) ); 341 this,SLOT( playIt( QListViewItem *)) );
342 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 342 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
343 343
344//playlists 344//playlists
345 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 345 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
346 346
347 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 347 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
348 348
349 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 349 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
350 350
351 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 351 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
352 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 352 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
353 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 353 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
354 354
355 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 355 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
356 356
357 setCentralWidget( vbox5 ); 357 setCentralWidget( vbox5 );
358 358
359 Config cfg( "OpiePlayer" ); 359 Config cfg( "OpiePlayer" );
360 readConfig( cfg ); 360 readConfig( cfg );
361 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 361 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
362 loadList(DocLnk( currentPlaylist)); 362 loadList(DocLnk( currentPlaylist));
363 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); 363 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
364 364
365 initializeStates(); 365 initializeStates();
366 // audioUI->setFocus(); 366 // audioUI->setFocus();
367} 367}
368 368
369 369
370PlayListWidget::~PlayListWidget() { 370PlayListWidget::~PlayListWidget() {
371 Config cfg( "OpiePlayer" ); 371 Config cfg( "OpiePlayer" );
372 writeConfig( cfg ); 372 writeConfig( cfg );
373 373
374 if ( d->current ) 374 if ( d->current )
375 delete d->current; 375 delete d->current;
376 if(d) delete d; 376 if(d) delete d;
377} 377}
378 378
379 379
380void PlayListWidget::initializeStates() { 380void PlayListWidget::initializeStates() {
381 381
382 d->tbPlay->setOn( mediaPlayerState->playing() ); 382 d->tbPlay->setOn( mediaPlayerState->playing() );
383 d->tbLoop->setOn( mediaPlayerState->looping() ); 383 d->tbLoop->setOn( mediaPlayerState->looping() );
384 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 384 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
385 setPlaylist( true); 385 setPlaylist( true);
386} 386}
387 387
388 388
389void PlayListWidget::readConfig( Config& cfg ) { 389void PlayListWidget::readConfig( Config& cfg ) {
390 cfg.setGroup("PlayList"); 390 cfg.setGroup("PlayList");
391 QString currentString = cfg.readEntry("current", "" ); 391 QString currentString = cfg.readEntry("current", "" );
392 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 392 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
393 for ( int i = 0; i < noOfFiles; i++ ) { 393 for ( int i = 0; i < noOfFiles; i++ ) {
394 QString entryName; 394 QString entryName;
395 entryName.sprintf( "File%i", i + 1 ); 395 entryName.sprintf( "File%i", i + 1 );
396 QString linkFile = cfg.readEntry( entryName ); 396 QString linkFile = cfg.readEntry( entryName );
397 DocLnk lnk( linkFile ); 397 DocLnk lnk( linkFile );
398 if ( lnk.isValid() ) { 398 if ( lnk.isValid() ) {
399 d->selectedFiles->addToSelection( lnk ); 399 d->selectedFiles->addToSelection( lnk );
400 } 400 }
401 } 401 }
402 d->selectedFiles->setSelectedItem( currentString); 402 d->selectedFiles->setSelectedItem( currentString);
403} 403}
404 404
405 405
406void PlayListWidget::writeConfig( Config& cfg ) const { 406void PlayListWidget::writeConfig( Config& cfg ) const {
407 407
408 d->selectedFiles->writeCurrent( cfg); 408 d->selectedFiles->writeCurrent( cfg);
409 cfg.setGroup("PlayList"); 409 cfg.setGroup("PlayList");
410 int noOfFiles = 0; 410 int noOfFiles = 0;
411 d->selectedFiles->first(); 411 d->selectedFiles->first();
412 do { 412 do {
413 const DocLnk *lnk = d->selectedFiles->current(); 413 const DocLnk *lnk = d->selectedFiles->current();
414 if ( lnk ) { 414 if ( lnk ) {
415 QString entryName; 415 QString entryName;
416 entryName.sprintf( "File%i", noOfFiles + 1 ); 416 entryName.sprintf( "File%i", noOfFiles + 1 );
417// qDebug(entryName); 417// qDebug(entryName);
418 cfg.writeEntry( entryName, lnk->linkFile() ); 418 cfg.writeEntry( entryName, lnk->linkFile() );
419 // if this link does exist, add it so we have the file 419 // if this link does exist, add it so we have the file
420 // next time... 420 // next time...
421 if ( !QFile::exists( lnk->linkFile() ) ) { 421 if ( !QFile::exists( lnk->linkFile() ) ) {
422 // the way writing lnks doesn't really check for out 422 // the way writing lnks doesn't really check for out
423 // of disk space, but check it anyway. 423 // of disk space, but check it anyway.
424 if ( !lnk->writeLink() ) { 424 if ( !lnk->writeLink() ) {
425 QMessageBox::critical( 0, tr("Out of space"), 425 QMessageBox::critical( 0, tr("Out of space"),
426 tr( "There was a problem saving " 426 tr( "There was a problem saving "
427 "the playlist.\n" 427 "the playlist.\n"
428 "Your playlist " 428 "Your playlist "
429 "may be missing some entries\n" 429 "may be missing some entries\n"
430 "the next time you start it." ) 430 "the next time you start it." )
431 ); 431 );
432 } 432 }
433 } 433 }
434 noOfFiles++; 434 noOfFiles++;
435 } 435 }
436 } 436 }
437 while ( d->selectedFiles->next() ); 437 while ( d->selectedFiles->next() );
438 cfg.writeEntry("NumberOfFiles", noOfFiles ); 438 cfg.writeEntry("NumberOfFiles", noOfFiles );
439} 439}
440 440
441 441
442void PlayListWidget::addToSelection( const DocLnk& lnk ) { 442void PlayListWidget::addToSelection( const DocLnk& lnk ) {
443 d->setDocumentUsed = false; 443 d->setDocumentUsed = false;
444 if ( mediaPlayerState->playlist() ) { 444 if ( mediaPlayerState->playlist() ) {
445 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 445 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
446 d->selectedFiles->addToSelection( lnk ); 446 d->selectedFiles->addToSelection( lnk );
447 } 447 }
448 else 448 else
449 mediaPlayerState->setPlaying( true); 449 mediaPlayerState->setPlaying( true);
450} 450}
451 451
452 452
453void PlayListWidget::clearList() { 453void PlayListWidget::clearList() {
454 while ( first() ) 454 while ( first() )
455 d->selectedFiles->removeSelected(); 455 d->selectedFiles->removeSelected();
456} 456}
457 457
458 458
459void PlayListWidget::addAllToList() { 459void PlayListWidget::addAllToList() {
460 DocLnkSet filesAll; 460 DocLnkSet filesAll;
461 Global::findDocuments(&filesAll, "video/*;audio/*"); 461 Global::findDocuments(&filesAll, "video/*;audio/*");
462 QListIterator<DocLnk> Adit( filesAll.children() ); 462 QListIterator<DocLnk> Adit( filesAll.children() );
463 for ( ; Adit.current(); ++Adit ) 463 for ( ; Adit.current(); ++Adit )
464 if(QFileInfo(Adit.current()->file()).exists()) 464 if(QFileInfo(Adit.current()->file()).exists())
465 d->selectedFiles->addToSelection( **Adit ); 465 d->selectedFiles->addToSelection( **Adit );
466 tabWidget->setCurrentPage(0); 466 tabWidget->setCurrentPage(0);
467 467
468 writeCurrentM3u(); 468 writeCurrentM3u();
469 d->selectedFiles->first(); 469 d->selectedFiles->first();
470} 470}
471 471
472 472
473void PlayListWidget::addAllMusicToList() { 473void PlayListWidget::addAllMusicToList() {
474 QListIterator<DocLnk> dit( files.children() ); 474 QListIterator<DocLnk> dit( files.children() );
475 for ( ; dit.current(); ++dit ) 475 for ( ; dit.current(); ++dit )
476 if(QFileInfo(dit.current()->file()).exists()) 476 if(QFileInfo(dit.current()->file()).exists())
477 d->selectedFiles->addToSelection( **dit ); 477 d->selectedFiles->addToSelection( **dit );
478 tabWidget->setCurrentPage(0); 478 tabWidget->setCurrentPage(0);
479 479
480 writeCurrentM3u(); 480 writeCurrentM3u();
481 d->selectedFiles->first(); 481 d->selectedFiles->first();
482} 482}
483 483
484 484
485void PlayListWidget::addAllVideoToList() { 485void PlayListWidget::addAllVideoToList() {
486 QListIterator<DocLnk> dit( vFiles.children() ); 486 QListIterator<DocLnk> dit( vFiles.children() );
487 for ( ; dit.current(); ++dit ) 487 for ( ; dit.current(); ++dit )
488 if(QFileInfo( dit.current()->file()).exists()) 488 if(QFileInfo( dit.current()->file()).exists())
489 d->selectedFiles->addToSelection( **dit ); 489 d->selectedFiles->addToSelection( **dit );
490 tabWidget->setCurrentPage(0); 490 tabWidget->setCurrentPage(0);
491 491
492 writeCurrentM3u(); 492 writeCurrentM3u();
493 d->selectedFiles->first(); 493 d->selectedFiles->first();
494} 494}
495 495
496 496
497void PlayListWidget::setDocument(const QString& fileref) { 497void PlayListWidget::setDocument(const QString& fileref) {
498 fromSetDocument = true; 498 fromSetDocument = true;
499 d->setDocumentUsed = TRUE; 499 d->setDocumentUsed = TRUE;
500 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
500 mediaPlayerState->setPlaying( FALSE ); 501 mediaPlayerState->setPlaying( FALSE );
501 qApp->processEvents(); 502 qApp->processEvents();
502 mediaPlayerState->setPlaying( TRUE ); 503 mediaPlayerState->setPlaying( TRUE );
503} 504}
504 505
505void PlayListWidget::setDocumentEx(const QString& fileref) { 506void PlayListWidget::setDocumentEx(const QString& fileref) {
506 507
507 QFileInfo fileInfo(fileref); 508 QFileInfo fileInfo(fileref);
508 if ( !fileInfo.exists() ) { 509 if ( !fileInfo.exists() ) {
509 QMessageBox::critical( 0, tr( "Invalid File" ), 510 QMessageBox::critical( 0, tr( "Invalid File" ),
510 tr( "There was a problem in getting the file." ) ); 511 tr( "There was a problem in getting the file." ) );
511 return; 512 return;
512 } 513 }
513 qDebug("setDocument "+fileref); 514 qDebug("setDocument "+fileref);
514 QString extension = fileInfo.extension(false); 515 QString extension = fileInfo.extension(false);
515 if( extension.find( "m3u", 0, false) != -1) { //is m3u 516 if( extension.find( "m3u", 0, false) != -1) { //is m3u
516 readm3u( fileref); 517 readm3u( fileref);
517 } 518 }
518 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 519 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
519 readPls( fileref); 520 readPls( fileref);
520 } 521 }
521 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 522 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
522 clearList(); 523 clearList();
523 DocLnk lnk; 524 DocLnk lnk;
524 lnk.setName( fileInfo.baseName() ); //sets name 525 lnk.setName( fileInfo.baseName() ); //sets name
525 lnk.setFile( fileref ); //sets file name 526 lnk.setFile( fileref ); //sets file name
526 //addToSelection( lnk ); 527 //addToSelection( lnk );
527 528
528 loadList( lnk); 529 loadList( lnk);
529 d->selectedFiles->first(); 530 d->selectedFiles->first();
530 } else { 531 } else {
531 clearList(); 532 clearList();
532 DocLnk lnk; 533 DocLnk lnk;
533 lnk.setName( fileInfo.baseName() ); //sets name 534 lnk.setName( fileInfo.baseName() ); //sets name
534 lnk.setFile( fileref ); //sets file name 535 lnk.setFile( fileref ); //sets file name
535 addToSelection( lnk ); 536 addToSelection( lnk );
536// addToSelection( DocLnk( fileref ) ); 537// addToSelection( DocLnk( fileref ) );
537 d->setDocumentUsed = TRUE; 538 d->setDocumentUsed = TRUE;
538 mediaPlayerState->setPlaying( FALSE ); 539 mediaPlayerState->setPlaying( FALSE );
539 qApp->processEvents(); 540 qApp->processEvents();
540 mediaPlayerState->setPlaying( TRUE ); 541 mediaPlayerState->setPlaying( TRUE );
541 // qApp->processEvents(); 542 // qApp->processEvents();
542 setCaption(tr("OpiePlayer")); 543 setCaption(tr("OpiePlayer"));
543 } 544 }
544} 545}
545 546
546 547
547void PlayListWidget::setActiveWindow() { 548void PlayListWidget::setActiveWindow() {
548 qDebug("SETTING active window"); 549 qDebug("SETTING active window");
549 550
550 // When we get raised we need to ensure that it switches views 551 // When we get raised we need to ensure that it switches views
551 char origView = mediaPlayerState->view(); 552 char origView = mediaPlayerState->view();
552 mediaPlayerState->setView( 'l' ); // invalidate 553 mediaPlayerState->setView( 'l' ); // invalidate
553 mediaPlayerState->setView( origView ); // now switch back 554 mediaPlayerState->setView( origView ); // now switch back
554} 555}
555 556
556 557
557void PlayListWidget::useSelectedDocument() { 558void PlayListWidget::useSelectedDocument() {
558 d->setDocumentUsed = FALSE; 559 d->setDocumentUsed = FALSE;
559} 560}
560 561
561 562
562const DocLnk *PlayListWidget::current() { // this is fugly 563const DocLnk *PlayListWidget::current() { // this is fugly
563 564
564// if( fromSetDocument) { 565// if( fromSetDocument) {
565// qDebug("from setDoc"); 566// qDebug("from setDoc");
566// DocLnkSet files; 567// DocLnkSet files;
567// Global::findDocuments(&files, "video/*;audio/*"); 568// Global::findDocuments(&files, "video/*;audio/*");
568// QListIterator<DocLnk> dit( files.children() ); 569// QListIterator<DocLnk> dit( files.children() );
569// for ( ; dit.current(); ++dit ) { 570// for ( ; dit.current(); ++dit ) {
570// if(dit.current()->linkFile() == setDocFileRef) { 571// if(dit.current()->linkFile() == setDocFileRef) {
571// qDebug(setDocFileRef); 572// qDebug(setDocFileRef);
572// return dit; 573// return dit;
573// } 574// }
574// } 575// }
575// } else 576// } else
576 577
577 qDebug("current"); 578 qDebug("current");
578 579
579 switch (tabWidget->currentPageIndex()) { 580 switch (tabWidget->currentPageIndex()) {
580 case 0: //playlist 581 case 0: //playlist
581 { 582 {
582 qDebug("playlist"); 583 qDebug("playlist");
583 if ( mediaPlayerState->playlist() ) { 584 if ( mediaPlayerState->playlist() ) {
584 return d->selectedFiles->current(); 585 return d->selectedFiles->current();
585 } 586 }
586 else if ( d->setDocumentUsed && d->current ) { 587 else if ( d->setDocumentUsed && d->current ) {
587 return d->current; 588 return d->current;
588 } else { 589 } else {
589 return &(d->files->selectedDocument()); 590 return &(d->files->selectedDocument());
590 } 591 }
591 } 592 }
592 break; 593 break;
593 case 1://audio 594 case 1://audio
594 { 595 {
595 qDebug("audioView"); 596 qDebug("audioView");
596 QListIterator<DocLnk> dit( files.children() ); 597 QListIterator<DocLnk> dit( files.children() );
597 for ( ; dit.current(); ++dit ) { 598 for ( ; dit.current(); ++dit ) {
598 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 599 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
599 qDebug("here"); 600 qDebug("here");
600 insanityBool=TRUE; 601 insanityBool=TRUE;
601 return dit; 602 return dit;
602 } 603 }
603 } 604 }
604 } 605 }
605 break; 606 break;
606 case 2: // video 607 case 2: // video
607 { 608 {
608 qDebug("videoView"); 609 qDebug("videoView");
609 QListIterator<DocLnk> Vdit( vFiles.children() ); 610 QListIterator<DocLnk> Vdit( vFiles.children() );
610 for ( ; Vdit.current(); ++Vdit ) { 611 for ( ; Vdit.current(); ++Vdit ) {
611 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 612 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
612 insanityBool=TRUE; 613 insanityBool=TRUE;
613 return Vdit; 614 return Vdit;
614 } 615 }
615 } 616 }
616 } 617 }
617 break; 618 break;
618 }; 619 };
619 return 0; 620 return 0;
620} 621}
621 622
622bool PlayListWidget::prev() { 623bool PlayListWidget::prev() {
623 if ( mediaPlayerState->playlist() ) { 624 if ( mediaPlayerState->playlist() ) {
624 if ( mediaPlayerState->shuffled() ) { 625 if ( mediaPlayerState->shuffled() ) {
625 const DocLnk *cur = current(); 626 const DocLnk *cur = current();
626 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 627 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
627 for ( int i = 0; i < j; i++ ) { 628 for ( int i = 0; i < j; i++ ) {
628 if ( !d->selectedFiles->next() ) 629 if ( !d->selectedFiles->next() )
629 d->selectedFiles->first(); 630 d->selectedFiles->first();
630 } 631 }
631 if ( cur == current() ) 632 if ( cur == current() )
632 if ( !d->selectedFiles->next() ) 633 if ( !d->selectedFiles->next() )
633 d->selectedFiles->first(); 634 d->selectedFiles->first();
634 return TRUE; 635 return TRUE;
635 } else { 636 } else {
636 if ( !d->selectedFiles->prev() ) { 637 if ( !d->selectedFiles->prev() ) {
637 if ( mediaPlayerState->looping() ) { 638 if ( mediaPlayerState->looping() ) {
638 return d->selectedFiles->last(); 639 return d->selectedFiles->last();
639 } else { 640 } else {
640 return FALSE; 641 return FALSE;
641 } 642 }
642 } 643 }
643 return TRUE; 644 return TRUE;
644 } 645 }
645 } else { 646 } else {
646 return mediaPlayerState->looping(); 647 return mediaPlayerState->looping();
647 } 648 }
648} 649}
649 650
650 651
651bool PlayListWidget::next() { 652bool PlayListWidget::next() {
652 if ( mediaPlayerState->playlist() ) { 653 if ( mediaPlayerState->playlist() ) {
653 if ( mediaPlayerState->shuffled() ) { 654 if ( mediaPlayerState->shuffled() ) {
654 return prev(); 655 return prev();
655 } else { 656 } else {
656 if ( !d->selectedFiles->next() ) { 657 if ( !d->selectedFiles->next() ) {
657 if ( mediaPlayerState->looping() ) { 658 if ( mediaPlayerState->looping() ) {
658 return d->selectedFiles->first(); 659 return d->selectedFiles->first();
659 } else { 660 } else {
660 return FALSE; 661 return FALSE;
661 } 662 }
662 } 663 }
663 return TRUE; 664 return TRUE;
664 } 665 }
665 } else { 666 } else {
666 return mediaPlayerState->looping(); 667 return mediaPlayerState->looping();
667 } 668 }
668} 669}
669 670
670 671
671bool PlayListWidget::first() { 672bool PlayListWidget::first() {
672 if ( mediaPlayerState->playlist() ) 673 if ( mediaPlayerState->playlist() )
673 return d->selectedFiles->first(); 674 return d->selectedFiles->first();
674 else 675 else
675 return mediaPlayerState->looping(); 676 return mediaPlayerState->looping();
676} 677}
677 678
678 679
679bool PlayListWidget::last() { 680bool PlayListWidget::last() {
680 if ( mediaPlayerState->playlist() ) 681 if ( mediaPlayerState->playlist() )
681 return d->selectedFiles->last(); 682 return d->selectedFiles->last();
682 else 683 else
683 return mediaPlayerState->looping(); 684 return mediaPlayerState->looping();
684} 685}
685 686
686 687
687void PlayListWidget::saveList() { 688void PlayListWidget::saveList() {
688 writem3u(); 689 writem3u();
689} 690}
690 691
691void PlayListWidget::loadList( const DocLnk & lnk) { 692void PlayListWidget::loadList( const DocLnk & lnk) {