author | llornkcor <llornkcor> | 2002-12-16 03:52:02 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-16 03:52:02 (UTC) |
commit | b1880703eea8601e06cf3d3e8593b649cd1a485e (patch) (unidiff) | |
tree | a7c9d9c1bc2971d4a062cfb68b433bffa4c557d1 | |
parent | de714f7a5d6b50b4689a217bbed58180da8acc27 (diff) | |
download | opie-b1880703eea8601e06cf3d3e8593b649cd1a485e.zip opie-b1880703eea8601e06cf3d3e8593b649cd1a485e.tar.gz opie-b1880703eea8601e06cf3d3e8593b649cd1a485e.tar.bz2 |
some stuff from op2
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 8b25a4c..30e4daa 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -80,18 +80,18 @@ | |||
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | 86 | static inline QString fullBaseName ( const QFileInfo &fi ) |
87 | { | 87 | { |
88 | QString str = fi. fileName ( ); | 88 | QString str = fi. fileName ( ); |
89 | return str. left ( str. findRev ( '.' )); | 89 | return str. left ( str. findRev ( '.' )); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
94 | // class myFileSelector { | 94 | // class myFileSelector { |
95 | 95 | ||
96 | // }; | 96 | // }; |
97 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
@@ -462,34 +462,46 @@ void PlayListWidget::addAllVideoToList() { | |||
462 | writeCurrentM3u(); | 462 | writeCurrentM3u(); |
463 | d->selectedFiles->first(); | 463 | d->selectedFiles->first(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PlayListWidget::setDocument(const QString& fileref) { | 467 | void PlayListWidget::setDocument(const QString& fileref) { |
468 | qDebug(fileref); | 468 | qDebug(fileref); |
469 | fromSetDocument = TRUE; | 469 | fromSetDocument = TRUE; |
470 | if ( fileref.isNull() ) { | 470 | QFileInfo fileInfo(fileref); |
471 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 471 | if ( !fileInfo.exists() ) { |
472 | QMessageBox::critical( 0, tr( "Invalid File" ), | ||
473 | tr( "There was a problem in getting the file." ) ); | ||
472 | return; | 474 | return; |
473 | } | 475 | } |
474 | // qDebug("setDocument "+fileref); | 476 | // qDebug("setDocument "+fileref); |
475 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 477 | QString extension = fileInfo.extension(false); |
478 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | ||
476 | readm3u( fileref); | 479 | readm3u( fileref); |
477 | } | 480 | } |
478 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 481 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
479 | readPls( fileref); | 482 | readPls( fileref); |
480 | } | 483 | } |
481 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 484 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
482 | clearList(); | 485 | clearList(); |
483 | loadList(DocLnk(fileref)); | 486 | DocLnk lnk; |
487 | lnk.setName( fileInfo.baseName() ); //sets name | ||
488 | lnk.setFile( fileref ); //sets file name | ||
489 | //addToSelection( lnk ); | ||
490 | |||
491 | loadList( lnk); | ||
484 | d->selectedFiles->first(); | 492 | d->selectedFiles->first(); |
485 | } else { | 493 | } else { |
486 | clearList(); | 494 | clearList(); |
487 | addToSelection( DocLnk( fileref ) ); | 495 | DocLnk lnk; |
496 | lnk.setName( fileInfo.baseName() ); //sets name | ||
497 | lnk.setFile( fileref ); //sets file name | ||
498 | addToSelection( lnk ); | ||
499 | // addToSelection( DocLnk( fileref ) ); | ||
488 | d->setDocumentUsed = TRUE; | 500 | d->setDocumentUsed = TRUE; |
489 | mediaPlayerState->setPlaying( FALSE ); | 501 | mediaPlayerState->setPlaying( FALSE ); |
490 | qApp->processEvents(); | 502 | qApp->processEvents(); |
491 | mediaPlayerState->setPlaying( TRUE ); | 503 | mediaPlayerState->setPlaying( TRUE ); |
492 | qApp->processEvents(); | 504 | qApp->processEvents(); |
493 | setCaption(tr("OpiePlayer")); | 505 | setCaption(tr("OpiePlayer")); |
494 | } | 506 | } |
495 | } | 507 | } |
@@ -1186,25 +1198,26 @@ void PlayListWidget::writem3u() { | |||
1186 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1198 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1187 | fileDlg->exec(); | 1199 | fileDlg->exec(); |
1188 | QString name, filename, list; | 1200 | QString name, filename, list; |
1189 | Om3u *m3uList; | 1201 | Om3u *m3uList; |
1190 | 1202 | ||
1191 | if( fileDlg->result() == 1 ) { | 1203 | if( fileDlg->result() == 1 ) { |
1192 | name = fileDlg->text(); | 1204 | name = fileDlg->text(); |
1193 | // qDebug( filename ); | 1205 | // qDebug( filename ); |
1194 | 1206 | if( name.find("/",0,true) != -1) {// assume they specify a file path | |
1195 | if( name.left( 1) != "/" ) { | 1207 | filename = name; |
1196 | filename = QPEApplication::documentDir() + "/" + name; | 1208 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1197 | } | ||
1198 | |||
1199 | if( name.right( 3 ) != "m3u" ) { | ||
1200 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | ||
1201 | } | 1209 | } |
1210 | else //otherwise dump it somewhere noticable | ||
1211 | filename = QPEApplication::documentDir() + "/" + name; | ||
1202 | 1212 | ||
1213 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | ||
1214 | filename += ".m3u"; | ||
1215 | |||
1203 | if( d->selectedFiles->first()) { | 1216 | if( d->selectedFiles->first()) { |
1204 | m3uList = new Om3u(filename, IO_ReadWrite); | 1217 | m3uList = new Om3u(filename, IO_ReadWrite); |
1205 | 1218 | ||
1206 | do { | 1219 | do { |
1207 | m3uList->add( d->selectedFiles->current()->file()); | 1220 | m3uList->add( d->selectedFiles->current()->file()); |
1208 | } | 1221 | } |
1209 | while ( d->selectedFiles->next() ); | 1222 | while ( d->selectedFiles->next() ); |
1210 | // qDebug( list ); | 1223 | // qDebug( list ); |