Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 5f750ba..a1a1016 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -22,49 +22,38 @@ | |||
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qtoolbar.h> |
35 | #include <qpe/qpeapplication.h> | ||
36 | #include <qpe/storage.h> | ||
37 | #include <qpe/mimetype.h> | ||
38 | #include <qpe/global.h> | ||
39 | #include <qpe/resource.h> | ||
40 | #include <qpe/config.h> | ||
41 | 35 | ||
42 | #include <opie/ofiledialog.h> | 36 | #include <opie/ofiledialog.h> |
43 | 37 | ||
44 | #include <qdatetime.h> | ||
45 | #include <qdir.h> | ||
46 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
47 | #include <qregexp.h> | ||
48 | #include <qtextstream.h> | ||
49 | 39 | ||
50 | #include "playlistselection.h" | 40 | #include "playlistselection.h" |
51 | #include "playlistwidget.h" | 41 | #include "playlistwidget.h" |
52 | #include "mediaplayerstate.h" | 42 | #include "mediaplayerstate.h" |
53 | #include "inputDialog.h" | 43 | #include "inputDialog.h" |
54 | #include "om3u.h" | 44 | #include "om3u.h" |
55 | #include "playlistfileview.h" | 45 | #include "playlistfileview.h" |
56 | 46 | ||
57 | //only needed for the random play | 47 | //only needed for the random play |
58 | #include <stdlib.h> | ||
59 | #include <assert.h> | 48 | #include <assert.h> |
60 | 49 | ||
61 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 50 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
62 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) | 51 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) |
63 | { | 52 | { |
64 | 53 | ||
65 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 54 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
66 | "opieplayer2/add_to_playlist", | 55 | "opieplayer2/add_to_playlist", |
67 | this , SLOT(addSelected() ) ); | 56 | this , SLOT(addSelected() ) ); |
68 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 57 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
69 | "opieplayer2/remove_from_playlist", | 58 | "opieplayer2/remove_from_playlist", |
70 | this , SLOT(removeSelected() ) ); | 59 | this , SLOT(removeSelected() ) ); |
@@ -658,57 +647,59 @@ void PlayListWidget::openURL() { | |||
658 | 647 | ||
659 | 648 | ||
660 | void PlayListWidget::openFile() { | 649 | void PlayListWidget::openFile() { |
661 | 650 | ||
662 | QString filename, name; | 651 | QString filename, name; |
663 | 652 | ||
664 | Config cfg( "OpiePlayer" ); | 653 | Config cfg( "OpiePlayer" ); |
665 | cfg.setGroup("Dialog"); | 654 | cfg.setGroup("Dialog"); |
666 | MimeTypes types; | 655 | MimeTypes types; |
667 | QStringList audio, video, all; | 656 | QStringList audio, video, all; |
668 | audio << "audio/*"; | 657 | audio << "audio/*"; |
669 | audio << "playlist/plain"; | 658 | audio << "playlist/plain"; |
659 | audio << "application/ogg"; | ||
670 | audio << "audio/x-mpegurl"; | 660 | audio << "audio/x-mpegurl"; |
671 | 661 | ||
672 | video << "video/*"; | 662 | video << "video/*"; |
673 | video << "playlist/plain"; | 663 | video << "playlist/plain"; |
674 | 664 | ||
675 | all += audio; | 665 | all += audio; |
676 | all += video; | 666 | all += video; |
677 | types.insert("All Media Files", all ); | 667 | types.insert("All Media Files", all ); |
678 | types.insert("Audio", audio ); | 668 | types.insert("Audio", audio ); |
679 | types.insert("Video", video ); | 669 | types.insert("Video", video ); |
680 | 670 | ||
681 | QString str = OFileDialog::getOpenFileName( 1, | 671 | QString str = OFileDialog::getOpenFileName( 1, |
682 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 672 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
683 | types, 0 ); | 673 | types, 0 ); |
684 | if(str.left(2) == "//") str=str.right(str.length()-1); | ||
685 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | ||
686 | 674 | ||
675 | if(str.left(2) == "//") { | ||
676 | str=str.right(str.length()-1); | ||
677 | } | ||
678 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | ||
687 | 679 | ||
688 | if( !str.isEmpty() ) { | 680 | if( !str.isEmpty() ) { |
681 | |||
689 | qDebug( "Selected filename is " + str ); | 682 | qDebug( "Selected filename is " + str ); |
690 | filename = str; | 683 | filename = str; |
691 | DocLnk lnk; | 684 | DocLnk lnk; |
692 | Config cfg( "OpiePlayer" ); | ||
693 | cfg.setGroup("PlayList"); | ||
694 | 685 | ||
695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 686 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
696 | readListFromFile( filename ); | 687 | readListFromFile( filename ); |
697 | } else { | 688 | } else { |
698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 689 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
699 | lnk.setFile( filename ); //sets file name | 690 | lnk.setFile( filename ); //sets file name |
700 | d->selectedFiles->addToSelection( lnk); | 691 | d->selectedFiles->addToSelection( lnk ); |
701 | writeCurrentM3u(); | 692 | writeCurrentM3u(); |
702 | d->selectedFiles->setSelectedItem( lnk.name()); | 693 | d->selectedFiles->setSelectedItem( lnk.name() ); |
703 | } | 694 | } |
704 | } | 695 | } |
705 | } | 696 | } |
706 | 697 | ||
707 | 698 | ||
708 | void PlayListWidget::readListFromFile( const QString &filename ) { | 699 | void PlayListWidget::readListFromFile( const QString &filename ) { |
709 | qDebug( "read list filename " + filename ); | 700 | qDebug( "read list filename " + filename ); |
710 | QFileInfo fi(filename); | 701 | QFileInfo fi(filename); |
711 | Om3u *m3uList; | 702 | Om3u *m3uList; |
712 | QString s, name; | 703 | QString s, name; |
713 | m3uList = new Om3u( filename, IO_ReadOnly ); | 704 | m3uList = new Om3u( filename, IO_ReadOnly ); |
714 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 705 | if(fi.extension(false).find("m3u",0,false) != -1 ) |