summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-05 19:13:57 (UTC)
committer simon <simon>2002-12-05 19:13:57 (UTC)
commit15d4d1f2fc8b37d30694acc5765a822718af6c13 (patch) (unidiff)
tree53769a23884812cf009f48271fbb02bc55531754
parent4b77aaa27305f0ec120aa6ec4d860f62b7fa7a3f (diff)
downloadopie-15d4d1f2fc8b37d30694acc5765a822718af6c13.zip
opie-15d4d1f2fc8b37d30694acc5765a822718af6c13.tar.gz
opie-15d4d1f2fc8b37d30694acc5765a822718af6c13.tar.bz2
- fixed a minor memory leak
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index ac52b07..2df7f27 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -750,107 +750,106 @@ void PlayListWidget::readPls( const QString &filename ) {
750 m3uList->readPls(); 750 m3uList->readPls();
751 751
752 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 752 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
753 s = *it; 753 s = *it;
754 // s.replace( QRegExp( "%20" )," " ); 754 // s.replace( QRegExp( "%20" )," " );
755 DocLnk lnk( s ); 755 DocLnk lnk( s );
756 QFileInfo f( s ); 756 QFileInfo f( s );
757 QString name = f.baseName(); 757 QString name = f.baseName();
758 758
759 if( name.left( 4 ) == "http" ) { 759 if( name.left( 4 ) == "http" ) {
760 name = s.right( s.length() - 7); 760 name = s.right( s.length() - 7);
761 } else { 761 } else {
762 name = s; 762 name = s;
763 } 763 }
764 764
765 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 765 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
766 766
767 lnk.setName( name ); 767 lnk.setName( name );
768 if( s.at( s.length() - 4) == '.') {// if this is probably a file 768 if( s.at( s.length() - 4) == '.') {// if this is probably a file
769 lnk.setFile( s ); 769 lnk.setFile( s );
770 } else { //if its a url 770 } else { //if its a url
771// if( name.right( 1 ).find( '/' ) == -1) { 771// if( name.right( 1 ).find( '/' ) == -1) {
772// s += "/"; 772// s += "/";
773// } 773// }
774 lnk.setFile( s ); 774 lnk.setFile( s );
775 } 775 }
776 lnk.setType( "audio/x-mpegurl" ); 776 lnk.setType( "audio/x-mpegurl" );
777 777
778 lnk.writeLink(); 778 lnk.writeLink();
779 d->selectedFiles->addToSelection( lnk ); 779 d->selectedFiles->addToSelection( lnk );
780 } 780 }
781 781
782 m3uList->close(); 782 m3uList->close();
783 delete m3uList; 783 delete m3uList;
784} 784}
785 785
786/* 786/*
787 writes current playlist to current m3u file */ 787 writes current playlist to current m3u file */
788void PlayListWidget::writeCurrentM3u() { 788void PlayListWidget::writeCurrentM3u() {
789 qDebug("writing to current m3u"); 789 qDebug("writing to current m3u");
790 Config cfg( "OpiePlayer" ); 790 Config cfg( "OpiePlayer" );
791 cfg.setGroup("PlayList"); 791 cfg.setGroup("PlayList");
792 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 792 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
793 793
794 Om3u *m3uList; 794 Om3u *m3uList;
795 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 795 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
796 if( d->selectedFiles->first()) { 796 if( d->selectedFiles->first()) {
797 797
798 do { 798 do {
799 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 799 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
800 m3uList->add( d->selectedFiles->current()->file() ); 800 m3uList->add( d->selectedFiles->current()->file() );
801 }
802 while ( d->selectedFiles->next() );
803 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
804 m3uList->write();
805 m3uList->close();
801 } 806 }
802 while ( d->selectedFiles->next() );
803 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
804 m3uList->write();
805 m3uList->close();
806
807 delete m3uList; 807 delete m3uList;
808 }
809 808
810} 809}
811 810
812 /* 811 /*
813 writes current playlist to m3u file */ 812 writes current playlist to m3u file */
814void PlayListWidget::writem3u() { 813void PlayListWidget::writem3u() {
815 InputDialog *fileDlg; 814 InputDialog *fileDlg;
816 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 815 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
817 fileDlg->exec(); 816 fileDlg->exec();
818 QString name, filename, list; 817 QString name, filename, list;
819 Om3u *m3uList; 818 Om3u *m3uList;
820 819
821 if( fileDlg->result() == 1 ) { 820 if( fileDlg->result() == 1 ) {
822 name = fileDlg->text(); 821 name = fileDlg->text();
823// qDebug( filename ); 822// qDebug( filename );
824 823
825 if( name.left( 1) != "/" ) { 824 if( name.left( 1) != "/" ) {
826 filename = QPEApplication::documentDir() + "/" + name; 825 filename = QPEApplication::documentDir() + "/" + name;
827 } 826 }
828 827
829 if( name.right( 3 ) != "m3u" ) { 828 if( name.right( 3 ) != "m3u" ) {
830 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 829 filename = QPEApplication::documentDir() + "/" +name+".m3u";
831 } 830 }
832 831
833 if( d->selectedFiles->first()) { 832 if( d->selectedFiles->first()) {
834 m3uList = new Om3u(filename, IO_ReadWrite); 833 m3uList = new Om3u(filename, IO_ReadWrite);
835 834
836 do { 835 do {
837 m3uList->add( d->selectedFiles->current()->file()); 836 m3uList->add( d->selectedFiles->current()->file());
838 } 837 }
839 while ( d->selectedFiles->next() ); 838 while ( d->selectedFiles->next() );
840 // qDebug( list ); 839 // qDebug( list );
841 m3uList->write(); 840 m3uList->write();
842 m3uList->close(); 841 m3uList->close();
843 delete m3uList; 842 delete m3uList;
844 843
845 delete fileDlg; 844 delete fileDlg;
846 845
847 DocLnk lnk; 846 DocLnk lnk;
848 lnk.setFile( filename); 847 lnk.setFile( filename);
849 lnk.setIcon("opieplayer2/playlist2"); 848 lnk.setIcon("opieplayer2/playlist2");
850 lnk.setName( name); //sets file name 849 lnk.setName( name); //sets file name
851 850
852 // qDebug(filename); 851 // qDebug(filename);
853 Config config( "OpiePlayer" ); 852 Config config( "OpiePlayer" );
854 config.setGroup( "PlayList" ); 853 config.setGroup( "PlayList" );
855 854
856 config.writeEntry("CurrentPlaylist",filename); 855 config.writeEntry("CurrentPlaylist",filename);