-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.h b/noncore/multimedia/opieplayer2/playlistselection.h index d10bc82..9cc4e30 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.h +++ b/noncore/multimedia/opieplayer2/playlistselection.h | |||
@@ -1,63 +1,65 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_SELECTION_H | 20 | #ifndef PLAY_LIST_SELECTION_H |
21 | #define PLAY_LIST_SELECTION_H | 21 | #define PLAY_LIST_SELECTION_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | class PlayListSelection : public QListView { | 28 | class PlayListSelection : public QListView { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | PlayListSelection( QWidget *parent, const char *name=0 ); | 31 | PlayListSelection( QWidget *parent, const char *name=0 ); |
32 | ~PlayListSelection(); | 32 | ~PlayListSelection(); |
33 | 33 | ||
34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) | 34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) |
35 | public slots: | 35 | public slots: |
36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist | 36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist |
37 | void removeSelected(); // Remove a media file from the playlist | 37 | void removeSelected(); // Remove a media file from the playlist |
38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier | 38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier |
39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later | 39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later |
40 | void unSelect(); | 40 | void unSelect(); |
41 | void writeCurrent( Config &); | 41 | void writeCurrent( Config &); |
42 | void setSelectedItem( const QString & ); | 42 | void setSelectedItem( const QString & ); |
43 | bool prev(); | 43 | bool prev(); |
44 | bool next(); | 44 | bool next(); |
45 | bool first(); | 45 | bool first(); |
46 | bool last(); | 46 | bool last(); |
47 | 47 | ||
48 | bool isEmpty() const { return childCount() == 0; } | ||
49 | |||
48 | protected: | 50 | protected: |
49 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 51 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
50 | /* #ifdef USE_PLAYLIST_BACKGROUND */ | 52 | /* #ifdef USE_PLAYLIST_BACKGROUND */ |
51 | virtual void drawBackground( QPainter *p, const QRect &r ); | 53 | virtual void drawBackground( QPainter *p, const QRect &r ); |
52 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; | 54 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; |
53 | /* #endif */ | 55 | /* #endif */ |
54 | 56 | ||
55 | private: | 57 | private: |
56 | QList<DocLnk> selectedList; | 58 | QList<DocLnk> selectedList; |
57 | const DocLnk *lnk; | 59 | const DocLnk *lnk; |
58 | }; | 60 | }; |
59 | 61 | ||
60 | 62 | ||
61 | #endif // PLAY_LIST_SELECTION_H | 63 | #endif // PLAY_LIST_SELECTION_H |
62 | 64 | ||
63 | 65 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index f53def6..b08204e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -293,402 +293,410 @@ void PlayListWidget::addAllToList() { | |||
293 | 293 | ||
294 | // if(!audioScan) | 294 | // if(!audioScan) |
295 | // scanForAudio(); | 295 | // scanForAudio(); |
296 | // if(!videoScan) | 296 | // if(!videoScan) |
297 | // scanForVideo(); | 297 | // scanForVideo(); |
298 | 298 | ||
299 | // DocLnkSet filesAll; | 299 | // DocLnkSet filesAll; |
300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
301 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 301 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
302 | // for ( ; Adit.current(); ++Adit ) { | 302 | // for ( ; Adit.current(); ++Adit ) { |
303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
304 | // d->selectedFiles->addToSelection( **Adit ); | 304 | // d->selectedFiles->addToSelection( **Adit ); |
305 | // } | 305 | // } |
306 | // } | 306 | // } |
307 | 307 | ||
308 | // qDebug("elapsed time %d", t.elapsed() ); | 308 | // qDebug("elapsed time %d", t.elapsed() ); |
309 | 309 | ||
310 | tabWidget->setCurrentPage(0); | 310 | tabWidget->setCurrentPage(0); |
311 | 311 | ||
312 | writeCurrentM3u(); | 312 | writeCurrentM3u(); |
313 | d->selectedFiles->first(); | 313 | d->selectedFiles->first(); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | void PlayListWidget::addAllMusicToList() { | 317 | void PlayListWidget::addAllMusicToList() { |
318 | 318 | ||
319 | if(!audioScan) { | 319 | if(!audioScan) { |
320 | if(audioView->childCount() < 1) | 320 | if(audioView->childCount() < 1) |
321 | populateAudioView(); | 321 | populateAudioView(); |
322 | } | 322 | } |
323 | 323 | ||
324 | QListViewItemIterator audioIt( audioView ); | 324 | QListViewItemIterator audioIt( audioView ); |
325 | DocLnk lnk; | 325 | DocLnk lnk; |
326 | QString filename; | 326 | QString filename; |
327 | // iterate through all items of the listview | 327 | // iterate through all items of the listview |
328 | for ( ; audioIt.current(); ++audioIt ) { | 328 | for ( ; audioIt.current(); ++audioIt ) { |
329 | filename = audioIt.current()->text(3); | 329 | filename = audioIt.current()->text(3); |
330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
331 | lnk.setFile( filename ); //sets file name | 331 | lnk.setFile( filename ); //sets file name |
332 | d->selectedFiles->addToSelection( lnk); | 332 | d->selectedFiles->addToSelection( lnk); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* if(!audioScan) | 335 | /* if(!audioScan) |
336 | scanForAudio(); | 336 | scanForAudio(); |
337 | QListIterator<DocLnk> dit( files.children() ); | 337 | QListIterator<DocLnk> dit( files.children() ); |
338 | for ( ; dit.current(); ++dit ) { | 338 | for ( ; dit.current(); ++dit ) { |
339 | if( QFileInfo(dit.current()->file() ).exists() ) { | 339 | if( QFileInfo(dit.current()->file() ).exists() ) { |
340 | d->selectedFiles->addToSelection( **dit ); | 340 | d->selectedFiles->addToSelection( **dit ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | */ | 343 | */ |
344 | tabWidget->setCurrentPage(0); | 344 | tabWidget->setCurrentPage(0); |
345 | writeCurrentM3u(); | 345 | writeCurrentM3u(); |
346 | d->selectedFiles->first(); | 346 | d->selectedFiles->first(); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | void PlayListWidget::addAllVideoToList() { | 350 | void PlayListWidget::addAllVideoToList() { |
351 | 351 | ||
352 | if(!videoScan) { | 352 | if(!videoScan) { |
353 | if(videoView->childCount() < 1) | 353 | if(videoView->childCount() < 1) |
354 | populateVideoView(); | 354 | populateVideoView(); |
355 | } | 355 | } |
356 | 356 | ||
357 | QListViewItemIterator videoIt( videoView ); | 357 | QListViewItemIterator videoIt( videoView ); |
358 | DocLnk lnk; | 358 | DocLnk lnk; |
359 | QString filename; | 359 | QString filename; |
360 | for ( ; videoIt.current(); ++videoIt ) { | 360 | for ( ; videoIt.current(); ++videoIt ) { |
361 | filename = videoIt.current()->text(3); | 361 | filename = videoIt.current()->text(3); |
362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
363 | lnk.setFile( filename ); //sets file name | 363 | lnk.setFile( filename ); //sets file name |
364 | d->selectedFiles->addToSelection( lnk); | 364 | d->selectedFiles->addToSelection( lnk); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | /* if(!videoScan) | 368 | /* if(!videoScan) |
369 | scanForVideo(); | 369 | scanForVideo(); |
370 | QListIterator<DocLnk> dit( vFiles.children() ); | 370 | QListIterator<DocLnk> dit( vFiles.children() ); |
371 | for ( ; dit.current(); ++dit ) { | 371 | for ( ; dit.current(); ++dit ) { |
372 | if( QFileInfo( dit.current()->file() ).exists() ) { | 372 | if( QFileInfo( dit.current()->file() ).exists() ) { |
373 | d->selectedFiles->addToSelection( **dit ); | 373 | d->selectedFiles->addToSelection( **dit ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | */ | 376 | */ |
377 | tabWidget->setCurrentPage(0); | 377 | tabWidget->setCurrentPage(0); |
378 | writeCurrentM3u(); | 378 | writeCurrentM3u(); |
379 | d->selectedFiles->first(); | 379 | d->selectedFiles->first(); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | void PlayListWidget::setDocument( const QString& fileref ) { | 383 | void PlayListWidget::setDocument( const QString& fileref ) { |
384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
385 | fromSetDocument = TRUE; | 385 | fromSetDocument = TRUE; |
386 | if ( fileref.isNull() ) { | 386 | if ( fileref.isNull() ) { |
387 | QMessageBox::warning( this, tr( "Invalid File" ), | 387 | QMessageBox::warning( this, tr( "Invalid File" ), |
388 | tr( "There was a problem in getting the file." ) ); | 388 | tr( "There was a problem in getting the file." ) ); |
389 | return; | 389 | return; |
390 | } | 390 | } |
391 | 391 | ||
392 | clearList(); | 392 | clearList(); |
393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
394 | readm3u( fileref ); | 394 | readm3u( fileref ); |
395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
396 | readm3u( DocLnk( fileref).file() ); | 396 | readm3u( DocLnk( fileref).file() ); |
397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
398 | readPls( fileref ); | 398 | readPls( fileref ); |
399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
400 | readPls( DocLnk( fileref).file() ); | 400 | readPls( DocLnk( fileref).file() ); |
401 | } else { | 401 | } else { |
402 | clearList(); | 402 | clearList(); |
403 | addToSelection( DocLnk( fileref ) ); | 403 | addToSelection( DocLnk( fileref ) ); |
404 | writeCurrentM3u(); | 404 | writeCurrentM3u(); |
405 | 405 | ||
406 | d->setDocumentUsed = TRUE; | 406 | d->setDocumentUsed = TRUE; |
407 | mediaPlayerState->setPlaying( FALSE ); | 407 | mediaPlayerState->setPlaying( FALSE ); |
408 | mediaPlayerState->setPlaying( TRUE ); | 408 | mediaPlayerState->setPlaying( TRUE ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | void PlayListWidget::useSelectedDocument() { | 413 | void PlayListWidget::useSelectedDocument() { |
414 | d->setDocumentUsed = FALSE; | 414 | d->setDocumentUsed = FALSE; |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | const DocLnk *PlayListWidget::current() const { // this is fugly | 418 | const DocLnk *PlayListWidget::current() const { // this is fugly |
419 | assert( currentTab() == CurrentPlayList ); | 419 | assert( currentTab() == CurrentPlayList ); |
420 | 420 | ||
421 | return d->selectedFiles->current(); | 421 | const DocLnk *lnk = d->selectedFiles->current(); |
422 | if ( !lnk ) { | ||
423 | d->selectedFiles->first(); | ||
424 | lnk = d->selectedFiles->current(); | ||
425 | } | ||
426 | assert( lnk ); | ||
427 | return lnk; | ||
422 | } | 428 | } |
423 | 429 | ||
424 | 430 | ||
425 | bool PlayListWidget::prev() { | 431 | bool PlayListWidget::prev() { |
426 | if ( mediaPlayerState->isShuffled() ) { | 432 | if ( mediaPlayerState->isShuffled() ) { |
427 | const DocLnk *cur = current(); | 433 | const DocLnk *cur = current(); |
428 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 434 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
429 | for ( int i = 0; i < j; i++ ) { | 435 | for ( int i = 0; i < j; i++ ) { |
430 | if ( !d->selectedFiles->next() ) | 436 | if ( !d->selectedFiles->next() ) |
431 | d->selectedFiles->first(); | 437 | d->selectedFiles->first(); |
432 | } | 438 | } |
433 | if ( cur == current() ) | 439 | if ( cur == current() ) |
434 | if ( !d->selectedFiles->next() ) { | 440 | if ( !d->selectedFiles->next() ) { |
435 | d->selectedFiles->first(); | 441 | d->selectedFiles->first(); |
436 | } | 442 | } |
437 | return TRUE; | 443 | return TRUE; |
438 | } else { | 444 | } else { |
439 | if ( !d->selectedFiles->prev() ) { | 445 | if ( !d->selectedFiles->prev() ) { |
440 | if ( mediaPlayerState->isLooping() ) { | 446 | if ( mediaPlayerState->isLooping() ) { |
441 | return d->selectedFiles->last(); | 447 | return d->selectedFiles->last(); |
442 | } else { | 448 | } else { |
443 | return FALSE; | 449 | return FALSE; |
444 | } | 450 | } |
445 | } | 451 | } |
446 | return TRUE; | 452 | return TRUE; |
447 | } | 453 | } |
448 | } | 454 | } |
449 | 455 | ||
450 | 456 | ||
451 | bool PlayListWidget::next() { | 457 | bool PlayListWidget::next() { |
452 | //qDebug("<<<<<<<<<<<<next()"); | 458 | //qDebug("<<<<<<<<<<<<next()"); |
453 | if ( mediaPlayerState->isShuffled() ) { | 459 | if ( mediaPlayerState->isShuffled() ) { |
454 | return prev(); | 460 | return prev(); |
455 | } else { | 461 | } else { |
456 | if ( !d->selectedFiles->next() ) { | 462 | if ( !d->selectedFiles->next() ) { |
457 | if ( mediaPlayerState->isLooping() ) { | 463 | if ( mediaPlayerState->isLooping() ) { |
458 | return d->selectedFiles->first(); | 464 | return d->selectedFiles->first(); |
459 | } else { | 465 | } else { |
460 | return FALSE; | 466 | return FALSE; |
461 | } | 467 | } |
462 | } | 468 | } |
463 | return TRUE; | 469 | return TRUE; |
464 | } | 470 | } |
465 | } | 471 | } |
466 | 472 | ||
467 | 473 | ||
468 | bool PlayListWidget::first() { | 474 | bool PlayListWidget::first() { |
469 | return d->selectedFiles->first(); | 475 | return d->selectedFiles->first(); |
470 | } | 476 | } |
471 | 477 | ||
472 | 478 | ||
473 | bool PlayListWidget::last() { | 479 | bool PlayListWidget::last() { |
474 | return d->selectedFiles->last(); | 480 | return d->selectedFiles->last(); |
475 | } | 481 | } |
476 | 482 | ||
477 | 483 | ||
478 | void PlayListWidget::saveList() { | 484 | void PlayListWidget::saveList() { |
479 | writem3u(); | 485 | writem3u(); |
480 | } | 486 | } |
481 | 487 | ||
482 | 488 | ||
483 | void PlayListWidget::loadList( const DocLnk & lnk) { | 489 | void PlayListWidget::loadList( const DocLnk & lnk) { |
484 | QString name = lnk.name(); | 490 | QString name = lnk.name(); |
485 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 491 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
486 | 492 | ||
487 | if( name.length()>0) { | 493 | if( name.length()>0) { |
488 | setCaption("OpiePlayer: "+name); | 494 | setCaption("OpiePlayer: "+name); |
489 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 495 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
490 | clearList(); | 496 | clearList(); |
491 | readm3u(lnk.file()); | 497 | readm3u(lnk.file()); |
492 | tabWidget->setCurrentPage(0); | 498 | tabWidget->setCurrentPage(0); |
493 | } | 499 | } |
494 | } | 500 | } |
495 | 501 | ||
496 | void PlayListWidget::addSelected() { | 502 | void PlayListWidget::addSelected() { |
497 | assert( inFileListMode() ); | 503 | assert( inFileListMode() ); |
498 | 504 | ||
499 | QListView *fileListView = currentFileListView(); | 505 | QListView *fileListView = currentFileListView(); |
500 | QListViewItemIterator it( fileListView ); | 506 | QListViewItemIterator it( fileListView ); |
501 | for ( ; it.current(); ++it ) | 507 | for ( ; it.current(); ++it ) |
502 | if ( it.current()->isSelected() ) { | 508 | if ( it.current()->isSelected() ) { |
503 | QString filename = it.current()->text(3); | 509 | QString filename = it.current()->text(3); |
504 | 510 | ||
505 | DocLnk lnk; | 511 | DocLnk lnk; |
506 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 512 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
507 | lnk.setFile( filename ); //sets file name | 513 | lnk.setFile( filename ); //sets file name |
508 | 514 | ||
509 | d->selectedFiles->addToSelection( lnk ); | 515 | d->selectedFiles->addToSelection( lnk ); |
510 | } | 516 | } |
511 | 517 | ||
512 | fileListView->clearSelection(); | 518 | fileListView->clearSelection(); |
513 | 519 | ||
514 | tabWidget->setCurrentPage( 0 ); | 520 | tabWidget->setCurrentPage( 0 ); |
515 | writeCurrentM3u(); | 521 | writeCurrentM3u(); |
516 | } | 522 | } |
517 | 523 | ||
518 | 524 | ||
519 | void PlayListWidget::removeSelected() { | 525 | void PlayListWidget::removeSelected() { |
520 | d->selectedFiles->removeSelected( ); | 526 | d->selectedFiles->removeSelected( ); |
521 | writeCurrentM3u(); | 527 | writeCurrentM3u(); |
522 | } | 528 | } |
523 | 529 | ||
524 | 530 | ||
525 | void PlayListWidget::playIt( QListViewItem *it) { | 531 | void PlayListWidget::playIt( QListViewItem *it) { |
526 | if(!it) return; | 532 | if(!it) return; |
527 | mediaPlayerState->setPlaying(FALSE); | 533 | mediaPlayerState->setPlaying(FALSE); |
528 | mediaPlayerState->setPlaying(TRUE); | 534 | mediaPlayerState->setPlaying(TRUE); |
529 | d->selectedFiles->unSelect(); | 535 | d->selectedFiles->unSelect(); |
530 | } | 536 | } |
531 | 537 | ||
532 | 538 | ||
533 | void PlayListWidget::addToSelection( QListViewItem *it) { | 539 | void PlayListWidget::addToSelection( QListViewItem *it) { |
534 | d->setDocumentUsed = FALSE; | 540 | d->setDocumentUsed = FALSE; |
535 | 541 | ||
536 | if(it) { | 542 | if(it) { |
537 | if ( currentTab() == CurrentPlayList ) | 543 | if ( currentTab() == CurrentPlayList ) |
538 | return; | 544 | return; |
539 | // case 1: { | 545 | // case 1: { |
540 | DocLnk lnk; | 546 | DocLnk lnk; |
541 | QString filename; | 547 | QString filename; |
542 | 548 | ||
543 | filename=it->text(3); | 549 | filename=it->text(3); |
544 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
545 | lnk.setFile( filename ); //sets file name | 551 | lnk.setFile( filename ); //sets file name |
546 | d->selectedFiles->addToSelection( lnk); | 552 | d->selectedFiles->addToSelection( lnk); |
547 | 553 | ||
548 | writeCurrentM3u(); | 554 | writeCurrentM3u(); |
549 | tabWidget->setCurrentPage(0); | 555 | tabWidget->setCurrentPage(0); |
550 | 556 | ||
551 | } | 557 | } |
552 | } | 558 | } |
553 | 559 | ||
554 | 560 | ||
555 | void PlayListWidget::tabChanged(QWidget *) { | 561 | void PlayListWidget::tabChanged(QWidget *) { |
556 | 562 | ||
557 | d->tbPlay->setEnabled( true ); | 563 | d->tbPlay->setEnabled( true ); |
558 | 564 | ||
559 | switch ( currentTab() ) { | 565 | switch ( currentTab() ) { |
560 | case CurrentPlayList: | 566 | case CurrentPlayList: |
561 | { | 567 | { |
562 | if( !tbDeletePlaylist->isHidden() ) { | 568 | if( !tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->hide(); | 569 | tbDeletePlaylist->hide(); |
564 | } | 570 | } |
565 | d->tbRemoveFromList->setEnabled(TRUE); | 571 | d->tbRemoveFromList->setEnabled(TRUE); |
566 | d->tbAddToList->setEnabled(FALSE); | 572 | d->tbAddToList->setEnabled(FALSE); |
573 | |||
574 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | ||
567 | } | 575 | } |
568 | break; | 576 | break; |
569 | case AudioFiles: | 577 | case AudioFiles: |
570 | { | 578 | { |
571 | // audioView->clear(); | 579 | // audioView->clear(); |
572 | if(!audioPopulated) populateAudioView(); | 580 | if(!audioPopulated) populateAudioView(); |
573 | 581 | ||
574 | if( !tbDeletePlaylist->isHidden() ) { | 582 | if( !tbDeletePlaylist->isHidden() ) { |
575 | tbDeletePlaylist->hide(); | 583 | tbDeletePlaylist->hide(); |
576 | } | 584 | } |
577 | d->tbRemoveFromList->setEnabled(FALSE); | 585 | d->tbRemoveFromList->setEnabled(FALSE); |
578 | d->tbAddToList->setEnabled(TRUE); | 586 | d->tbAddToList->setEnabled(TRUE); |
579 | } | 587 | } |
580 | break; | 588 | break; |
581 | case VideoFiles: | 589 | case VideoFiles: |
582 | { | 590 | { |
583 | // videoView->clear(); | 591 | // videoView->clear(); |
584 | if(!videoPopulated) populateVideoView(); | 592 | if(!videoPopulated) populateVideoView(); |
585 | if( !tbDeletePlaylist->isHidden() ) { | 593 | if( !tbDeletePlaylist->isHidden() ) { |
586 | tbDeletePlaylist->hide(); | 594 | tbDeletePlaylist->hide(); |
587 | } | 595 | } |
588 | d->tbRemoveFromList->setEnabled(FALSE); | 596 | d->tbRemoveFromList->setEnabled(FALSE); |
589 | d->tbAddToList->setEnabled(TRUE); | 597 | d->tbAddToList->setEnabled(TRUE); |
590 | } | 598 | } |
591 | break; | 599 | break; |
592 | case PlayLists: | 600 | case PlayLists: |
593 | { | 601 | { |
594 | if( tbDeletePlaylist->isHidden() ) { | 602 | if( tbDeletePlaylist->isHidden() ) { |
595 | tbDeletePlaylist->show(); | 603 | tbDeletePlaylist->show(); |
596 | } | 604 | } |
597 | playLists->reread(); | 605 | playLists->reread(); |
598 | d->tbAddToList->setEnabled(FALSE); | 606 | d->tbAddToList->setEnabled(FALSE); |
599 | 607 | ||
600 | d->tbPlay->setEnabled( false ); | 608 | d->tbPlay->setEnabled( false ); |
601 | } | 609 | } |
602 | break; | 610 | break; |
603 | }; | 611 | }; |
604 | } | 612 | } |
605 | 613 | ||
606 | 614 | ||
607 | void PlayListWidget::btnPlay(bool b) { | 615 | void PlayListWidget::btnPlay(bool b) { |
608 | // mediaPlayerState->setPlaying(false); | 616 | // mediaPlayerState->setPlaying(false); |
609 | mediaPlayerState->setPlaying(b); | 617 | mediaPlayerState->setPlaying(b); |
610 | insanityBool=FALSE; | 618 | insanityBool=FALSE; |
611 | } | 619 | } |
612 | 620 | ||
613 | void PlayListWidget::deletePlaylist() { | 621 | void PlayListWidget::deletePlaylist() { |
614 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
615 | (tr("You really want to delete\nthis playlist?")), | 623 | (tr("You really want to delete\nthis playlist?")), |
616 | (tr("Yes")), (tr("No")), 0 )){ | 624 | (tr("Yes")), (tr("No")), 0 )){ |
617 | case 0: // Yes clicked, | 625 | case 0: // Yes clicked, |
618 | QFile().remove(playLists->selectedDocument().file()); | 626 | QFile().remove(playLists->selectedDocument().file()); |
619 | QFile().remove(playLists->selectedDocument().linkFile()); | 627 | QFile().remove(playLists->selectedDocument().linkFile()); |
620 | playLists->reread(); | 628 | playLists->reread(); |
621 | break; | 629 | break; |
622 | case 1: // Cancel | 630 | case 1: // Cancel |
623 | break; | 631 | break; |
624 | }; | 632 | }; |
625 | } | 633 | } |
626 | 634 | ||
627 | 635 | ||
628 | void PlayListWidget::playSelected() { | 636 | void PlayListWidget::playSelected() { |
629 | btnPlay( TRUE); | 637 | btnPlay( TRUE); |
630 | } | 638 | } |
631 | 639 | ||
632 | 640 | ||
633 | void PlayListWidget::scanForAudio() { | 641 | void PlayListWidget::scanForAudio() { |
634 | // qDebug("scan for audio"); | 642 | // qDebug("scan for audio"); |
635 | files.detachChildren(); | 643 | files.detachChildren(); |
636 | QListIterator<DocLnk> sdit( files.children() ); | 644 | QListIterator<DocLnk> sdit( files.children() ); |
637 | for ( ; sdit.current(); ++sdit ) { | 645 | for ( ; sdit.current(); ++sdit ) { |
638 | delete sdit.current(); | 646 | delete sdit.current(); |
639 | } | 647 | } |
640 | // Global::findDocuments( &files, "audio/*"); | 648 | // Global::findDocuments( &files, "audio/*"); |
641 | Global::findDocuments( &files, audioMimes); | 649 | Global::findDocuments( &files, audioMimes); |
642 | audioScan = true; | 650 | audioScan = true; |
643 | populateAudioView(); | 651 | populateAudioView(); |
644 | } | 652 | } |
645 | 653 | ||
646 | void PlayListWidget::scanForVideo() { | 654 | void PlayListWidget::scanForVideo() { |
647 | // qDebug("scan for video"); | 655 | // qDebug("scan for video"); |
648 | vFiles.detachChildren(); | 656 | vFiles.detachChildren(); |
649 | QListIterator<DocLnk> sdit( vFiles.children() ); | 657 | QListIterator<DocLnk> sdit( vFiles.children() ); |
650 | for ( ; sdit.current(); ++sdit ) { | 658 | for ( ; sdit.current(); ++sdit ) { |
651 | delete sdit.current(); | 659 | delete sdit.current(); |
652 | } | 660 | } |
653 | Global::findDocuments(&vFiles, "video/*"); | 661 | Global::findDocuments(&vFiles, "video/*"); |
654 | videoScan = true; | 662 | videoScan = true; |
655 | populateVideoView(); | 663 | populateVideoView(); |
656 | } | 664 | } |
657 | 665 | ||
658 | void PlayListWidget::populateAudioView() { | 666 | void PlayListWidget::populateAudioView() { |
659 | audioView->clear(); | 667 | audioView->clear(); |
660 | StorageInfo storageInfo; | 668 | StorageInfo storageInfo; |
661 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 669 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
662 | if(!audioScan) { | 670 | if(!audioScan) { |
663 | scanForAudio(); | 671 | scanForAudio(); |
664 | } | 672 | } |
665 | 673 | ||
666 | QListIterator<DocLnk> dit( files.children() ); | 674 | QListIterator<DocLnk> dit( files.children() ); |
667 | // QListIterator<FileSystem> it ( fs ); | 675 | // QListIterator<FileSystem> it ( fs ); |
668 | audioView->clear(); | 676 | audioView->clear(); |
669 | 677 | ||
670 | QString storage; | 678 | QString storage; |
671 | for ( ; dit.current(); ++dit ) { | 679 | for ( ; dit.current(); ++dit ) { |
672 | // // for( ; it.current(); ++it ){ | 680 | // // for( ; it.current(); ++it ){ |
673 | // const QString name = (*dit)->name(); | 681 | // const QString name = (*dit)->name(); |
674 | // const QString path = (*dit)->path(); | 682 | // const QString path = (*dit)->path(); |
675 | // if(dit.current()->file().find(path) != -1 ) { | 683 | // if(dit.current()->file().find(path) != -1 ) { |
676 | // storage = name; | 684 | // storage = name; |
677 | // // } | 685 | // // } |
678 | // } | 686 | // } |
679 | 687 | ||
680 | QListViewItem * newItem; | 688 | QListViewItem * newItem; |
681 | if ( QFile( dit.current()->file()).exists() || | 689 | if ( QFile( dit.current()->file()).exists() || |
682 | dit.current()->file().left(4) == "http" ) { | 690 | dit.current()->file().left(4) == "http" ) { |
683 | long size; | 691 | long size; |
684 | if( dit.current()->file().left(4) == "http" ) | 692 | if( dit.current()->file().left(4) == "http" ) |
685 | size=0; | 693 | size=0; |
686 | else | 694 | else |
687 | size = QFile( dit.current()->file() ).size(); | 695 | size = QFile( dit.current()->file() ).size(); |
688 | 696 | ||
689 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 697 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
690 | QString::number(size ), "" /*storage*/, | 698 | QString::number(size ), "" /*storage*/, |
691 | dit.current()->file() ); | 699 | dit.current()->file() ); |
692 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 700 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
693 | // qDebug("<<<< "+dit.current()->file()); | 701 | // qDebug("<<<< "+dit.current()->file()); |
694 | } | 702 | } |