-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 17 |
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 ) { m3uList->readPls(); for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { s = *it; // s.replace( QRegExp( "%20" )," " ); DocLnk lnk( s ); QFileInfo f( s ); QString name = f.baseName(); if( name.left( 4 ) == "http" ) { name = s.right( s.length() - 7); } else { name = s; } name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); lnk.setName( name ); if( s.at( s.length() - 4) == '.') {// if this is probably a file lnk.setFile( s ); } else { //if its a url // if( name.right( 1 ).find( '/' ) == -1) { // s += "/"; // } lnk.setFile( s ); } lnk.setType( "audio/x-mpegurl" ); lnk.writeLink(); d->selectedFiles->addToSelection( lnk ); } m3uList->close(); delete m3uList; } /* writes current playlist to current m3u file */ void PlayListWidget::writeCurrentM3u() { qDebug("writing to current m3u"); Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); Om3u *m3uList; m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); if( d->selectedFiles->first()) { - do { - // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); - m3uList->add( d->selectedFiles->current()->file() ); + do { + // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); + m3uList->add( d->selectedFiles->current()->file() ); + } + while ( d->selectedFiles->next() ); + // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); + m3uList->write(); + m3uList->close(); } - while ( d->selectedFiles->next() ); - // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); - m3uList->write(); - m3uList->close(); - delete m3uList; - } } /* writes current playlist to m3u file */ void PlayListWidget::writem3u() { InputDialog *fileDlg; fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); fileDlg->exec(); QString name, filename, list; Om3u *m3uList; if( fileDlg->result() == 1 ) { name = fileDlg->text(); // qDebug( filename ); if( name.left( 1) != "/" ) { filename = QPEApplication::documentDir() + "/" + name; } if( name.right( 3 ) != "m3u" ) { filename = QPEApplication::documentDir() + "/" +name+".m3u"; } if( d->selectedFiles->first()) { m3uList = new Om3u(filename, IO_ReadWrite); do { m3uList->add( d->selectedFiles->current()->file()); } while ( d->selectedFiles->next() ); // qDebug( list ); m3uList->write(); m3uList->close(); delete m3uList; delete fileDlg; DocLnk lnk; lnk.setFile( filename); lnk.setIcon("opieplayer2/playlist2"); lnk.setName( name); //sets file name // qDebug(filename); Config config( "OpiePlayer" ); config.setGroup( "PlayList" ); config.writeEntry("CurrentPlaylist",filename); |