author | llornkcor <llornkcor> | 2002-12-16 03:52:02 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-16 03:52:02 (UTC) |
commit | b1880703eea8601e06cf3d3e8593b649cd1a485e (patch) (side-by-side diff) | |
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 @@ -76,26 +76,26 @@ #include <stdlib.h> #define BUTTONS_ON_TOOLBAR #define SIDE_BUTTONS #define CAN_SAVE_LOAD_PLAYLISTS extern AudioWidget *audioUI; extern VideoWidget *videoUI; extern MediaPlayerState *mediaPlayerState; static inline QString fullBaseName ( const QFileInfo &fi ) { - QString str = fi. fileName ( ); - return str. left ( str. findRev ( '.' )); + QString str = fi. fileName ( ); + return str. left ( str. findRev ( '.' )); } QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; // class myFileSelector { // }; class PlayListWidgetPrivate { public: QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; QFrame *playListFrame; FileSelector *files; @@ -458,42 +458,54 @@ void PlayListWidget::addAllVideoToList() { if(QFileInfo( dit.current()->file()).exists()) d->selectedFiles->addToSelection( **dit ); tabWidget->setCurrentPage(0); writeCurrentM3u(); d->selectedFiles->first(); } void PlayListWidget::setDocument(const QString& fileref) { qDebug(fileref); fromSetDocument = TRUE; - if ( fileref.isNull() ) { - QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); + QFileInfo fileInfo(fileref); + if ( !fileInfo.exists() ) { + QMessageBox::critical( 0, tr( "Invalid File" ), + tr( "There was a problem in getting the file." ) ); return; } // qDebug("setDocument "+fileref); - if(fileref.find("m3u",0,TRUE) != -1) { //is m3u + QString extension = fileInfo.extension(false); + if( extension.find( "m3u", 0, false) != -1) { //is m3u readm3u( fileref); } - else if(fileref.find("pls",0,TRUE) != -1) { //is pls + else if( extension.find( "pls", 0, false) != -1 ) { //is pls readPls( fileref); } - else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist + else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist clearList(); - loadList(DocLnk(fileref)); + DocLnk lnk; + lnk.setName( fileInfo.baseName() ); //sets name + lnk.setFile( fileref ); //sets file name + //addToSelection( lnk ); + + loadList( lnk); d->selectedFiles->first(); } else { clearList(); - addToSelection( DocLnk( fileref ) ); + DocLnk lnk; + lnk.setName( fileInfo.baseName() ); //sets name + lnk.setFile( fileref ); //sets file name + addToSelection( lnk ); +// addToSelection( DocLnk( fileref ) ); d->setDocumentUsed = TRUE; mediaPlayerState->setPlaying( FALSE ); qApp->processEvents(); mediaPlayerState->setPlaying( TRUE ); qApp->processEvents(); setCaption(tr("OpiePlayer")); } } void PlayListWidget::setActiveWindow() { qDebug("SETTING active window"); @@ -1182,33 +1194,34 @@ void PlayListWidget::writeCurrentM3u() { /* 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( 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( filename.right( 3 ) != "m3u" ) //needs filename extension + filename += ".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(); if(m3uList) delete m3uList; |