Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 72 |
1 files changed, 3 insertions, 69 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 12b8a71..460a0bf 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -602,168 +602,102 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
602 | d->tbAddToList->setEnabled(FALSE); | 602 | d->tbAddToList->setEnabled(FALSE); |
603 | 603 | ||
604 | d->tbPlay->setEnabled( false ); | 604 | d->tbPlay->setEnabled( false ); |
605 | } | 605 | } |
606 | break; | 606 | break; |
607 | }; | 607 | }; |
608 | } | 608 | } |
609 | 609 | ||
610 | 610 | ||
611 | void PlayListWidget::btnPlay(bool b) { | 611 | void PlayListWidget::btnPlay(bool b) { |
612 | // mediaPlayerState->setPlaying(false); | 612 | // mediaPlayerState->setPlaying(false); |
613 | mediaPlayerState.setPlaying(b); | 613 | mediaPlayerState.setPlaying(b); |
614 | insanityBool=FALSE; | 614 | insanityBool=FALSE; |
615 | } | 615 | } |
616 | 616 | ||
617 | void PlayListWidget::deletePlaylist() { | 617 | void PlayListWidget::deletePlaylist() { |
618 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 618 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
619 | (tr("You really want to delete\nthis playlist?")), | 619 | (tr("You really want to delete\nthis playlist?")), |
620 | (tr("Yes")), (tr("No")), 0 )){ | 620 | (tr("Yes")), (tr("No")), 0 )){ |
621 | case 0: // Yes clicked, | 621 | case 0: // Yes clicked, |
622 | QFile().remove(playLists->selectedDocument().file()); | 622 | QFile().remove(playLists->selectedDocument().file()); |
623 | QFile().remove(playLists->selectedDocument().linkFile()); | 623 | QFile().remove(playLists->selectedDocument().linkFile()); |
624 | playLists->reread(); | 624 | playLists->reread(); |
625 | break; | 625 | break; |
626 | case 1: // Cancel | 626 | case 1: // Cancel |
627 | break; | 627 | break; |
628 | }; | 628 | }; |
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
632 | void PlayListWidget::playSelected() { | 632 | void PlayListWidget::playSelected() { |
633 | btnPlay( TRUE); | 633 | btnPlay( TRUE); |
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | ||
637 | void PlayListWidget::scanForAudio() { | 637 | void PlayListWidget::scanForAudio() { |
638 | audioView->scanFiles(); | 638 | audioView->scanFiles(); |
639 | audioView->scannedFiles() = true; | 639 | audioView->scannedFiles() = true; |
640 | populateAudioView(); | 640 | populateAudioView(); |
641 | } | 641 | } |
642 | 642 | ||
643 | void PlayListWidget::scanForVideo() { | 643 | void PlayListWidget::scanForVideo() { |
644 | videoView->scanFiles(); | 644 | videoView->scanFiles(); |
645 | videoView->scannedFiles() = true; | 645 | videoView->scannedFiles() = true; |
646 | populateVideoView(); | 646 | populateVideoView(); |
647 | } | 647 | } |
648 | 648 | ||
649 | void PlayListWidget::populateAudioView() { | 649 | void PlayListWidget::populateAudioView() { |
650 | audioView->clear(); | 650 | audioView->populateView(); |
651 | StorageInfo storageInfo; | 651 | audioPopulated = true; |
652 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
653 | if(!audioView->scannedFiles()) { | ||
654 | scanForAudio(); | ||
655 | } | ||
656 | |||
657 | QListIterator<DocLnk> dit( audioView->files().children() ); | ||
658 | // QListIterator<FileSystem> it ( fs ); | ||
659 | audioView->clear(); | ||
660 | |||
661 | QString storage; | ||
662 | for ( ; dit.current(); ++dit ) { | ||
663 | // // for( ; it.current(); ++it ){ | ||
664 | // const QString name = (*dit)->name(); | ||
665 | // const QString path = (*dit)->path(); | ||
666 | // if(dit.current()->file().find(path) != -1 ) { | ||
667 | // storage = name; | ||
668 | // // } | ||
669 | // } | ||
670 | |||
671 | QListViewItem * newItem; | ||
672 | if ( QFile( dit.current()->file()).exists() || | ||
673 | dit.current()->file().left(4) == "http" ) { | ||
674 | long size; | ||
675 | if( dit.current()->file().left(4) == "http" ) | ||
676 | size=0; | ||
677 | else | ||
678 | size = QFile( dit.current()->file() ).size(); | ||
679 | |||
680 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | ||
681 | QString::number(size ), "" /*storage*/, | ||
682 | dit.current()->file() ); | ||
683 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | ||
684 | // qDebug("<<<< "+dit.current()->file()); | ||
685 | } | ||
686 | } | ||
687 | audioPopulated=true; | ||
688 | } | 652 | } |
689 | 653 | ||
690 | |||
691 | void PlayListWidget::populateVideoView() { | 654 | void PlayListWidget::populateVideoView() { |
692 | videoView->clear(); | 655 | videoView->populateView(); |
693 | StorageInfo storageInfo; | ||
694 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
695 | |||
696 | if(!videoView->scannedFiles()) { | ||
697 | scanForVideo(); | ||
698 | } | ||
699 | |||
700 | QListIterator<DocLnk> Vdit( videoView->files().children() ); | ||
701 | // QListIterator<FileSystem> it ( fs ); | ||
702 | videoView->clear(); | ||
703 | QString storage, pathName; | ||
704 | for ( ; Vdit.current(); ++Vdit ) { | ||
705 | // // for( ; it.current(); ++it ) { | ||
706 | // const QString name = (*Vdit)->name(); | ||
707 | // const QString path = (*Vdit)->path(); | ||
708 | // if( Vdit.current()->file().find(path) != -1 ) { | ||
709 | // storage=name; | ||
710 | // pathName=path; | ||
711 | // // } | ||
712 | // } | ||
713 | |||
714 | QListViewItem * newItem; | ||
715 | if ( QFile( Vdit.current()->file() ).exists() ) { | ||
716 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | ||
717 | QString::number( QFile( Vdit.current()->file() ).size() ), | ||
718 | ""/*storage*/, Vdit.current()->file()); | ||
719 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | ||
720 | } | ||
721 | } | ||
722 | videoPopulated=true; | 656 | videoPopulated=true; |
723 | } | 657 | } |
724 | 658 | ||
725 | QListView *PlayListWidget::currentFileListView() const | 659 | QListView *PlayListWidget::currentFileListView() const |
726 | { | 660 | { |
727 | switch ( currentTab() ) { | 661 | switch ( currentTab() ) { |
728 | case AudioFiles: return audioView; | 662 | case AudioFiles: return audioView; |
729 | case VideoFiles: return videoView; | 663 | case VideoFiles: return videoView; |
730 | default: assert( false ); | 664 | default: assert( false ); |
731 | } | 665 | } |
732 | return 0; | 666 | return 0; |
733 | } | 667 | } |
734 | 668 | ||
735 | bool PlayListWidget::inFileListMode() const | 669 | bool PlayListWidget::inFileListMode() const |
736 | { | 670 | { |
737 | TabType tab = currentTab(); | 671 | TabType tab = currentTab(); |
738 | return tab == AudioFiles || tab == VideoFiles; | 672 | return tab == AudioFiles || tab == VideoFiles; |
739 | } | 673 | } |
740 | 674 | ||
741 | void PlayListWidget::openFile() { | 675 | void PlayListWidget::openFile() { |
742 | // http://66.28.164.33:2080 | 676 | // http://66.28.164.33:2080 |
743 | // http://somafm.com/star0242.m3u | 677 | // http://somafm.com/star0242.m3u |
744 | QString filename, name; | 678 | QString filename, name; |
745 | InputDialog *fileDlg; | 679 | InputDialog *fileDlg; |
746 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 680 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
747 | fileDlg->exec(); | 681 | fileDlg->exec(); |
748 | if( fileDlg->result() == 1 ) { | 682 | if( fileDlg->result() == 1 ) { |
749 | filename = fileDlg->text(); | 683 | filename = fileDlg->text(); |
750 | qDebug( "Selected filename is " + filename ); | 684 | qDebug( "Selected filename is " + filename ); |
751 | // Om3u *m3uList; | 685 | // Om3u *m3uList; |
752 | DocLnk lnk; | 686 | DocLnk lnk; |
753 | Config cfg( "OpiePlayer" ); | 687 | Config cfg( "OpiePlayer" ); |
754 | cfg.setGroup("PlayList"); | 688 | cfg.setGroup("PlayList"); |
755 | 689 | ||
756 | if(filename.left(4) == "http") { | 690 | if(filename.left(4) == "http") { |
757 | QString m3uFile, m3uFilePath; | 691 | QString m3uFile, m3uFilePath; |
758 | if(filename.find(":",8,TRUE) != -1) { //found a port | 692 | if(filename.find(":",8,TRUE) != -1) { //found a port |
759 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 693 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
760 | m3uFile = m3uFile.right( 7); | 694 | m3uFile = m3uFile.right( 7); |
761 | } else if(filename.left(4) == "http"){ | 695 | } else if(filename.left(4) == "http"){ |
762 | m3uFile=filename; | 696 | m3uFile=filename; |
763 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 697 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
764 | } else{ | 698 | } else{ |
765 | m3uFile=filename; | 699 | m3uFile=filename; |
766 | } | 700 | } |
767 | 701 | ||
768 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 702 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
769 | lnk.setName( filename ); //sets name | 703 | lnk.setName( filename ); //sets name |