summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 7ada5ee..75c7332 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -664,96 +664,98 @@ void PlayListWidget::populateAudioView() {
664 long size; 664 long size;
665 if( dit.current()->file().left(4) == "http" ) 665 if( dit.current()->file().left(4) == "http" )
666 size=0; 666 size=0;
667 else 667 else
668 size = QFile( dit.current()->file() ).size(); 668 size = QFile( dit.current()->file() ).size();
669 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 669 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
670 QString::number(size ), storage, dit.current()->file()); 670 QString::number(size ), storage, dit.current()->file());
671 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 671 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
672 } 672 }
673 } 673 }
674} 674}
675 675
676 676
677void PlayListWidget::populateVideoView() { 677void PlayListWidget::populateVideoView() {
678 videoView->clear(); 678 videoView->clear();
679 StorageInfo storageInfo; 679 StorageInfo storageInfo;
680 const QList<FileSystem> &fs = storageInfo.fileSystems(); 680 const QList<FileSystem> &fs = storageInfo.fileSystems();
681 681
682 if(!videoScan ) { 682 if(!videoScan ) {
683 scanForVideo(); 683 scanForVideo();
684 } 684 }
685 685
686 QListIterator<DocLnk> Vdit( vFiles.children() ); 686 QListIterator<DocLnk> Vdit( vFiles.children() );
687 QListIterator<FileSystem> it ( fs ); 687 QListIterator<FileSystem> it ( fs );
688 videoView->clear(); 688 videoView->clear();
689 QString storage, pathName; 689 QString storage, pathName;
690 for ( ; Vdit.current(); ++Vdit ) { 690 for ( ; Vdit.current(); ++Vdit ) {
691 for( ; it.current(); ++it ) { 691 for( ; it.current(); ++it ) {
692 const QString name = (*it)->name(); 692 const QString name = (*it)->name();
693 const QString path = (*it)->path(); 693 const QString path = (*it)->path();
694 if( Vdit.current()->file().find(path) != -1 ) { 694 if( Vdit.current()->file().find(path) != -1 ) {
695 storage=name; 695 storage=name;
696 pathName=path; 696 pathName=path;
697 } 697 }
698 } 698 }
699 699
700 QListViewItem * newItem; 700 QListViewItem * newItem;
701 if ( QFile( Vdit.current()->file() ).exists() ) { 701 if ( QFile( Vdit.current()->file() ).exists() ) {
702 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 702 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
703 QString::number( QFile( Vdit.current()->file() ).size() ), 703 QString::number( QFile( Vdit.current()->file() ).size() ),
704 storage, Vdit.current()->file()); 704 storage, Vdit.current()->file());
705 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 705 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
706 } 706 }
707 } 707 }
708} 708}
709 709
710 710
711void PlayListWidget::openFile() { 711void PlayListWidget::openFile() {
712 // http://66.28.164.33:2080
713 // http://somafm.com/star0242.m3u
712 QString filename, name; 714 QString filename, name;
713 InputDialog *fileDlg; 715 InputDialog *fileDlg;
714 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 716 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
715 fileDlg->exec(); 717 fileDlg->exec();
716 if( fileDlg->result() == 1 ) { 718 if( fileDlg->result() == 1 ) {
717 filename = fileDlg->text(); 719 filename = fileDlg->text();
718 qDebug( "Selected filename is " + filename ); 720 qDebug( "Selected filename is " + filename );
719 Om3u *m3uList; 721 Om3u *m3uList;
720 DocLnk lnk; 722 DocLnk lnk;
721 Config cfg( "OpiePlayer" ); 723 Config cfg( "OpiePlayer" );
722 cfg.setGroup("PlayList"); 724 cfg.setGroup("PlayList");
723 725
724 if(filename.left(4) == "http") { 726 if(filename.left(4) == "http") {
725 QString m3uFile, m3uFilePath; 727 QString m3uFile, m3uFilePath;
726 if(filename.find(":",8,TRUE) != -1) { //found a port 728 if(filename.find(":",8,TRUE) != -1) { //found a port
727 m3uFile = filename.left( filename.find( ":",8,TRUE)); 729 m3uFile = filename.left( filename.find( ":",8,TRUE));
728 m3uFile = m3uFile.right( 7); 730 m3uFile = m3uFile.right( 7);
729 } else if(filename.left(4) == "http"){ 731 } else if(filename.left(4) == "http"){
730 m3uFile=filename; 732 m3uFile=filename;
731 m3uFile = m3uFile.right( m3uFile.length() - 7); 733 m3uFile = m3uFile.right( m3uFile.length() - 7);
732 } else{ 734 } else{
733 m3uFile=filename; 735 m3uFile=filename;
734 } 736 }
735 737
736// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 738// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
737 lnk.setName( filename ); //sets name 739 lnk.setName( filename ); //sets name
738 lnk.setFile( filename ); //sets file name 740 lnk.setFile( filename ); //sets file name
739 lnk.setIcon("opieplayer2/musicfile"); 741 lnk.setIcon("opieplayer2/musicfile");
740 d->selectedFiles->addToSelection( lnk ); 742 d->selectedFiles->addToSelection( lnk );
741 writeCurrentM3u(); 743 writeCurrentM3u();
742 } 744 }
743 else if( filename.right( 3) == "m3u" ) { 745 else if( filename.right( 3) == "m3u" ) {
744 readm3u( filename ); 746 readm3u( filename );
745 747
746 } else if( filename.right(3) == "pls" ) { 748 } else if( filename.right(3) == "pls" ) {
747 readPls( filename ); 749 readPls( filename );
748 } else { 750 } else {
749 d->selectedFiles->addToSelection( DocLnk(filename) ); 751 d->selectedFiles->addToSelection( DocLnk(filename) );
750 writeCurrentM3u(); 752 writeCurrentM3u();
751 } 753 }
752 } 754 }
753 755
754 if( fileDlg ) { 756 if( fileDlg ) {
755 delete fileDlg; 757 delete fileDlg;
756 } 758 }
757} 759}
758 760
759/* 761/*
@@ -814,97 +816,97 @@ reads pls and adds files/urls to playlist */
814void PlayListWidget::readPls( const QString &filename ) { 816void PlayListWidget::readPls( const QString &filename ) {
815 817
816 qDebug( "pls filename is " + filename ); 818 qDebug( "pls filename is " + filename );
817 Om3u *m3uList; 819 Om3u *m3uList;
818 QString s, name; 820 QString s, name;
819 m3uList = new Om3u( filename, IO_ReadOnly ); 821 m3uList = new Om3u( filename, IO_ReadOnly );
820 m3uList->readPls(); 822 m3uList->readPls();
821 823
822 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 824 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
823 s = *it; 825 s = *it;
824 // s.replace( QRegExp( "%20" )," " ); 826 // s.replace( QRegExp( "%20" )," " );
825 DocLnk lnk( s ); 827 DocLnk lnk( s );
826 QFileInfo f( s ); 828 QFileInfo f( s );
827 QString name = f.baseName(); 829 QString name = f.baseName();
828 830
829 if( name.left( 4 ) == "http" ) { 831 if( name.left( 4 ) == "http" ) {
830 name = s.right( s.length() - 7); 832 name = s.right( s.length() - 7);
831 } else { 833 } else {
832 name = s; 834 name = s;
833 } 835 }
834 836
835 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 837 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
836 838
837 lnk.setName( name ); 839 lnk.setName( name );
838 if( s.at( s.length() - 4) == '.') {// if this is probably a file 840 if( s.at( s.length() - 4) == '.') {// if this is probably a file
839 lnk.setFile( s ); 841 lnk.setFile( s );
840 } else { //if its a url 842 } else { //if its a url
841 if( name.right( 1 ).find( '/' ) == -1) { 843 if( name.right( 1 ).find( '/' ) == -1) {
842 s += "/"; 844 s += "/";
843 } 845 }
844 lnk.setFile( s ); 846 lnk.setFile( s );
845 } 847 }
846 lnk.setType( "audio/x-mpegurl" ); 848 lnk.setType( "audio/x-mpegurl" );
847 849
848 lnk.writeLink(); 850 lnk.writeLink();
849 d->selectedFiles->addToSelection( lnk ); 851 d->selectedFiles->addToSelection( lnk );
850 } 852 }
851 853
852 m3uList->close(); 854 m3uList->close();
853 if(m3uList) delete m3uList; 855 if(m3uList) delete m3uList;
854} 856}
855 857
856/* 858/*
857 writes current playlist to current m3u file */ 859 writes current playlist to current m3u file */
858void PlayListWidget::writeCurrentM3u() { 860void PlayListWidget::writeCurrentM3u() {
859 qDebug("writing to current m3u"); 861 qDebug("writing to current m3u");
860 Config cfg( "OpiePlayer" ); 862 Config cfg( "OpiePlayer" );
861 cfg.setGroup("PlayList"); 863 cfg.setGroup("PlayList");
862 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 864 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
863 865
864 if( d->selectedFiles->first()) { 866 if( d->selectedFiles->first()) {
865 Om3u *m3uList; 867 Om3u *m3uList;
866 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 868 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
867 869
868 do { 870 do {
869 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 871 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
870 m3uList->add( d->selectedFiles->current()->file() ); 872 m3uList->add( d->selectedFiles->current()->file() );
871 } 873 }
872 while ( d->selectedFiles->next() ); 874 while ( d->selectedFiles->next() );
873 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 875 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
874 m3uList->write(); 876 m3uList->write();
875 m3uList->close(); 877 m3uList->close();
876 878
877 if(m3uList) delete m3uList; 879 if(m3uList) delete m3uList;
878 } 880 }
879} 881}
880 882
881 /* 883 /*
882 writes current playlist to m3u file */ 884 writes current playlist to m3u file */
883void PlayListWidget::writem3u() { 885void PlayListWidget::writem3u() {
884 InputDialog *fileDlg; 886 InputDialog *fileDlg;
885 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 887 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
886 fileDlg->exec(); 888 fileDlg->exec();
887 QString name, filename, list; 889 QString name, filename, list;
888 Om3u *m3uList; 890 Om3u *m3uList;
889 891
890 if( fileDlg->result() == 1 ) { 892 if( fileDlg->result() == 1 ) {
891 name = fileDlg->text(); 893 name = fileDlg->text();
892// qDebug( filename ); 894// qDebug( filename );
893 895
894 if( name.left( 1) != "/" ) { 896 if( name.left( 1) != "/" ) {
895 filename = QPEApplication::documentDir() + "/" + name; 897 filename = QPEApplication::documentDir() + "/" + name;
896 } 898 }
897 899
898 if( name.right( 3 ) != "m3u" ) { 900 if( name.right( 3 ) != "m3u" ) {
899 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 901 filename = QPEApplication::documentDir() + "/" +name+".m3u";
900 } 902 }
901 903
902 if( d->selectedFiles->first()) { 904 if( d->selectedFiles->first()) {
903 m3uList = new Om3u(filename, IO_ReadWrite); 905 m3uList = new Om3u(filename, IO_ReadWrite);
904 906
905 do { 907 do {
906 m3uList->add( d->selectedFiles->current()->file()); 908 m3uList->add( d->selectedFiles->current()->file());
907 } 909 }
908 while ( d->selectedFiles->next() ); 910 while ( d->selectedFiles->next() );
909 // qDebug( list ); 911 // qDebug( list );
910 m3uList->write(); 912 m3uList->write();