-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index ce73252..b04fe8d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -501,232 +501,236 @@ 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 | if ( currentTab() == CurrentPlayList ) | 577 | if ( currentTab() == CurrentPlayList ) |
578 | return; | 578 | return; |
579 | // case 1: { | 579 | // case 1: { |
580 | DocLnk lnk; | 580 | DocLnk lnk; |
581 | QString filename; | 581 | QString filename; |
582 | 582 | ||
583 | filename=it->text(3); | 583 | filename=it->text(3); |
584 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 584 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
585 | lnk.setFile( filename ); //sets file name | 585 | lnk.setFile( filename ); //sets file name |
586 | d->selectedFiles->addToSelection( lnk); | 586 | d->selectedFiles->addToSelection( lnk); |
587 | 587 | ||
588 | writeCurrentM3u(); | 588 | writeCurrentM3u(); |
589 | tabWidget->setCurrentPage(0); | 589 | tabWidget->setCurrentPage(0); |
590 | 590 | ||
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void PlayListWidget::tabChanged(QWidget *) { | 595 | void PlayListWidget::tabChanged(QWidget *) { |
596 | 596 | ||
597 | d->tbPlay->setEnabled( true ); | ||
598 | |||
597 | switch ( currentTab() ) { | 599 | switch ( currentTab() ) { |
598 | case CurrentPlayList: | 600 | case CurrentPlayList: |
599 | { | 601 | { |
600 | if( !tbDeletePlaylist->isHidden() ) { | 602 | if( !tbDeletePlaylist->isHidden() ) { |
601 | tbDeletePlaylist->hide(); | 603 | tbDeletePlaylist->hide(); |
602 | } | 604 | } |
603 | d->tbRemoveFromList->setEnabled(TRUE); | 605 | d->tbRemoveFromList->setEnabled(TRUE); |
604 | d->tbAddToList->setEnabled(FALSE); | 606 | d->tbAddToList->setEnabled(FALSE); |
605 | } | 607 | } |
606 | break; | 608 | break; |
607 | case AudioFiles: | 609 | case AudioFiles: |
608 | { | 610 | { |
609 | // audioView->clear(); | 611 | // audioView->clear(); |
610 | if(!audioPopulated) populateAudioView(); | 612 | if(!audioPopulated) populateAudioView(); |
611 | 613 | ||
612 | if( !tbDeletePlaylist->isHidden() ) { | 614 | if( !tbDeletePlaylist->isHidden() ) { |
613 | tbDeletePlaylist->hide(); | 615 | tbDeletePlaylist->hide(); |
614 | } | 616 | } |
615 | d->tbRemoveFromList->setEnabled(FALSE); | 617 | d->tbRemoveFromList->setEnabled(FALSE); |
616 | d->tbAddToList->setEnabled(TRUE); | 618 | d->tbAddToList->setEnabled(TRUE); |
617 | } | 619 | } |
618 | break; | 620 | break; |
619 | case VideoFiles: | 621 | case VideoFiles: |
620 | { | 622 | { |
621 | // videoView->clear(); | 623 | // videoView->clear(); |
622 | if(!videoPopulated) populateVideoView(); | 624 | if(!videoPopulated) populateVideoView(); |
623 | if( !tbDeletePlaylist->isHidden() ) { | 625 | if( !tbDeletePlaylist->isHidden() ) { |
624 | tbDeletePlaylist->hide(); | 626 | tbDeletePlaylist->hide(); |
625 | } | 627 | } |
626 | d->tbRemoveFromList->setEnabled(FALSE); | 628 | d->tbRemoveFromList->setEnabled(FALSE); |
627 | d->tbAddToList->setEnabled(TRUE); | 629 | d->tbAddToList->setEnabled(TRUE); |
628 | } | 630 | } |
629 | break; | 631 | break; |
630 | case PlayLists: | 632 | case PlayLists: |
631 | { | 633 | { |
632 | if( tbDeletePlaylist->isHidden() ) { | 634 | if( tbDeletePlaylist->isHidden() ) { |
633 | tbDeletePlaylist->show(); | 635 | tbDeletePlaylist->show(); |
634 | } | 636 | } |
635 | playLists->reread(); | 637 | playLists->reread(); |
636 | d->tbAddToList->setEnabled(FALSE); | 638 | d->tbAddToList->setEnabled(FALSE); |
639 | |||
640 | d->tbPlay->setEnabled( false ); | ||
637 | } | 641 | } |
638 | break; | 642 | break; |
639 | }; | 643 | }; |
640 | } | 644 | } |
641 | 645 | ||
642 | 646 | ||
643 | void PlayListWidget::btnPlay(bool b) { | 647 | void PlayListWidget::btnPlay(bool b) { |
644 | // mediaPlayerState->setPlaying(false); | 648 | // mediaPlayerState->setPlaying(false); |
645 | mediaPlayerState->setPlaying(b); | 649 | mediaPlayerState->setPlaying(b); |
646 | insanityBool=FALSE; | 650 | insanityBool=FALSE; |
647 | } | 651 | } |
648 | 652 | ||
649 | void PlayListWidget::deletePlaylist() { | 653 | void PlayListWidget::deletePlaylist() { |
650 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 654 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
651 | (tr("You really want to delete\nthis playlist?")), | 655 | (tr("You really want to delete\nthis playlist?")), |
652 | (tr("Yes")), (tr("No")), 0 )){ | 656 | (tr("Yes")), (tr("No")), 0 )){ |
653 | case 0: // Yes clicked, | 657 | case 0: // Yes clicked, |
654 | QFile().remove(playLists->selectedDocument().file()); | 658 | QFile().remove(playLists->selectedDocument().file()); |
655 | QFile().remove(playLists->selectedDocument().linkFile()); | 659 | QFile().remove(playLists->selectedDocument().linkFile()); |
656 | playLists->reread(); | 660 | playLists->reread(); |
657 | break; | 661 | break; |
658 | case 1: // Cancel | 662 | case 1: // Cancel |
659 | break; | 663 | break; |
660 | }; | 664 | }; |
661 | } | 665 | } |
662 | 666 | ||
663 | 667 | ||
664 | void PlayListWidget::playSelected() { | 668 | void PlayListWidget::playSelected() { |
665 | btnPlay( TRUE); | 669 | btnPlay( TRUE); |
666 | } | 670 | } |
667 | 671 | ||
668 | 672 | ||
669 | void PlayListWidget::scanForAudio() { | 673 | void PlayListWidget::scanForAudio() { |
670 | // qDebug("scan for audio"); | 674 | // qDebug("scan for audio"); |
671 | files.detachChildren(); | 675 | files.detachChildren(); |
672 | QListIterator<DocLnk> sdit( files.children() ); | 676 | QListIterator<DocLnk> sdit( files.children() ); |
673 | for ( ; sdit.current(); ++sdit ) { | 677 | for ( ; sdit.current(); ++sdit ) { |
674 | delete sdit.current(); | 678 | delete sdit.current(); |
675 | } | 679 | } |
676 | // Global::findDocuments( &files, "audio/*"); | 680 | // Global::findDocuments( &files, "audio/*"); |
677 | Global::findDocuments( &files, audioMimes); | 681 | Global::findDocuments( &files, audioMimes); |
678 | audioScan = true; | 682 | audioScan = true; |
679 | populateAudioView(); | 683 | populateAudioView(); |
680 | } | 684 | } |
681 | 685 | ||
682 | void PlayListWidget::scanForVideo() { | 686 | void PlayListWidget::scanForVideo() { |
683 | // qDebug("scan for video"); | 687 | // qDebug("scan for video"); |
684 | vFiles.detachChildren(); | 688 | vFiles.detachChildren(); |
685 | QListIterator<DocLnk> sdit( vFiles.children() ); | 689 | QListIterator<DocLnk> sdit( vFiles.children() ); |
686 | for ( ; sdit.current(); ++sdit ) { | 690 | for ( ; sdit.current(); ++sdit ) { |
687 | delete sdit.current(); | 691 | delete sdit.current(); |
688 | } | 692 | } |
689 | Global::findDocuments(&vFiles, "video/*"); | 693 | Global::findDocuments(&vFiles, "video/*"); |
690 | videoScan = true; | 694 | videoScan = true; |
691 | populateVideoView(); | 695 | populateVideoView(); |
692 | } | 696 | } |
693 | 697 | ||
694 | void PlayListWidget::populateAudioView() { | 698 | void PlayListWidget::populateAudioView() { |
695 | audioView->clear(); | 699 | audioView->clear(); |
696 | StorageInfo storageInfo; | 700 | StorageInfo storageInfo; |
697 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 701 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
698 | if(!audioScan) { | 702 | if(!audioScan) { |
699 | scanForAudio(); | 703 | scanForAudio(); |
700 | } | 704 | } |
701 | 705 | ||
702 | QListIterator<DocLnk> dit( files.children() ); | 706 | QListIterator<DocLnk> dit( files.children() ); |
703 | // QListIterator<FileSystem> it ( fs ); | 707 | // QListIterator<FileSystem> it ( fs ); |
704 | audioView->clear(); | 708 | audioView->clear(); |
705 | 709 | ||
706 | QString storage; | 710 | QString storage; |
707 | for ( ; dit.current(); ++dit ) { | 711 | for ( ; dit.current(); ++dit ) { |
708 | // // for( ; it.current(); ++it ){ | 712 | // // for( ; it.current(); ++it ){ |
709 | // const QString name = (*dit)->name(); | 713 | // const QString name = (*dit)->name(); |
710 | // const QString path = (*dit)->path(); | 714 | // const QString path = (*dit)->path(); |
711 | // if(dit.current()->file().find(path) != -1 ) { | 715 | // if(dit.current()->file().find(path) != -1 ) { |
712 | // storage = name; | 716 | // storage = name; |
713 | // // } | 717 | // // } |
714 | // } | 718 | // } |
715 | 719 | ||
716 | QListViewItem * newItem; | 720 | QListViewItem * newItem; |
717 | if ( QFile( dit.current()->file()).exists() || | 721 | if ( QFile( dit.current()->file()).exists() || |
718 | dit.current()->file().left(4) == "http" ) { | 722 | dit.current()->file().left(4) == "http" ) { |
719 | long size; | 723 | long size; |
720 | if( dit.current()->file().left(4) == "http" ) | 724 | if( dit.current()->file().left(4) == "http" ) |
721 | size=0; | 725 | size=0; |
722 | else | 726 | else |
723 | size = QFile( dit.current()->file() ).size(); | 727 | size = QFile( dit.current()->file() ).size(); |
724 | 728 | ||
725 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 729 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
726 | QString::number(size ), "" /*storage*/, | 730 | QString::number(size ), "" /*storage*/, |
727 | dit.current()->file() ); | 731 | dit.current()->file() ); |
728 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 732 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
729 | // qDebug("<<<< "+dit.current()->file()); | 733 | // qDebug("<<<< "+dit.current()->file()); |
730 | } | 734 | } |
731 | } | 735 | } |
732 | audioPopulated=true; | 736 | audioPopulated=true; |