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