-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 0764c01..809d5ac 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -426,140 +426,141 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | // qDebug("setDocument "+fileref); | 428 | // qDebug("setDocument "+fileref); |
429 | if(fileref.find("playlist",0,TRUE) == -1) { | 429 | if(fileref.find("playlist",0,TRUE) == -1) { |
430 | clearList(); | 430 | clearList(); |
431 | addToSelection( DocLnk( fileref ) ); | 431 | addToSelection( DocLnk( fileref ) ); |
432 | d->setDocumentUsed = TRUE; | 432 | d->setDocumentUsed = TRUE; |
433 | mediaPlayerState->setPlaying( FALSE ); | 433 | mediaPlayerState->setPlaying( FALSE ); |
434 | qApp->processEvents(); | 434 | qApp->processEvents(); |
435 | mediaPlayerState->setPlaying( TRUE ); | 435 | mediaPlayerState->setPlaying( TRUE ); |
436 | qApp->processEvents(); | 436 | qApp->processEvents(); |
437 | setCaption(tr("OpiePlayer")); | 437 | setCaption(tr("OpiePlayer")); |
438 | 438 | ||
439 | } else { //is playlist | 439 | } else { //is playlist |
440 | clearList(); | 440 | clearList(); |
441 | loadList(DocLnk(fileref)); | 441 | loadList(DocLnk(fileref)); |
442 | d->selectedFiles->first(); | 442 | d->selectedFiles->first(); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void PlayListWidget::setActiveWindow() { | 447 | void PlayListWidget::setActiveWindow() { |
448 | // When we get raised we need to ensure that it switches views | 448 | // When we get raised we need to ensure that it switches views |
449 | char origView = mediaPlayerState->view(); | 449 | char origView = mediaPlayerState->view(); |
450 | mediaPlayerState->setView( 'l' ); // invalidate | 450 | mediaPlayerState->setView( 'l' ); // invalidate |
451 | mediaPlayerState->setView( origView ); // now switch back | 451 | mediaPlayerState->setView( origView ); // now switch back |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PlayListWidget::useSelectedDocument() { | 455 | void PlayListWidget::useSelectedDocument() { |
456 | d->setDocumentUsed = FALSE; | 456 | d->setDocumentUsed = FALSE; |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | const DocLnk *PlayListWidget::current() { // this is fugly | 460 | const DocLnk *PlayListWidget::current() { // this is fugly |
461 | 461 | ||
462 | // if( fromSetDocument) { | 462 | // if( fromSetDocument) { |
463 | // qDebug("from setDoc"); | 463 | // qDebug("from setDoc"); |
464 | // DocLnkSet files; | 464 | // DocLnkSet files; |
465 | // Global::findDocuments(&files, "video/*;audio/*"); | 465 | // Global::findDocuments(&files, "video/*;audio/*"); |
466 | // QListIterator<DocLnk> dit( files.children() ); | 466 | // QListIterator<DocLnk> dit( files.children() ); |
467 | // for ( ; dit.current(); ++dit ) { | 467 | // for ( ; dit.current(); ++dit ) { |
468 | // if(dit.current()->linkFile() == setDocFileRef) { | 468 | // if(dit.current()->linkFile() == setDocFileRef) { |
469 | // qDebug(setDocFileRef); | 469 | // qDebug(setDocFileRef); |
470 | // return dit; | 470 | // return dit; |
471 | // } | 471 | // } |
472 | // } | 472 | // } |
473 | // } else | 473 | // } else |
474 | // qDebug("current"); | 474 | |
475 | // switch (tabWidget->currentPageIndex()) { | 475 | |
476 | // case 0: //playlist | 476 | switch (tabWidget->currentPageIndex()) { |
477 | // { | 477 | case 0: //playlist |
478 | // qDebug("playlist"); | 478 | { |
479 | if ( mediaPlayerState->playlist() ) { | 479 | qDebug("playlist"); |
480 | return d->selectedFiles->current(); | 480 | if ( mediaPlayerState->playlist() ) { |
481 | } | 481 | return d->selectedFiles->current(); |
482 | else if ( d->setDocumentUsed && d->current ) { | 482 | } |
483 | return d->current; | 483 | else if ( d->setDocumentUsed && d->current ) { |
484 | } else { | 484 | return d->current; |
485 | return d->files->selected(); | 485 | } else { |
486 | } | 486 | return d->files->selected(); |
487 | // } | 487 | } |
488 | // break; | 488 | } |
489 | // case 1://audio | 489 | break; |
490 | // { | 490 | case 1://audio |
491 | // qDebug("audioView"); | 491 | { |
492 | // Global::findDocuments(&files, "audio/*"); | 492 | qDebug("audioView"); |
493 | // QListIterator<DocLnk> dit( files.children() ); | 493 | // Global::findDocuments(&files, "audio/*"); |
494 | // for ( ; dit.current(); ++dit ) { | 494 | QListIterator<DocLnk> dit( files.children() ); |
495 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 495 | for ( ; dit.current(); ++dit ) { |
496 | // qDebug("here"); | 496 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
497 | // insanityBool=TRUE; | 497 | qDebug("here"); |
498 | // return dit; | 498 | insanityBool=TRUE; |
499 | // } | 499 | return dit; |
500 | // } | 500 | } |
501 | // } | 501 | } |
502 | // break; | 502 | } |
503 | // case 2: // video | 503 | break; |
504 | // { | 504 | case 2: // video |
505 | // qDebug("videoView"); | 505 | { |
506 | // Global::findDocuments(&vFiles, "video/*"); | 506 | qDebug("videoView"); |
507 | // QListIterator<DocLnk> Vdit( vFiles.children() ); | 507 | // Global::findDocuments(&vFiles, "video/*"); |
508 | // for ( ; Vdit.current(); ++Vdit ) { | 508 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
509 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 509 | for ( ; Vdit.current(); ++Vdit ) { |
510 | // insanityBool=TRUE; | 510 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
511 | // return Vdit; | 511 | insanityBool=TRUE; |
512 | // } | 512 | return Vdit; |
513 | // } | 513 | } |
514 | // } | 514 | } |
515 | // break; | 515 | } |
516 | // }; | 516 | break; |
517 | // return 0; | 517 | }; |
518 | return 0; | ||
518 | } | 519 | } |
519 | 520 | ||
520 | bool PlayListWidget::prev() { | 521 | bool PlayListWidget::prev() { |
521 | if ( mediaPlayerState->playlist() ) { | 522 | if ( mediaPlayerState->playlist() ) { |
522 | if ( mediaPlayerState->shuffled() ) { | 523 | if ( mediaPlayerState->shuffled() ) { |
523 | const DocLnk *cur = current(); | 524 | const DocLnk *cur = current(); |
524 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 525 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
525 | for ( int i = 0; i < j; i++ ) { | 526 | for ( int i = 0; i < j; i++ ) { |
526 | if ( !d->selectedFiles->next() ) | 527 | if ( !d->selectedFiles->next() ) |
527 | d->selectedFiles->first(); | 528 | d->selectedFiles->first(); |
528 | } | 529 | } |
529 | if ( cur == current() ) | 530 | if ( cur == current() ) |
530 | if ( !d->selectedFiles->next() ) | 531 | if ( !d->selectedFiles->next() ) |
531 | d->selectedFiles->first(); | 532 | d->selectedFiles->first(); |
532 | return TRUE; | 533 | return TRUE; |
533 | } else { | 534 | } else { |
534 | if ( !d->selectedFiles->prev() ) { | 535 | if ( !d->selectedFiles->prev() ) { |
535 | if ( mediaPlayerState->looping() ) { | 536 | if ( mediaPlayerState->looping() ) { |
536 | return d->selectedFiles->last(); | 537 | return d->selectedFiles->last(); |
537 | } else { | 538 | } else { |
538 | return FALSE; | 539 | return FALSE; |
539 | } | 540 | } |
540 | } | 541 | } |
541 | return TRUE; | 542 | return TRUE; |
542 | } | 543 | } |
543 | } else { | 544 | } else { |
544 | return mediaPlayerState->looping(); | 545 | return mediaPlayerState->looping(); |
545 | } | 546 | } |
546 | } | 547 | } |
547 | 548 | ||
548 | 549 | ||
549 | bool PlayListWidget::next() { | 550 | bool PlayListWidget::next() { |
550 | if ( mediaPlayerState->playlist() ) { | 551 | if ( mediaPlayerState->playlist() ) { |
551 | if ( mediaPlayerState->shuffled() ) { | 552 | if ( mediaPlayerState->shuffled() ) { |
552 | return prev(); | 553 | return prev(); |
553 | } else { | 554 | } else { |
554 | if ( !d->selectedFiles->next() ) { | 555 | if ( !d->selectedFiles->next() ) { |
555 | if ( mediaPlayerState->looping() ) { | 556 | if ( mediaPlayerState->looping() ) { |
556 | return d->selectedFiles->first(); | 557 | return d->selectedFiles->first(); |
557 | } else { | 558 | } else { |
558 | return FALSE; | 559 | return FALSE; |
559 | } | 560 | } |
560 | } | 561 | } |
561 | return TRUE; | 562 | return TRUE; |
562 | } | 563 | } |
563 | } else { | 564 | } else { |
564 | return mediaPlayerState->looping(); | 565 | return mediaPlayerState->looping(); |
565 | } | 566 | } |
@@ -749,114 +750,111 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
749 | { | 750 | { |
750 | if( !tbDeletePlaylist->isHidden()) | 751 | if( !tbDeletePlaylist->isHidden()) |
751 | tbDeletePlaylist->hide(); | 752 | tbDeletePlaylist->hide(); |
752 | d->tbRemoveFromList->setEnabled(TRUE); | 753 | d->tbRemoveFromList->setEnabled(TRUE); |
753 | d->tbAddToList->setEnabled(FALSE); | 754 | d->tbAddToList->setEnabled(FALSE); |
754 | } | 755 | } |
755 | break; | 756 | break; |
756 | case 1: | 757 | case 1: |
757 | { | 758 | { |
758 | if( !tbDeletePlaylist->isHidden()) | 759 | if( !tbDeletePlaylist->isHidden()) |
759 | tbDeletePlaylist->hide(); | 760 | tbDeletePlaylist->hide(); |
760 | d->tbRemoveFromList->setEnabled(FALSE); | 761 | d->tbRemoveFromList->setEnabled(FALSE); |
761 | d->tbAddToList->setEnabled(TRUE); | 762 | d->tbAddToList->setEnabled(TRUE); |
762 | } | 763 | } |
763 | break; | 764 | break; |
764 | case 2: | 765 | case 2: |
765 | { | 766 | { |
766 | if( !tbDeletePlaylist->isHidden()) | 767 | if( !tbDeletePlaylist->isHidden()) |
767 | tbDeletePlaylist->hide(); | 768 | tbDeletePlaylist->hide(); |
768 | d->tbRemoveFromList->setEnabled(FALSE); | 769 | d->tbRemoveFromList->setEnabled(FALSE); |
769 | d->tbAddToList->setEnabled(TRUE); | 770 | d->tbAddToList->setEnabled(TRUE); |
770 | } | 771 | } |
771 | break; | 772 | break; |
772 | case 3: | 773 | case 3: |
773 | { | 774 | { |
774 | if( tbDeletePlaylist->isHidden()) | 775 | if( tbDeletePlaylist->isHidden()) |
775 | tbDeletePlaylist->show(); | 776 | tbDeletePlaylist->show(); |
776 | playLists->reread(); | 777 | playLists->reread(); |
777 | } | 778 | } |
778 | break; | 779 | break; |
779 | }; | 780 | }; |
780 | } | 781 | } |
781 | 782 | ||
782 | 783 | ||
783 | 784 | ||
784 | void PlayListWidget::btnPlay(bool b) { | 785 | void PlayListWidget::btnPlay(bool b) { |
785 | 786 | ||
786 | // mediaPlayerState->setPlaying(b); | 787 | // mediaPlayerState->setPlaying(b); |
787 | switch ( tabWidget->currentPageIndex()) { | 788 | switch ( tabWidget->currentPageIndex()) { |
788 | case 0: | 789 | case 0: |
789 | { | 790 | { |
790 | mediaPlayerState->setPlaying(b); | 791 | mediaPlayerState->setPlaying(b); |
791 | } | 792 | } |
792 | break; | 793 | break; |
793 | case 1: | 794 | case 1: |
794 | { | 795 | { |
795 | addToSelection( audioView->selectedItem() ); | 796 | addToSelection( audioView->selectedItem() ); |
796 | mediaPlayerState->setPlaying(b); | 797 | mediaPlayerState->setPlaying(b); |
797 | // qApp->processEvents(); | ||
798 | d->selectedFiles->removeSelected( ); | 798 | d->selectedFiles->removeSelected( ); |
799 | tabWidget->setCurrentPage(1); | 799 | tabWidget->setCurrentPage(1); |
800 | audioView->clearSelection(); | 800 | d->selectedFiles->unSelect(); |
801 | // d->selectedFiles->unSelect(); | 801 | // audioView->clearSelection(); |
802 | // mediaPlayerState->setPlaying(FALSE); | ||
803 | } | 802 | } |
804 | break; | 803 | break; |
805 | case 2: | 804 | case 2: |
806 | { | 805 | { |
807 | addToSelection( videoView->selectedItem() ); | 806 | addToSelection( videoView->selectedItem() ); |
808 | mediaPlayerState->setPlaying(b); | 807 | mediaPlayerState->setPlaying(b); |
809 | qApp->processEvents(); | 808 | qApp->processEvents(); |
810 | d->selectedFiles->removeSelected( ); | 809 | d->selectedFiles->removeSelected( ); |
811 | tabWidget->setCurrentPage(2); | 810 | tabWidget->setCurrentPage(2); |
812 | videoView->clearSelection(); | 811 | d->selectedFiles->unSelect(); |
813 | // d->selectedFiles->unSelect(); | 812 | // videoView->clearSelection(); |
814 | // mediaPlayerState->setPlaying(FALSE); | ||
815 | } | 813 | } |
816 | break; | 814 | break; |
817 | }; | 815 | }; |
818 | } | 816 | } |
819 | 817 | ||
820 | void PlayListWidget::deletePlaylist() { | 818 | void PlayListWidget::deletePlaylist() { |
821 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
822 | (tr("You really want to delete\nthis playlist?")), | 820 | (tr("You really want to delete\nthis playlist?")), |
823 | (tr("Yes")), (tr("No")), 0 )){ | 821 | (tr("Yes")), (tr("No")), 0 )){ |
824 | case 0: // Yes clicked, | 822 | case 0: // Yes clicked, |
825 | QFile().remove(playLists->selected()->file()); | 823 | QFile().remove(playLists->selected()->file()); |
826 | QFile().remove(playLists->selected()->linkFile()); | 824 | QFile().remove(playLists->selected()->linkFile()); |
827 | playLists->reread(); | 825 | playLists->reread(); |
828 | break; | 826 | break; |
829 | case 1: // Cancel | 827 | case 1: // Cancel |
830 | break; | 828 | break; |
831 | }; | 829 | }; |
832 | 830 | ||
833 | } | 831 | } |
834 | 832 | ||
835 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
836 | { | 834 | { |
837 | switch (mouse) { | 835 | switch (mouse) { |
838 | case 1: | 836 | case 1: |
839 | break; | 837 | break; |
840 | case 2:{ | 838 | case 2:{ |
841 | QPopupMenu m; | 839 | QPopupMenu m; |
842 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 840 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
843 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
844 | m.insertSeparator(); | 842 | m.insertSeparator(); |
845 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
846 | m.exec( QCursor::pos() ); | 844 | m.exec( QCursor::pos() ); |
847 | } | 845 | } |
848 | break; | 846 | break; |
849 | }; | 847 | }; |
850 | } | 848 | } |
851 | 849 | ||
852 | void PlayListWidget::playSelected() | 850 | void PlayListWidget::playSelected() |
853 | { | 851 | { |
854 | btnPlay( TRUE); | 852 | btnPlay( TRUE); |
855 | } | 853 | } |
856 | 854 | ||
857 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
858 | { | 856 | { |
859 | switch (mouse) { | 857 | switch (mouse) { |
860 | case 1: | 858 | case 1: |
861 | break; | 859 | break; |
862 | case 2:{ | 860 | case 2:{ |