author | harlekin <harlekin> | 2003-06-18 20:19:16 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-06-18 20:19:16 (UTC) |
commit | 9bfda722eeba2f5861393e9f5f41170fab502da8 (patch) (unidiff) | |
tree | eb01205e55bfe4f59d48d4c45b60013f1bd434ee /noncore/multimedia/opieplayer2/playlistwidget.cpp | |
parent | db7c5730e22188f365eb9d52aed961066fbda026 (diff) | |
download | opie-9bfda722eeba2f5861393e9f5f41170fab502da8.zip opie-9bfda722eeba2f5861393e9f5f41170fab502da8.tar.gz opie-9bfda722eeba2f5861393e9f5f41170fab502da8.tar.bz2 |
separate Add URL from Add file
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 80 |
1 files changed, 67 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index c91a565..4e31670 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
@@ -37,6 +37,9 @@ | |||
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/config.h> | ||
41 | |||
42 | #include <opie/ofiledialog.h> | ||
40 | 43 | ||
41 | #include <qdatetime.h> | 44 | #include <qdatetime.h> |
42 | #include <qdir.h> | 45 | #include <qdir.h> |
@@ -85,8 +88,10 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 89 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
89 | this,SLOT( openFile() ) ); | 92 | this,SLOT( openFile() ) ); |
93 | (void)new MenuItem( pmPlayList, tr("Add URL"), | ||
94 | this,SLOT( openURL() ) ); | ||
90 | pmPlayList->insertSeparator(-1); | 95 | pmPlayList->insertSeparator(-1); |
91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 96 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
92 | audioView, SLOT( scanFiles() ) ); | 97 | audioView, SLOT( scanFiles() ) ); |
@@ -327,7 +332,7 @@ void PlayListWidget::setDocument( const QString& fileref ) { | |||
327 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 332 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
328 | fromSetDocument = TRUE; | 333 | fromSetDocument = TRUE; |
329 | QFileInfo fileInfo(fileref); | 334 | QFileInfo fileInfo(fileref); |
330 | 335 | ||
331 | if ( !fileInfo.exists() ) { | 336 | if ( !fileInfo.exists() ) { |
332 | QMessageBox::warning( this, tr( "Invalid File" ), | 337 | QMessageBox::warning( this, tr( "Invalid File" ), |
333 | tr( "There was a problem in getting the file." ) ); | 338 | tr( "There was a problem in getting the file." ) ); |
@@ -337,7 +342,7 @@ void PlayListWidget::setDocument( const QString& fileref ) { | |||
337 | clearList(); | 342 | clearList(); |
338 | QString extension = fileInfo.extension(false); | 343 | QString extension = fileInfo.extension(false); |
339 | 344 | ||
340 | if( extension.find( "m3u", 0, false) != -1 | 345 | if( extension.find( "m3u", 0, false) != -1 |
341 | || extension.find( "pls", 0, false) != -1 ) { | 346 | || extension.find( "pls", 0, false) != -1 ) { |
342 | readListFromFile( fileref ); | 347 | readListFromFile( fileref ); |
343 | } else { | 348 | } else { |
@@ -602,12 +607,12 @@ bool PlayListWidget::inFileListMode() const | |||
602 | return tab == AudioFiles || tab == VideoFiles; | 607 | return tab == AudioFiles || tab == VideoFiles; |
603 | } | 608 | } |
604 | 609 | ||
605 | void PlayListWidget::openFile() { | 610 | void PlayListWidget::openURL() { |
606 | // http://66.28.164.33:2080 | 611 | // http://66.28.164.33:2080 |
607 | // http://somafm.com/star0242.m3u | 612 | // http://somafm.com/star0242.m3u |
608 | QString filename, name; | 613 | QString filename, name; |
609 | InputDialog *fileDlg; | 614 | InputDialog *fileDlg; |
610 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 615 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
611 | fileDlg->exec(); | 616 | fileDlg->exec(); |
612 | if( fileDlg->result() == 1 ) { | 617 | if( fileDlg->result() == 1 ) { |
613 | filename = fileDlg->text(); | 618 | filename = fileDlg->text(); |
@@ -653,6 +658,55 @@ void PlayListWidget::openFile() { | |||
653 | delete fileDlg; | 658 | delete fileDlg; |
654 | } | 659 | } |
655 | 660 | ||
661 | |||
662 | void PlayListWidget::openFile() { | ||
663 | |||
664 | QString filename, name; | ||
665 | |||
666 | Config cfg( "OpiePlayer" ); | ||
667 | cfg.setGroup("Dialog"); | ||
668 | MimeTypes types; | ||
669 | QStringList audio, video, all; | ||
670 | audio << "audio/*"; | ||
671 | audio << "playlist/plain"; | ||
672 | audio << "audio/x-mpegurl"; | ||
673 | |||
674 | video << "video/*"; | ||
675 | video << "playlist/plain"; | ||
676 | |||
677 | all += audio; | ||
678 | all += video; | ||
679 | types.insert("All Media Files", all ); | ||
680 | types.insert("Audio", audio ); | ||
681 | types.insert("Video", video ); | ||
682 | |||
683 | QString str = OFileDialog::getOpenFileName( 1, | ||
684 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | ||
685 | types, 0 ); | ||
686 | if(str.left(2) == "//") str=str.right(str.length()-1); | ||
687 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | ||
688 | |||
689 | |||
690 | if( !str.isEmpty() ) { | ||
691 | qDebug( "Selected filename is " + str ); | ||
692 | filename = str; | ||
693 | DocLnk lnk; | ||
694 | Config cfg( "OpiePlayer" ); | ||
695 | cfg.setGroup("PlayList"); | ||
696 | |||
697 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | ||
698 | readListFromFile( filename ); | ||
699 | } else { | ||
700 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
701 | lnk.setFile( filename ); //sets file name | ||
702 | d->selectedFiles->addToSelection( lnk); | ||
703 | writeCurrentM3u(); | ||
704 | d->selectedFiles->setSelectedItem( lnk.name()); | ||
705 | } | ||
706 | } | ||
707 | } | ||
708 | |||
709 | |||
656 | void PlayListWidget::readListFromFile( const QString &filename ) { | 710 | void PlayListWidget::readListFromFile( const QString &filename ) { |
657 | qDebug( "read list filename " + filename ); | 711 | qDebug( "read list filename " + filename ); |
658 | QFileInfo fi(filename); | 712 | QFileInfo fi(filename); |
@@ -676,7 +730,7 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
676 | } else { //is file | 730 | } else { //is file |
677 | lnk.setName( QFileInfo(s).baseName()); | 731 | lnk.setName( QFileInfo(s).baseName()); |
678 | if(s.left(1) != "/") { | 732 | if(s.left(1) != "/") { |
679 | 733 | ||
680 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 734 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
681 | } else { | 735 | } else { |
682 | lnk.setFile( s); | 736 | lnk.setFile( s); |
@@ -744,7 +798,7 @@ void PlayListWidget::writem3u() { | |||
744 | 798 | ||
745 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 799 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
746 | filename += ".m3u"; | 800 | filename += ".m3u"; |
747 | 801 | ||
748 | if( d->selectedFiles->first()) { //ramble through playlist view | 802 | if( d->selectedFiles->first()) { //ramble through playlist view |
749 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 803 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
750 | 804 | ||
@@ -931,9 +985,9 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
931 | } else if ( msg == "togglePause()" ) { | 985 | } else if ( msg == "togglePause()" ) { |
932 | mediaPlayerState.togglePaused(); | 986 | mediaPlayerState.togglePaused(); |
933 | } else if ( msg == "next()" ) { //select next in list | 987 | } else if ( msg == "next()" ) { //select next in list |
934 | mediaPlayerState.setNext(); | 988 | mediaPlayerState.setNext(); |
935 | } else if ( msg == "prev()" ) { //select previous in list | 989 | } else if ( msg == "prev()" ) { //select previous in list |
936 | mediaPlayerState.setPrev(); | 990 | mediaPlayerState.setPrev(); |
937 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 991 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
938 | mediaPlayerState.toggleLooping(); | 992 | mediaPlayerState.toggleLooping(); |
939 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 993 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
@@ -961,5 +1015,5 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
961 | stream >> file; | 1015 | stream >> file; |
962 | 1016 | ||
963 | } | 1017 | } |
964 | 1018 | ||
965 | } | 1019 | } |