author | llornkcor <llornkcor> | 2002-11-14 03:14:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-14 03:14:00 (UTC) |
commit | 5250e8571646f422a0830adcb137df8332ec0fe7 (patch) (unidiff) | |
tree | 6409f4ced4259f37705e4289baedba6ad02e098a | |
parent | 4a60497bd689bd01ca301378f382bff6863b592e (diff) | |
download | opie-5250e8571646f422a0830adcb137df8332ec0fe7.zip opie-5250e8571646f422a0830adcb137df8332ec0fe7.tar.gz opie-5250e8571646f422a0830adcb137df8332ec0fe7.tar.bz2 |
dont try to find media anymore
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6bedb57..16467c0 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -524,441 +524,445 @@ void PlayListWidget::loadList( const DocLnk & lnk) { | |||
524 | clearList(); | 524 | clearList(); |
525 | readm3u(lnk.file()); | 525 | readm3u(lnk.file()); |
526 | tabWidget->setCurrentPage(0); | 526 | tabWidget->setCurrentPage(0); |
527 | } | 527 | } |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | void PlayListWidget::setPlaylist( bool shown ) { | 531 | void PlayListWidget::setPlaylist( bool shown ) { |
532 | if ( shown ) { | 532 | if ( shown ) { |
533 | d->playListFrame->show(); | 533 | d->playListFrame->show(); |
534 | } else { | 534 | } else { |
535 | d->playListFrame->hide(); | 535 | d->playListFrame->hide(); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | void PlayListWidget::addSelected() { | 540 | void PlayListWidget::addSelected() { |
541 | qDebug("addSelected"); | 541 | qDebug("addSelected"); |
542 | DocLnk lnk; | 542 | DocLnk lnk; |
543 | QString filename; | 543 | QString filename; |
544 | switch (whichList()) { | 544 | switch (whichList()) { |
545 | 545 | ||
546 | case 0: //playlist | 546 | case 0: //playlist |
547 | return; | 547 | return; |
548 | break; | 548 | break; |
549 | case 1: { //audio | 549 | case 1: { //audio |
550 | filename=audioView->currentItem()->text(3); | 550 | filename=audioView->currentItem()->text(3); |
551 | // d->selectedFiles->next(); | 551 | // d->selectedFiles->next(); |
552 | } | 552 | } |
553 | break; | 553 | break; |
554 | 554 | ||
555 | case 2: { // video | 555 | case 2: { // video |
556 | filename=videoView->currentItem()->text(3); | 556 | filename=videoView->currentItem()->text(3); |
557 | // tabWidget->setCurrentPage(0); | 557 | // tabWidget->setCurrentPage(0); |
558 | 558 | ||
559 | } | 559 | } |
560 | break; | 560 | break; |
561 | }; | 561 | }; |
562 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 562 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
563 | lnk.setFile( filename ); //sets file name | 563 | lnk.setFile( filename ); //sets file name |
564 | d->selectedFiles->addToSelection( lnk); | 564 | d->selectedFiles->addToSelection( lnk); |
565 | tabWidget->setCurrentPage(0); | 565 | tabWidget->setCurrentPage(0); |
566 | writeCurrentM3u(); | 566 | writeCurrentM3u(); |
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | void PlayListWidget::removeSelected() { | 570 | void PlayListWidget::removeSelected() { |
571 | d->selectedFiles->removeSelected( ); | 571 | d->selectedFiles->removeSelected( ); |
572 | writeCurrentM3u(); | 572 | writeCurrentM3u(); |
573 | } | 573 | } |
574 | 574 | ||
575 | 575 | ||
576 | void PlayListWidget::playIt( QListViewItem *it) { | 576 | void PlayListWidget::playIt( QListViewItem *it) { |
577 | if(!it) return; | 577 | if(!it) return; |
578 | mediaPlayerState->setPlaying(FALSE); | 578 | mediaPlayerState->setPlaying(FALSE); |
579 | mediaPlayerState->setPlaying(TRUE); | 579 | mediaPlayerState->setPlaying(TRUE); |
580 | d->selectedFiles->unSelect(); | 580 | d->selectedFiles->unSelect(); |
581 | } | 581 | } |
582 | 582 | ||
583 | 583 | ||
584 | void PlayListWidget::addToSelection( QListViewItem *it) { | 584 | void PlayListWidget::addToSelection( QListViewItem *it) { |
585 | d->setDocumentUsed = FALSE; | 585 | d->setDocumentUsed = FALSE; |
586 | 586 | ||
587 | if(it) { | 587 | if(it) { |
588 | switch ( whichList()) { | 588 | switch ( whichList()) { |
589 | case 0: //playlist | 589 | case 0: //playlist |
590 | return; | 590 | return; |
591 | break; | 591 | break; |
592 | }; | 592 | }; |
593 | // case 1: { | 593 | // case 1: { |
594 | DocLnk lnk; | 594 | DocLnk lnk; |
595 | QString filename; | 595 | QString filename; |
596 | 596 | ||
597 | filename=it->text(3); | 597 | filename=it->text(3); |
598 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 598 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
599 | lnk.setFile( filename ); //sets file name | 599 | lnk.setFile( filename ); //sets file name |
600 | d->selectedFiles->addToSelection( lnk); | 600 | d->selectedFiles->addToSelection( lnk); |
601 | 601 | ||
602 | writeCurrentM3u(); | 602 | writeCurrentM3u(); |
603 | tabWidget->setCurrentPage(0); | 603 | tabWidget->setCurrentPage(0); |
604 | 604 | ||
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
609 | void PlayListWidget::tabChanged(QWidget *) { | 609 | void PlayListWidget::tabChanged(QWidget *) { |
610 | 610 | ||
611 | switch ( whichList()) { | 611 | switch ( whichList()) { |
612 | case 0: | 612 | case 0: |
613 | { | 613 | { |
614 | if( !tbDeletePlaylist->isHidden() ) { | 614 | if( !tbDeletePlaylist->isHidden() ) { |
615 | tbDeletePlaylist->hide(); | 615 | tbDeletePlaylist->hide(); |
616 | } | 616 | } |
617 | d->tbRemoveFromList->setEnabled(TRUE); | 617 | d->tbRemoveFromList->setEnabled(TRUE); |
618 | d->tbAddToList->setEnabled(FALSE); | 618 | d->tbAddToList->setEnabled(FALSE); |
619 | } | 619 | } |
620 | break; | 620 | break; |
621 | case 1: | 621 | case 1: |
622 | { | 622 | { |
623 | // audioView->clear(); | 623 | // audioView->clear(); |
624 | if(!audioPopulated) populateAudioView(); | 624 | if(!audioPopulated) populateAudioView(); |
625 | 625 | ||
626 | if( !tbDeletePlaylist->isHidden() ) { | 626 | if( !tbDeletePlaylist->isHidden() ) { |
627 | tbDeletePlaylist->hide(); | 627 | tbDeletePlaylist->hide(); |
628 | } | 628 | } |
629 | d->tbRemoveFromList->setEnabled(FALSE); | 629 | d->tbRemoveFromList->setEnabled(FALSE); |
630 | d->tbAddToList->setEnabled(TRUE); | 630 | d->tbAddToList->setEnabled(TRUE); |
631 | } | 631 | } |
632 | break; | 632 | break; |
633 | case 2: | 633 | case 2: |
634 | { | 634 | { |
635 | // videoView->clear(); | 635 | // videoView->clear(); |
636 | if(!videoPopulated) populateVideoView(); | 636 | if(!videoPopulated) populateVideoView(); |
637 | if( !tbDeletePlaylist->isHidden() ) { | 637 | if( !tbDeletePlaylist->isHidden() ) { |
638 | tbDeletePlaylist->hide(); | 638 | tbDeletePlaylist->hide(); |
639 | } | 639 | } |
640 | d->tbRemoveFromList->setEnabled(FALSE); | 640 | d->tbRemoveFromList->setEnabled(FALSE); |
641 | d->tbAddToList->setEnabled(TRUE); | 641 | d->tbAddToList->setEnabled(TRUE); |
642 | } | 642 | } |
643 | break; | 643 | break; |
644 | case 3: | 644 | case 3: |
645 | { | 645 | { |
646 | if( tbDeletePlaylist->isHidden() ) { | 646 | if( tbDeletePlaylist->isHidden() ) { |
647 | tbDeletePlaylist->show(); | 647 | tbDeletePlaylist->show(); |
648 | } | 648 | } |
649 | playLists->reread(); | 649 | playLists->reread(); |
650 | } | 650 | } |
651 | break; | 651 | break; |
652 | }; | 652 | }; |
653 | } | 653 | } |
654 | 654 | ||
655 | 655 | ||
656 | void PlayListWidget::btnPlay(bool b) { | 656 | void PlayListWidget::btnPlay(bool b) { |
657 | // mediaPlayerState->setPlaying(false); | 657 | // mediaPlayerState->setPlaying(false); |
658 | mediaPlayerState->setPlaying(b); | 658 | mediaPlayerState->setPlaying(b); |
659 | insanityBool=FALSE; | 659 | insanityBool=FALSE; |
660 | } | 660 | } |
661 | 661 | ||
662 | void PlayListWidget::deletePlaylist() { | 662 | void PlayListWidget::deletePlaylist() { |
663 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 663 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
664 | (tr("You really want to delete\nthis playlist?")), | 664 | (tr("You really want to delete\nthis playlist?")), |
665 | (tr("Yes")), (tr("No")), 0 )){ | 665 | (tr("Yes")), (tr("No")), 0 )){ |
666 | case 0: // Yes clicked, | 666 | case 0: // Yes clicked, |
667 | QFile().remove(playLists->selectedDocument().file()); | 667 | QFile().remove(playLists->selectedDocument().file()); |
668 | QFile().remove(playLists->selectedDocument().linkFile()); | 668 | QFile().remove(playLists->selectedDocument().linkFile()); |
669 | playLists->reread(); | 669 | playLists->reread(); |
670 | break; | 670 | break; |
671 | case 1: // Cancel | 671 | case 1: // Cancel |
672 | break; | 672 | break; |
673 | }; | 673 | }; |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void PlayListWidget::playSelected() { | 677 | void PlayListWidget::playSelected() { |
678 | btnPlay( TRUE); | 678 | btnPlay( TRUE); |
679 | } | 679 | } |
680 | 680 | ||
681 | 681 | ||
682 | void PlayListWidget::scanForAudio() { | 682 | void PlayListWidget::scanForAudio() { |
683 | // qDebug("scan for audio"); | 683 | // qDebug("scan for audio"); |
684 | files.detachChildren(); | 684 | files.detachChildren(); |
685 | QListIterator<DocLnk> sdit( files.children() ); | 685 | QListIterator<DocLnk> sdit( files.children() ); |
686 | for ( ; sdit.current(); ++sdit ) { | 686 | for ( ; sdit.current(); ++sdit ) { |
687 | delete sdit.current(); | 687 | delete sdit.current(); |
688 | } | 688 | } |
689 | // Global::findDocuments( &files, "audio/*"); | 689 | // Global::findDocuments( &files, "audio/*"); |
690 | Global::findDocuments( &files, audioMimes); | 690 | Global::findDocuments( &files, audioMimes); |
691 | audioScan = true; | 691 | audioScan = true; |
692 | populateAudioView(); | 692 | populateAudioView(); |
693 | } | 693 | } |
694 | 694 | ||
695 | void PlayListWidget::scanForVideo() { | 695 | void PlayListWidget::scanForVideo() { |
696 | // qDebug("scan for video"); | 696 | // qDebug("scan for video"); |
697 | vFiles.detachChildren(); | 697 | vFiles.detachChildren(); |
698 | QListIterator<DocLnk> sdit( vFiles.children() ); | 698 | QListIterator<DocLnk> sdit( vFiles.children() ); |
699 | for ( ; sdit.current(); ++sdit ) { | 699 | for ( ; sdit.current(); ++sdit ) { |
700 | delete sdit.current(); | 700 | delete sdit.current(); |
701 | } | 701 | } |
702 | Global::findDocuments(&vFiles, "video/*"); | 702 | Global::findDocuments(&vFiles, "video/*"); |
703 | videoScan = true; | 703 | videoScan = true; |
704 | populateVideoView(); | 704 | populateVideoView(); |
705 | } | 705 | } |
706 | 706 | ||
707 | void PlayListWidget::populateAudioView() { | 707 | void PlayListWidget::populateAudioView() { |
708 | audioView->clear(); | 708 | audioView->clear(); |
709 | StorageInfo storageInfo; | 709 | StorageInfo storageInfo; |
710 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 710 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
711 | if(!audioScan) { | 711 | if(!audioScan) { |
712 | scanForAudio(); | 712 | scanForAudio(); |
713 | } | 713 | } |
714 | 714 | ||
715 | QListIterator<DocLnk> dit( files.children() ); | 715 | QListIterator<DocLnk> dit( files.children() ); |
716 | QListIterator<FileSystem> it ( fs ); | 716 | // QListIterator<FileSystem> it ( fs ); |
717 | audioView->clear(); | ||
717 | 718 | ||
718 | QString storage; | 719 | QString storage; |
719 | for ( ; dit.current(); ++dit ) { | 720 | for ( ; dit.current(); ++dit ) { |
720 | for( ; it.current(); ++it ){ | 721 | // // for( ; it.current(); ++it ){ |
721 | const QString name = (*it)->name(); | 722 | // const QString name = (*dit)->name(); |
722 | const QString path = (*it)->path(); | 723 | // const QString path = (*dit)->path(); |
723 | if(dit.current()->file().find(path) != -1 ) { | 724 | // if(dit.current()->file().find(path) != -1 ) { |
724 | storage = name; | 725 | // storage = name; |
725 | } | 726 | // // } |
726 | } | 727 | // } |
727 | 728 | ||
728 | QListViewItem * newItem; | 729 | QListViewItem * newItem; |
729 | if ( QFile( dit.current()->file()).exists() || | 730 | if ( QFile( dit.current()->file()).exists() || |
730 | dit.current()->file().left(4) == "http" ) { | 731 | dit.current()->file().left(4) == "http" ) { |
731 | long size; | 732 | long size; |
732 | if( dit.current()->file().left(4) == "http" ) | 733 | if( dit.current()->file().left(4) == "http" ) |
733 | size=0; | 734 | size=0; |
734 | else | 735 | else |
735 | size = QFile( dit.current()->file() ).size(); | 736 | size = QFile( dit.current()->file() ).size(); |
737 | |||
736 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 738 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
737 | QString::number(size ), storage, dit.current()->file()); | 739 | QString::number(size ), "" /*storage*/, |
740 | dit.current()->file() ); | ||
738 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 741 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
739 | } | 742 | // qDebug("<<<< "+dit.current()->file()); |
743 | } | ||
740 | } | 744 | } |
741 | audioPopulated=true; | 745 | audioPopulated=true; |
742 | } | 746 | } |
743 | 747 | ||
744 | 748 | ||
745 | void PlayListWidget::populateVideoView() { | 749 | void PlayListWidget::populateVideoView() { |
746 | videoView->clear(); | 750 | videoView->clear(); |
747 | StorageInfo storageInfo; | 751 | StorageInfo storageInfo; |
748 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 752 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
749 | 753 | ||
750 | if(!videoScan ) { | 754 | if(!videoScan ) { |
751 | scanForVideo(); | 755 | scanForVideo(); |
752 | } | 756 | } |
753 | 757 | ||
754 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 758 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
755 | QListIterator<FileSystem> it ( fs ); | 759 | // QListIterator<FileSystem> it ( fs ); |
756 | videoView->clear(); | 760 | videoView->clear(); |
757 | QString storage, pathName; | 761 | QString storage, pathName; |
758 | for ( ; Vdit.current(); ++Vdit ) { | 762 | for ( ; Vdit.current(); ++Vdit ) { |
759 | for( ; it.current(); ++it ) { | 763 | // // for( ; it.current(); ++it ) { |
760 | const QString name = (*it)->name(); | 764 | // const QString name = (*Vdit)->name(); |
761 | const QString path = (*it)->path(); | 765 | // const QString path = (*Vdit)->path(); |
762 | if( Vdit.current()->file().find(path) != -1 ) { | 766 | // if( Vdit.current()->file().find(path) != -1 ) { |
763 | storage=name; | 767 | // storage=name; |
764 | pathName=path; | 768 | // pathName=path; |
765 | } | 769 | // // } |
766 | } | 770 | // } |
767 | 771 | ||
768 | QListViewItem * newItem; | 772 | QListViewItem * newItem; |
769 | if ( QFile( Vdit.current()->file() ).exists() ) { | 773 | if ( QFile( Vdit.current()->file() ).exists() ) { |
770 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 774 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
771 | QString::number( QFile( Vdit.current()->file() ).size() ), | 775 | QString::number( QFile( Vdit.current()->file() ).size() ), |
772 | storage, Vdit.current()->file()); | 776 | ""/*storage*/, Vdit.current()->file()); |
773 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 777 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
774 | } | 778 | } |
775 | } | 779 | } |
776 | videoPopulated=true; | 780 | videoPopulated=true; |
777 | } | 781 | } |
778 | 782 | ||
779 | 783 | ||
780 | void PlayListWidget::openFile() { | 784 | void PlayListWidget::openFile() { |
781 | // http://66.28.164.33:2080 | 785 | // http://66.28.164.33:2080 |
782 | // http://somafm.com/star0242.m3u | 786 | // http://somafm.com/star0242.m3u |
783 | QString filename, name; | 787 | QString filename, name; |
784 | InputDialog *fileDlg; | 788 | InputDialog *fileDlg; |
785 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 789 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
786 | fileDlg->exec(); | 790 | fileDlg->exec(); |
787 | if( fileDlg->result() == 1 ) { | 791 | if( fileDlg->result() == 1 ) { |
788 | filename = fileDlg->text(); | 792 | filename = fileDlg->text(); |
789 | qDebug( "Selected filename is " + filename ); | 793 | qDebug( "Selected filename is " + filename ); |
790 | Om3u *m3uList; | 794 | Om3u *m3uList; |
791 | DocLnk lnk; | 795 | DocLnk lnk; |
792 | Config cfg( "OpiePlayer" ); | 796 | Config cfg( "OpiePlayer" ); |
793 | cfg.setGroup("PlayList"); | 797 | cfg.setGroup("PlayList"); |
794 | 798 | ||
795 | if(filename.left(4) == "http") { | 799 | if(filename.left(4) == "http") { |
796 | QString m3uFile, m3uFilePath; | 800 | QString m3uFile, m3uFilePath; |
797 | if(filename.find(":",8,TRUE) != -1) { //found a port | 801 | if(filename.find(":",8,TRUE) != -1) { //found a port |
798 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 802 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
799 | m3uFile = m3uFile.right( 7); | 803 | m3uFile = m3uFile.right( 7); |
800 | } else if(filename.left(4) == "http"){ | 804 | } else if(filename.left(4) == "http"){ |
801 | m3uFile=filename; | 805 | m3uFile=filename; |
802 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 806 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
803 | } else{ | 807 | } else{ |
804 | m3uFile=filename; | 808 | m3uFile=filename; |
805 | } | 809 | } |
806 | 810 | ||
807 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 811 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
808 | lnk.setName( filename ); //sets name | 812 | lnk.setName( filename ); //sets name |
809 | lnk.setFile( filename ); //sets file name | 813 | lnk.setFile( filename ); //sets file name |
810 | 814 | ||
811 | // lnk.setIcon("opieplayer2/musicfile"); | 815 | // lnk.setIcon("opieplayer2/musicfile"); |
812 | 816 | ||
813 | d->selectedFiles->addToSelection( lnk ); | 817 | d->selectedFiles->addToSelection( lnk ); |
814 | writeCurrentM3u(); | 818 | writeCurrentM3u(); |
815 | d->selectedFiles->setSelectedItem( lnk.name()); | 819 | d->selectedFiles->setSelectedItem( lnk.name()); |
816 | } | 820 | } |
817 | else if( filename.right( 3) == "m3u" ) { | 821 | else if( filename.right( 3) == "m3u" ) { |
818 | readm3u( filename ); | 822 | readm3u( filename ); |
819 | 823 | ||
820 | } else if( filename.right(3) == "pls" ) { | 824 | } else if( filename.right(3) == "pls" ) { |
821 | readPls( filename ); | 825 | readPls( filename ); |
822 | } else { | 826 | } else { |
823 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 827 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
824 | lnk.setFile( filename ); //sets file name | 828 | lnk.setFile( filename ); //sets file name |
825 | d->selectedFiles->addToSelection( lnk); | 829 | d->selectedFiles->addToSelection( lnk); |
826 | writeCurrentM3u(); | 830 | writeCurrentM3u(); |
827 | d->selectedFiles->setSelectedItem( lnk.name()); | 831 | d->selectedFiles->setSelectedItem( lnk.name()); |
828 | } | 832 | } |
829 | } | 833 | } |
830 | 834 | ||
831 | if( fileDlg ) { | 835 | if( fileDlg ) { |
832 | delete fileDlg; | 836 | delete fileDlg; |
833 | } | 837 | } |
834 | } | 838 | } |
835 | 839 | ||
836 | /* | 840 | /* |
837 | reads m3u and shows files/urls to playlist widget */ | 841 | reads m3u and shows files/urls to playlist widget */ |
838 | void PlayListWidget::readm3u( const QString &filename ) { | 842 | void PlayListWidget::readm3u( const QString &filename ) { |
839 | qDebug( "read m3u filename " + filename ); | 843 | qDebug( "read m3u filename " + filename ); |
840 | 844 | ||
841 | Om3u *m3uList; | 845 | Om3u *m3uList; |
842 | QString s, name; | 846 | QString s, name; |
843 | m3uList = new Om3u( filename, IO_ReadOnly ); | 847 | m3uList = new Om3u( filename, IO_ReadOnly ); |
844 | m3uList->readM3u(); | 848 | m3uList->readM3u(); |
845 | DocLnk lnk; | 849 | DocLnk lnk; |
846 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 850 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
847 | s = *it; | 851 | s = *it; |
848 | // qDebug("reading "+ s); | 852 | // qDebug("reading "+ s); |
849 | if(s.left(4)=="http") { | 853 | if(s.left(4)=="http") { |
850 | lnk.setName( s ); //sets file name | 854 | lnk.setName( s ); //sets file name |
851 | lnk.setIcon("opieplayer2/musicfile"); | 855 | lnk.setIcon("opieplayer2/musicfile"); |
852 | lnk.setFile( s ); //sets file name | 856 | lnk.setFile( s ); //sets file name |
853 | 857 | ||
854 | } else { | 858 | } else { |
855 | // if( QFileInfo( s ).exists() ) { | 859 | // if( QFileInfo( s ).exists() ) { |
856 | lnk.setName( QFileInfo(s).baseName()); | 860 | lnk.setName( QFileInfo(s).baseName()); |
857 | // if(s.right(4) == '.') {//if regular file | 861 | // if(s.right(4) == '.') {//if regular file |
858 | if(s.left(1) != "/") { | 862 | if(s.left(1) != "/") { |
859 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 863 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
860 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 864 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
861 | // lnk.setIcon(MimeType(s).pixmap() ); | 865 | // lnk.setIcon(MimeType(s).pixmap() ); |
862 | // lnk.setIcon("SoundPlayer"); | 866 | // lnk.setIcon("SoundPlayer"); |
863 | } else { | 867 | } else { |
864 | // qDebug("set link2 "+s); | 868 | // qDebug("set link2 "+s); |
865 | lnk.setFile( s); | 869 | lnk.setFile( s); |
866 | // lnk.setIcon(MimeType(s).pixmap() ); | 870 | // lnk.setIcon(MimeType(s).pixmap() ); |
867 | // lnk.setIcon("SoundPlayer"); | 871 | // lnk.setIcon("SoundPlayer"); |
868 | } | 872 | } |
869 | } | 873 | } |
870 | d->selectedFiles->addToSelection( lnk ); | 874 | d->selectedFiles->addToSelection( lnk ); |
871 | } | 875 | } |
872 | Config config( "OpiePlayer" ); | 876 | Config config( "OpiePlayer" ); |
873 | config.setGroup( "PlayList" ); | 877 | config.setGroup( "PlayList" ); |
874 | 878 | ||
875 | config.writeEntry("CurrentPlaylist",filename); | 879 | config.writeEntry("CurrentPlaylist",filename); |
876 | config.write(); | 880 | config.write(); |
877 | currentPlayList=filename; | 881 | currentPlayList=filename; |
878 | 882 | ||
879 | // m3uList->write(); | 883 | // m3uList->write(); |
880 | m3uList->close(); | 884 | m3uList->close(); |
881 | if(m3uList) delete m3uList; | 885 | if(m3uList) delete m3uList; |
882 | 886 | ||
883 | d->selectedFiles->setSelectedItem( s); | 887 | d->selectedFiles->setSelectedItem( s); |
884 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 888 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
885 | 889 | ||
886 | } | 890 | } |
887 | 891 | ||
888 | /* | 892 | /* |
889 | reads pls and adds files/urls to playlist */ | 893 | reads pls and adds files/urls to playlist */ |
890 | void PlayListWidget::readPls( const QString &filename ) { | 894 | void PlayListWidget::readPls( const QString &filename ) { |
891 | 895 | ||
892 | qDebug( "pls filename is " + filename ); | 896 | qDebug( "pls filename is " + filename ); |
893 | Om3u *m3uList; | 897 | Om3u *m3uList; |
894 | QString s, name; | 898 | QString s, name; |
895 | m3uList = new Om3u( filename, IO_ReadOnly ); | 899 | m3uList = new Om3u( filename, IO_ReadOnly ); |
896 | m3uList->readPls(); | 900 | m3uList->readPls(); |
897 | 901 | ||
898 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 902 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
899 | s = *it; | 903 | s = *it; |
900 | // s.replace( QRegExp( "%20" )," " ); | 904 | // s.replace( QRegExp( "%20" )," " ); |
901 | DocLnk lnk( s ); | 905 | DocLnk lnk( s ); |
902 | QFileInfo f( s ); | 906 | QFileInfo f( s ); |
903 | QString name = f.baseName(); | 907 | QString name = f.baseName(); |
904 | 908 | ||
905 | if( name.left( 4 ) == "http" ) { | 909 | if( name.left( 4 ) == "http" ) { |
906 | name = s.right( s.length() - 7); | 910 | name = s.right( s.length() - 7); |
907 | } else { | 911 | } else { |
908 | name = s; | 912 | name = s; |
909 | } | 913 | } |
910 | 914 | ||
911 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 915 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
912 | 916 | ||
913 | lnk.setName( name ); | 917 | lnk.setName( name ); |
914 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 918 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
915 | lnk.setFile( s ); | 919 | lnk.setFile( s ); |
916 | } else { //if its a url | 920 | } else { //if its a url |
917 | // if( name.right( 1 ).find( '/' ) == -1) { | 921 | // if( name.right( 1 ).find( '/' ) == -1) { |
918 | // s += "/"; | 922 | // s += "/"; |
919 | // } | 923 | // } |
920 | lnk.setFile( s ); | 924 | lnk.setFile( s ); |
921 | } | 925 | } |
922 | lnk.setType( "audio/x-mpegurl" ); | 926 | lnk.setType( "audio/x-mpegurl" ); |
923 | 927 | ||
924 | lnk.writeLink(); | 928 | lnk.writeLink(); |
925 | d->selectedFiles->addToSelection( lnk ); | 929 | d->selectedFiles->addToSelection( lnk ); |
926 | } | 930 | } |
927 | 931 | ||
928 | m3uList->close(); | 932 | m3uList->close(); |
929 | if(m3uList) delete m3uList; | 933 | if(m3uList) delete m3uList; |
930 | } | 934 | } |
931 | 935 | ||
932 | /* | 936 | /* |
933 | writes current playlist to current m3u file */ | 937 | writes current playlist to current m3u file */ |
934 | void PlayListWidget::writeCurrentM3u() { | 938 | void PlayListWidget::writeCurrentM3u() { |
935 | qDebug("writing to current m3u"); | 939 | qDebug("writing to current m3u"); |
936 | Config cfg( "OpiePlayer" ); | 940 | Config cfg( "OpiePlayer" ); |
937 | cfg.setGroup("PlayList"); | 941 | cfg.setGroup("PlayList"); |
938 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 942 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
939 | 943 | ||
940 | Om3u *m3uList; | 944 | Om3u *m3uList; |
941 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 945 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
942 | if( d->selectedFiles->first()) { | 946 | if( d->selectedFiles->first()) { |
943 | 947 | ||
944 | do { | 948 | do { |
945 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 949 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
946 | m3uList->add( d->selectedFiles->current()->file() ); | 950 | m3uList->add( d->selectedFiles->current()->file() ); |
947 | } | 951 | } |
948 | while ( d->selectedFiles->next() ); | 952 | while ( d->selectedFiles->next() ); |
949 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 953 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
950 | m3uList->write(); | 954 | m3uList->write(); |
951 | m3uList->close(); | 955 | m3uList->close(); |
952 | 956 | ||
953 | if(m3uList) delete m3uList; | 957 | if(m3uList) delete m3uList; |
954 | } | 958 | } |
955 | 959 | ||
956 | } | 960 | } |
957 | 961 | ||
958 | /* | 962 | /* |
959 | writes current playlist to m3u file */ | 963 | writes current playlist to m3u file */ |
960 | void PlayListWidget::writem3u() { | 964 | void PlayListWidget::writem3u() { |
961 | InputDialog *fileDlg; | 965 | InputDialog *fileDlg; |
962 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 966 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
963 | fileDlg->exec(); | 967 | fileDlg->exec(); |
964 | QString name, filename, list; | 968 | QString name, filename, list; |