author | simon <simon> | 2002-12-02 15:11:50 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 15:11:50 (UTC) |
commit | 9f770813346acbe7817b20c5fe0fea03827fc41a (patch) (unidiff) | |
tree | 271e8091f19e5701576fa5f1503cca08f955a7b0 | |
parent | 5380767372ecf3ab22f799abda32f414b0cc7ede (diff) | |
download | opie-9f770813346acbe7817b20c5fe0fea03827fc41a.zip opie-9f770813346acbe7817b20c5fe0fea03827fc41a.tar.gz opie-9f770813346acbe7817b20c5fe0fea03827fc41a.tar.bz2 |
- removed whichList() alltogether
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 4 |
2 files changed, 11 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index a8429e3..fd256b7 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -193,961 +193,954 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
193 | Om3u *m3uList; | 193 | Om3u *m3uList; |
194 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 194 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
195 | if( d->selectedFiles->first() ) { | 195 | if( d->selectedFiles->first() ) { |
196 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 196 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
197 | do { | 197 | do { |
198 | // qDebug(d->selectedFiles->current()->file()); | 198 | // qDebug(d->selectedFiles->current()->file()); |
199 | m3uList->add( d->selectedFiles->current()->file() ); | 199 | m3uList->add( d->selectedFiles->current()->file() ); |
200 | } | 200 | } |
201 | while ( d->selectedFiles->next() ); | 201 | while ( d->selectedFiles->next() ); |
202 | 202 | ||
203 | m3uList->write(); | 203 | m3uList->write(); |
204 | m3uList->close(); | 204 | m3uList->close(); |
205 | if(m3uList) delete m3uList; | 205 | if(m3uList) delete m3uList; |
206 | 206 | ||
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 211 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
212 | d->setDocumentUsed = FALSE; | 212 | d->setDocumentUsed = FALSE; |
213 | if ( mediaPlayerState->isUsingPlaylist() ) { | 213 | if ( mediaPlayerState->isUsingPlaylist() ) { |
214 | if( QFileInfo( lnk.file() ).exists() || | 214 | if( QFileInfo( lnk.file() ).exists() || |
215 | lnk.file().left(4) == "http" ) { | 215 | lnk.file().left(4) == "http" ) { |
216 | d->selectedFiles->addToSelection( lnk ); | 216 | d->selectedFiles->addToSelection( lnk ); |
217 | } | 217 | } |
218 | // writeCurrentM3u(); | 218 | // writeCurrentM3u(); |
219 | } | 219 | } |
220 | else | 220 | else |
221 | mediaPlayerState->setPlaying( TRUE ); | 221 | mediaPlayerState->setPlaying( TRUE ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void PlayListWidget::clearList() { | 225 | void PlayListWidget::clearList() { |
226 | while ( first() ) { | 226 | while ( first() ) { |
227 | d->selectedFiles->removeSelected(); | 227 | d->selectedFiles->removeSelected(); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 231 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
232 | switch (mouse) { | 232 | switch (mouse) { |
233 | case 1: | 233 | case 1: |
234 | break; | 234 | break; |
235 | case 2: | 235 | case 2: |
236 | { | 236 | { |
237 | QPopupMenu m; | 237 | QPopupMenu m; |
238 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 238 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
239 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 239 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
240 | m.exec( QCursor::pos() ); | 240 | m.exec( QCursor::pos() ); |
241 | } | 241 | } |
242 | break; | 242 | break; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 247 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
248 | switch (mouse) { | 248 | switch (mouse) { |
249 | case 1: | 249 | case 1: |
250 | break; | 250 | break; |
251 | case 2: | 251 | case 2: |
252 | { | 252 | { |
253 | QPopupMenu m; | 253 | QPopupMenu m; |
254 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 254 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
255 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 255 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
256 | m.exec( QCursor::pos() ); | 256 | m.exec( QCursor::pos() ); |
257 | } | 257 | } |
258 | break; | 258 | break; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | void PlayListWidget::addAllToList() { | 263 | void PlayListWidget::addAllToList() { |
264 | 264 | ||
265 | // QTime t; | 265 | // QTime t; |
266 | // t.start(); | 266 | // t.start(); |
267 | 267 | ||
268 | if(!audioScan) { | 268 | if(!audioScan) { |
269 | if(audioView->childCount() < 1) | 269 | if(audioView->childCount() < 1) |
270 | populateAudioView(); | 270 | populateAudioView(); |
271 | } | 271 | } |
272 | 272 | ||
273 | QListViewItemIterator audioIt( audioView ); | 273 | QListViewItemIterator audioIt( audioView ); |
274 | DocLnk lnk; | 274 | DocLnk lnk; |
275 | QString filename; | 275 | QString filename; |
276 | // iterate through all items of the listview | 276 | // iterate through all items of the listview |
277 | for ( ; audioIt.current(); ++audioIt ) { | 277 | for ( ; audioIt.current(); ++audioIt ) { |
278 | filename = audioIt.current()->text(3); | 278 | filename = audioIt.current()->text(3); |
279 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 279 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
280 | lnk.setFile( filename ); //sets file name | 280 | lnk.setFile( filename ); //sets file name |
281 | d->selectedFiles->addToSelection( lnk); | 281 | d->selectedFiles->addToSelection( lnk); |
282 | } | 282 | } |
283 | 283 | ||
284 | if(!videoScan) { | 284 | if(!videoScan) { |
285 | if(videoView->childCount() < 1) | 285 | if(videoView->childCount() < 1) |
286 | populateVideoView(); | 286 | populateVideoView(); |
287 | } | 287 | } |
288 | 288 | ||
289 | QListViewItemIterator videoIt( videoView ); | 289 | QListViewItemIterator videoIt( videoView ); |
290 | for ( ; videoIt.current(); ++videoIt ) { | 290 | for ( ; videoIt.current(); ++videoIt ) { |
291 | filename = videoIt.current()->text(3); | 291 | filename = videoIt.current()->text(3); |
292 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 292 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
293 | lnk.setFile( filename ); //sets file name | 293 | lnk.setFile( filename ); //sets file name |
294 | d->selectedFiles->addToSelection( lnk); | 294 | d->selectedFiles->addToSelection( lnk); |
295 | } | 295 | } |
296 | 296 | ||
297 | // d->selectedFiles->addToSelection( ); | 297 | // d->selectedFiles->addToSelection( ); |
298 | // if ( it.current()->isSelected() ) | 298 | // if ( it.current()->isSelected() ) |
299 | // lst->append( audioIt.current() ); | 299 | // lst->append( audioIt.current() ); |
300 | // } | 300 | // } |
301 | 301 | ||
302 | 302 | ||
303 | // if(!audioScan) | 303 | // if(!audioScan) |
304 | // scanForAudio(); | 304 | // scanForAudio(); |
305 | // if(!videoScan) | 305 | // if(!videoScan) |
306 | // scanForVideo(); | 306 | // scanForVideo(); |
307 | 307 | ||
308 | // DocLnkSet filesAll; | 308 | // DocLnkSet filesAll; |
309 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 309 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
310 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 310 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
311 | // for ( ; Adit.current(); ++Adit ) { | 311 | // for ( ; Adit.current(); ++Adit ) { |
312 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 312 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
313 | // d->selectedFiles->addToSelection( **Adit ); | 313 | // d->selectedFiles->addToSelection( **Adit ); |
314 | // } | 314 | // } |
315 | // } | 315 | // } |
316 | 316 | ||
317 | // qDebug("elapsed time %d", t.elapsed() ); | 317 | // qDebug("elapsed time %d", t.elapsed() ); |
318 | 318 | ||
319 | tabWidget->setCurrentPage(0); | 319 | tabWidget->setCurrentPage(0); |
320 | 320 | ||
321 | writeCurrentM3u(); | 321 | writeCurrentM3u(); |
322 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | void PlayListWidget::addAllMusicToList() { | 326 | void PlayListWidget::addAllMusicToList() { |
327 | 327 | ||
328 | if(!audioScan) { | 328 | if(!audioScan) { |
329 | if(audioView->childCount() < 1) | 329 | if(audioView->childCount() < 1) |
330 | populateAudioView(); | 330 | populateAudioView(); |
331 | } | 331 | } |
332 | 332 | ||
333 | QListViewItemIterator audioIt( audioView ); | 333 | QListViewItemIterator audioIt( audioView ); |
334 | DocLnk lnk; | 334 | DocLnk lnk; |
335 | QString filename; | 335 | QString filename; |
336 | // iterate through all items of the listview | 336 | // iterate through all items of the listview |
337 | for ( ; audioIt.current(); ++audioIt ) { | 337 | for ( ; audioIt.current(); ++audioIt ) { |
338 | filename = audioIt.current()->text(3); | 338 | filename = audioIt.current()->text(3); |
339 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 339 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
340 | lnk.setFile( filename ); //sets file name | 340 | lnk.setFile( filename ); //sets file name |
341 | d->selectedFiles->addToSelection( lnk); | 341 | d->selectedFiles->addToSelection( lnk); |
342 | } | 342 | } |
343 | 343 | ||
344 | /* if(!audioScan) | 344 | /* if(!audioScan) |
345 | scanForAudio(); | 345 | scanForAudio(); |
346 | QListIterator<DocLnk> dit( files.children() ); | 346 | QListIterator<DocLnk> dit( files.children() ); |
347 | for ( ; dit.current(); ++dit ) { | 347 | for ( ; dit.current(); ++dit ) { |
348 | if( QFileInfo(dit.current()->file() ).exists() ) { | 348 | if( QFileInfo(dit.current()->file() ).exists() ) { |
349 | d->selectedFiles->addToSelection( **dit ); | 349 | d->selectedFiles->addToSelection( **dit ); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | */ | 352 | */ |
353 | tabWidget->setCurrentPage(0); | 353 | tabWidget->setCurrentPage(0); |
354 | writeCurrentM3u(); | 354 | writeCurrentM3u(); |
355 | d->selectedFiles->first(); | 355 | d->selectedFiles->first(); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void PlayListWidget::addAllVideoToList() { | 359 | void PlayListWidget::addAllVideoToList() { |
360 | 360 | ||
361 | if(!videoScan) { | 361 | if(!videoScan) { |
362 | if(videoView->childCount() < 1) | 362 | if(videoView->childCount() < 1) |
363 | populateVideoView(); | 363 | populateVideoView(); |
364 | } | 364 | } |
365 | 365 | ||
366 | QListViewItemIterator videoIt( videoView ); | 366 | QListViewItemIterator videoIt( videoView ); |
367 | DocLnk lnk; | 367 | DocLnk lnk; |
368 | QString filename; | 368 | QString filename; |
369 | for ( ; videoIt.current(); ++videoIt ) { | 369 | for ( ; videoIt.current(); ++videoIt ) { |
370 | filename = videoIt.current()->text(3); | 370 | filename = videoIt.current()->text(3); |
371 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 371 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
372 | lnk.setFile( filename ); //sets file name | 372 | lnk.setFile( filename ); //sets file name |
373 | d->selectedFiles->addToSelection( lnk); | 373 | d->selectedFiles->addToSelection( lnk); |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | /* if(!videoScan) | 377 | /* if(!videoScan) |
378 | scanForVideo(); | 378 | scanForVideo(); |
379 | QListIterator<DocLnk> dit( vFiles.children() ); | 379 | QListIterator<DocLnk> dit( vFiles.children() ); |
380 | for ( ; dit.current(); ++dit ) { | 380 | for ( ; dit.current(); ++dit ) { |
381 | if( QFileInfo( dit.current()->file() ).exists() ) { | 381 | if( QFileInfo( dit.current()->file() ).exists() ) { |
382 | d->selectedFiles->addToSelection( **dit ); | 382 | d->selectedFiles->addToSelection( **dit ); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | */ | 385 | */ |
386 | tabWidget->setCurrentPage(0); | 386 | tabWidget->setCurrentPage(0); |
387 | writeCurrentM3u(); | 387 | writeCurrentM3u(); |
388 | d->selectedFiles->first(); | 388 | d->selectedFiles->first(); |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | void PlayListWidget::setDocument( const QString& fileref ) { | 392 | void PlayListWidget::setDocument( const QString& fileref ) { |
393 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 393 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
394 | fromSetDocument = TRUE; | 394 | fromSetDocument = TRUE; |
395 | if ( fileref.isNull() ) { | 395 | if ( fileref.isNull() ) { |
396 | QMessageBox::warning( this, tr( "Invalid File" ), | 396 | QMessageBox::warning( this, tr( "Invalid File" ), |
397 | tr( "There was a problem in getting the file." ) ); | 397 | tr( "There was a problem in getting the file." ) ); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | 400 | ||
401 | clearList(); | 401 | clearList(); |
402 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 402 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
403 | readm3u( fileref ); | 403 | readm3u( fileref ); |
404 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 404 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
405 | readm3u( DocLnk( fileref).file() ); | 405 | readm3u( DocLnk( fileref).file() ); |
406 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 406 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
407 | readPls( fileref ); | 407 | readPls( fileref ); |
408 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 408 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
409 | readPls( DocLnk( fileref).file() ); | 409 | readPls( DocLnk( fileref).file() ); |
410 | } else { | 410 | } else { |
411 | clearList(); | 411 | clearList(); |
412 | addToSelection( DocLnk( fileref ) ); | 412 | addToSelection( DocLnk( fileref ) ); |
413 | writeCurrentM3u(); | 413 | writeCurrentM3u(); |
414 | 414 | ||
415 | d->setDocumentUsed = TRUE; | 415 | d->setDocumentUsed = TRUE; |
416 | mediaPlayerState->setPlaying( FALSE ); | 416 | mediaPlayerState->setPlaying( FALSE ); |
417 | mediaPlayerState->setPlaying( TRUE ); | 417 | mediaPlayerState->setPlaying( TRUE ); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void PlayListWidget::useSelectedDocument() { | 422 | void PlayListWidget::useSelectedDocument() { |
423 | d->setDocumentUsed = FALSE; | 423 | d->setDocumentUsed = FALSE; |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | const DocLnk *PlayListWidget::current() { // this is fugly | 427 | const DocLnk *PlayListWidget::current() { // this is fugly |
428 | assert( currentTab() == CurrentPlayList ); | 428 | assert( currentTab() == CurrentPlayList ); |
429 | 429 | ||
430 | // qDebug("playlist"); | 430 | // qDebug("playlist"); |
431 | if ( mediaPlayerState->isUsingPlaylist() ) { | 431 | if ( mediaPlayerState->isUsingPlaylist() ) { |
432 | return d->selectedFiles->current(); | 432 | return d->selectedFiles->current(); |
433 | } else if ( d->setDocumentUsed && d->current ) { | 433 | } else if ( d->setDocumentUsed && d->current ) { |
434 | return d->current; | 434 | return d->current; |
435 | } else { | 435 | } else { |
436 | return &(d->files->selectedDocument()); | 436 | return &(d->files->selectedDocument()); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | bool PlayListWidget::prev() { | 441 | bool PlayListWidget::prev() { |
442 | if ( mediaPlayerState->isUsingPlaylist() ) { | 442 | if ( mediaPlayerState->isUsingPlaylist() ) { |
443 | if ( mediaPlayerState->isShuffled() ) { | 443 | if ( mediaPlayerState->isShuffled() ) { |
444 | const DocLnk *cur = current(); | 444 | const DocLnk *cur = current(); |
445 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 445 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
446 | for ( int i = 0; i < j; i++ ) { | 446 | for ( int i = 0; i < j; i++ ) { |
447 | if ( !d->selectedFiles->next() ) | 447 | if ( !d->selectedFiles->next() ) |
448 | d->selectedFiles->first(); | 448 | d->selectedFiles->first(); |
449 | } | 449 | } |
450 | if ( cur == current() ) | 450 | if ( cur == current() ) |
451 | if ( !d->selectedFiles->next() ) { | 451 | if ( !d->selectedFiles->next() ) { |
452 | d->selectedFiles->first(); | 452 | d->selectedFiles->first(); |
453 | } | 453 | } |
454 | return TRUE; | 454 | return TRUE; |
455 | } else { | 455 | } else { |
456 | if ( !d->selectedFiles->prev() ) { | 456 | if ( !d->selectedFiles->prev() ) { |
457 | if ( mediaPlayerState->isLooping() ) { | 457 | if ( mediaPlayerState->isLooping() ) { |
458 | return d->selectedFiles->last(); | 458 | return d->selectedFiles->last(); |
459 | } else { | 459 | } else { |
460 | return FALSE; | 460 | return FALSE; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | return TRUE; | 463 | return TRUE; |
464 | } | 464 | } |
465 | } else { | 465 | } else { |
466 | return mediaPlayerState->isLooping(); | 466 | return mediaPlayerState->isLooping(); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | 470 | ||
471 | bool PlayListWidget::next() { | 471 | bool PlayListWidget::next() { |
472 | //qDebug("<<<<<<<<<<<<next()"); | 472 | //qDebug("<<<<<<<<<<<<next()"); |
473 | if ( mediaPlayerState->isUsingPlaylist() ) { | 473 | if ( mediaPlayerState->isUsingPlaylist() ) { |
474 | if ( mediaPlayerState->isShuffled() ) { | 474 | if ( mediaPlayerState->isShuffled() ) { |
475 | return prev(); | 475 | return prev(); |
476 | } else { | 476 | } else { |
477 | if ( !d->selectedFiles->next() ) { | 477 | if ( !d->selectedFiles->next() ) { |
478 | if ( mediaPlayerState->isLooping() ) { | 478 | if ( mediaPlayerState->isLooping() ) { |
479 | return d->selectedFiles->first(); | 479 | return d->selectedFiles->first(); |
480 | } else { | 480 | } else { |
481 | return FALSE; | 481 | return FALSE; |
482 | } | 482 | } |
483 | } | 483 | } |
484 | return TRUE; | 484 | return TRUE; |
485 | } | 485 | } |
486 | } else { | 486 | } else { |
487 | return mediaPlayerState->isLooping(); | 487 | return mediaPlayerState->isLooping(); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | bool PlayListWidget::first() { | 492 | bool PlayListWidget::first() { |
493 | if ( mediaPlayerState->isUsingPlaylist() ) | 493 | if ( mediaPlayerState->isUsingPlaylist() ) |
494 | return d->selectedFiles->first(); | 494 | return d->selectedFiles->first(); |
495 | else | 495 | else |
496 | return mediaPlayerState->isLooping(); | 496 | return mediaPlayerState->isLooping(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | bool PlayListWidget::last() { | 500 | bool PlayListWidget::last() { |
501 | if ( mediaPlayerState->isUsingPlaylist() ) | 501 | if ( mediaPlayerState->isUsingPlaylist() ) |
502 | return d->selectedFiles->last(); | 502 | return d->selectedFiles->last(); |
503 | else | 503 | else |
504 | return mediaPlayerState->isLooping(); | 504 | return mediaPlayerState->isLooping(); |
505 | } | 505 | } |
506 | 506 | ||
507 | 507 | ||
508 | void PlayListWidget::saveList() { | 508 | void PlayListWidget::saveList() { |
509 | writem3u(); | 509 | writem3u(); |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | void PlayListWidget::loadList( const DocLnk & lnk) { | 513 | void PlayListWidget::loadList( const DocLnk & lnk) { |
514 | QString name = lnk.name(); | 514 | QString name = lnk.name(); |
515 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 515 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
516 | 516 | ||
517 | if( name.length()>0) { | 517 | if( name.length()>0) { |
518 | setCaption("OpiePlayer: "+name); | 518 | setCaption("OpiePlayer: "+name); |
519 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 519 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
520 | clearList(); | 520 | clearList(); |
521 | readm3u(lnk.file()); | 521 | readm3u(lnk.file()); |
522 | tabWidget->setCurrentPage(0); | 522 | tabWidget->setCurrentPage(0); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | 526 | ||
527 | void PlayListWidget::setPlaylist( bool shown ) { | 527 | void PlayListWidget::setPlaylist( bool shown ) { |
528 | if ( shown ) { | 528 | if ( shown ) { |
529 | d->playListFrame->show(); | 529 | d->playListFrame->show(); |
530 | } else { | 530 | } else { |
531 | d->playListFrame->hide(); | 531 | d->playListFrame->hide(); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void PlayListWidget::addSelected() { | 536 | void PlayListWidget::addSelected() { |
537 | assert( inFileListMode() ); | 537 | assert( inFileListMode() ); |
538 | 538 | ||
539 | QListView *fileListView = currentFileListView(); | 539 | QListView *fileListView = currentFileListView(); |
540 | QListViewItemIterator it( fileListView ); | 540 | QListViewItemIterator it( fileListView ); |
541 | for ( ; it.current(); ++it ) | 541 | for ( ; it.current(); ++it ) |
542 | if ( it.current()->isSelected() ) { | 542 | if ( it.current()->isSelected() ) { |
543 | QString filename = it.current()->text(3); | 543 | QString filename = it.current()->text(3); |
544 | 544 | ||
545 | DocLnk lnk; | 545 | DocLnk lnk; |
546 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 546 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
547 | lnk.setFile( filename ); //sets file name | 547 | lnk.setFile( filename ); //sets file name |
548 | 548 | ||
549 | d->selectedFiles->addToSelection( lnk ); | 549 | d->selectedFiles->addToSelection( lnk ); |
550 | } | 550 | } |
551 | 551 | ||
552 | fileListView->clearSelection(); | 552 | fileListView->clearSelection(); |
553 | 553 | ||
554 | tabWidget->setCurrentPage( 0 ); | 554 | tabWidget->setCurrentPage( 0 ); |
555 | writeCurrentM3u(); | 555 | writeCurrentM3u(); |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | void PlayListWidget::removeSelected() { | 559 | void PlayListWidget::removeSelected() { |
560 | d->selectedFiles->removeSelected( ); | 560 | d->selectedFiles->removeSelected( ); |
561 | writeCurrentM3u(); | 561 | writeCurrentM3u(); |
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
565 | void PlayListWidget::playIt( QListViewItem *it) { | 565 | void PlayListWidget::playIt( QListViewItem *it) { |
566 | if(!it) return; | 566 | if(!it) return; |
567 | mediaPlayerState->setPlaying(FALSE); | 567 | mediaPlayerState->setPlaying(FALSE); |
568 | mediaPlayerState->setPlaying(TRUE); | 568 | mediaPlayerState->setPlaying(TRUE); |
569 | d->selectedFiles->unSelect(); | 569 | d->selectedFiles->unSelect(); |
570 | } | 570 | } |
571 | 571 | ||
572 | 572 | ||
573 | void PlayListWidget::addToSelection( QListViewItem *it) { | 573 | void PlayListWidget::addToSelection( QListViewItem *it) { |
574 | d->setDocumentUsed = FALSE; | 574 | d->setDocumentUsed = FALSE; |
575 | 575 | ||
576 | if(it) { | 576 | if(it) { |
577 | switch ( whichList()) { | 577 | if ( currentTab() == CurrentPlayList ) |
578 | case 0: //playlist | 578 | return; |
579 | return; | ||
580 | break; | ||
581 | }; | ||
582 | // case 1: { | 579 | // case 1: { |
583 | DocLnk lnk; | 580 | DocLnk lnk; |
584 | QString filename; | 581 | QString filename; |
585 | 582 | ||
586 | filename=it->text(3); | 583 | filename=it->text(3); |
587 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 584 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
588 | lnk.setFile( filename ); //sets file name | 585 | lnk.setFile( filename ); //sets file name |
589 | d->selectedFiles->addToSelection( lnk); | 586 | d->selectedFiles->addToSelection( lnk); |
590 | 587 | ||
591 | writeCurrentM3u(); | 588 | writeCurrentM3u(); |
592 | tabWidget->setCurrentPage(0); | 589 | tabWidget->setCurrentPage(0); |
593 | 590 | ||
594 | } | 591 | } |
595 | } | 592 | } |
596 | 593 | ||
597 | 594 | ||
598 | void PlayListWidget::tabChanged(QWidget *) { | 595 | void PlayListWidget::tabChanged(QWidget *) { |
599 | 596 | ||
600 | switch ( whichList()) { | 597 | switch ( currentTab() ) { |
601 | case 0: | 598 | case CurrentPlayList: |
602 | { | 599 | { |
603 | if( !tbDeletePlaylist->isHidden() ) { | 600 | if( !tbDeletePlaylist->isHidden() ) { |
604 | tbDeletePlaylist->hide(); | 601 | tbDeletePlaylist->hide(); |
605 | } | 602 | } |
606 | d->tbRemoveFromList->setEnabled(TRUE); | 603 | d->tbRemoveFromList->setEnabled(TRUE); |
607 | d->tbAddToList->setEnabled(FALSE); | 604 | d->tbAddToList->setEnabled(FALSE); |
608 | } | 605 | } |
609 | break; | 606 | break; |
610 | case 1: | 607 | case AudioFiles: |
611 | { | 608 | { |
612 | // audioView->clear(); | 609 | // audioView->clear(); |
613 | if(!audioPopulated) populateAudioView(); | 610 | if(!audioPopulated) populateAudioView(); |
614 | 611 | ||
615 | if( !tbDeletePlaylist->isHidden() ) { | 612 | if( !tbDeletePlaylist->isHidden() ) { |
616 | tbDeletePlaylist->hide(); | 613 | tbDeletePlaylist->hide(); |
617 | } | 614 | } |
618 | d->tbRemoveFromList->setEnabled(FALSE); | 615 | d->tbRemoveFromList->setEnabled(FALSE); |
619 | d->tbAddToList->setEnabled(TRUE); | 616 | d->tbAddToList->setEnabled(TRUE); |
620 | } | 617 | } |
621 | break; | 618 | break; |
622 | case 2: | 619 | case VideoFiles: |
623 | { | 620 | { |
624 | // videoView->clear(); | 621 | // videoView->clear(); |
625 | if(!videoPopulated) populateVideoView(); | 622 | if(!videoPopulated) populateVideoView(); |
626 | if( !tbDeletePlaylist->isHidden() ) { | 623 | if( !tbDeletePlaylist->isHidden() ) { |
627 | tbDeletePlaylist->hide(); | 624 | tbDeletePlaylist->hide(); |
628 | } | 625 | } |
629 | d->tbRemoveFromList->setEnabled(FALSE); | 626 | d->tbRemoveFromList->setEnabled(FALSE); |
630 | d->tbAddToList->setEnabled(TRUE); | 627 | d->tbAddToList->setEnabled(TRUE); |
631 | } | 628 | } |
632 | break; | 629 | break; |
633 | case 3: | 630 | case PlayLists: |
634 | { | 631 | { |
635 | if( tbDeletePlaylist->isHidden() ) { | 632 | if( tbDeletePlaylist->isHidden() ) { |
636 | tbDeletePlaylist->show(); | 633 | tbDeletePlaylist->show(); |
637 | } | 634 | } |
638 | playLists->reread(); | 635 | playLists->reread(); |
639 | d->tbAddToList->setEnabled(FALSE); | 636 | d->tbAddToList->setEnabled(FALSE); |
640 | } | 637 | } |
641 | break; | 638 | break; |
642 | }; | 639 | }; |
643 | } | 640 | } |
644 | 641 | ||
645 | 642 | ||
646 | void PlayListWidget::btnPlay(bool b) { | 643 | void PlayListWidget::btnPlay(bool b) { |
647 | // mediaPlayerState->setPlaying(false); | 644 | // mediaPlayerState->setPlaying(false); |
648 | mediaPlayerState->setPlaying(b); | 645 | mediaPlayerState->setPlaying(b); |
649 | insanityBool=FALSE; | 646 | insanityBool=FALSE; |
650 | } | 647 | } |
651 | 648 | ||
652 | void PlayListWidget::deletePlaylist() { | 649 | void PlayListWidget::deletePlaylist() { |
653 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 650 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
654 | (tr("You really want to delete\nthis playlist?")), | 651 | (tr("You really want to delete\nthis playlist?")), |
655 | (tr("Yes")), (tr("No")), 0 )){ | 652 | (tr("Yes")), (tr("No")), 0 )){ |
656 | case 0: // Yes clicked, | 653 | case 0: // Yes clicked, |
657 | QFile().remove(playLists->selectedDocument().file()); | 654 | QFile().remove(playLists->selectedDocument().file()); |
658 | QFile().remove(playLists->selectedDocument().linkFile()); | 655 | QFile().remove(playLists->selectedDocument().linkFile()); |
659 | playLists->reread(); | 656 | playLists->reread(); |
660 | break; | 657 | break; |
661 | case 1: // Cancel | 658 | case 1: // Cancel |
662 | break; | 659 | break; |
663 | }; | 660 | }; |
664 | } | 661 | } |
665 | 662 | ||
666 | 663 | ||
667 | void PlayListWidget::playSelected() { | 664 | void PlayListWidget::playSelected() { |
668 | btnPlay( TRUE); | 665 | btnPlay( TRUE); |
669 | } | 666 | } |
670 | 667 | ||
671 | 668 | ||
672 | void PlayListWidget::scanForAudio() { | 669 | void PlayListWidget::scanForAudio() { |
673 | // qDebug("scan for audio"); | 670 | // qDebug("scan for audio"); |
674 | files.detachChildren(); | 671 | files.detachChildren(); |
675 | QListIterator<DocLnk> sdit( files.children() ); | 672 | QListIterator<DocLnk> sdit( files.children() ); |
676 | for ( ; sdit.current(); ++sdit ) { | 673 | for ( ; sdit.current(); ++sdit ) { |
677 | delete sdit.current(); | 674 | delete sdit.current(); |
678 | } | 675 | } |
679 | // Global::findDocuments( &files, "audio/*"); | 676 | // Global::findDocuments( &files, "audio/*"); |
680 | Global::findDocuments( &files, audioMimes); | 677 | Global::findDocuments( &files, audioMimes); |
681 | audioScan = true; | 678 | audioScan = true; |
682 | populateAudioView(); | 679 | populateAudioView(); |
683 | } | 680 | } |
684 | 681 | ||
685 | void PlayListWidget::scanForVideo() { | 682 | void PlayListWidget::scanForVideo() { |
686 | // qDebug("scan for video"); | 683 | // qDebug("scan for video"); |
687 | vFiles.detachChildren(); | 684 | vFiles.detachChildren(); |
688 | QListIterator<DocLnk> sdit( vFiles.children() ); | 685 | QListIterator<DocLnk> sdit( vFiles.children() ); |
689 | for ( ; sdit.current(); ++sdit ) { | 686 | for ( ; sdit.current(); ++sdit ) { |
690 | delete sdit.current(); | 687 | delete sdit.current(); |
691 | } | 688 | } |
692 | Global::findDocuments(&vFiles, "video/*"); | 689 | Global::findDocuments(&vFiles, "video/*"); |
693 | videoScan = true; | 690 | videoScan = true; |
694 | populateVideoView(); | 691 | populateVideoView(); |
695 | } | 692 | } |
696 | 693 | ||
697 | void PlayListWidget::populateAudioView() { | 694 | void PlayListWidget::populateAudioView() { |
698 | audioView->clear(); | 695 | audioView->clear(); |
699 | StorageInfo storageInfo; | 696 | StorageInfo storageInfo; |
700 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 697 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
701 | if(!audioScan) { | 698 | if(!audioScan) { |
702 | scanForAudio(); | 699 | scanForAudio(); |
703 | } | 700 | } |
704 | 701 | ||
705 | QListIterator<DocLnk> dit( files.children() ); | 702 | QListIterator<DocLnk> dit( files.children() ); |
706 | // QListIterator<FileSystem> it ( fs ); | 703 | // QListIterator<FileSystem> it ( fs ); |
707 | audioView->clear(); | 704 | audioView->clear(); |
708 | 705 | ||
709 | QString storage; | 706 | QString storage; |
710 | for ( ; dit.current(); ++dit ) { | 707 | for ( ; dit.current(); ++dit ) { |
711 | // // for( ; it.current(); ++it ){ | 708 | // // for( ; it.current(); ++it ){ |
712 | // const QString name = (*dit)->name(); | 709 | // const QString name = (*dit)->name(); |
713 | // const QString path = (*dit)->path(); | 710 | // const QString path = (*dit)->path(); |
714 | // if(dit.current()->file().find(path) != -1 ) { | 711 | // if(dit.current()->file().find(path) != -1 ) { |
715 | // storage = name; | 712 | // storage = name; |
716 | // // } | 713 | // // } |
717 | // } | 714 | // } |
718 | 715 | ||
719 | QListViewItem * newItem; | 716 | QListViewItem * newItem; |
720 | if ( QFile( dit.current()->file()).exists() || | 717 | if ( QFile( dit.current()->file()).exists() || |
721 | dit.current()->file().left(4) == "http" ) { | 718 | dit.current()->file().left(4) == "http" ) { |
722 | long size; | 719 | long size; |
723 | if( dit.current()->file().left(4) == "http" ) | 720 | if( dit.current()->file().left(4) == "http" ) |
724 | size=0; | 721 | size=0; |
725 | else | 722 | else |
726 | size = QFile( dit.current()->file() ).size(); | 723 | size = QFile( dit.current()->file() ).size(); |
727 | 724 | ||
728 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 725 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
729 | QString::number(size ), "" /*storage*/, | 726 | QString::number(size ), "" /*storage*/, |
730 | dit.current()->file() ); | 727 | dit.current()->file() ); |
731 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 728 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
732 | // qDebug("<<<< "+dit.current()->file()); | 729 | // qDebug("<<<< "+dit.current()->file()); |
733 | } | 730 | } |
734 | } | 731 | } |
735 | audioPopulated=true; | 732 | audioPopulated=true; |
736 | } | 733 | } |
737 | 734 | ||
738 | 735 | ||
739 | void PlayListWidget::populateVideoView() { | 736 | void PlayListWidget::populateVideoView() { |
740 | videoView->clear(); | 737 | videoView->clear(); |
741 | StorageInfo storageInfo; | 738 | StorageInfo storageInfo; |
742 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 739 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
743 | 740 | ||
744 | if(!videoScan ) { | 741 | if(!videoScan ) { |
745 | scanForVideo(); | 742 | scanForVideo(); |
746 | } | 743 | } |
747 | 744 | ||
748 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 745 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
749 | // QListIterator<FileSystem> it ( fs ); | 746 | // QListIterator<FileSystem> it ( fs ); |
750 | videoView->clear(); | 747 | videoView->clear(); |
751 | QString storage, pathName; | 748 | QString storage, pathName; |
752 | for ( ; Vdit.current(); ++Vdit ) { | 749 | for ( ; Vdit.current(); ++Vdit ) { |
753 | // // for( ; it.current(); ++it ) { | 750 | // // for( ; it.current(); ++it ) { |
754 | // const QString name = (*Vdit)->name(); | 751 | // const QString name = (*Vdit)->name(); |
755 | // const QString path = (*Vdit)->path(); | 752 | // const QString path = (*Vdit)->path(); |
756 | // if( Vdit.current()->file().find(path) != -1 ) { | 753 | // if( Vdit.current()->file().find(path) != -1 ) { |
757 | // storage=name; | 754 | // storage=name; |
758 | // pathName=path; | 755 | // pathName=path; |
759 | // // } | 756 | // // } |
760 | // } | 757 | // } |
761 | 758 | ||
762 | QListViewItem * newItem; | 759 | QListViewItem * newItem; |
763 | if ( QFile( Vdit.current()->file() ).exists() ) { | 760 | if ( QFile( Vdit.current()->file() ).exists() ) { |
764 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 761 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
765 | QString::number( QFile( Vdit.current()->file() ).size() ), | 762 | QString::number( QFile( Vdit.current()->file() ).size() ), |
766 | ""/*storage*/, Vdit.current()->file()); | 763 | ""/*storage*/, Vdit.current()->file()); |
767 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 764 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
768 | } | 765 | } |
769 | } | 766 | } |
770 | videoPopulated=true; | 767 | videoPopulated=true; |
771 | } | 768 | } |
772 | 769 | ||
773 | QListView *PlayListWidget::currentFileListView() const | 770 | QListView *PlayListWidget::currentFileListView() const |
774 | { | 771 | { |
775 | switch ( currentTab() ) { | 772 | switch ( currentTab() ) { |
776 | case AudioFiles: return audioView; | 773 | case AudioFiles: return audioView; |
777 | case VideoFiles: return videoView; | 774 | case VideoFiles: return videoView; |
778 | default: assert( false ); | 775 | default: assert( false ); |
779 | } | 776 | } |
780 | return 0; | 777 | return 0; |
781 | } | 778 | } |
782 | 779 | ||
783 | bool PlayListWidget::inFileListMode() const | 780 | bool PlayListWidget::inFileListMode() const |
784 | { | 781 | { |
785 | TabType tab = currentTab(); | 782 | TabType tab = currentTab(); |
786 | return tab == AudioFiles || tab == VideoFiles; | 783 | return tab == AudioFiles || tab == VideoFiles; |
787 | } | 784 | } |
788 | 785 | ||
789 | void PlayListWidget::openFile() { | 786 | void PlayListWidget::openFile() { |
790 | // http://66.28.164.33:2080 | 787 | // http://66.28.164.33:2080 |
791 | // http://somafm.com/star0242.m3u | 788 | // http://somafm.com/star0242.m3u |
792 | QString filename, name; | 789 | QString filename, name; |
793 | InputDialog *fileDlg; | 790 | InputDialog *fileDlg; |
794 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 791 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
795 | fileDlg->exec(); | 792 | fileDlg->exec(); |
796 | if( fileDlg->result() == 1 ) { | 793 | if( fileDlg->result() == 1 ) { |
797 | filename = fileDlg->text(); | 794 | filename = fileDlg->text(); |
798 | qDebug( "Selected filename is " + filename ); | 795 | qDebug( "Selected filename is " + filename ); |
799 | // Om3u *m3uList; | 796 | // Om3u *m3uList; |
800 | DocLnk lnk; | 797 | DocLnk lnk; |
801 | Config cfg( "OpiePlayer" ); | 798 | Config cfg( "OpiePlayer" ); |
802 | cfg.setGroup("PlayList"); | 799 | cfg.setGroup("PlayList"); |
803 | 800 | ||
804 | if(filename.left(4) == "http") { | 801 | if(filename.left(4) == "http") { |
805 | QString m3uFile, m3uFilePath; | 802 | QString m3uFile, m3uFilePath; |
806 | if(filename.find(":",8,TRUE) != -1) { //found a port | 803 | if(filename.find(":",8,TRUE) != -1) { //found a port |
807 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 804 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
808 | m3uFile = m3uFile.right( 7); | 805 | m3uFile = m3uFile.right( 7); |
809 | } else if(filename.left(4) == "http"){ | 806 | } else if(filename.left(4) == "http"){ |
810 | m3uFile=filename; | 807 | m3uFile=filename; |
811 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 808 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
812 | } else{ | 809 | } else{ |
813 | m3uFile=filename; | 810 | m3uFile=filename; |
814 | } | 811 | } |
815 | 812 | ||
816 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 813 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
817 | lnk.setName( filename ); //sets name | 814 | lnk.setName( filename ); //sets name |
818 | lnk.setFile( filename ); //sets file name | 815 | lnk.setFile( filename ); //sets file name |
819 | 816 | ||
820 | // lnk.setIcon("opieplayer2/musicfile"); | 817 | // lnk.setIcon("opieplayer2/musicfile"); |
821 | 818 | ||
822 | d->selectedFiles->addToSelection( lnk ); | 819 | d->selectedFiles->addToSelection( lnk ); |
823 | writeCurrentM3u(); | 820 | writeCurrentM3u(); |
824 | d->selectedFiles->setSelectedItem( lnk.name()); | 821 | d->selectedFiles->setSelectedItem( lnk.name()); |
825 | } | 822 | } |
826 | else if( filename.right( 3) == "m3u" ) { | 823 | else if( filename.right( 3) == "m3u" ) { |
827 | readm3u( filename ); | 824 | readm3u( filename ); |
828 | 825 | ||
829 | } else if( filename.right(3) == "pls" ) { | 826 | } else if( filename.right(3) == "pls" ) { |
830 | readPls( filename ); | 827 | readPls( filename ); |
831 | } else { | 828 | } else { |
832 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 829 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
833 | lnk.setFile( filename ); //sets file name | 830 | lnk.setFile( filename ); //sets file name |
834 | d->selectedFiles->addToSelection( lnk); | 831 | d->selectedFiles->addToSelection( lnk); |
835 | writeCurrentM3u(); | 832 | writeCurrentM3u(); |
836 | d->selectedFiles->setSelectedItem( lnk.name()); | 833 | d->selectedFiles->setSelectedItem( lnk.name()); |
837 | } | 834 | } |
838 | } | 835 | } |
839 | 836 | ||
840 | if( fileDlg ) { | 837 | if( fileDlg ) { |
841 | delete fileDlg; | 838 | delete fileDlg; |
842 | } | 839 | } |
843 | } | 840 | } |
844 | 841 | ||
845 | /* | 842 | /* |
846 | reads m3u and shows files/urls to playlist widget */ | 843 | reads m3u and shows files/urls to playlist widget */ |
847 | void PlayListWidget::readm3u( const QString &filename ) { | 844 | void PlayListWidget::readm3u( const QString &filename ) { |
848 | qDebug( "read m3u filename " + filename ); | 845 | qDebug( "read m3u filename " + filename ); |
849 | 846 | ||
850 | Om3u *m3uList; | 847 | Om3u *m3uList; |
851 | QString s, name; | 848 | QString s, name; |
852 | m3uList = new Om3u( filename, IO_ReadOnly ); | 849 | m3uList = new Om3u( filename, IO_ReadOnly ); |
853 | m3uList->readM3u(); | 850 | m3uList->readM3u(); |
854 | DocLnk lnk; | 851 | DocLnk lnk; |
855 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 852 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
856 | s = *it; | 853 | s = *it; |
857 | // qDebug("reading "+ s); | 854 | // qDebug("reading "+ s); |
858 | if(s.left(4)=="http") { | 855 | if(s.left(4)=="http") { |
859 | lnk.setName( s ); //sets file name | 856 | lnk.setName( s ); //sets file name |
860 | lnk.setIcon("opieplayer2/musicfile"); | 857 | lnk.setIcon("opieplayer2/musicfile"); |
861 | lnk.setFile( s ); //sets file name | 858 | lnk.setFile( s ); //sets file name |
862 | 859 | ||
863 | } else { | 860 | } else { |
864 | // if( QFileInfo( s ).exists() ) { | 861 | // if( QFileInfo( s ).exists() ) { |
865 | lnk.setName( QFileInfo(s).baseName()); | 862 | lnk.setName( QFileInfo(s).baseName()); |
866 | // if(s.right(4) == '.') {//if regular file | 863 | // if(s.right(4) == '.') {//if regular file |
867 | if(s.left(1) != "/") { | 864 | if(s.left(1) != "/") { |
868 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 865 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
869 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 866 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
870 | // lnk.setIcon(MimeType(s).pixmap() ); | 867 | // lnk.setIcon(MimeType(s).pixmap() ); |
871 | // lnk.setIcon("SoundPlayer"); | 868 | // lnk.setIcon("SoundPlayer"); |
872 | } else { | 869 | } else { |
873 | // qDebug("set link2 "+s); | 870 | // qDebug("set link2 "+s); |
874 | lnk.setFile( s); | 871 | lnk.setFile( s); |
875 | // lnk.setIcon(MimeType(s).pixmap() ); | 872 | // lnk.setIcon(MimeType(s).pixmap() ); |
876 | // lnk.setIcon("SoundPlayer"); | 873 | // lnk.setIcon("SoundPlayer"); |
877 | } | 874 | } |
878 | } | 875 | } |
879 | d->selectedFiles->addToSelection( lnk ); | 876 | d->selectedFiles->addToSelection( lnk ); |
880 | } | 877 | } |
881 | Config config( "OpiePlayer" ); | 878 | Config config( "OpiePlayer" ); |
882 | config.setGroup( "PlayList" ); | 879 | config.setGroup( "PlayList" ); |
883 | 880 | ||
884 | config.writeEntry("CurrentPlaylist",filename); | 881 | config.writeEntry("CurrentPlaylist",filename); |
885 | config.write(); | 882 | config.write(); |
886 | currentPlayList=filename; | 883 | currentPlayList=filename; |
887 | 884 | ||
888 | // m3uList->write(); | 885 | // m3uList->write(); |
889 | m3uList->close(); | 886 | m3uList->close(); |
890 | if(m3uList) delete m3uList; | 887 | if(m3uList) delete m3uList; |
891 | 888 | ||
892 | d->selectedFiles->setSelectedItem( s); | 889 | d->selectedFiles->setSelectedItem( s); |
893 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 890 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
894 | 891 | ||
895 | } | 892 | } |
896 | 893 | ||
897 | /* | 894 | /* |
898 | reads pls and adds files/urls to playlist */ | 895 | reads pls and adds files/urls to playlist */ |
899 | void PlayListWidget::readPls( const QString &filename ) { | 896 | void PlayListWidget::readPls( const QString &filename ) { |
900 | 897 | ||
901 | qDebug( "pls filename is " + filename ); | 898 | qDebug( "pls filename is " + filename ); |
902 | Om3u *m3uList; | 899 | Om3u *m3uList; |
903 | QString s, name; | 900 | QString s, name; |
904 | m3uList = new Om3u( filename, IO_ReadOnly ); | 901 | m3uList = new Om3u( filename, IO_ReadOnly ); |
905 | m3uList->readPls(); | 902 | m3uList->readPls(); |
906 | 903 | ||
907 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 904 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
908 | s = *it; | 905 | s = *it; |
909 | // s.replace( QRegExp( "%20" )," " ); | 906 | // s.replace( QRegExp( "%20" )," " ); |
910 | DocLnk lnk( s ); | 907 | DocLnk lnk( s ); |
911 | QFileInfo f( s ); | 908 | QFileInfo f( s ); |
912 | QString name = f.baseName(); | 909 | QString name = f.baseName(); |
913 | 910 | ||
914 | if( name.left( 4 ) == "http" ) { | 911 | if( name.left( 4 ) == "http" ) { |
915 | name = s.right( s.length() - 7); | 912 | name = s.right( s.length() - 7); |
916 | } else { | 913 | } else { |
917 | name = s; | 914 | name = s; |
918 | } | 915 | } |
919 | 916 | ||
920 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 917 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
921 | 918 | ||
922 | lnk.setName( name ); | 919 | lnk.setName( name ); |
923 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 920 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
924 | lnk.setFile( s ); | 921 | lnk.setFile( s ); |
925 | } else { //if its a url | 922 | } else { //if its a url |
926 | // if( name.right( 1 ).find( '/' ) == -1) { | 923 | // if( name.right( 1 ).find( '/' ) == -1) { |
927 | // s += "/"; | 924 | // s += "/"; |
928 | // } | 925 | // } |
929 | lnk.setFile( s ); | 926 | lnk.setFile( s ); |
930 | } | 927 | } |
931 | lnk.setType( "audio/x-mpegurl" ); | 928 | lnk.setType( "audio/x-mpegurl" ); |
932 | 929 | ||
933 | lnk.writeLink(); | 930 | lnk.writeLink(); |
934 | d->selectedFiles->addToSelection( lnk ); | 931 | d->selectedFiles->addToSelection( lnk ); |
935 | } | 932 | } |
936 | 933 | ||
937 | m3uList->close(); | 934 | m3uList->close(); |
938 | if(m3uList) delete m3uList; | 935 | if(m3uList) delete m3uList; |
939 | } | 936 | } |
940 | 937 | ||
941 | /* | 938 | /* |
942 | writes current playlist to current m3u file */ | 939 | writes current playlist to current m3u file */ |
943 | void PlayListWidget::writeCurrentM3u() { | 940 | void PlayListWidget::writeCurrentM3u() { |
944 | qDebug("writing to current m3u"); | 941 | qDebug("writing to current m3u"); |
945 | Config cfg( "OpiePlayer" ); | 942 | Config cfg( "OpiePlayer" ); |
946 | cfg.setGroup("PlayList"); | 943 | cfg.setGroup("PlayList"); |
947 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 944 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
948 | 945 | ||
949 | Om3u *m3uList; | 946 | Om3u *m3uList; |
950 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 947 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
951 | if( d->selectedFiles->first()) { | 948 | if( d->selectedFiles->first()) { |
952 | 949 | ||
953 | do { | 950 | do { |
954 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 951 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
955 | m3uList->add( d->selectedFiles->current()->file() ); | 952 | m3uList->add( d->selectedFiles->current()->file() ); |
956 | } | 953 | } |
957 | while ( d->selectedFiles->next() ); | 954 | while ( d->selectedFiles->next() ); |
958 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 955 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
959 | m3uList->write(); | 956 | m3uList->write(); |
960 | m3uList->close(); | 957 | m3uList->close(); |
961 | 958 | ||
962 | if(m3uList) delete m3uList; | 959 | if(m3uList) delete m3uList; |
963 | } | 960 | } |
964 | 961 | ||
965 | } | 962 | } |
966 | 963 | ||
967 | /* | 964 | /* |
968 | writes current playlist to m3u file */ | 965 | writes current playlist to m3u file */ |
969 | void PlayListWidget::writem3u() { | 966 | void PlayListWidget::writem3u() { |
970 | InputDialog *fileDlg; | 967 | InputDialog *fileDlg; |
971 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 968 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
972 | fileDlg->exec(); | 969 | fileDlg->exec(); |
973 | QString name, filename, list; | 970 | QString name, filename, list; |
974 | Om3u *m3uList; | 971 | Om3u *m3uList; |
975 | 972 | ||
976 | if( fileDlg->result() == 1 ) { | 973 | if( fileDlg->result() == 1 ) { |
977 | name = fileDlg->text(); | 974 | name = fileDlg->text(); |
978 | // qDebug( filename ); | 975 | // qDebug( filename ); |
979 | 976 | ||
980 | if( name.left( 1) != "/" ) { | 977 | if( name.left( 1) != "/" ) { |
981 | filename = QPEApplication::documentDir() + "/" + name; | 978 | filename = QPEApplication::documentDir() + "/" + name; |
982 | } | 979 | } |
983 | 980 | ||
984 | if( name.right( 3 ) != "m3u" ) { | 981 | if( name.right( 3 ) != "m3u" ) { |
985 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 982 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
986 | } | 983 | } |
987 | 984 | ||
988 | if( d->selectedFiles->first()) { | 985 | if( d->selectedFiles->first()) { |
989 | m3uList = new Om3u(filename, IO_ReadWrite); | 986 | m3uList = new Om3u(filename, IO_ReadWrite); |
990 | 987 | ||
991 | do { | 988 | do { |
992 | m3uList->add( d->selectedFiles->current()->file()); | 989 | m3uList->add( d->selectedFiles->current()->file()); |
993 | } | 990 | } |
994 | while ( d->selectedFiles->next() ); | 991 | while ( d->selectedFiles->next() ); |
995 | // qDebug( list ); | 992 | // qDebug( list ); |
996 | m3uList->write(); | 993 | m3uList->write(); |
997 | m3uList->close(); | 994 | m3uList->close(); |
998 | if(m3uList) delete m3uList; | 995 | if(m3uList) delete m3uList; |
999 | 996 | ||
1000 | if(fileDlg) delete fileDlg; | 997 | if(fileDlg) delete fileDlg; |
1001 | 998 | ||
1002 | DocLnk lnk; | 999 | DocLnk lnk; |
1003 | lnk.setFile( filename); | 1000 | lnk.setFile( filename); |
1004 | lnk.setIcon("opieplayer2/playlist2"); | 1001 | lnk.setIcon("opieplayer2/playlist2"); |
1005 | lnk.setName( name); //sets file name | 1002 | lnk.setName( name); //sets file name |
1006 | 1003 | ||
1007 | // qDebug(filename); | 1004 | // qDebug(filename); |
1008 | Config config( "OpiePlayer" ); | 1005 | Config config( "OpiePlayer" ); |
1009 | config.setGroup( "PlayList" ); | 1006 | config.setGroup( "PlayList" ); |
1010 | 1007 | ||
1011 | config.writeEntry("CurrentPlaylist",filename); | 1008 | config.writeEntry("CurrentPlaylist",filename); |
1012 | currentPlayList=filename; | 1009 | currentPlayList=filename; |
1013 | 1010 | ||
1014 | if(!lnk.writeLink()) { | 1011 | if(!lnk.writeLink()) { |
1015 | qDebug("Writing doclink did not work"); | 1012 | qDebug("Writing doclink did not work"); |
1016 | } | 1013 | } |
1017 | 1014 | ||
1018 | setCaption(tr("OpiePlayer: ") + name); | 1015 | setCaption(tr("OpiePlayer: ") + name); |
1019 | } | 1016 | } |
1020 | } | 1017 | } |
1021 | } | 1018 | } |
1022 | 1019 | ||
1023 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 1020 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
1024 | switch ( e->key() ) { | 1021 | switch ( e->key() ) { |
1025 | ////////////////////////////// Zaurus keys | 1022 | ////////////////////////////// Zaurus keys |
1026 | case Key_F9: //activity | 1023 | case Key_F9: //activity |
1027 | // if(audioUI->isHidden()) | 1024 | // if(audioUI->isHidden()) |
1028 | // audioUI->showMaximized(); | 1025 | // audioUI->showMaximized(); |
1029 | break; | 1026 | break; |
1030 | case Key_F10: //contacts | 1027 | case Key_F10: //contacts |
1031 | // if( videoUI->isHidden()) | 1028 | // if( videoUI->isHidden()) |
1032 | // videoUI->showMaximized(); | 1029 | // videoUI->showMaximized(); |
1033 | break; | 1030 | break; |
1034 | case Key_F11: //menu | 1031 | case Key_F11: //menu |
1035 | break; | 1032 | break; |
1036 | case Key_F12: //home | 1033 | case Key_F12: //home |
1037 | // doBlank(); | 1034 | // doBlank(); |
1038 | break; | 1035 | break; |
1039 | case Key_F13: //mail | 1036 | case Key_F13: //mail |
1040 | // doUnblank(); | 1037 | // doUnblank(); |
1041 | break; | 1038 | break; |
1042 | case Key_Q: //add to playlist | 1039 | case Key_Q: //add to playlist |
1043 | addSelected(); | 1040 | addSelected(); |
1044 | break; | 1041 | break; |
1045 | case Key_R: //remove from playlist | 1042 | case Key_R: //remove from playlist |
1046 | removeSelected(); | 1043 | removeSelected(); |
1047 | break; | 1044 | break; |
1048 | // case Key_P: //play | 1045 | // case Key_P: //play |
1049 | // qDebug("Play"); | 1046 | // qDebug("Play"); |
1050 | // playSelected(); | 1047 | // playSelected(); |
1051 | // break; | 1048 | // break; |
1052 | case Key_Space: | 1049 | case Key_Space: |
1053 | // playSelected(); puh | 1050 | // playSelected(); puh |
1054 | break; | 1051 | break; |
1055 | case Key_1: | 1052 | case Key_1: |
1056 | tabWidget->setCurrentPage( 0 ); | 1053 | tabWidget->setCurrentPage( 0 ); |
1057 | break; | 1054 | break; |
1058 | case Key_2: | 1055 | case Key_2: |
1059 | tabWidget->setCurrentPage( 1 ); | 1056 | tabWidget->setCurrentPage( 1 ); |
1060 | break; | 1057 | break; |
1061 | case Key_3: | 1058 | case Key_3: |
1062 | tabWidget->setCurrentPage( 2 ); | 1059 | tabWidget->setCurrentPage( 2 ); |
1063 | break; | 1060 | break; |
1064 | case Key_4: | 1061 | case Key_4: |
1065 | tabWidget->setCurrentPage( 3 ); | 1062 | tabWidget->setCurrentPage( 3 ); |
1066 | break; | 1063 | break; |
1067 | case Key_Down: | 1064 | case Key_Down: |
1068 | if ( !d->selectedFiles->next() ) | 1065 | if ( !d->selectedFiles->next() ) |
1069 | d->selectedFiles->first(); | 1066 | d->selectedFiles->first(); |
1070 | break; | 1067 | break; |
1071 | case Key_Up: | 1068 | case Key_Up: |
1072 | if ( !d->selectedFiles->prev() ) | 1069 | if ( !d->selectedFiles->prev() ) |
1073 | // d->selectedFiles->last(); | 1070 | // d->selectedFiles->last(); |
1074 | break; | 1071 | break; |
1075 | } | 1072 | } |
1076 | } | 1073 | } |
1077 | 1074 | ||
1078 | void PlayListWidget::pmViewActivated(int index) { | 1075 | void PlayListWidget::pmViewActivated(int index) { |
1079 | // qDebug("%d", index); | 1076 | // qDebug("%d", index); |
1080 | switch(index) { | 1077 | switch(index) { |
1081 | case -16: | 1078 | case -16: |
1082 | { | 1079 | { |
1083 | mediaPlayerState->toggleFullscreen(); | 1080 | mediaPlayerState->toggleFullscreen(); |
1084 | bool b=mediaPlayerState->isFullscreen(); | 1081 | bool b=mediaPlayerState->isFullscreen(); |
1085 | pmView->setItemChecked( index, b); | 1082 | pmView->setItemChecked( index, b); |
1086 | Config cfg( "OpiePlayer" ); | 1083 | Config cfg( "OpiePlayer" ); |
1087 | cfg.writeEntry( "FullScreen", b ); | 1084 | cfg.writeEntry( "FullScreen", b ); |
1088 | } | 1085 | } |
1089 | break; | 1086 | break; |
1090 | }; | 1087 | }; |
1091 | } | 1088 | } |
1092 | 1089 | ||
1093 | void PlayListWidget::populateSkinsMenu() { | 1090 | void PlayListWidget::populateSkinsMenu() { |
1094 | int item = 0; | 1091 | int item = 0; |
1095 | defaultSkinIndex = 0; | 1092 | defaultSkinIndex = 0; |
1096 | QString skinName; | 1093 | QString skinName; |
1097 | Config cfg( "OpiePlayer" ); | 1094 | Config cfg( "OpiePlayer" ); |
1098 | cfg.setGroup("Options" ); | 1095 | cfg.setGroup("Options" ); |
1099 | QString skin = cfg.readEntry( "Skin", "default" ); | 1096 | QString skin = cfg.readEntry( "Skin", "default" ); |
1100 | 1097 | ||
1101 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1098 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1102 | skinsDir.setFilter( QDir::Dirs ); | 1099 | skinsDir.setFilter( QDir::Dirs ); |
1103 | skinsDir.setSorting(QDir::Name ); | 1100 | skinsDir.setSorting(QDir::Name ); |
1104 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1101 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1105 | QFileInfoListIterator it( *skinslist ); | 1102 | QFileInfoListIterator it( *skinslist ); |
1106 | QFileInfo *fi; | 1103 | QFileInfo *fi; |
1107 | while ( ( fi = it.current() ) ) { | 1104 | while ( ( fi = it.current() ) ) { |
1108 | skinName = fi->fileName(); | 1105 | skinName = fi->fileName(); |
1109 | // qDebug( fi->fileName() ); | 1106 | // qDebug( fi->fileName() ); |
1110 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1107 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1111 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1108 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1112 | } | 1109 | } |
1113 | if( skinName == "default" ) { | 1110 | if( skinName == "default" ) { |
1114 | defaultSkinIndex = item; | 1111 | defaultSkinIndex = item; |
1115 | } | 1112 | } |
1116 | if( skinName == skin ) { | 1113 | if( skinName == skin ) { |
1117 | skinsMenu->setItemChecked( item, TRUE ); | 1114 | skinsMenu->setItemChecked( item, TRUE ); |
1118 | } | 1115 | } |
1119 | ++it; | 1116 | ++it; |
1120 | } | 1117 | } |
1121 | } | 1118 | } |
1122 | 1119 | ||
1123 | void PlayListWidget::skinsMenuActivated( int item ) { | 1120 | void PlayListWidget::skinsMenuActivated( int item ) { |
1124 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1121 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1125 | skinsMenu->setItemChecked( i, FALSE ); | 1122 | skinsMenu->setItemChecked( i, FALSE ); |
1126 | } | 1123 | } |
1127 | skinsMenu->setItemChecked( item, TRUE ); | 1124 | skinsMenu->setItemChecked( item, TRUE ); |
1128 | 1125 | ||
1129 | Config cfg( "OpiePlayer" ); | 1126 | Config cfg( "OpiePlayer" ); |
1130 | cfg.setGroup("Options"); | 1127 | cfg.setGroup("Options"); |
1131 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1128 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1132 | QMessageBox::warning( this, tr( "OpiePlayer" ), | 1129 | QMessageBox::warning( this, tr( "OpiePlayer" ), |
1133 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); | 1130 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); |
1134 | } | 1131 | } |
1135 | 1132 | ||
1136 | int PlayListWidget::whichList() const { | ||
1137 | return tabWidget->currentPageIndex(); | ||
1138 | } | ||
1139 | |||
1140 | PlayListWidget::TabType PlayListWidget::currentTab() const | 1133 | PlayListWidget::TabType PlayListWidget::currentTab() const |
1141 | { | 1134 | { |
1142 | static const TabType indexToTabType[ NumTabTypes ] = | 1135 | static const TabType indexToTabType[ TabTypeCount ] = |
1143 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 1136 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
1144 | 1137 | ||
1145 | int index = tabWidget->currentPageIndex(); | 1138 | int index = tabWidget->currentPageIndex(); |
1146 | assert( index < NumTabTypes && index >= 0 ); | 1139 | assert( index < TabTypeCount && index >= 0 ); |
1147 | 1140 | ||
1148 | return indexToTabType[ index ]; | 1141 | return indexToTabType[ index ]; |
1149 | } | 1142 | } |
1150 | 1143 | ||
1151 | QString PlayListWidget::currentFileListPathName() const { | 1144 | QString PlayListWidget::currentFileListPathName() const { |
1152 | return currentFileListView()->currentItem()->text( 3 ); | 1145 | return currentFileListView()->currentItem()->text( 3 ); |
1153 | } | 1146 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 238a75c..2e2ff89 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,128 +1,128 @@ | |||
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; |
48 | class Config; | 48 | class Config; |
49 | class QListViewItem; | 49 | class QListViewItem; |
50 | class QListView; | 50 | class QListView; |
51 | class QPoint; | 51 | class QPoint; |
52 | class QAction; | 52 | class QAction; |
53 | class QLabel; | 53 | class QLabel; |
54 | 54 | ||
55 | class PlayListWidget : public PlayListWidgetGui { | 55 | class PlayListWidget : public PlayListWidgetGui { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists, NumTabTypes = 4 }; | 58 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
59 | enum { TabTypeCount = 4 }; | ||
59 | 60 | ||
60 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 61 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
61 | ~PlayListWidget(); | 62 | ~PlayListWidget(); |
62 | DocLnkSet files; | 63 | DocLnkSet files; |
63 | DocLnkSet vFiles; | 64 | DocLnkSet vFiles; |
64 | bool fromSetDocument; | 65 | bool fromSetDocument; |
65 | bool insanityBool; | 66 | bool insanityBool; |
66 | QString setDocFileRef, currentPlayList; | 67 | QString setDocFileRef, currentPlayList; |
67 | // retrieve the current playlist entry (media file link) | 68 | // retrieve the current playlist entry (media file link) |
68 | const DocLnk *current(); | 69 | const DocLnk *current(); |
69 | void useSelectedDocument(); | 70 | void useSelectedDocument(); |
70 | int selected; | 71 | int selected; |
71 | int whichList() const; | ||
72 | TabType currentTab() const; | 72 | TabType currentTab() const; |
73 | 73 | ||
74 | public slots: | 74 | public slots: |
75 | bool first(); | 75 | bool first(); |
76 | bool last(); | 76 | bool last(); |
77 | bool next(); | 77 | bool next(); |
78 | bool prev(); | 78 | bool prev(); |
79 | void writeDefaultPlaylist( ); | 79 | void writeDefaultPlaylist( ); |
80 | QString currentFileListPathName() const; | 80 | QString currentFileListPathName() const; |
81 | protected: | 81 | protected: |
82 | void keyReleaseEvent( QKeyEvent *e); | 82 | void keyReleaseEvent( QKeyEvent *e); |
83 | 83 | ||
84 | private: | 84 | private: |
85 | int defaultSkinIndex; | 85 | int defaultSkinIndex; |
86 | bool audioScan, videoScan, audioPopulated, videoPopulated; | 86 | bool audioScan, videoScan, audioPopulated, videoPopulated; |
87 | void readm3u(const QString &); | 87 | void readm3u(const QString &); |
88 | void readPls(const QString &); | 88 | void readPls(const QString &); |
89 | void initializeStates(); | 89 | void initializeStates(); |
90 | void populateAudioView(); | 90 | void populateAudioView(); |
91 | void populateVideoView(); | 91 | void populateVideoView(); |
92 | 92 | ||
93 | QListView *currentFileListView() const; | 93 | QListView *currentFileListView() const; |
94 | 94 | ||
95 | bool inFileListMode() const; | 95 | bool inFileListMode() const; |
96 | 96 | ||
97 | private slots: | 97 | private slots: |
98 | void populateSkinsMenu(); | 98 | void populateSkinsMenu(); |
99 | void skinsMenuActivated(int); | 99 | void skinsMenuActivated(int); |
100 | void pmViewActivated(int); | 100 | void pmViewActivated(int); |
101 | void writem3u(); | 101 | void writem3u(); |
102 | void writeCurrentM3u(); | 102 | void writeCurrentM3u(); |
103 | void scanForAudio(); | 103 | void scanForAudio(); |
104 | void scanForVideo(); | 104 | void scanForVideo(); |
105 | void openFile(); | 105 | void openFile(); |
106 | void setDocument( const QString& fileref ); | 106 | void setDocument( const QString& fileref ); |
107 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 107 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
108 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 108 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
109 | void setPlaylist( bool ); // Show/Hide the playlist | 109 | void setPlaylist( bool ); // Show/Hide the playlist |
110 | void clearList(); | 110 | void clearList(); |
111 | void addAllToList(); | 111 | void addAllToList(); |
112 | void addAllMusicToList(); | 112 | void addAllMusicToList(); |
113 | void addAllVideoToList(); | 113 | void addAllVideoToList(); |
114 | void saveList(); // Save the playlist | 114 | void saveList(); // Save the playlist |
115 | void loadList( const DocLnk &); // Load a playlist | 115 | void loadList( const DocLnk &); // Load a playlist |
116 | void playIt( QListViewItem *); | 116 | void playIt( QListViewItem *); |
117 | void btnPlay(bool); | 117 | void btnPlay(bool); |
118 | void deletePlaylist(); | 118 | void deletePlaylist(); |
119 | void addSelected(); | 119 | void addSelected(); |
120 | void removeSelected(); | 120 | void removeSelected(); |
121 | void tabChanged(QWidget*); | 121 | void tabChanged(QWidget*); |
122 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 122 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
123 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 123 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
124 | void playSelected(); | 124 | void playSelected(); |
125 | }; | 125 | }; |
126 | 126 | ||
127 | #endif // PLAY_LIST_WIDGET_H | 127 | #endif // PLAY_LIST_WIDGET_H |
128 | 128 | ||