summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp157
-rw-r--r--noncore/multimedia/opieplayer2/om3u.h79
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp612
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
5 files changed, 559 insertions, 295 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
new file mode 100644
index 0000000..d378145
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -0,0 +1,157 @@
1/*
2                This file is part of the Opie Project
3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#include "playlistwidget.h"
33#include "om3u.h"
34
35#include <qpe/applnk.h>
36#include <qpe/qpeapplication.h>
37#include <qpe/storage.h>
38#include <qpe/mimetype.h>
39#include <qpe/global.h>
40#include <qpe/resource.h>
41
42#include <qdir.h>
43#include <qregexp.h>
44#include <qstring.h>
45#include <qtextstream.h>
46#include <qstringlist.h>
47#include <qcstring.h>
48
49//extern PlayListWidget *playList;
50
51Om3u::Om3u( const QString &filePath)
52 : QStringList (){
53//filePath is path name to m3u
54//qDebug("<<<<<<<new m3u "+filePath);
55 f.setName(filePath);
56 if(f.exists())
57 f.open( IO_ReadWrite );
58 else
59 f.open( IO_ReadWrite | IO_Truncate);
60}
61
62Om3u::~Om3u(){}
63
64void Om3u::readM3u() { //it's m3u
65// qDebug("<<<<<<reading m3u "+f.name());
66 QTextStream t(&f);
67 QString s;
68 while ( !t.atEnd() ) {
69 s=t.readLine();
70
71 if( s.find( "#", 0, TRUE) == -1 ) {
72 if( s.find( " ", 0, TRUE) == -1 ) {
73 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
74 s = s.right( s.length() -2 );
75 QFileInfo f( s );
76 QString name = f.baseName();
77 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
78 s=s.replace( QRegExp( "\\" ), "/" );
79 append(s);
80// qDebug(s);
81 } else { // is url
82 s.replace( QRegExp( "%20" )," " );
83 QString name;
84 if( name.left( 4 ) == "http" ) {
85 name = s.right( s.length() - 7 );
86 } else {
87 name = s;
88 }
89 append(name);
90// qDebug(name);
91 }
92 }
93 }
94 }
95}
96
97void Om3u::readPls() { //it's a pls file
98 QTextStream t( &f );
99 QString s;
100 while ( !t.atEnd() ) {
101 s = t.readLine();
102 if( s.left(4) == "File" ) {
103 s = s.right( s.length() - 6 );
104 s.replace( QRegExp( "%20" )," ");
105// qDebug( "adding " + s + " to playlist" );
106 // numberofentries=2
107 // File1=http
108 // Title
109 // Length
110 // Version
111 // File2=http
112 s = s.replace( QRegExp( "\\" ), "/" );
113 QFileInfo f( s );
114 QString name = f.baseName();
115 if( name.left( 4 ) == "http" ) {
116 name = s.right( s.length() - 7);
117 } else {
118 name = s;
119 }
120 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
121 if( s.at( s.length() - 4) == '.') // if this is probably a file
122 append(s);
123 else { //if its a url
124 if( name.right( 1 ).find( '/' ) == -1) {
125 s += "/";
126 }
127 append(s);
128 }
129 }
130 }
131}
132
133void Om3u::write() { //writes list to m3u file
134 QString list;
135 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
136 qDebug(*it);
137 list += *it+"\n";
138 }
139 f.writeBlock( list, list.length() );
140 f.close();
141}
142
143void Om3u::add(const QString &filePath) { //adds to m3u file
144 append(filePath);
145}
146
147void Om3u::remove(const QString &filePath) { //removes from m3u list
148
149}
150
151void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
152
153}
154
155void Om3u::close() { //closes m3u file
156 f.close();
157}
diff --git a/noncore/multimedia/opieplayer2/om3u.h b/noncore/multimedia/opieplayer2/om3u.h
new file mode 100644
index 0000000..392980e
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/om3u.h
@@ -0,0 +1,79 @@
1/*
2                This file is part of the Opie Project
3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#ifndef OM3U_H
33#define OM3U_H
34
35#include "playlistwidget.h"
36
37#include <qpe/applnk.h>
38#include <qpe/qpeapplication.h>
39#include <qpe/storage.h>
40#include <qpe/mimetype.h>
41#include <qpe/global.h>
42#include <qpe/resource.h>
43
44#include <qdir.h>
45#include <qregexp.h>
46#include <qstring.h>
47#include <qtextstream.h>
48#include <qstringlist.h>
49#include <qcstring.h>
50#include <qfile.h>
51
52
53class Om3u : public QStringList {
54// Q_OBJECT
55public:
56 Om3u( const QString &filePath);
57 ~Om3u();
58 void readM3u();
59 void readPls();
60 void write();
61 void add(const QString &);
62 void remove(const QString &);
63 void deleteFile(const QString &);
64 void close();
65
66public slots:
67
68protected:
69
70private:
71 QFile f;
72private slots:
73
74
75};
76
77#endif// M3U_H
78
79
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index 619d36d..52814e7 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,24 +1,24 @@
1TEMPLATE = app 1TEMPLATE = app
2#CONFIG = qt warn_on release 2#CONFIG = qt warn_on release
3CONFIG = qt warn_on debug 3CONFIG = qt warn_on debug
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \ 5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ 6 videowidget.h audiowidget.h playlistwidget.h om3u.h mediaplayer.h inputDialog.h \
7 frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ 7 frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\
8 alphablend.h yuv2rgb.h 8 alphablend.h yuv2rgb.h
9SOURCES = main.cpp \ 9SOURCES = main.cpp \
10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \ 10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \
11 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ 11 videowidget.cpp audiowidget.cpp playlistwidget.cpp om3u.cpp mediaplayer.cpp inputDialog.cpp \
12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ 12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \
13 playlistwidgetgui.cpp\ 13 playlistwidgetgui.cpp\
14 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S 14 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S
15TARGET = opieplayer2 15TARGET = opieplayer2
16INCLUDEPATH += $(OPIEDIR)/include 16INCLUDEPATH += $(OPIEDIR)/include
17DEPENDPATH += $(OPIEDIR)/include 17DEPENDPATH += $(OPIEDIR)/include
18LIBS += -lqpe -lpthread -lopie -lxine 18LIBS += -lqpe -lpthread -lopie -lxine
19MOC_DIR = qpeobj 19MOC_DIR = qpeobj
20OBJECTS_DIR = qpeobj 20OBJECTS_DIR = qpeobj
21 21
22#INCLUDEPATH += $(OPIEDIR)/include 22#INCLUDEPATH += $(OPIEDIR)/include
23#DEPENDPATH += $(OPIEDIR)/include 23#DEPENDPATH += $(OPIEDIR)/include
24 24
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 6acdd1d..ab6b593 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -26,85 +26,86 @@
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 40
41#include <qdir.h> 41#include <qdir.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46#include "playlistselection.h" 46#include "playlistselection.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
49#include "inputDialog.h" 49#include "inputDialog.h"
50#include "om3u.h"
50 51
51//only needed for the random play 52//only needed for the random play
52#include <stdlib.h> 53#include <stdlib.h>
53 54
54#include "audiowidget.h" 55#include "audiowidget.h"
55#include "videowidget.h" 56#include "videowidget.h"
56 57
57extern MediaPlayerState *mediaPlayerState; 58extern MediaPlayerState *mediaPlayerState;
58 59
59 60
60PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 61PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
61 : PlayListWidgetGui( parent, name, fl ) { 62 : PlayListWidgetGui( parent, name, fl ) {
62 63
63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 64 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
64 "opieplayer2/add_to_playlist", 65 "opieplayer2/add_to_playlist",
65 this , SLOT(addSelected() ) ); 66 this , SLOT(addSelected() ) );
66 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 67 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
67 "opieplayer2/remove_from_playlist", 68 "opieplayer2/remove_from_playlist",
68 this , SLOT(removeSelected() ) ); 69 this , SLOT(removeSelected() ) );
69 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 70 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
70 this , SLOT( btnPlay( bool) ), TRUE ); 71 this , SLOT( btnPlay( bool) ), TRUE );
71 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 72 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
72 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 73 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
73 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 74 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
74 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 75 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
75 76
76 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 77 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 78 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
78 this, SLOT( addAllMusicToList() ) ); 79 this, SLOT( addAllMusicToList() ) );
79 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
80 this, SLOT( addAllVideoToList() ) ); 81 this, SLOT( addAllVideoToList() ) );
81 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 82 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
82 this, SLOT( addAllToList() ) ); 83 this, SLOT( addAllToList() ) );
83 pmPlayList->insertSeparator(-1); 84 pmPlayList->insertSeparator(-1);
84 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 85// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
85 this, SLOT( saveList() ) ); 86// this, SLOT( saveList() ) );
86 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), 87 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
87 this, SLOT(writem3u() ) ); 88 this, SLOT(writem3u() ) );
88 pmPlayList->insertSeparator(-1); 89 pmPlayList->insertSeparator(-1);
89 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 90 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
90 this,SLOT( openFile() ) ); 91 this,SLOT( openFile() ) );
91 pmPlayList->insertSeparator(-1); 92 pmPlayList->insertSeparator(-1);
92 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 93 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
93 this,SLOT( scanForAudio() ) ); 94 this,SLOT( scanForAudio() ) );
94 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 95 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
95 this,SLOT( scanForVideo() ) ); 96 this,SLOT( scanForVideo() ) );
96 97
97 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 98 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
98 mediaPlayerState, SLOT( toggleFullscreen() ) ); 99 mediaPlayerState, SLOT( toggleFullscreen() ) );
99 100
100 Config cfg( "OpiePlayer" ); 101 Config cfg( "OpiePlayer" );
101 bool b= cfg.readBoolEntry("FullScreen", 0); 102 bool b= cfg.readBoolEntry("FullScreen", 0);
102 mediaPlayerState->setFullscreen( b ); 103 mediaPlayerState->setFullscreen( b );
103 pmView->setItemChecked( -16, b ); 104 pmView->setItemChecked( -16, b );
104 105
105 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 106 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
106 d->selectedFiles, SLOT(moveSelectedUp() ) ); 107 d->selectedFiles, SLOT(moveSelectedUp() ) );
107 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 108 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
108 d->selectedFiles, SLOT(removeSelected() ) ); 109 d->selectedFiles, SLOT(removeSelected() ) );
109 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 110 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
110 d->selectedFiles, SLOT(moveSelectedDown() ) ); 111 d->selectedFiles, SLOT(moveSelectedDown() ) );
@@ -126,130 +127,183 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
126 this, SLOT( addToSelection( QListViewItem *) ) ); 127 this, SLOT( addToSelection( QListViewItem *) ) );
127 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 128 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
128 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
129 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 130 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
130 this,SLOT( playIt( QListViewItem *) ) ); 131 this,SLOT( playIt( QListViewItem *) ) );
131 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 132 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
132 this, SLOT( addToSelection( QListViewItem *) ) ); 133 this, SLOT( addToSelection( QListViewItem *) ) );
133 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 134 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
134 this, SLOT( loadList( const DocLnk & ) ) ); 135 this, SLOT( loadList( const DocLnk & ) ) );
135 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 136 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
136 this, SLOT( tabChanged( QWidget* ) ) ); 137 this, SLOT( tabChanged( QWidget* ) ) );
137 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 138 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
138 d->tbPlay, SLOT( setOn( bool ) ) ); 139 d->tbPlay, SLOT( setOn( bool ) ) );
139 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 140 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
140 d->tbLoop, SLOT( setOn( bool ) ) ); 141 d->tbLoop, SLOT( setOn( bool ) ) );
141 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 142 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
142 d->tbShuffle, SLOT( setOn( bool ) ) ); 143 d->tbShuffle, SLOT( setOn( bool ) ) );
143 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
144 this, SLOT( setPlaylist( bool ) ) ); 145 this, SLOT( setPlaylist( bool ) ) );
145 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 146 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
146 this, SLOT( playIt( QListViewItem *) ) ); 147 this, SLOT( playIt( QListViewItem *) ) );
147 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 148 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
148 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 149 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
149 150
150 readConfig( cfg ); 151// cfg.setGroup( "PlayList" );
151 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 152// if( cfg.readBoolEntry("newPlaylist") ){
152 loadList(DocLnk( currentPlaylist ) ); 153 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
153 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 154 loadList(DocLnk( currentPlaylist ) );
154 155 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
156// } else {
157// readConfig( cfg );
158
159// }
155 // see which skins are installed 160 // see which skins are installed
156 videoScan=FALSE; 161 videoScan=FALSE;
157 audioScan=FALSE; 162 audioScan=FALSE;
158 populateSkinsMenu(); 163 populateSkinsMenu();
159 initializeStates(); 164 initializeStates();
160} 165}
161 166
162 167
163PlayListWidget::~PlayListWidget() { 168PlayListWidget::~PlayListWidget() {
164 // WTF?!@?! 169 // WTF?!@?!
165 170
166 if ( d->current ) { 171 if ( d->current ) {
167 delete d->current; 172 delete d->current;
168 } 173 }
169 delete d; 174 delete d;
170} 175}
171 176
172 177
173void PlayListWidget::initializeStates() { 178void PlayListWidget::initializeStates() {
174 d->tbPlay->setOn( mediaPlayerState->playing() ); 179 d->tbPlay->setOn( mediaPlayerState->playing() );
175 d->tbLoop->setOn( mediaPlayerState->looping() ); 180 d->tbLoop->setOn( mediaPlayerState->looping() );
176 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 181 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
177 setPlaylist( true ); 182 setPlaylist( true );
178} 183}
179 184
180 185
181void PlayListWidget::readConfig( Config& cfg ) { 186void PlayListWidget::readConfig( Config& cfg ) {
187
182 cfg.setGroup( "PlayList" ); 188 cfg.setGroup( "PlayList" );
183 QString currentString = cfg.readEntry( "current", "" ); 189 QString currentString = cfg.readEntry( "current", "" );
184 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); 190 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
191
185 for ( int i = 0; i < noOfFiles; i++ ) { 192 for ( int i = 0; i < noOfFiles; i++ ) {
186 QString entryName; 193 QString entryName;
187 entryName.sprintf( "File%i", i + 1 ); 194 entryName.sprintf( "File%i", i + 1 );
195
188 QString linkFile = cfg.readEntry( entryName ); 196 QString linkFile = cfg.readEntry( entryName );
197
198 qDebug("reading "+linkFile);
199
189 if( QFileInfo( linkFile ).exists() ) { 200 if( QFileInfo( linkFile ).exists() ) {
201
190 DocLnk lnk( linkFile ); 202 DocLnk lnk( linkFile );
203
191 if ( QFileInfo( lnk.file() ).exists() || 204 if ( QFileInfo( lnk.file() ).exists() ||
205
192 linkFile.find( "http" , 0, TRUE) != -1) { 206 linkFile.find( "http" , 0, TRUE) != -1) {
207
193 d->selectedFiles->addToSelection( lnk ); 208 d->selectedFiles->addToSelection( lnk );
209
194 } 210 }
195 } 211 }
196 } 212 }
197 d->selectedFiles->setSelectedItem( currentString ); 213 d->selectedFiles->setSelectedItem( currentString );
214
198} 215}
199 216
200 217
201void PlayListWidget::writeConfig( Config& cfg ) const { 218void PlayListWidget::writeConfig( Config& cfg ) const {
202 d->selectedFiles->writeCurrent( cfg ); 219
203 cfg.setGroup( "PlayList" ); 220// Config config( "OpiePlayer" );
204 int noOfFiles = 0; 221// config.setGroup( "PlayList" );
205 d->selectedFiles->first(); 222
206 do { 223// if(config.readBoolEntry("newPlaylist")) {
207 const DocLnk *lnk = d->selectedFiles->current(); 224// new for testing
208 if ( lnk ) { 225 QString name, filename, list;
209 QString entryName; 226 Om3u *m3uList;
210 entryName.sprintf( "File%i", noOfFiles + 1 ); 227 name = "default";
211 cfg.writeEntry( entryName, lnk->linkFile() ); 228
212 // if this link does exist, add it so we have the file 229 filename=QPEApplication::documentDir() + "/" + name+".m3u";
213 // next time... 230
214 if ( !QFile::exists( lnk->linkFile() ) ) { 231 m3uList = new Om3u(filename);
215 // the way writing lnks doesn't really check for out 232
216 // of disk space, but check it anyway. 233 d->selectedFiles->first();
217 if ( !lnk->writeLink() ) { 234 do {
218 QMessageBox::critical( 0, tr("Out of space"), 235 m3uList->add( d->selectedFiles->current()->file());
219 tr( "There was a problem saving "
220 "the playlist.\n"
221 "Your playlist "
222 "may be missing some entries\n"
223 "the next time you start it." )
224 );
225 }
226 }
227 noOfFiles++;
228 } 236 }
229 } 237 while ( d->selectedFiles->next() );
230 while ( d->selectedFiles->next() ); 238
231 cfg.writeEntry("NumberOfFiles", noOfFiles ); 239 qDebug( list );
240
241 m3uList->write();
242 m3uList->close();
243 if(m3uList) delete m3uList;
244
245 DocLnk lnk;
246 lnk.setFile( filename);
247 lnk.setIcon("opieplayer2/playlist2");
248 lnk.setName( name); //sets file name
249
250 qDebug("writing default playlist "+filename);
251
252 config.writeEntry("CurrentPlaylist", filename);
253// currentPlayList=filename;
254
255 if(!lnk.writeLink()) {
256 qDebug("Writing doclink did not work");
257 }
258
259// } else {
260
261// d->selectedFiles->writeCurrent( cfg );
262// int noOfFiles = 0;
263// d->selectedFiles->first();
264
265// do {
266// const DocLnk *lnk = d->selectedFiles->current();
267
268// if ( lnk ) {
269
270// QString entryName;
271// entryName.sprintf( "File%i", noOfFiles + 1 );
272
273// cfg.writeEntry( entryName, lnk->linkFile() );
274// // if this link does exist, add it so we have the file
275// // next time...
276
277// if ( !QFile::exists( lnk->linkFile() ) ) {
278// lnk->writeLink();
279// }
280// }
281// noOfFiles++;
282// }
283// while ( d->selectedFiles->next() );
284// cfg.writeEntry("NumberOfFiles", noOfFiles );
285// }
232} 286}
233 287
234 288
235void PlayListWidget::addToSelection( const DocLnk& lnk ) { 289void PlayListWidget::addToSelection( const DocLnk& lnk ) {
236 d->setDocumentUsed = FALSE; 290 d->setDocumentUsed = FALSE;
237 if ( mediaPlayerState->playlist() ) { 291 if ( mediaPlayerState->playlist() ) {
238 if( QFileInfo( lnk.file() ).exists() || 292 if( QFileInfo( lnk.file() ).exists() ||
239 lnk.file().left(4) == "http" ) 293 lnk.file().left(4) == "http" )
240 d->selectedFiles->addToSelection( lnk ); 294 d->selectedFiles->addToSelection( lnk );
241 } 295 }
242 else 296 else
243 mediaPlayerState->setPlaying( TRUE ); 297 mediaPlayerState->setPlaying( TRUE );
244} 298}
245 299
246 300
247void PlayListWidget::clearList() { 301void PlayListWidget::clearList() {
248 while ( first() ) { 302 while ( first() ) {
249 d->selectedFiles->removeSelected(); 303 d->selectedFiles->removeSelected();
250 } 304 }
251} 305}
252 306
253 307
254void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 308void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
255 switch (mouse) { 309 switch (mouse) {
@@ -379,133 +433,151 @@ bool PlayListWidget::prev() {
379 d->selectedFiles->first(); 433 d->selectedFiles->first();
380 } 434 }
381 if ( cur == current() ) 435 if ( cur == current() )
382 if ( !d->selectedFiles->next() ) { 436 if ( !d->selectedFiles->next() ) {
383 d->selectedFiles->first(); 437 d->selectedFiles->first();
384 } 438 }
385 return TRUE; 439 return TRUE;
386 } else { 440 } else {
387 if ( !d->selectedFiles->prev() ) { 441 if ( !d->selectedFiles->prev() ) {
388 if ( mediaPlayerState->looping() ) { 442 if ( mediaPlayerState->looping() ) {
389 return d->selectedFiles->last(); 443 return d->selectedFiles->last();
390 } else { 444 } else {
391 return FALSE; 445 return FALSE;
392 } 446 }
393 } 447 }
394 return TRUE; 448 return TRUE;
395 } 449 }
396 } else { 450 } else {
397 return mediaPlayerState->looping(); 451 return mediaPlayerState->looping();
398 } 452 }
399} 453}
400 454
401 455
402bool PlayListWidget::next() { 456bool PlayListWidget::next() {
403qDebug("<<<<<<<<<<<<next()"); 457//qDebug("<<<<<<<<<<<<next()");
404 if ( mediaPlayerState->playlist() ) { 458 if ( mediaPlayerState->playlist() ) {
405 if ( mediaPlayerState->shuffled() ) { 459 if ( mediaPlayerState->shuffled() ) {
406 return prev(); 460 return prev();
407 } else { 461 } else {
408 if ( !d->selectedFiles->next() ) { 462 if ( !d->selectedFiles->next() ) {
409 if ( mediaPlayerState->looping() ) { 463 if ( mediaPlayerState->looping() ) {
410 return d->selectedFiles->first(); 464 return d->selectedFiles->first();
411 } else { 465 } else {
412 return FALSE; 466 return FALSE;
413 } 467 }
414 } 468 }
415 return TRUE; 469 return TRUE;
416 } 470 }
417 } else { 471 } else {
418 return mediaPlayerState->looping(); 472 return mediaPlayerState->looping();
419 } 473 }
420} 474}
421 475
422 476
423bool PlayListWidget::first() { 477bool PlayListWidget::first() {
424 if ( mediaPlayerState->playlist() ) 478 if ( mediaPlayerState->playlist() )
425 return d->selectedFiles->first(); 479 return d->selectedFiles->first();
426 else 480 else
427 return mediaPlayerState->looping(); 481 return mediaPlayerState->looping();
428} 482}
429 483
430 484
431bool PlayListWidget::last() { 485bool PlayListWidget::last() {
432 if ( mediaPlayerState->playlist() ) 486 if ( mediaPlayerState->playlist() )
433 return d->selectedFiles->last(); 487 return d->selectedFiles->last();
434 else 488 else
435 return mediaPlayerState->looping(); 489 return mediaPlayerState->looping();
436} 490}
437 491
438 492
439void PlayListWidget::saveList() { 493 void PlayListWidget::saveList() {
494// Config config( "OpiePlayer" );
495// config.setGroup( "PlayList" );
496
497// if(config.readBoolEntry("newPlaylist") ){
498 writem3u();
499
500// } else {
501
502// QString filename;
503// InputDialog *fileDlg = 0l;
504// fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
505// fileDlg->exec();
506// if( fileDlg->result() == 1 ) {
507// if ( d->current )
508// delete d->current;
509// filename = fileDlg->text();//+".playlist";
510// // qDebug("saving playlist "+filename+".playlist");
511
512// Config cfg( filename +".playlist");
513// writeConfig( cfg );
514
515// DocLnk lnk;
516// lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf");
517// //sets File property
518// lnk.setType("playlist/plain");
519// lnk.setIcon("opieplayer2/playlist2");
520// lnk.setName( filename); //sets file name
521// // qDebug(filename);
522// if(!lnk.writeLink()) {
523// qDebug("Writing doclink did not work");
524// }
525// }
526
527// config.writeEntry("CurrentPlaylist",filename);
528// setCaption(tr("OpiePlayer: ")+filename);
529// d->selectedFiles->first();
530// if(fileDlg) {
531// delete fileDlg;
532// }
533// }
534 }
440 535
441 QString filename;
442 InputDialog *fileDlg = 0l;
443 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
444 fileDlg->exec();
445 if( fileDlg->result() == 1 ) {
446 if ( d->current )
447 delete d->current;
448 filename = fileDlg->text();//+".playlist";
449 // qDebug("saving playlist "+filename+".playlist");
450 Config cfg( filename +".playlist");
451 writeConfig( cfg );
452
453 DocLnk lnk;
454 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf");
455//sets File property
456 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
457 lnk.setIcon("opieplayer2/playlist2");
458 lnk.setName( filename); //sets file name
459 // qDebug(filename);
460 if(!lnk.writeLink()) {
461 qDebug("Writing doclink did not work");
462 }
463 }
464 Config config( "OpiePlayer" );
465 config.writeEntry("CurrentPlaylist",filename);
466 setCaption(tr("OpiePlayer: ")+filename);
467 d->selectedFiles->first();
468 if(fileDlg) {
469 delete fileDlg;
470 }
471}
472 536
473void PlayListWidget::loadList( const DocLnk & lnk) { 537void PlayListWidget::loadList( const DocLnk & lnk) {
474 QString name= lnk.name(); 538 QString name = lnk.name();
475// qDebug("currentList is "+name); 539 qDebug("currentList is "+name);
540
476 if( name.length()>0) { 541 if( name.length()>0) {
477 setCaption("OpiePlayer: "+name); 542 setCaption("OpiePlayer: "+name);
478 // qDebug("load list "+ name+".playlist"); 543 qDebug("<<<<<<<<<<<<load list "+ lnk.file());
479 clearList(); 544 clearList();
480 Config cfg( name+".playlist"); 545
481 readConfig(cfg); 546// if(name.right(3) == "m3u") {
547
548 readm3u(lnk.file());
549// } else {
550// / Config cfg( name+".playlist");
551// readConfig(cfg);
482 552
483 tabWidget->setCurrentPage(0); 553 tabWidget->setCurrentPage(0);
484 554
485 Config config( "OpiePlayer" ); 555 Config config( "OpiePlayer" );
486 config.writeEntry("CurrentPlaylist", name); 556 config.setGroup( "PlayList" );
487 // d->selectedFiles->first(); 557 config.writeEntry("CurrentPlaylist", lnk.file());
558// // d->selectedFiles->first();
559// }
488 } 560 }
489} 561}
490 562
491 563
492void PlayListWidget::setPlaylist( bool shown ) { 564void PlayListWidget::setPlaylist( bool shown ) {
493 if ( shown ) { 565 if ( shown ) {
494 d->playListFrame->show(); 566 d->playListFrame->show();
495 } else { 567 } else {
496 d->playListFrame->hide(); 568 d->playListFrame->hide();
497 } 569 }
498} 570}
499 571
500 572
501void PlayListWidget::addSelected() { 573void PlayListWidget::addSelected() {
502 574
503 Config cfg( "OpiePlayer" ); 575 Config cfg( "OpiePlayer" );
504 cfg.setGroup("PlayList"); 576 cfg.setGroup("PlayList");
505 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 577 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
506 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 578 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
507 579
508 switch (whichList()) { 580 switch (whichList()) {
509 case 0: //playlist 581 case 0: //playlist
510 break; 582 break;
511 case 1: { //audio 583 case 1: { //audio
@@ -559,49 +631,49 @@ void PlayListWidget::playIt( QListViewItem *it) {
559 mediaPlayerState->setPlaying(TRUE); 631 mediaPlayerState->setPlaying(TRUE);
560 d->selectedFiles->unSelect(); 632 d->selectedFiles->unSelect();
561} 633}
562 634
563 635
564void PlayListWidget::addToSelection( QListViewItem *it) { 636void PlayListWidget::addToSelection( QListViewItem *it) {
565 d->setDocumentUsed = FALSE; 637 d->setDocumentUsed = FALSE;
566 638
567 if(it) { 639 if(it) {
568 switch ( whichList()) { 640 switch ( whichList()) {
569 case 1: { 641 case 1: {
570 QListIterator<DocLnk> dit( files.children() ); 642 QListIterator<DocLnk> dit( files.children() );
571 for ( ; dit.current(); ++dit ) { 643 for ( ; dit.current(); ++dit ) {
572 if( dit.current()->name() == it->text(0)) { 644 if( dit.current()->name() == it->text(0)) {
573 if(QFileInfo( dit.current()->file()).exists()) 645 if(QFileInfo( dit.current()->file()).exists())
574 d->selectedFiles->addToSelection( **dit ); 646 d->selectedFiles->addToSelection( **dit );
575 } 647 }
576 } 648 }
577 } 649 }
578 break; 650 break;
579 case 2: { 651 case 2: {
580 QListIterator<DocLnk> dit( vFiles.children() ); 652 QListIterator<DocLnk> dit( vFiles.children() );
581 for ( ; dit.current(); ++dit ) { 653 for ( ; dit.current(); ++dit ) {
582 if( dit.current()->name() == it->text(0)) { 654 if( dit.current()->name() == it->text(0)) {
583 if(QFileInfo( dit.current()->file()).exists()) 655 if( QFileInfo( dit.current()->file()).exists() )
584 d->selectedFiles->addToSelection( **dit ); 656 d->selectedFiles->addToSelection( **dit );
585 } 657 }
586 } 658 }
587 } 659 }
588 break; 660 break;
589 case 0: 661 case 0:
590 break; 662 break;
591 }; 663 };
592 tabWidget->setCurrentPage(0); 664 tabWidget->setCurrentPage(0);
593 } 665 }
594} 666}
595 667
596 668
597void PlayListWidget::tabChanged(QWidget *) { 669void PlayListWidget::tabChanged(QWidget *) {
598 670
599 switch ( whichList()) { 671 switch ( whichList()) {
600 case 0: 672 case 0:
601 { 673 {
602 if( !tbDeletePlaylist->isHidden() ) { 674 if( !tbDeletePlaylist->isHidden() ) {
603 tbDeletePlaylist->hide(); 675 tbDeletePlaylist->hide();
604 } 676 }
605 d->tbRemoveFromList->setEnabled(TRUE); 677 d->tbRemoveFromList->setEnabled(TRUE);
606 d->tbAddToList->setEnabled(FALSE); 678 d->tbAddToList->setEnabled(FALSE);
607 } 679 }
@@ -623,106 +695,80 @@ void PlayListWidget::tabChanged(QWidget *) {
623 videoView->clear(); 695 videoView->clear();
624 populateVideoView(); 696 populateVideoView();
625 if( !tbDeletePlaylist->isHidden() ) { 697 if( !tbDeletePlaylist->isHidden() ) {
626 tbDeletePlaylist->hide(); 698 tbDeletePlaylist->hide();
627 } 699 }
628 d->tbRemoveFromList->setEnabled(FALSE); 700 d->tbRemoveFromList->setEnabled(FALSE);
629 d->tbAddToList->setEnabled(TRUE); 701 d->tbAddToList->setEnabled(TRUE);
630 } 702 }
631 break; 703 break;
632 case 3: 704 case 3:
633 { 705 {
634 if( tbDeletePlaylist->isHidden() ) { 706 if( tbDeletePlaylist->isHidden() ) {
635 tbDeletePlaylist->show(); 707 tbDeletePlaylist->show();
636 } 708 }
637 playLists->reread(); 709 playLists->reread();
638 } 710 }
639 break; 711 break;
640 }; 712 };
641} 713}
642 714
643 715
644void PlayListWidget::btnPlay(bool b) { 716void PlayListWidget::btnPlay(bool b) {
645// mediaPlayerState->setPlaying(false); 717// mediaPlayerState->setPlaying(false);
646 mediaPlayerState->setPlaying(b); 718 mediaPlayerState->setPlaying(b);
647// qApp->processEvents();
648 insanityBool=FALSE; 719 insanityBool=FALSE;
649// switch ( whichList()) {
650// case 0:
651// {
652// mediaPlayerState->setPlaying(b);
653// }
654// break;
655// case 1:
656// {
657// mediaPlayerState->setPlaying(b);
658// qApp->processEvents();
659// insanityBool=FALSE;
660// }// audioView->clearSelection();
661// break;
662// case 2:
663// {
664// // addToSelection( videoView->currentItem() );
665// mediaPlayerState->setPlaying(b);
666// qApp->processEvents();
667// // d->selectedFiles->removeSelected( );
668// // tabWidget->setCurrentPage(2);
669// // d->selectedFiles->unSelect();
670// insanityBool=FALSE;
671// }// videoView->clearSelection();
672// break;
673// };
674
675} 720}
676 721
677void PlayListWidget::deletePlaylist() { 722void PlayListWidget::deletePlaylist() {
678 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 723 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
679 (tr("You really want to delete\nthis playlist?")), 724 (tr("You really want to delete\nthis playlist?")),
680 (tr("Yes")), (tr("No")), 0 )){ 725 (tr("Yes")), (tr("No")), 0 )){
681 case 0: // Yes clicked, 726 case 0: // Yes clicked,
682 QFile().remove(playLists->selectedDocument().file()); 727 QFile().remove(playLists->selectedDocument().file());
683 QFile().remove(playLists->selectedDocument().linkFile()); 728 QFile().remove(playLists->selectedDocument().linkFile());
684 playLists->reread(); 729 playLists->reread();
685 break; 730 break;
686 case 1: // Cancel 731 case 1: // Cancel
687 break; 732 break;
688 }; 733 };
689} 734}
690 735
691 736
692void PlayListWidget::playSelected() { 737void PlayListWidget::playSelected() {
693 btnPlay( TRUE); 738 btnPlay( TRUE);
694} 739}
695 740
696 741
697void PlayListWidget::scanForAudio() { 742void PlayListWidget::scanForAudio() {
698// qDebug("scan for audio"); 743// qDebug("scan for audio");
699 files.detachChildren(); 744 files.detachChildren();
700 QListIterator<DocLnk> sdit( files.children() ); 745 QListIterator<DocLnk> sdit( files.children() );
701 for ( ; sdit.current(); ++sdit ) { 746 for ( ; sdit.current(); ++sdit ) {
702 delete sdit.current(); 747 delete sdit.current();
703 } 748 }
704 Global::findDocuments(&files, "audio/*"); 749// Global::findDocuments( &files, "audio/*");
750 Global::findDocuments( &files, "audio/mpeg;audio/x-wav;audio/x-ogg");
705 audioScan = TRUE; 751 audioScan = TRUE;
706} 752}
707 753
708void PlayListWidget::scanForVideo() { 754void PlayListWidget::scanForVideo() {
709// qDebug("scan for video"); 755// qDebug("scan for video");
710 vFiles.detachChildren(); 756 vFiles.detachChildren();
711 QListIterator<DocLnk> sdit( vFiles.children() ); 757 QListIterator<DocLnk> sdit( vFiles.children() );
712 for ( ; sdit.current(); ++sdit ) { 758 for ( ; sdit.current(); ++sdit ) {
713 delete sdit.current(); 759 delete sdit.current();
714 } 760 }
715 Global::findDocuments(&vFiles, "video/*"); 761 Global::findDocuments(&vFiles, "video/*");
716 videoScan = TRUE; 762 videoScan = TRUE;
717} 763}
718 764
719void PlayListWidget::populateAudioView() { 765void PlayListWidget::populateAudioView() {
720 audioView->clear(); 766 audioView->clear();
721 StorageInfo storageInfo; 767 StorageInfo storageInfo;
722 const QList<FileSystem> &fs = storageInfo.fileSystems(); 768 const QList<FileSystem> &fs = storageInfo.fileSystems();
723 if(!audioScan) { 769 if(!audioScan) {
724 scanForAudio(); 770 scanForAudio();
725 } 771 }
726 772
727 QListIterator<DocLnk> dit( files.children() ); 773 QListIterator<DocLnk> dit( files.children() );
728 QListIterator<FileSystem> it ( fs ); 774 QListIterator<FileSystem> it ( fs );
@@ -776,317 +822,299 @@ void PlayListWidget::populateVideoView() {
776 } 822 }
777 } 823 }
778 824
779 QListViewItem * newItem; 825 QListViewItem * newItem;
780 if ( QFile( Vdit.current()->file() ).exists() ) { 826 if ( QFile( Vdit.current()->file() ).exists() ) {
781 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 827 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
782 QString::number( QFile( Vdit.current()->file() ).size() ), 828 QString::number( QFile( Vdit.current()->file() ).size() ),
783 storage, Vdit.current()->file()); 829 storage, Vdit.current()->file());
784 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 830 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
785 } 831 }
786 } 832 }
787} 833}
788 834
789 835
790void PlayListWidget::openFile() { 836void PlayListWidget::openFile() {
791 QString filename, name; 837 QString filename, name;
792 InputDialog *fileDlg; 838 InputDialog *fileDlg;
793 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 839 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
794 fileDlg->exec(); 840 fileDlg->exec();
795 if( fileDlg->result() == 1 ) { 841 if( fileDlg->result() == 1 ) {
796 filename = fileDlg->text(); 842 filename = fileDlg->text();
797 843
798 qDebug( "Selected filename is " + filename ); 844 qDebug( "Selected filename is " + filename );
799 845
800 if(filename.left(4) == "http") { 846 if(filename.left(4) == "http") { //if http, lets write a new m3u
847 Om3u *m3uList;
801 DocLnk lnk; 848 DocLnk lnk;
802 QString m3uFile, m3uFilePath; 849 QString m3uFile, m3uFilePath;
803 if(filename.find(":",8,TRUE) != -1) { 850
804//found a port 851 if(filename.find(":",8,TRUE) != -1) { //found a port
805 m3uFile=filename.left(filename.find(":",8,TRUE)); 852 m3uFile = filename.left( filename.find( ":",8,TRUE));
806 853
807 m3uFile=m3uFile.right(m3uFile.length()-7); 854 m3uFile = m3uFile.right( 7);
808 qDebug(m3uFile);
809 m3uFilePath= QDir::homeDirPath()+"/"+m3uFile+".m3u";
810
811 QFile f(m3uFilePath );
812 f.open( IO_WriteOnly );
813 f.writeBlock( filename, filename.length() );
814 f.close();
815
816 lnk.setName( m3uFile ); //sets file name
817 lnk.setFile( m3uFilePath ); //sets File property
818 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
819 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
820 855
821 } else if(filename.left(4) == "http"){ 856 } else if(filename.left(4) == "http"){
822 857
823 m3uFile=m3uFile.right(m3uFile.length()-7); 858 m3uFile=filename;
824 qDebug(m3uFile); 859 m3uFile = m3uFile.right( m3uFile.length() - 7);
825
826 m3uFilePath= QDir::homeDirPath()+"/"+m3uFile+".m3u";
827 860
828 QFile f(m3uFilePath ); 861 } else{
829 f.open( IO_WriteOnly ); 862 m3uFile=filename;
830 f.writeBlock( filename, filename.length() ); 863 }
831 f.close();
832 864
833 lnk.setName( m3uFile ); //sets file name 865// qDebug( m3uFile);
834 lnk.setFile( m3uFilePath ); //sets File property
835 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
836 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
837 866
838 } else{ 867//this is where this new m3u is going to live at
868 m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u";
869// m3uFile += ".m3u";
870 m3uList = new Om3u( m3uFile+".m3u");
839 871
840 QFile f( filename ); 872 m3uList->add( filename);
841 f.open( IO_WriteOnly ); 873 m3uList->write();
842 f.writeBlock( filename, filename.length() ); 874 if(m3uList) delete m3uList;
843 f.close();
844 875
845 lnk.setName( filename ); //sets file name 876// qDebug( m3uFile);
846 lnk.setFile( filename ); //sets File property 877 lnk.setName( filename ); //sets file name
847 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); 878 lnk.setFile( m3uFilePath ); //sets File property
848 lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); 879 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
849 } 880
850 lnk.setExec( "opieplayer" ); 881 lnk.setExec( "opieplayer2" );
851 lnk.setIcon( "opieplayer2/MPEGPlayer" ); 882 lnk.setIcon("opieplayer2/playlist2");
852 883
853 if( !lnk.writeLink() ) { 884 if( !lnk.writeLink() ) {
854 qDebug( "Writing doclink did not work" ); 885 qDebug( "Writing doclink did not work" );
855 } 886 }
856 d->selectedFiles->addToSelection( lnk ); 887 d->selectedFiles->addToSelection( lnk );
857 888
858 } 889 }
859 else if( filename.right( 3 ) == "m3u" ) { 890 else if( filename.right( 3 ) == "m3u" ) {
860 readm3u( filename ); 891 readm3u( filename );
892
861 } else if( filename.right(3) == "pls" ) { 893 } else if( filename.right(3) == "pls" ) {
862 readPls( filename ); 894 readPls( filename );
863 } 895 }
864 } 896 }
865 if( fileDlg ) { 897 if( fileDlg ) {
866 delete fileDlg; 898 delete fileDlg;
867 } 899 }
868} 900}
869 901
902/*
903reads m3u and adds files/urls to playlist */
904void PlayListWidget::readm3u( const QString &filename ) {
905 qDebug( "read m3u filename " + filename );
906
907 Om3u *m3uList;
908 QString s, name;
909 m3uList = new Om3u( filename);
910 m3uList->readM3u();
911 DocLnk lnk;
912 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
913 s = *it;
914 s.replace( QRegExp( "%20" )," " );
915 qDebug("reading "+ s);
916
917 if( QFileInfo( s ).exists() ) {
918 lnk.setName( QFileInfo(s).baseName());
919 qDebug("set link "+s);
920 if(s.at(s.length()-4) == '.') //if regular file
921 lnk.setFile( s);
922 else
923 lnk.setFile( s+"/"); //if url with no extension
924
925 d->selectedFiles->addToSelection( lnk );
926 }
927 }
928 Config config( "OpiePlayer" );
929 config.setGroup( "PlayList" );
930
931 config.writeEntry("CurrentPlaylist",filename);
932 currentPlayList=filename;
933
934 m3uList->close();
935 if(m3uList) delete m3uList;
936
937 d->selectedFiles->setSelectedItem( s);
938 setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName());
939
940}
941
942/*
943reads pls and adds files/urls to playlist */
944void PlayListWidget::readPls( const QString &filename ) {
945
946 qDebug( "pls filename is " + filename );
947 Om3u *m3uList;
948 QString s, name;
949 m3uList = new Om3u( filename);
950 m3uList->readPls();
951
952 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
953 s = *it;
954 s.replace( QRegExp( "%20" )," " );
955 DocLnk lnk( s );
956 QFileInfo f( s );
957 QString name = f.baseName();
958
959 if( name.left( 4 ) == "http" ) {
960 name = s.right( s.length() - 7);
961 } else {
962 name = s;
963 }
964
965 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
966
967 lnk.setName( name );
968 if( s.at( s.length() - 4) == '.') {// if this is probably a file
969 lnk.setFile( s );
970 } else { //if its a url
971 if( name.right( 1 ).find( '/' ) == -1) {
972 s += "/";
973 }
974 lnk.setFile( s );
975 }
976 lnk.setType( "audio/x-mpegurl" );
977
978 lnk.writeLink();
979 d->selectedFiles->addToSelection( lnk );
980 }
981
982 m3uList->close();
983 if(m3uList) delete m3uList;
984}
985
986/*
987 writes current playlist to m3u file */
988void PlayListWidget::writem3u() {
989 InputDialog *fileDlg;
990 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
991 fileDlg->exec();
992 QString name, filename, list;
993 Om3u *m3uList;
994
995 if( fileDlg->result() == 1 ) {
996 name = fileDlg->text();
997 qDebug( filename );
998
999 if( name.left( 1) != "/" ) {
1000 filename = QPEApplication::documentDir() + "/" + name;
1001 }
1002
1003 if( name.right( 3 ) != "m3u" ) {
1004 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1005 }
1006
1007 m3uList = new Om3u(filename);
1008
1009 d->selectedFiles->first();
1010
1011 do {
1012 m3uList->add( d->selectedFiles->current()->file());
1013 }
1014 while ( d->selectedFiles->next() );
1015// qDebug( list );
1016
1017 m3uList->write();
1018 m3uList->close();
1019 }
1020 if(m3uList) delete m3uList;
1021 if(fileDlg) delete fileDlg;
1022
1023 DocLnk lnk;
1024 lnk.setFile( filename);
1025 lnk.setIcon("opieplayer2/playlist2");
1026 lnk.setName( name); //sets file name
1027
1028// qDebug(filename);
1029 Config config( "OpiePlayer" );
1030 config.setGroup( "PlayList" );
1031
1032 config.writeEntry("CurrentPlaylist",filename);
1033 currentPlayList=filename;
1034
1035 if(!lnk.writeLink()) {
1036 qDebug("Writing doclink did not work");
1037 }
1038
1039 setCaption(tr("OpiePlayer: ") + name);
1040}
1041
870void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1042void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
871 switch ( e->key() ) { 1043 switch ( e->key() ) {
872 ////////////////////////////// Zaurus keys 1044 ////////////////////////////// Zaurus keys
873 case Key_F9: //activity 1045 case Key_F9: //activity
874 // if(audioUI->isHidden()) 1046 // if(audioUI->isHidden())
875 // audioUI->showMaximized(); 1047 // audioUI->showMaximized();
876 break; 1048 break;
877 case Key_F10: //contacts 1049 case Key_F10: //contacts
878 // if( videoUI->isHidden()) 1050 // if( videoUI->isHidden())
879 // videoUI->showMaximized(); 1051 // videoUI->showMaximized();
880 break; 1052 break;
881 case Key_F11: //menu 1053 case Key_F11: //menu
882 break; 1054 break;
883 case Key_F12: //home 1055 case Key_F12: //home
884 // doBlank(); 1056 // doBlank();
885 break; 1057 break;
886 case Key_F13: //mail 1058 case Key_F13: //mail
887 // doUnblank(); 1059 // doUnblank();
888 break; 1060 break;
889 case Key_Q: //add to playlist 1061 case Key_Q: //add to playlist
890 addSelected(); 1062 addSelected();
891 break; 1063 break;
892 case Key_R: //remove from playlist 1064 case Key_R: //remove from playlist
893 removeSelected(); 1065 removeSelected();
894 break; 1066 break;
895 // case Key_P: //play 1067 // case Key_P: //play
896 // qDebug("Play"); 1068 // qDebug("Play");
897 // playSelected(); 1069 // playSelected();
898 // break; 1070 // break;
899 case Key_Space: 1071 case Key_Space:
900 // playSelected(); puh 1072 // playSelected(); puh
901 break; 1073 break;
902 case Key_1: 1074 case Key_1:
903 tabWidget->setCurrentPage( 0 ); 1075 tabWidget->setCurrentPage( 0 );
904 break; 1076 break;
905 case Key_2: 1077 case Key_2:
906 tabWidget->setCurrentPage( 1 ); 1078 tabWidget->setCurrentPage( 1 );
907 break; 1079 break;
908 case Key_3: 1080 case Key_3:
909 tabWidget->setCurrentPage( 2 ); 1081 tabWidget->setCurrentPage( 2 );
910 break; 1082 break;
911 case Key_4: 1083 case Key_4:
912 tabWidget->setCurrentPage( 3 ); 1084 tabWidget->setCurrentPage( 3 );
913 break; 1085 break;
914 case Key_Down: 1086 case Key_Down:
915 if ( !d->selectedFiles->next() ) 1087 if ( !d->selectedFiles->next() )
916 d->selectedFiles->first(); 1088 d->selectedFiles->first();
917
918 break; 1089 break;
919 case Key_Up: 1090 case Key_Up:
920 if ( !d->selectedFiles->prev() ) 1091 if ( !d->selectedFiles->prev() )
921 // d->selectedFiles->last(); 1092 // d->selectedFiles->last();
922
923 break; 1093 break;
924
925 } 1094 }
926} 1095}
927 1096
928void PlayListWidget::readm3u( const QString &filename ) {
929 qDebug( "m3u filename is " + filename );
930 QFile f( filename );
931
932 if( f.open( IO_ReadOnly ) ) {
933 QTextStream t(&f);
934 QString s;//, first, second;
935 int i=0;
936 while ( !t.atEnd() ) {
937 s=t.readLine();
938
939 if( s.find( "#", 0, TRUE) == -1 ) {
940 if( s.find( " ", 0, TRUE) == -1 ) {
941// not sure if this is neede since cf uses vfat
942 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
943 s = s.right( s.length() -2 );
944 DocLnk lnk( s );
945 QFileInfo f( s );
946 QString name = f.baseName();
947 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
948 lnk.setName( name );
949 s=s.replace( QRegExp( "\\" ), "/" );
950 lnk.setFile( s );
951 lnk.writeLink();
952 qDebug( "add " + name);
953 d->selectedFiles->addToSelection( lnk );
954 } else { // is url
955 s.replace( QRegExp( "%20" )," " );
956 DocLnk lnk( s );
957 QString name;
958 if( name.left( 4 ) == "http" ) {
959 name = s.right( s.length() - 7 );
960 } else {
961 name = s;
962 }
963 lnk.setName( name );
964 if( s.at( s.length() - 4) == '.' ) {
965 lnk.setFile( s );
966 } else {
967 lnk.setFile( s + "/" );
968 }
969 lnk.setType( "audio/x-mpegurl" );
970 lnk.writeLink();
971 d->selectedFiles->addToSelection( lnk );
972 }
973 i++;
974 }
975 }
976 }
977 }
978 f.close();
979}
980
981void PlayListWidget::writem3u() {
982 InputDialog *fileDlg;
983 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
984 fileDlg->exec();
985 QString filename, list;
986 if( fileDlg->result() == 1 ) {
987 filename = fileDlg->text();
988 qDebug( filename );
989 int noOfFiles = 0;
990 d->selectedFiles->first();
991 do {
992 // we dont check for existance because of url's
993 // qDebug(d->selectedFiles->current()->file());
994
995 // so maybe we should do some net checking to ,-)
996 // no, cause it takes to long...
997
998 list += d->selectedFiles->current()->file() + "\n";
999 noOfFiles++;
1000 }
1001 while ( d->selectedFiles->next() );
1002 qDebug( list );
1003 if( filename.left( 1) != "/" ) {
1004 filename=QPEApplication::documentDir() + "/" + filename;
1005 }
1006 if( filename.right( 3 ) != "m3u" ) {
1007 filename=filename+".m3u";
1008 }
1009 QFile f( filename );
1010 f.open( IO_WriteOnly );
1011 f.writeBlock( list, list.length() );
1012 f.close();
1013 }
1014 if( fileDlg ) {
1015 delete fileDlg;
1016 }
1017}
1018
1019void PlayListWidget::readPls( const QString &filename ) {
1020
1021 qDebug( "pls filename is " + filename );
1022 QFile f( filename );
1023
1024 if( f.open( IO_ReadOnly ) ) {
1025 QTextStream t( &f );
1026 QString s;//, first, second;
1027 int i = 0;
1028 while ( !t.atEnd() ) {
1029 s = t.readLine();
1030 if( s.left(4) == "File" ) {
1031 s = s.right( s.length() - 6 );
1032 s.replace( QRegExp( "%20" )," ");
1033 qDebug( "adding " + s + " to playlist" );
1034 // numberofentries=2
1035 // File1=http
1036 // Title
1037 // Length
1038 // Version
1039 // File2=http
1040 s = s.replace( QRegExp( "\\" ), "/" );
1041 DocLnk lnk( s );
1042 QFileInfo f( s );
1043 QString name = f.baseName();
1044 if( name.left( 4 ) == "http" ) {
1045 name = s.right( s.length() - 7);
1046 } else {
1047 name = s;
1048 }
1049 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1050 lnk.setName( name );
1051 if( s.at( s.length() - 4) == '.') // if this is probably a file
1052 lnk.setFile( s );
1053 else { //if its a url
1054 if( name.right( 1 ).find( '/' ) == -1) {
1055 s += "/";
1056 }
1057 lnk.setFile( s );
1058 }
1059 lnk.setType( "audio/x-mpegurl" );
1060
1061 //qDebug("DocLnk add "+name);
1062 d->selectedFiles->addToSelection( lnk );
1063 }
1064 }
1065 i++;
1066 }
1067}
1068
1069void PlayListWidget::pmViewActivated(int index) { 1097void PlayListWidget::pmViewActivated(int index) {
1070// qDebug("%d", index); 1098// qDebug("%d", index);
1071 switch(index) { 1099 switch(index) {
1072 case -16: 1100 case -16:
1073 { 1101 {
1074 mediaPlayerState->toggleFullscreen(); 1102 mediaPlayerState->toggleFullscreen();
1075 bool b=mediaPlayerState->fullscreen(); 1103 bool b=mediaPlayerState->fullscreen();
1076 pmView->setItemChecked( index, b); 1104 pmView->setItemChecked( index, b);
1077 Config cfg( "OpiePlayer" ); 1105 Config cfg( "OpiePlayer" );
1078 cfg.writeEntry( "FullScreen", b ); 1106 cfg.writeEntry( "FullScreen", b );
1079 } 1107 }
1080 break; 1108 break;
1081 }; 1109 };
1082} 1110}
1083 1111
1084void PlayListWidget::populateSkinsMenu() { 1112void PlayListWidget::populateSkinsMenu() {
1085 int item = 0; 1113 int item = 0;
1086 defaultSkinIndex = 0; 1114 defaultSkinIndex = 0;
1087 QString skinName; 1115 QString skinName;
1088 Config cfg( "OpiePlayer" ); 1116 Config cfg( "OpiePlayer" );
1089 cfg.setGroup("Options" ); 1117 cfg.setGroup("Options" );
1090 QString skin = cfg.readEntry( "Skin", "default" ); 1118 QString skin = cfg.readEntry( "Skin", "default" );
1091 1119
1092 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1120 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 2873dca..428821a 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -40,49 +40,49 @@
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
59 ~PlayListWidget(); 59 ~PlayListWidget();
60 DocLnkSet files; 60 DocLnkSet files;
61 DocLnkSet vFiles; 61 DocLnkSet vFiles;
62 bool fromSetDocument; 62 bool fromSetDocument;
63 bool insanityBool; 63 bool insanityBool;
64 QString setDocFileRef; 64 QString setDocFileRef, currentPlayList;
65 // retrieve the current playlist entry (media file link) 65 // retrieve the current playlist entry (media file link)
66 const DocLnk *current(); 66 const DocLnk *current();
67 void useSelectedDocument(); 67 void useSelectedDocument();
68 int selected; 68 int selected;
69 int whichList(); 69 int whichList();
70 70
71public slots: 71public slots:
72 bool first(); 72 bool first();
73 bool last(); 73 bool last();
74 bool next(); 74 bool next();
75 bool prev(); 75 bool prev();
76 void writeConfig( Config& cfg ) const; 76 void writeConfig( Config& cfg ) const;
77 QString currentFileListPathName(); 77 QString currentFileListPathName();
78protected: 78protected:
79 void keyReleaseEvent( QKeyEvent *e); 79 void keyReleaseEvent( QKeyEvent *e);
80 80
81private: 81private:
82 int defaultSkinIndex; 82 int defaultSkinIndex;
83 bool audioScan, videoScan; 83 bool audioScan, videoScan;
84 void readm3u(const QString &); 84 void readm3u(const QString &);
85 void readPls(const QString &); 85 void readPls(const QString &);
86 void initializeStates(); 86 void initializeStates();
87 void readConfig( Config& cfg ); 87 void readConfig( Config& cfg );
88 void populateAudioView(); 88 void populateAudioView();