summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-16 03:24:09 (UTC)
committer llornkcor <llornkcor>2002-12-16 03:24:09 (UTC)
commitffefde3701c0aed084872d05710d78b7201efaa8 (patch) (side-by-side diff)
tree735f2fe5e07792685234b6b84011bdfdb4928365
parent64bc40080abc56e6bd804dadb44d2510f25f2efa (diff)
downloadopie-ffefde3701c0aed084872d05710d78b7201efaa8.zip
opie-ffefde3701c0aed084872d05710d78b7201efaa8.tar.gz
opie-ffefde3701c0aed084872d05710d78b7201efaa8.tar.bz2
fix writng m3u filenames when user specifies a directory
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp15
1 files changed, 8 insertions, 7 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
@@ -734,202 +734,203 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
config.write();
currentPlayList=filename;
// m3uList->write();
m3uList->close();
delete m3uList;
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
}
// /*
// reads pls and adds files/urls to playlist */
// void PlayListWidget::readPls( const QString &filename ) {
// qDebug( "pls filename is " + filename );
// Om3u *m3uList;
// QString s, name;
// m3uList = new Om3u( filename, IO_ReadOnly );
// 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() );
}
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.find("/",0,true) != -1) {// assume they specify a file path
+ filename = name;
+ name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
}
+ else //otherwise dump it somewhere noticable
+ filename = QPEApplication::documentDir() + "/" + name;
- if( name.right( 3 ) != "m3u" ) {
- filename = QPEApplication::documentDir() + "/" +name+".m3u";
- }
+ if( filename.right( 3 ) != "m3u" ) //needs filename extension
+ filename += ".m3u";
- if( d->selectedFiles->first()) {
+ if( d->selectedFiles->first()) { //ramble through playlist view
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);
currentPlayList=filename;
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
setCaption(tr("OpiePlayer: ") + name);
}
}
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_F9: //activity
// if(audioUI->isHidden())
// audioUI->showMaximized();
break;
case Key_F10: //contacts
// if( videoUI->isHidden())
// videoUI->showMaximized();
break;
case Key_F11: //menu
break;
case Key_F12: //home
// doBlank();
break;
case Key_F13: //mail
// doUnblank();
break;
case Key_Q: //add to playlist
addSelected();
break;
case Key_R: //remove from playlist
removeSelected();
break;
// case Key_P: //play
// qDebug("Play");
// playSelected();
// break;
case Key_Space:
// playSelected(); puh
break;
case Key_1:
tabWidget->setCurrentPage( 0 );
break;
case Key_2:
tabWidget->setCurrentPage( 1 );
break;
case Key_3:
tabWidget->setCurrentPage( 2 );
break;
case Key_4:
tabWidget->setCurrentPage( 3 );
break;
case Key_Down:
if ( !d->selectedFiles->next() )
d->selectedFiles->first();
break;
case Key_Up:
if ( !d->selectedFiles->prev() )
// d->selectedFiles->last();
break;
}
}
void PlayListWidget::pmViewActivated(int index) {
// qDebug("%d", index);
switch(index) {
case -16:
{
mediaPlayerState.toggleFullscreen();
bool b=mediaPlayerState.isFullscreen();