summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-06-18 20:19:16 (UTC)
committer harlekin <harlekin>2003-06-18 20:19:16 (UTC)
commit9bfda722eeba2f5861393e9f5f41170fab502da8 (patch) (unidiff)
treeeb01205e55bfe4f59d48d4c45b60013f1bd434ee
parentdb7c5730e22188f365eb9d52aed961066fbda026 (diff)
downloadopie-9bfda722eeba2f5861393e9f5f41170fab502da8.zip
opie-9bfda722eeba2f5861393e9f5f41170fab502da8.tar.gz
opie-9bfda722eeba2f5861393e9f5f41170fab502da8.tar.bz2
separate Add URL from Add file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp69
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.h35
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp80
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
4 files changed, 139 insertions, 48 deletions
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index 2c4be1b..ebde9c6 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,69 +1,74 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 =.
7 .=l.
8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU General Public
12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; General Public License for more
22++=   -.     .`     .: details.
23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30
31*/
32
33
1#include "inputDialog.h" 34#include "inputDialog.h"
2 35
3#include <qpe/resource.h> 36#include <qpe/resource.h>
4#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
5#include <qpe/config.h>
6#include <opie/ofiledialog.h>
7 38
8#include <qfileinfo.h> 39#include <qfileinfo.h>
9#include <qlineedit.h> 40#include <qlineedit.h>
10#include <qlayout.h> 41#include <qlayout.h>
11#include <qvariant.h> 42#include <qvariant.h>
12#include <qpushbutton.h> 43#include <qpushbutton.h>
13#include <qwhatsthis.h> 44#include <qwhatsthis.h>
14 45
15InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 46InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl ) { 47 : QDialog( parent, name, modal, fl ) {
17 if ( !name ) { 48 if ( !name ) {
18 setName( "InputDialog" ); 49 setName( "InputDialog" );
19 } 50 }
20 resize( 234, 115); 51 resize( 234, 115);
21 setMaximumSize( QSize( 240, 40)); 52 setMaximumSize( QSize( 240, 40));
22 setCaption( tr( name ) ); 53 setCaption( tr( name ) );
23 54
24 QPushButton *browserButton; 55 QPushButton *browserButton;
25 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 56 //browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
26 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 57 //browserButton->setGeometry( QRect( 205, 10, 22, 22));
27 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 58 //connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
28 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 59 LineEdit1 = new QLineEdit( this, "LineEdit1" );
29 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 60 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
30 LineEdit1->setFocus(); 61 LineEdit1->setFocus();
31} 62}
32/* 63/*
33 * return the current text(input) 64 * return the current text(input)
34 */ 65 */
35QString InputDialog::text() const { 66QString InputDialog::text() const {
36 return LineEdit1->text(); 67 return LineEdit1->text();
37} 68}
38/* 69/*
39 * Destroys the object and frees any allocated resources 70 * Destroys the object and frees any allocated resources
40 */ 71 */
41InputDialog::~InputDialog() { 72InputDialog::~InputDialog() {
42} 73}
43 74
44void InputDialog::browse() {
45 Config cfg( "OpiePlayer" );
46 cfg.setGroup("Dialog");
47 MimeTypes types;
48 QStringList audio, video, all;
49 audio << "audio/*";
50 audio << "playlist/plain";
51 audio << "audio/x-mpegurl";
52
53 video << "video/*";
54 video << "playlist/plain";
55
56 all += audio;
57 all += video;
58 types.insert("All Media Files", all );
59 types.insert("Audio", audio );
60 types.insert("Video", video );
61
62 QString str = OFileDialog::getOpenFileName( 1,
63 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
64 types, 0 );
65 if(str.left(2) == "//") str=str.right(str.length()-1);
66 LineEdit1->setText(str);
67 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
68}
69
diff --git a/noncore/multimedia/opieplayer2/inputDialog.h b/noncore/multimedia/opieplayer2/inputDialog.h
index 0f36ea4..f64f6d4 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.h
+++ b/noncore/multimedia/opieplayer2/inputDialog.h
@@ -1,25 +1,56 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 =.
7 .=l.
8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU General Public
12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; General Public License for more
22++=   -.     .`     .: details.
23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30
31*/
32
33
1 34
2#ifndef INPUTDIALOG_H 35#ifndef INPUTDIALOG_H
3#define INPUTDIALOG_H 36#define INPUTDIALOG_H
4 37
5#include <qvariant.h> 38#include <qvariant.h>
6#include <qdialog.h> 39#include <qdialog.h>
7 40
8class QLineEdit; 41class QLineEdit;
9 42
10class InputDialog : public QDialog { 43class InputDialog : public QDialog {
11 Q_OBJECT 44 Q_OBJECT
12 45
13public: 46public:
14 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 47 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
15 ~InputDialog(); 48 ~InputDialog();
16 QString text()const; 49 QString text()const;
17 50
18private: 51private:
19 QLineEdit* LineEdit1; 52 QLineEdit* LineEdit1;
20 53
21protected slots:
22 void browse();
23}; 54};
24 55
25#endif // INPUTDIALOG_H 56#endif // INPUTDIALOG_H
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,20 +1,20 @@
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 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
@@ -24,32 +24,35 @@
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 <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
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>
43#include <qmessagebox.h> 46#include <qmessagebox.h>
44#include <qregexp.h> 47#include <qregexp.h>
45#include <qtextstream.h> 48#include <qtextstream.h>
46 49
47#include "playlistselection.h" 50#include "playlistselection.h"
48#include "playlistwidget.h" 51#include "playlistwidget.h"
49#include "mediaplayerstate.h" 52#include "mediaplayerstate.h"
50#include "inputDialog.h" 53#include "inputDialog.h"
51#include "om3u.h" 54#include "om3u.h"
52#include "playlistfileview.h" 55#include "playlistfileview.h"
53 56
54//only needed for the random play 57//only needed for the random play
55#include <stdlib.h> 58#include <stdlib.h>
@@ -72,34 +75,36 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 75 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
73 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 76 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
74 77
75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 78 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 79 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
77 this, SLOT( addAllMusicToList() ) ); 80 this, SLOT( addAllMusicToList() ) );
78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 81 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
79 this, SLOT( addAllVideoToList() ) ); 82 this, SLOT( addAllVideoToList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 83 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
81 this, SLOT( addAllToList() ) ); 84 this, SLOT( addAllToList() ) );
82 pmPlayList->insertSeparator(-1); 85 pmPlayList->insertSeparator(-1);
83// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 86// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
84// this, SLOT( saveList() ) ); 87// this, SLOT( saveList() ) );
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() ) );
93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 98 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
94 videoView, SLOT( scanFiles() ) ); 99 videoView, SLOT( scanFiles() ) );
95 100
96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 101 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
97 &mediaPlayerState, SLOT( toggleFullscreen() ) ); 102 &mediaPlayerState, SLOT( toggleFullscreen() ) );
98 103
99 Config cfg( "OpiePlayer" ); 104 Config cfg( "OpiePlayer" );
100 bool b= cfg.readBoolEntry("FullScreen", 0); 105 bool b= cfg.readBoolEntry("FullScreen", 0);
101 mediaPlayerState.setFullscreen( b ); 106 mediaPlayerState.setFullscreen( b );
102 pmView->setItemChecked( -16, b ); 107 pmView->setItemChecked( -16, b );
103 108
104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 109 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
105 d->selectedFiles, SLOT(moveSelectedUp() ) ); 110 d->selectedFiles, SLOT(moveSelectedUp() ) );
@@ -314,43 +319,43 @@ void PlayListWidget::addAllVideoToList() {
314 for ( ; videoIt.current(); ++videoIt ) { 319 for ( ; videoIt.current(); ++videoIt ) {
315 filename = videoIt.current()->text(3); 320 filename = videoIt.current()->text(3);
316 lnk.setName( QFileInfo(filename).baseName() ); //sets name 321 lnk.setName( QFileInfo(filename).baseName() ); //sets name
317 lnk.setFile( filename ); //sets file name 322 lnk.setFile( filename ); //sets file name
318 d->selectedFiles->addToSelection( lnk); 323 d->selectedFiles->addToSelection( lnk);
319 } 324 }
320 tabWidget->setCurrentPage(0); 325 tabWidget->setCurrentPage(0);
321 writeCurrentM3u(); 326 writeCurrentM3u();
322 d->selectedFiles->first(); 327 d->selectedFiles->first();
323} 328}
324 329
325 330
326void PlayListWidget::setDocument( const QString& fileref ) { 331void 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." ) );
334 return; 339 return;
335 } 340 }
336 341
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 {
344 clearList(); 349 clearList();
345 DocLnk lnk; 350 DocLnk lnk;
346 lnk.setName( fileInfo.baseName() ); //sets name 351 lnk.setName( fileInfo.baseName() ); //sets name
347 lnk.setFile( fileref ); //sets file name 352 lnk.setFile( fileref ); //sets file name
348 addToSelection( lnk ); 353 addToSelection( lnk );
349 writeCurrentM3u(); 354 writeCurrentM3u();
350 355
351 d->setDocumentUsed = TRUE; 356 d->setDocumentUsed = TRUE;
352 mediaPlayerState.setPlaying( FALSE ); 357 mediaPlayerState.setPlaying( FALSE );
353 mediaPlayerState.setPlaying( TRUE ); 358 mediaPlayerState.setPlaying( TRUE );
354 } 359 }
355} 360}
356 361
@@ -589,38 +594,38 @@ void PlayListWidget::deletePlaylist() {
589 case 1: // Cancel 594 case 1: // Cancel
590 break; 595 break;
591 }; 596 };
592} 597}
593 598
594 599
595void PlayListWidget::playSelected() { 600void PlayListWidget::playSelected() {
596 btnPlay( TRUE); 601 btnPlay( TRUE);
597} 602}
598 603
599bool PlayListWidget::inFileListMode() const 604bool PlayListWidget::inFileListMode() const
600{ 605{
601 TabType tab = currentTab(); 606 TabType tab = currentTab();
602 return tab == AudioFiles || tab == VideoFiles; 607 return tab == AudioFiles || tab == VideoFiles;
603} 608}
604 609
605void PlayListWidget::openFile() { 610void 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();
614 qDebug( "Selected filename is " + filename ); 619 qDebug( "Selected filename is " + filename );
615 // Om3u *m3uList; 620 // Om3u *m3uList;
616 DocLnk lnk; 621 DocLnk lnk;
617 Config cfg( "OpiePlayer" ); 622 Config cfg( "OpiePlayer" );
618 cfg.setGroup("PlayList"); 623 cfg.setGroup("PlayList");
619 624
620 if(filename.left(4) == "http") { 625 if(filename.left(4) == "http") {
621 QString m3uFile, m3uFilePath; 626 QString m3uFile, m3uFilePath;
622 if(filename.find(":",8,TRUE) != -1) { //found a port 627 if(filename.find(":",8,TRUE) != -1) { //found a port
623 m3uFile = filename.left( filename.find( ":",8,TRUE)); 628 m3uFile = filename.left( filename.find( ":",8,TRUE));
624 m3uFile = m3uFile.right( 7); 629 m3uFile = m3uFile.right( 7);
625 } else if(filename.left(4) == "http"){ 630 } else if(filename.left(4) == "http"){
626 m3uFile=filename; 631 m3uFile=filename;
@@ -640,56 +645,105 @@ void PlayListWidget::openFile() {
640 } 645 }
641 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 646 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
642 readListFromFile( filename ); 647 readListFromFile( filename );
643 } else { 648 } else {
644 lnk.setName( QFileInfo(filename).baseName() ); //sets name 649 lnk.setName( QFileInfo(filename).baseName() ); //sets name
645 lnk.setFile( filename ); //sets file name 650 lnk.setFile( filename ); //sets file name
646 d->selectedFiles->addToSelection( lnk); 651 d->selectedFiles->addToSelection( lnk);
647 writeCurrentM3u(); 652 writeCurrentM3u();
648 d->selectedFiles->setSelectedItem( lnk.name()); 653 d->selectedFiles->setSelectedItem( lnk.name());
649 } 654 }
650 } 655 }
651 656
652 657
653 delete fileDlg; 658 delete fileDlg;
654} 659}
655 660
661
662void 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
656void PlayListWidget::readListFromFile( const QString &filename ) { 710void 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);
659 Om3u *m3uList; 713 Om3u *m3uList;
660 QString s, name; 714 QString s, name;
661 m3uList = new Om3u( filename, IO_ReadOnly ); 715 m3uList = new Om3u( filename, IO_ReadOnly );
662 if(fi.extension(false).find("m3u",0,false) != -1 ) 716 if(fi.extension(false).find("m3u",0,false) != -1 )
663 m3uList->readM3u(); 717 m3uList->readM3u();
664 else if(fi.extension(false).find("pls",0,false) != -1 ) 718 else if(fi.extension(false).find("pls",0,false) != -1 )
665 m3uList->readPls(); 719 m3uList->readPls();
666 720
667 DocLnk lnk; 721 DocLnk lnk;
668 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 722 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
669 s = *it; 723 s = *it;
670 // qDebug(s); 724 // qDebug(s);
671 if(s.left(4)=="http") { 725 if(s.left(4)=="http") {
672 lnk.setName( s ); //sets file name 726 lnk.setName( s ); //sets file name
673 lnk.setIcon("opieplayer2/musicfile"); 727 lnk.setIcon("opieplayer2/musicfile");
674 lnk.setFile( s ); //sets file name 728 lnk.setFile( s ); //sets file name
675 729
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);
683 } 737 }
684 } 738 }
685 d->selectedFiles->addToSelection( lnk ); 739 d->selectedFiles->addToSelection( lnk );
686 } 740 }
687 Config config( "OpiePlayer" ); 741 Config config( "OpiePlayer" );
688 config.setGroup( "PlayList" ); 742 config.setGroup( "PlayList" );
689 743
690 config.writeEntry("CurrentPlaylist",filename); 744 config.writeEntry("CurrentPlaylist",filename);
691 config.write(); 745 config.write();
692 currentPlayList=filename; 746 currentPlayList=filename;
693 747
694 m3uList->close(); 748 m3uList->close();
695 delete m3uList; 749 delete m3uList;
@@ -731,33 +785,33 @@ void PlayListWidget::writem3u() {
731 fileDlg->exec(); 785 fileDlg->exec();
732 QString name, filename, list; 786 QString name, filename, list;
733 Om3u *m3uList; 787 Om3u *m3uList;
734 788
735 if( fileDlg->result() == 1 ) { 789 if( fileDlg->result() == 1 ) {
736 name = fileDlg->text(); 790 name = fileDlg->text();
737// qDebug( filename ); 791// qDebug( filename );
738 if( name.find("/",0,true) != -1) {// assume they specify a file path 792 if( name.find("/",0,true) != -1) {// assume they specify a file path
739 filename = name; 793 filename = name;
740 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 794 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
741 } 795 }
742 else //otherwise dump it somewhere noticable 796 else //otherwise dump it somewhere noticable
743 filename = QPEApplication::documentDir() + "/" + name; 797 filename = QPEApplication::documentDir() + "/" + name;
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
751 do { 805 do {
752 m3uList->add( d->selectedFiles->current()->file()); 806 m3uList->add( d->selectedFiles->current()->file());
753 } 807 }
754 while ( d->selectedFiles->next() ); 808 while ( d->selectedFiles->next() );
755 // qDebug( list ); 809 // qDebug( list );
756 m3uList->write(); 810 m3uList->write();
757 m3uList->close(); 811 m3uList->close();
758 delete m3uList; 812 delete m3uList;
759 813
760 delete fileDlg; 814 delete fileDlg;
761 815
762 DocLnk lnk; 816 DocLnk lnk;
763 lnk.setFile( filename); 817 lnk.setFile( filename);
@@ -918,48 +972,48 @@ PlayListWidget::Entry PlayListWidget::currentEntry() const
918 972
919QString PlayListWidget::currentFileListPathName() const { 973QString PlayListWidget::currentFileListPathName() const {
920 return currentFileListView->currentItem()->text( 3 ); 974 return currentFileListView->currentItem()->text( 3 );
921} 975}
922 976
923 977
924void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 978void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
925 qDebug("qcop message "+msg ); 979 qDebug("qcop message "+msg );
926 QDataStream stream ( data, IO_ReadOnly ); 980 QDataStream stream ( data, IO_ReadOnly );
927 if ( msg == "play()" ) { //plays current selection 981 if ( msg == "play()" ) { //plays current selection
928 btnPlay( true); 982 btnPlay( true);
929 } else if ( msg == "stop()" ) { 983 } else if ( msg == "stop()" ) {
930 mediaPlayerState.setPlaying( false); 984 mediaPlayerState.setPlaying( false);
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
940 mediaPlayerState.toggleShuffled(); 994 mediaPlayerState.toggleShuffled();
941 } else if ( msg == "volUp()" ) { //volume more 995 } else if ( msg == "volUp()" ) { //volume more
942// emit moreClicked(); 996// emit moreClicked();
943// emit moreReleased(); 997// emit moreReleased();
944 } else if ( msg == "volDown()" ) { //volume less 998 } else if ( msg == "volDown()" ) { //volume less
945// emit lessClicked(); 999// emit lessClicked();
946// emit lessReleased(); 1000// emit lessReleased();
947 } else if ( msg == "play(QString)" ) { //play this now 1001 } else if ( msg == "play(QString)" ) { //play this now
948 QString file; 1002 QString file;
949 stream >> file; 1003 stream >> file;
950 setDocument( (const QString &) file); 1004 setDocument( (const QString &) file);
951 } else if ( msg == "add(QString)" ) { //add to playlist 1005 } else if ( msg == "add(QString)" ) { //add to playlist
952 QString file; 1006 QString file;
953 stream >> file; 1007 stream >> file;
954 QFileInfo fileInfo(file); 1008 QFileInfo fileInfo(file);
955 DocLnk lnk; 1009 DocLnk lnk;
956 lnk.setName( fileInfo.baseName() ); //sets name 1010 lnk.setName( fileInfo.baseName() ); //sets name
957 lnk.setFile( file ); //sets file name 1011 lnk.setFile( file ); //sets file name
958 addToSelection( lnk ); 1012 addToSelection( lnk );
959 } else if ( msg == "rem(QString)" ) { //remove from playlist 1013 } else if ( msg == "rem(QString)" ) { //remove from playlist
960 QString file; 1014 QString file;
961 stream >> file; 1015 stream >> file;
962 1016
963 } 1017 }
964 1018
965} 1019}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 54e9d16..5230b03 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,20 +1,20 @@
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 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
@@ -98,32 +98,33 @@ private:
98 int defaultSkinIndex; 98 int defaultSkinIndex;
99/* void readm3u(const QString &); */ 99/* void readm3u(const QString &); */
100/* void readPls(const QString &); */ 100/* void readPls(const QString &); */
101 void readListFromFile(const QString &); 101 void readListFromFile(const QString &);
102 void initializeStates(); 102 void initializeStates();
103 103
104 bool inFileListMode() const; 104 bool inFileListMode() const;
105 105
106private slots: 106private slots:
107 void qcopReceive(const QCString&, const QByteArray&); 107 void qcopReceive(const QCString&, const QByteArray&);
108 void populateSkinsMenu(); 108 void populateSkinsMenu();
109 void skinsMenuActivated(int); 109 void skinsMenuActivated(int);
110 void pmViewActivated(int); 110 void pmViewActivated(int);
111 void writem3u(); 111 void writem3u();
112 void writeCurrentM3u(); 112 void writeCurrentM3u();
113 void openFile(); 113 void openFile();
114 void openURL();
114 void setDocument( const QString& fileref ); 115 void setDocument( const QString& fileref );
115 void addToSelection( const DocLnk& ); // Add a media file to the playlist 116 void addToSelection( const DocLnk& ); // Add a media file to the playlist
116 void addToSelection( QListViewItem* ); // Add a media file to the playlist 117 void addToSelection( QListViewItem* ); // Add a media file to the playlist
117 void clearList(); 118 void clearList();
118 void addAllToList(); 119 void addAllToList();
119 void addAllMusicToList(); 120 void addAllMusicToList();
120 void addAllVideoToList(); 121 void addAllVideoToList();
121 void saveList(); // Save the playlist 122 void saveList(); // Save the playlist
122 void loadList( const DocLnk &); // Load a playlist 123 void loadList( const DocLnk &); // Load a playlist
123 void playIt( QListViewItem *); 124 void playIt( QListViewItem *);
124 void btnPlay(bool); 125 void btnPlay(bool);
125 void deletePlaylist(); 126 void deletePlaylist();
126 void addSelected(); 127 void addSelected();
127 void removeSelected(); 128 void removeSelected();
128 void tabChanged(QWidget*); 129 void tabChanged(QWidget*);
129 void viewPressed( int, QListViewItem *, const QPoint&, int); 130 void viewPressed( int, QListViewItem *, const QPoint&, int);