author | llornkcor <llornkcor> | 2002-12-16 03:24:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-16 03:24:09 (UTC) |
commit | ffefde3701c0aed084872d05710d78b7201efaa8 (patch) (unidiff) | |
tree | 735f2fe5e07792685234b6b84011bdfdb4928365 | |
parent | 64bc40080abc56e6bd804dadb44d2510f25f2efa (diff) | |
download | opie-ffefde3701c0aed084872d05710d78b7201efaa8.zip opie-ffefde3701c0aed084872d05710d78b7201efaa8.tar.gz opie-ffefde3701c0aed084872d05710d78b7201efaa8.tar.bz2 |
fix writng m3u filenames when user specifies a directory
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6e2457f..707f4d2 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -806,61 +806,62 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
806 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 806 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
807 | m3uList->add( d->selectedFiles->current()->file() ); | 807 | m3uList->add( d->selectedFiles->current()->file() ); |
808 | } | 808 | } |
809 | while ( d->selectedFiles->next() ); | 809 | while ( d->selectedFiles->next() ); |
810 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 810 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
811 | m3uList->write(); | 811 | m3uList->write(); |
812 | m3uList->close(); | 812 | m3uList->close(); |
813 | } | 813 | } |
814 | delete m3uList; | 814 | delete m3uList; |
815 | 815 | ||
816 | } | 816 | } |
817 | 817 | ||
818 | /* | 818 | /* |
819 | writes current playlist to m3u file */ | 819 | writes current playlist to m3u file */ |
820 | void PlayListWidget::writem3u() { | 820 | void PlayListWidget::writem3u() { |
821 | InputDialog *fileDlg; | 821 | InputDialog *fileDlg; |
822 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 822 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
823 | fileDlg->exec(); | 823 | fileDlg->exec(); |
824 | QString name, filename, list; | 824 | QString name, filename, list; |
825 | Om3u *m3uList; | 825 | Om3u *m3uList; |
826 | 826 | ||
827 | if( fileDlg->result() == 1 ) { | 827 | if( fileDlg->result() == 1 ) { |
828 | name = fileDlg->text(); | 828 | name = fileDlg->text(); |
829 | // qDebug( filename ); | 829 | // qDebug( filename ); |
830 | 830 | if( name.find("/",0,true) != -1) {// assume they specify a file path | |
831 | if( name.left( 1) != "/" ) { | 831 | filename = name; |
832 | filename = QPEApplication::documentDir() + "/" + name; | 832 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
833 | } | ||
834 | |||
835 | if( name.right( 3 ) != "m3u" ) { | ||
836 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | ||
837 | } | 833 | } |
834 | else //otherwise dump it somewhere noticable | ||
835 | filename = QPEApplication::documentDir() + "/" + name; | ||
838 | 836 | ||
839 | if( d->selectedFiles->first()) { | 837 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
840 | m3uList = new Om3u(filename, IO_ReadWrite); | 838 | filename += ".m3u"; |
839 | |||
840 | if( d->selectedFiles->first()) { //ramble through playlist view | ||
841 | m3uList = new Om3u( filename, IO_ReadWrite); | ||
841 | 842 | ||
842 | do { | 843 | do { |
843 | m3uList->add( d->selectedFiles->current()->file()); | 844 | m3uList->add( d->selectedFiles->current()->file()); |
844 | } | 845 | } |
845 | while ( d->selectedFiles->next() ); | 846 | while ( d->selectedFiles->next() ); |
846 | // qDebug( list ); | 847 | // qDebug( list ); |
847 | m3uList->write(); | 848 | m3uList->write(); |
848 | m3uList->close(); | 849 | m3uList->close(); |
849 | delete m3uList; | 850 | delete m3uList; |
850 | 851 | ||
851 | delete fileDlg; | 852 | delete fileDlg; |
852 | 853 | ||
853 | DocLnk lnk; | 854 | DocLnk lnk; |
854 | lnk.setFile( filename); | 855 | lnk.setFile( filename); |
855 | lnk.setIcon("opieplayer2/playlist2"); | 856 | lnk.setIcon("opieplayer2/playlist2"); |
856 | lnk.setName( name); //sets file name | 857 | lnk.setName( name); //sets file name |
857 | 858 | ||
858 | // qDebug(filename); | 859 | // qDebug(filename); |
859 | Config config( "OpiePlayer" ); | 860 | Config config( "OpiePlayer" ); |
860 | config.setGroup( "PlayList" ); | 861 | config.setGroup( "PlayList" ); |
861 | 862 | ||
862 | config.writeEntry("CurrentPlaylist",filename); | 863 | config.writeEntry("CurrentPlaylist",filename); |
863 | currentPlayList=filename; | 864 | currentPlayList=filename; |
864 | 865 | ||
865 | if(!lnk.writeLink()) { | 866 | if(!lnk.writeLink()) { |
866 | qDebug("Writing doclink did not work"); | 867 | qDebug("Writing doclink did not work"); |