author | llornkcor <llornkcor> | 2002-04-20 18:29:06 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-20 18:29:06 (UTC) |
commit | 758c9e817087252894b15c6f7476c1f16a02f65d (patch) (unidiff) | |
tree | de3a2fa88c3eeffae5602928b3a57c8f9ac2ac86 | |
parent | b37f1e1eec635165da7dbf06e968cd5368d92d4e (diff) | |
download | opie-758c9e817087252894b15c6f7476c1f16a02f65d.zip opie-758c9e817087252894b15c6f7476c1f16a02f65d.tar.gz opie-758c9e817087252894b15c6f7476c1f16a02f65d.tar.bz2 |
file/url
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 11f9752..4b1ff22 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -477,529 +477,527 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
477 | // if(dit.current()->linkFile() == setDocFileRef) { | 477 | // if(dit.current()->linkFile() == setDocFileRef) { |
478 | // qDebug(setDocFileRef); | 478 | // qDebug(setDocFileRef); |
479 | // return dit; | 479 | // return dit; |
480 | // } | 480 | // } |
481 | // } | 481 | // } |
482 | // } else | 482 | // } else |
483 | 483 | ||
484 | 484 | ||
485 | switch (tabWidget->currentPageIndex()) { | 485 | switch (tabWidget->currentPageIndex()) { |
486 | case 0: //playlist | 486 | case 0: //playlist |
487 | { | 487 | { |
488 | qDebug("playlist"); | 488 | qDebug("playlist"); |
489 | if ( mediaPlayerState->playlist() ) { | 489 | if ( mediaPlayerState->playlist() ) { |
490 | return d->selectedFiles->current(); | 490 | return d->selectedFiles->current(); |
491 | } | 491 | } |
492 | else if ( d->setDocumentUsed && d->current ) { | 492 | else if ( d->setDocumentUsed && d->current ) { |
493 | return d->current; | 493 | return d->current; |
494 | } else { | 494 | } else { |
495 | return d->files->selected(); | 495 | return d->files->selected(); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | break; | 498 | break; |
499 | case 1://audio | 499 | case 1://audio |
500 | { | 500 | { |
501 | qDebug("audioView"); | 501 | qDebug("audioView"); |
502 | // Global::findDocuments(&files, "audio/*"); | 502 | // Global::findDocuments(&files, "audio/*"); |
503 | QListIterator<DocLnk> dit( files.children() ); | 503 | QListIterator<DocLnk> dit( files.children() ); |
504 | for ( ; dit.current(); ++dit ) { | 504 | for ( ; dit.current(); ++dit ) { |
505 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 505 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
506 | qDebug("here"); | 506 | qDebug("here"); |
507 | insanityBool=TRUE; | 507 | insanityBool=TRUE; |
508 | return dit; | 508 | return dit; |
509 | } | 509 | } |
510 | } | 510 | } |
511 | } | 511 | } |
512 | break; | 512 | break; |
513 | case 2: // video | 513 | case 2: // video |
514 | { | 514 | { |
515 | qDebug("videoView"); | 515 | qDebug("videoView"); |
516 | // Global::findDocuments(&vFiles, "video/*"); | 516 | // Global::findDocuments(&vFiles, "video/*"); |
517 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 517 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
518 | for ( ; Vdit.current(); ++Vdit ) { | 518 | for ( ; Vdit.current(); ++Vdit ) { |
519 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 519 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
520 | insanityBool=TRUE; | 520 | insanityBool=TRUE; |
521 | return Vdit; | 521 | return Vdit; |
522 | } | 522 | } |
523 | } | 523 | } |
524 | } | 524 | } |
525 | break; | 525 | break; |
526 | }; | 526 | }; |
527 | return 0; | 527 | return 0; |
528 | } | 528 | } |
529 | 529 | ||
530 | bool PlayListWidget::prev() { | 530 | bool PlayListWidget::prev() { |
531 | if ( mediaPlayerState->playlist() ) { | 531 | if ( mediaPlayerState->playlist() ) { |
532 | if ( mediaPlayerState->shuffled() ) { | 532 | if ( mediaPlayerState->shuffled() ) { |
533 | const DocLnk *cur = current(); | 533 | const DocLnk *cur = current(); |
534 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 534 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
535 | for ( int i = 0; i < j; i++ ) { | 535 | for ( int i = 0; i < j; i++ ) { |
536 | if ( !d->selectedFiles->next() ) | 536 | if ( !d->selectedFiles->next() ) |
537 | d->selectedFiles->first(); | 537 | d->selectedFiles->first(); |
538 | } | 538 | } |
539 | if ( cur == current() ) | 539 | if ( cur == current() ) |
540 | if ( !d->selectedFiles->next() ) | 540 | if ( !d->selectedFiles->next() ) |
541 | d->selectedFiles->first(); | 541 | d->selectedFiles->first(); |
542 | return TRUE; | 542 | return TRUE; |
543 | } else { | 543 | } else { |
544 | if ( !d->selectedFiles->prev() ) { | 544 | if ( !d->selectedFiles->prev() ) { |
545 | if ( mediaPlayerState->looping() ) { | 545 | if ( mediaPlayerState->looping() ) { |
546 | return d->selectedFiles->last(); | 546 | return d->selectedFiles->last(); |
547 | } else { | 547 | } else { |
548 | return FALSE; | 548 | return FALSE; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | return TRUE; | 551 | return TRUE; |
552 | } | 552 | } |
553 | } else { | 553 | } else { |
554 | return mediaPlayerState->looping(); | 554 | return mediaPlayerState->looping(); |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | bool PlayListWidget::next() { | 559 | bool PlayListWidget::next() { |
560 | if ( mediaPlayerState->playlist() ) { | 560 | if ( mediaPlayerState->playlist() ) { |
561 | if ( mediaPlayerState->shuffled() ) { | 561 | if ( mediaPlayerState->shuffled() ) { |
562 | return prev(); | 562 | return prev(); |
563 | } else { | 563 | } else { |
564 | if ( !d->selectedFiles->next() ) { | 564 | if ( !d->selectedFiles->next() ) { |
565 | if ( mediaPlayerState->looping() ) { | 565 | if ( mediaPlayerState->looping() ) { |
566 | return d->selectedFiles->first(); | 566 | return d->selectedFiles->first(); |
567 | } else { | 567 | } else { |
568 | return FALSE; | 568 | return FALSE; |
569 | } | 569 | } |
570 | } | 570 | } |
571 | return TRUE; | 571 | return TRUE; |
572 | } | 572 | } |
573 | } else { | 573 | } else { |
574 | return mediaPlayerState->looping(); | 574 | return mediaPlayerState->looping(); |
575 | } | 575 | } |
576 | } | 576 | } |
577 | 577 | ||
578 | 578 | ||
579 | bool PlayListWidget::first() { | 579 | bool PlayListWidget::first() { |
580 | if ( mediaPlayerState->playlist() ) | 580 | if ( mediaPlayerState->playlist() ) |
581 | return d->selectedFiles->first(); | 581 | return d->selectedFiles->first(); |
582 | else | 582 | else |
583 | return mediaPlayerState->looping(); | 583 | return mediaPlayerState->looping(); |
584 | } | 584 | } |
585 | 585 | ||
586 | 586 | ||
587 | bool PlayListWidget::last() { | 587 | bool PlayListWidget::last() { |
588 | if ( mediaPlayerState->playlist() ) | 588 | if ( mediaPlayerState->playlist() ) |
589 | return d->selectedFiles->last(); | 589 | return d->selectedFiles->last(); |
590 | else | 590 | else |
591 | return mediaPlayerState->looping(); | 591 | return mediaPlayerState->looping(); |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void PlayListWidget::saveList() { | 595 | void PlayListWidget::saveList() { |
596 | 596 | ||
597 | QString filename; | 597 | QString filename; |
598 | InputDialog *fileDlg; | 598 | InputDialog *fileDlg; |
599 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 599 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
600 | fileDlg->exec(); | 600 | fileDlg->exec(); |
601 | if( fileDlg->result() == 1 ) { | 601 | if( fileDlg->result() == 1 ) { |
602 | if ( d->current ) | 602 | if ( d->current ) |
603 | delete d->current; | 603 | delete d->current; |
604 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 604 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
605 | // qDebug("saving playlist "+filename+".playlist"); | 605 | // qDebug("saving playlist "+filename+".playlist"); |
606 | Config cfg( filename +".playlist"); | 606 | Config cfg( filename +".playlist"); |
607 | writeConfig( cfg ); | 607 | writeConfig( cfg ); |
608 | 608 | ||
609 | // qDebug("same name so delete lnk??"); | 609 | // qDebug("same name so delete lnk??"); |
610 | // if( playLists->selected()->name() == filename) { | 610 | // if( playLists->selected()->name() == filename) { |
611 | 611 | ||
612 | // qDebug("same name so delete lnk"); | 612 | // qDebug("same name so delete lnk"); |
613 | // QFile().remove(playLists->selected()->file()); | 613 | // QFile().remove(playLists->selected()->file()); |
614 | // QFile().remove(playLists->selected()->linkFile()); | 614 | // QFile().remove(playLists->selected()->linkFile()); |
615 | // playLists->reread(); | 615 | // playLists->reread(); |
616 | // } | 616 | // } |
617 | // qDebug("new doclnk"); | 617 | // qDebug("new doclnk"); |
618 | DocLnk lnk; | 618 | DocLnk lnk; |
619 | // lnk.setComment( ""); | 619 | // lnk.setComment( ""); |
620 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 620 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
621 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 621 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
622 | lnk.setIcon("mpegplayer/playlist2"); | 622 | lnk.setIcon("mpegplayer/playlist2"); |
623 | lnk.setName( filename); //sets file name | 623 | lnk.setName( filename); //sets file name |
624 | // qDebug(filename); | 624 | // qDebug(filename); |
625 | if(!lnk.writeLink()) | 625 | if(!lnk.writeLink()) |
626 | qDebug("Writing doclink did not work"); | 626 | qDebug("Writing doclink did not work"); |
627 | } | 627 | } |
628 | Config config( "MediaPlayer" ); | 628 | Config config( "MediaPlayer" ); |
629 | config.writeEntry("CurrentPlaylist",filename); | 629 | config.writeEntry("CurrentPlaylist",filename); |
630 | setCaption(tr("OpiePlayer: ")+filename); | 630 | setCaption(tr("OpiePlayer: ")+filename); |
631 | d->selectedFiles->first(); | 631 | d->selectedFiles->first(); |
632 | if(fileDlg) | 632 | if(fileDlg) |
633 | delete fileDlg; | 633 | delete fileDlg; |
634 | } | 634 | } |
635 | 635 | ||
636 | void PlayListWidget::loadList( const DocLnk & lnk) { | 636 | void PlayListWidget::loadList( const DocLnk & lnk) { |
637 | QString name= lnk.name(); | 637 | QString name= lnk.name(); |
638 | // qDebug("currentList is "+name); | 638 | // qDebug("currentList is "+name); |
639 | if( name.length()>1) { | 639 | if( name.length()>1) { |
640 | setCaption("OpiePlayer: "+name); | 640 | setCaption("OpiePlayer: "+name); |
641 | // qDebug("load list "+ name+".playlist"); | 641 | // qDebug("load list "+ name+".playlist"); |
642 | clearList(); | 642 | clearList(); |
643 | Config cfg( name+".playlist"); | 643 | Config cfg( name+".playlist"); |
644 | readConfig(cfg); | 644 | readConfig(cfg); |
645 | 645 | ||
646 | tabWidget->setCurrentPage(0); | 646 | tabWidget->setCurrentPage(0); |
647 | 647 | ||
648 | Config config( "MediaPlayer" ); | 648 | Config config( "MediaPlayer" ); |
649 | config.writeEntry("CurrentPlaylist", name); | 649 | config.writeEntry("CurrentPlaylist", name); |
650 | // d->selectedFiles->first(); | 650 | // d->selectedFiles->first(); |
651 | } | 651 | } |
652 | 652 | ||
653 | } | 653 | } |
654 | 654 | ||
655 | void PlayListWidget::setPlaylist( bool shown ) { | 655 | void PlayListWidget::setPlaylist( bool shown ) { |
656 | if ( shown ) | 656 | if ( shown ) |
657 | d->playListFrame->show(); | 657 | d->playListFrame->show(); |
658 | else | 658 | else |
659 | d->playListFrame->hide(); | 659 | d->playListFrame->hide(); |
660 | } | 660 | } |
661 | 661 | ||
662 | void PlayListWidget::setView( char view ) { | 662 | void PlayListWidget::setView( char view ) { |
663 | if ( view == 'l' ) | 663 | if ( view == 'l' ) |
664 | showMaximized(); | 664 | showMaximized(); |
665 | else | 665 | else |
666 | hide(); | 666 | hide(); |
667 | } | 667 | } |
668 | 668 | ||
669 | void PlayListWidget::addSelected() { | 669 | void PlayListWidget::addSelected() { |
670 | 670 | ||
671 | Config cfg( "MediaPlayer" ); | 671 | Config cfg( "MediaPlayer" ); |
672 | cfg.setGroup("PlayList"); | 672 | cfg.setGroup("PlayList"); |
673 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 673 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
674 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 674 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
675 | 675 | ||
676 | switch (tabWidget->currentPageIndex()) { | 676 | switch (tabWidget->currentPageIndex()) { |
677 | case 0: //playlist | 677 | case 0: //playlist |
678 | break; | 678 | break; |
679 | case 1: { //audio | 679 | case 1: { //audio |
680 | for ( int i = 0; i < noOfFiles; i++ ) { | 680 | for ( int i = 0; i < noOfFiles; i++ ) { |
681 | QString entryName; | 681 | QString entryName; |
682 | entryName.sprintf( "File%i", i + 1 ); | 682 | entryName.sprintf( "File%i", i + 1 ); |
683 | QString linkFile = cfg.readEntry( entryName ); | 683 | QString linkFile = cfg.readEntry( entryName ); |
684 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 684 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
685 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 685 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
686 | tr("This is all ready in your playlist.\nContinue?"), | 686 | tr("This is all ready in your playlist.\nContinue?"), |
687 | tr("Yes"),tr("No"),0,0,1); | 687 | tr("Yes"),tr("No"),0,0,1); |
688 | if (result !=0) | 688 | if (result !=0) |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | } | 691 | } |
692 | addToSelection( audioView->selectedItem() ); | 692 | addToSelection( audioView->selectedItem() ); |
693 | tabWidget->setCurrentPage(1); | 693 | tabWidget->setCurrentPage(1); |
694 | } | 694 | } |
695 | break; | 695 | break; |
696 | case 2: { // video | 696 | case 2: { // video |
697 | for ( int i = 0; i < noOfFiles; i++ ) { | 697 | for ( int i = 0; i < noOfFiles; i++ ) { |
698 | QString entryName; | 698 | QString entryName; |
699 | entryName.sprintf( "File%i", i + 1 ); | 699 | entryName.sprintf( "File%i", i + 1 ); |
700 | QString linkFile = cfg.readEntry( entryName ); | 700 | QString linkFile = cfg.readEntry( entryName ); |
701 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 701 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
702 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 702 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
703 | tr("This is all ready in your playlist.\nContinue?"), | 703 | tr("This is all ready in your playlist.\nContinue?"), |
704 | tr("Yes"),tr("No"),0,0,1); | 704 | tr("Yes"),tr("No"),0,0,1); |
705 | if (result !=0) | 705 | if (result !=0) |
706 | return; | 706 | return; |
707 | } | 707 | } |
708 | } | 708 | } |
709 | addToSelection( videoView->selectedItem() ); | 709 | addToSelection( videoView->selectedItem() ); |
710 | tabWidget->setCurrentPage(2); | 710 | tabWidget->setCurrentPage(2); |
711 | } | 711 | } |
712 | break; | 712 | break; |
713 | }; | 713 | }; |
714 | } | 714 | } |
715 | 715 | ||
716 | void PlayListWidget::removeSelected() { | 716 | void PlayListWidget::removeSelected() { |
717 | d->selectedFiles->removeSelected( ); | 717 | d->selectedFiles->removeSelected( ); |
718 | } | 718 | } |
719 | 719 | ||
720 | void PlayListWidget::playIt( QListViewItem *it) { | 720 | void PlayListWidget::playIt( QListViewItem *it) { |
721 | // d->setDocumentUsed = FALSE; | 721 | // d->setDocumentUsed = FALSE; |
722 | mediaPlayerState->setPlaying(TRUE); | 722 | mediaPlayerState->setPlaying(TRUE); |
723 | } | 723 | } |
724 | 724 | ||
725 | void PlayListWidget::addToSelection( QListViewItem *it) { | 725 | void PlayListWidget::addToSelection( QListViewItem *it) { |
726 | d->setDocumentUsed = FALSE; | 726 | d->setDocumentUsed = FALSE; |
727 | 727 | ||
728 | if(it) { | 728 | if(it) { |
729 | switch (tabWidget->currentPageIndex()) { | 729 | switch (tabWidget->currentPageIndex()) { |
730 | case 1: { | 730 | case 1: { |
731 | QListIterator<DocLnk> dit( files.children() ); | 731 | QListIterator<DocLnk> dit( files.children() ); |
732 | for ( ; dit.current(); ++dit ) { | 732 | for ( ; dit.current(); ++dit ) { |
733 | if( dit.current()->name() == it->text(0)) { | 733 | if( dit.current()->name() == it->text(0)) { |
734 | d->selectedFiles->addToSelection( **dit ); | 734 | d->selectedFiles->addToSelection( **dit ); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | } | 737 | } |
738 | break; | 738 | break; |
739 | case 2: { | 739 | case 2: { |
740 | QListIterator<DocLnk> dit( vFiles.children() ); | 740 | QListIterator<DocLnk> dit( vFiles.children() ); |
741 | for ( ; dit.current(); ++dit ) { | 741 | for ( ; dit.current(); ++dit ) { |
742 | if( dit.current()->name() == it->text(0)) { | 742 | if( dit.current()->name() == it->text(0)) { |
743 | d->selectedFiles->addToSelection( **dit ); | 743 | d->selectedFiles->addToSelection( **dit ); |
744 | } | 744 | } |
745 | } | 745 | } |
746 | } | 746 | } |
747 | break; | 747 | break; |
748 | case 0: | 748 | case 0: |
749 | break; | 749 | break; |
750 | }; | 750 | }; |
751 | tabWidget->setCurrentPage(0); | 751 | tabWidget->setCurrentPage(0); |
752 | } | 752 | } |
753 | } | 753 | } |
754 | 754 | ||
755 | void PlayListWidget::tabChanged(QWidget *widg) { | 755 | void PlayListWidget::tabChanged(QWidget *widg) { |
756 | 756 | ||
757 | switch ( tabWidget->currentPageIndex()) { | 757 | switch ( tabWidget->currentPageIndex()) { |
758 | case 0: | 758 | case 0: |
759 | { | 759 | { |
760 | if( !tbDeletePlaylist->isHidden()) | 760 | if( !tbDeletePlaylist->isHidden()) |
761 | tbDeletePlaylist->hide(); | 761 | tbDeletePlaylist->hide(); |
762 | d->tbRemoveFromList->setEnabled(TRUE); | 762 | d->tbRemoveFromList->setEnabled(TRUE); |
763 | d->tbAddToList->setEnabled(FALSE); | 763 | d->tbAddToList->setEnabled(FALSE); |
764 | } | 764 | } |
765 | break; | 765 | break; |
766 | case 1: | 766 | case 1: |
767 | { | 767 | { |
768 | if( !tbDeletePlaylist->isHidden()) | 768 | if( !tbDeletePlaylist->isHidden()) |
769 | tbDeletePlaylist->hide(); | 769 | tbDeletePlaylist->hide(); |
770 | d->tbRemoveFromList->setEnabled(FALSE); | 770 | d->tbRemoveFromList->setEnabled(FALSE); |
771 | d->tbAddToList->setEnabled(TRUE); | 771 | d->tbAddToList->setEnabled(TRUE); |
772 | } | 772 | } |
773 | break; | 773 | break; |
774 | case 2: | 774 | case 2: |
775 | { | 775 | { |
776 | if( !tbDeletePlaylist->isHidden()) | 776 | if( !tbDeletePlaylist->isHidden()) |
777 | tbDeletePlaylist->hide(); | 777 | tbDeletePlaylist->hide(); |
778 | d->tbRemoveFromList->setEnabled(FALSE); | 778 | d->tbRemoveFromList->setEnabled(FALSE); |
779 | d->tbAddToList->setEnabled(TRUE); | 779 | d->tbAddToList->setEnabled(TRUE); |
780 | } | 780 | } |
781 | break; | 781 | break; |
782 | case 3: | 782 | case 3: |
783 | { | 783 | { |
784 | if( tbDeletePlaylist->isHidden()) | 784 | if( tbDeletePlaylist->isHidden()) |
785 | tbDeletePlaylist->show(); | 785 | tbDeletePlaylist->show(); |
786 | playLists->reread(); | 786 | playLists->reread(); |
787 | } | 787 | } |
788 | break; | 788 | break; |
789 | }; | 789 | }; |
790 | } | 790 | } |
791 | 791 | ||
792 | 792 | ||
793 | 793 | ||
794 | void PlayListWidget::btnPlay(bool b) { | 794 | void PlayListWidget::btnPlay(bool b) { |
795 | 795 | ||
796 | // mediaPlayerState->setPlaying(b); | 796 | // mediaPlayerState->setPlaying(b); |
797 | switch ( tabWidget->currentPageIndex()) { | 797 | switch ( tabWidget->currentPageIndex()) { |
798 | case 0: | 798 | case 0: |
799 | { | 799 | { |
800 | mediaPlayerState->setPlaying(b); | 800 | mediaPlayerState->setPlaying(b); |
801 | } | 801 | } |
802 | break; | 802 | break; |
803 | case 1: | 803 | case 1: |
804 | { | 804 | { |
805 | addToSelection( audioView->selectedItem() ); | 805 | addToSelection( audioView->selectedItem() ); |
806 | mediaPlayerState->setPlaying(b); | 806 | mediaPlayerState->setPlaying(b); |
807 | d->selectedFiles->removeSelected( ); | 807 | d->selectedFiles->removeSelected( ); |
808 | tabWidget->setCurrentPage(1); | 808 | tabWidget->setCurrentPage(1); |
809 | d->selectedFiles->unSelect(); | 809 | d->selectedFiles->unSelect(); |
810 | // audioView->clearSelection(); | 810 | // audioView->clearSelection(); |
811 | } | 811 | } |
812 | break; | 812 | break; |
813 | case 2: | 813 | case 2: |
814 | { | 814 | { |
815 | addToSelection( videoView->selectedItem() ); | 815 | addToSelection( videoView->selectedItem() ); |
816 | mediaPlayerState->setPlaying(b); | 816 | mediaPlayerState->setPlaying(b); |
817 | qApp->processEvents(); | 817 | qApp->processEvents(); |
818 | d->selectedFiles->removeSelected( ); | 818 | d->selectedFiles->removeSelected( ); |
819 | tabWidget->setCurrentPage(2); | 819 | tabWidget->setCurrentPage(2); |
820 | d->selectedFiles->unSelect(); | 820 | d->selectedFiles->unSelect(); |
821 | // videoView->clearSelection(); | 821 | // videoView->clearSelection(); |
822 | } | 822 | } |
823 | break; | 823 | break; |
824 | }; | 824 | }; |
825 | } | 825 | } |
826 | 826 | ||
827 | void PlayListWidget::deletePlaylist() { | 827 | void PlayListWidget::deletePlaylist() { |
828 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 828 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
829 | (tr("You really want to delete\nthis playlist?")), | 829 | (tr("You really want to delete\nthis playlist?")), |
830 | (tr("Yes")), (tr("No")), 0 )){ | 830 | (tr("Yes")), (tr("No")), 0 )){ |
831 | case 0: // Yes clicked, | 831 | case 0: // Yes clicked, |
832 | QFile().remove(playLists->selected()->file()); | 832 | QFile().remove(playLists->selected()->file()); |
833 | QFile().remove(playLists->selected()->linkFile()); | 833 | QFile().remove(playLists->selected()->linkFile()); |
834 | playLists->reread(); | 834 | playLists->reread(); |
835 | break; | 835 | break; |
836 | case 1: // Cancel | 836 | case 1: // Cancel |
837 | break; | 837 | break; |
838 | }; | 838 | }; |
839 | 839 | ||
840 | } | 840 | } |
841 | 841 | ||
842 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 842 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
843 | { | 843 | { |
844 | switch (mouse) { | 844 | switch (mouse) { |
845 | case 1: | 845 | case 1: |
846 | break; | 846 | break; |
847 | case 2:{ | 847 | case 2:{ |
848 | QPopupMenu m; | 848 | QPopupMenu m; |
849 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 849 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
850 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 850 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
851 | m.insertSeparator(); | 851 | m.insertSeparator(); |
852 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 852 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
853 | m.exec( QCursor::pos() ); | 853 | m.exec( QCursor::pos() ); |
854 | } | 854 | } |
855 | break; | 855 | break; |
856 | }; | 856 | }; |
857 | } | 857 | } |
858 | 858 | ||
859 | void PlayListWidget::playSelected() | 859 | void PlayListWidget::playSelected() |
860 | { | 860 | { |
861 | btnPlay( TRUE); | 861 | btnPlay( TRUE); |
862 | } | 862 | } |
863 | 863 | ||
864 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 864 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
865 | { | 865 | { |
866 | switch (mouse) { | 866 | switch (mouse) { |
867 | case 1: | 867 | case 1: |
868 | break; | 868 | break; |
869 | case 2:{ | 869 | case 2:{ |
870 | QPopupMenu m; | 870 | QPopupMenu m; |
871 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 871 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
872 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 872 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
873 | // m.insertSeparator(); | 873 | // m.insertSeparator(); |
874 | m.exec( QCursor::pos() ); | 874 | m.exec( QCursor::pos() ); |
875 | } | 875 | } |
876 | break; | 876 | break; |
877 | }; | 877 | }; |
878 | 878 | ||
879 | } | 879 | } |
880 | 880 | ||
881 | void PlayListWidget::listDelete() { | 881 | void PlayListWidget::listDelete() { |
882 | Config cfg( "MediaPlayer" ); | 882 | Config cfg( "MediaPlayer" ); |
883 | cfg.setGroup("PlayList"); | 883 | cfg.setGroup("PlayList"); |
884 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 884 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
885 | QString file; | 885 | QString file; |
886 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 886 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
887 | switch ( tabWidget->currentPageIndex()) { | 887 | switch ( tabWidget->currentPageIndex()) { |
888 | case 0: | 888 | case 0: |
889 | break; | 889 | break; |
890 | case 1: | 890 | case 1: |
891 | { | 891 | { |
892 | file = audioView->selectedItem()->text(0); | 892 | file = audioView->selectedItem()->text(0); |
893 | // Global::findDocuments(&files, "audio/*"); | 893 | // Global::findDocuments(&files, "audio/*"); |
894 | // AppLnkSet appFiles; | 894 | // AppLnkSet appFiles; |
895 | QListIterator<DocLnk> dit( files.children() ); | 895 | QListIterator<DocLnk> dit( files.children() ); |
896 | for ( ; dit.current(); ++dit ) { | 896 | for ( ; dit.current(); ++dit ) { |
897 | if( dit.current()->name() == file) { | 897 | if( dit.current()->name() == file) { |
898 | // qDebug(file); | 898 | // qDebug(file); |
899 | LnkProperties prop( dit.current() ); | 899 | LnkProperties prop( dit.current() ); |
900 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 900 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
901 | prop.showMaximized(); | 901 | prop.showMaximized(); |
902 | prop.exec(); | 902 | prop.exec(); |
903 | } | 903 | } |
904 | } | 904 | } |
905 | populateAudioView(); | 905 | populateAudioView(); |
906 | } | 906 | } |
907 | break; | 907 | break; |
908 | case 2: | 908 | case 2: |
909 | { | 909 | { |
910 | // file = videoView->selectedItem()->text(0); | 910 | // file = videoView->selectedItem()->text(0); |
911 | // for ( int i = 0; i < noOfFiles; i++ ) { | 911 | // for ( int i = 0; i < noOfFiles; i++ ) { |
912 | // QString entryName; | 912 | // QString entryName; |
913 | // entryName.sprintf( "File%i", i + 1 ); | 913 | // entryName.sprintf( "File%i", i + 1 ); |
914 | // QString linkFile = cfg.readEntry( entryName ); | 914 | // QString linkFile = cfg.readEntry( entryName ); |
915 | // AppLnk lnk( AppLnk(linkFile)); | 915 | // AppLnk lnk( AppLnk(linkFile)); |
916 | // if( lnk.name() == file ) { | 916 | // if( lnk.name() == file ) { |
917 | // LnkProperties prop( &lnk); | 917 | // LnkProperties prop( &lnk); |
918 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 918 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
919 | // prop.showMaximized(); | 919 | // prop.showMaximized(); |
920 | // prop.exec(); | 920 | // prop.exec(); |
921 | // } | 921 | // } |
922 | // } | 922 | // } |
923 | } | 923 | } |
924 | break; | 924 | break; |
925 | }; | 925 | }; |
926 | } | 926 | } |
927 | 927 | ||
928 | void PlayListWidget::populateAudioView() { | 928 | void PlayListWidget::populateAudioView() { |
929 | // if(files) | 929 | // if(files) |
930 | // files.~DocLnkSet(); | 930 | // files.~DocLnkSet(); |
931 | StorageInfo storageInfo; | 931 | StorageInfo storageInfo; |
932 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 932 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
933 | 933 | ||
934 | Global::findDocuments(&files, "audio/*"); | 934 | Global::findDocuments(&files, "audio/*"); |
935 | QListIterator<DocLnk> dit( files.children() ); | 935 | QListIterator<DocLnk> dit( files.children() ); |
936 | QListIterator<FileSystem> it ( fs ); | 936 | QListIterator<FileSystem> it ( fs ); |
937 | audioView->clear(); | 937 | audioView->clear(); |
938 | QString storage; | 938 | QString storage; |
939 | for ( ; dit.current(); ++dit ) { | 939 | for ( ; dit.current(); ++dit ) { |
940 | for( ; it.current(); ++it ){ | 940 | for( ; it.current(); ++it ){ |
941 | const QString name = (*it)->name(); | 941 | const QString name = (*it)->name(); |
942 | const QString path = (*it)->path(); | 942 | const QString path = (*it)->path(); |
943 | if(dit.current()->file().find(path) != -1 ) storage=name; | 943 | if(dit.current()->file().find(path) != -1 ) storage=name; |
944 | } | 944 | } |
945 | 945 | ||
946 | QListViewItem * newItem; | 946 | QListViewItem * newItem; |
947 | if ( QFile( dit.current()->file()).exists() ) { | 947 | if ( QFile( dit.current()->file()).exists() ) { |
948 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 948 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
949 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 949 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | } | 952 | } |
953 | 953 | ||
954 | void PlayListWidget::populateVideoView() { | 954 | void PlayListWidget::populateVideoView() { |
955 | StorageInfo storageInfo; | 955 | StorageInfo storageInfo; |
956 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 956 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
957 | 957 | ||
958 | Global::findDocuments(&vFiles, "video/*"); | 958 | Global::findDocuments(&vFiles, "video/*"); |
959 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 959 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
960 | QListIterator<FileSystem> it ( fs ); | 960 | QListIterator<FileSystem> it ( fs ); |
961 | videoView->clear(); | 961 | videoView->clear(); |
962 | QString storage; | 962 | QString storage; |
963 | for ( ; Vdit.current(); ++Vdit ) { | 963 | for ( ; Vdit.current(); ++Vdit ) { |
964 | for( ; it.current(); ++it ){ | 964 | for( ; it.current(); ++it ){ |
965 | const QString name = (*it)->name(); | 965 | const QString name = (*it)->name(); |
966 | const QString path = (*it)->path(); | 966 | const QString path = (*it)->path(); |
967 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 967 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
968 | } | 968 | } |
969 | 969 | ||
970 | QListViewItem * newItem; | 970 | QListViewItem * newItem; |
971 | if ( QFile( Vdit.current()->file()).exists() ) { | 971 | if ( QFile( Vdit.current()->file()).exists() ) { |
972 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 972 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
973 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 973 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
974 | } | 974 | } |
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | void PlayListWidget::openFile() { | 978 | void PlayListWidget::openFile() { |
979 | QString filename; | 979 | QString filename; |
980 | InputDialog *fileDlg; | 980 | InputDialog *fileDlg; |
981 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 981 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
982 | fileDlg->exec(); | 982 | fileDlg->exec(); |
983 | if( fileDlg->result() == 1 ) { | 983 | if( fileDlg->result() == 1 ) { |
984 | filename = fileDlg->LineEdit1->text(); | 984 | filename = fileDlg->LineEdit1->text(); |
985 | } | 985 | } |
986 | qDebug(filename); | 986 | qDebug(filename); |
987 | DocLnk lnk; | 987 | DocLnk lnk; |
988 | QString name = filename.right(filename.length()-filename.find("http://")-7); | 988 | QString name = filename.right(filename.length()-filename.find("http://")-7); |
989 | qDebug(name); | ||
989 | lnk.setName( name); //sets file name | 990 | lnk.setName( name); //sets file name |
990 | // lnk.setComment(); | 991 | // lnk.setComment(); |
991 | lnk.setFile(filename); //sets File property | 992 | lnk.setFile(filename); //sets File property |
992 | // problem is, the launcher sees this as a broken link and does not display it :( | 993 | // problem is, the launcher sees this as a broken link and does not display it :( |
993 | |||
994 | lnk.setType("audio/x-mpegurl"); | 994 | lnk.setType("audio/x-mpegurl"); |
995 | lnk.setExec("opieplayer"); | 995 | lnk.setExec("opieplayer"); |
996 | lnk.setIcon("opieplayer/MPEGPlayer"); | 996 | lnk.setIcon("opieplayer/MPEGPlayer"); |
997 | QString cmd="touch "+QPEApplication::documentDir()+"audio/x-mpegurl/"+name; | ||
998 | system( cmd.latin1()); | ||
999 | // d->selectedFiles->addToSelection( **dit ); | ||
1000 | 997 | ||
1001 | if(!lnk.writeLink()) | 998 | if(!lnk.writeLink()) |
1002 | qDebug("Writing doclink did not work"); | 999 | qDebug("Writing doclink did not work"); |
1000 | d->selectedFiles->addToSelection( lnk); | ||
1003 | if(fileDlg) | 1001 | if(fileDlg) |
1004 | delete fileDlg; | 1002 | delete fileDlg; |
1005 | } | 1003 | } |