summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-10 15:09:42 (UTC)
committer llornkcor <llornkcor>2002-11-10 15:09:42 (UTC)
commit1486b6f940adde3cd80592e436e8e025045d7f8e (patch) (unidiff)
treec7e0add7b96a10cbd5095bdfd2845c4e063ebccb
parent521b993fb4175e699e9ac832c50558af0354ca25 (diff)
downloadopie-1486b6f940adde3cd80592e436e8e025045d7f8e.zip
opie-1486b6f940adde3cd80592e436e8e025045d7f8e.tar.gz
opie-1486b6f940adde3cd80592e436e8e025045d7f8e.tar.bz2
need a default m3u to write too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 7ada5ee..75c7332 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -520,535 +520,537 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
520 } 520 }
521 writeCurrentM3u(); 521 writeCurrentM3u();
522 } 522 }
523 break; 523 break;
524 case 2: { 524 case 2: {
525 QListIterator<DocLnk> dit( vFiles.children() ); 525 QListIterator<DocLnk> dit( vFiles.children() );
526 for ( ; dit.current(); ++dit ) { 526 for ( ; dit.current(); ++dit ) {
527 if( dit.current()->name() == it->text(0)) { 527 if( dit.current()->name() == it->text(0)) {
528 if( QFileInfo( dit.current()->file()).exists() ) 528 if( QFileInfo( dit.current()->file()).exists() )
529 d->selectedFiles->addToSelection( **dit ); 529 d->selectedFiles->addToSelection( **dit );
530 } 530 }
531 } 531 }
532 writeCurrentM3u(); 532 writeCurrentM3u();
533 533
534 } 534 }
535 break; 535 break;
536 case 0: 536 case 0:
537 break; 537 break;
538 }; 538 };
539 tabWidget->setCurrentPage(0); 539 tabWidget->setCurrentPage(0);
540 } 540 }
541} 541}
542 542
543 543
544void PlayListWidget::tabChanged(QWidget *) { 544void PlayListWidget::tabChanged(QWidget *) {
545 545
546 switch ( whichList()) { 546 switch ( whichList()) {
547 case 0: 547 case 0:
548 { 548 {
549 if( !tbDeletePlaylist->isHidden() ) { 549 if( !tbDeletePlaylist->isHidden() ) {
550 tbDeletePlaylist->hide(); 550 tbDeletePlaylist->hide();
551 } 551 }
552 d->tbRemoveFromList->setEnabled(TRUE); 552 d->tbRemoveFromList->setEnabled(TRUE);
553 d->tbAddToList->setEnabled(FALSE); 553 d->tbAddToList->setEnabled(FALSE);
554 } 554 }
555 break; 555 break;
556 case 1: 556 case 1:
557 { 557 {
558 audioView->clear(); 558 audioView->clear();
559 populateAudioView(); 559 populateAudioView();
560 560
561 if( !tbDeletePlaylist->isHidden() ) { 561 if( !tbDeletePlaylist->isHidden() ) {
562 tbDeletePlaylist->hide(); 562 tbDeletePlaylist->hide();
563 } 563 }
564 d->tbRemoveFromList->setEnabled(FALSE); 564 d->tbRemoveFromList->setEnabled(FALSE);
565 d->tbAddToList->setEnabled(TRUE); 565 d->tbAddToList->setEnabled(TRUE);
566 } 566 }
567 break; 567 break;
568 case 2: 568 case 2:
569 { 569 {
570 videoView->clear(); 570 videoView->clear();
571 populateVideoView(); 571 populateVideoView();
572 if( !tbDeletePlaylist->isHidden() ) { 572 if( !tbDeletePlaylist->isHidden() ) {
573 tbDeletePlaylist->hide(); 573 tbDeletePlaylist->hide();
574 } 574 }
575 d->tbRemoveFromList->setEnabled(FALSE); 575 d->tbRemoveFromList->setEnabled(FALSE);
576 d->tbAddToList->setEnabled(TRUE); 576 d->tbAddToList->setEnabled(TRUE);
577 } 577 }
578 break; 578 break;
579 case 3: 579 case 3:
580 { 580 {
581 if( tbDeletePlaylist->isHidden() ) { 581 if( tbDeletePlaylist->isHidden() ) {
582 tbDeletePlaylist->show(); 582 tbDeletePlaylist->show();
583 } 583 }
584 playLists->reread(); 584 playLists->reread();
585 } 585 }
586 break; 586 break;
587 }; 587 };
588} 588}
589 589
590 590
591void PlayListWidget::btnPlay(bool b) { 591void PlayListWidget::btnPlay(bool b) {
592// mediaPlayerState->setPlaying(false); 592// mediaPlayerState->setPlaying(false);
593 mediaPlayerState->setPlaying(b); 593 mediaPlayerState->setPlaying(b);
594 insanityBool=FALSE; 594 insanityBool=FALSE;
595} 595}
596 596
597void PlayListWidget::deletePlaylist() { 597void PlayListWidget::deletePlaylist() {
598 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 598 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
599 (tr("You really want to delete\nthis playlist?")), 599 (tr("You really want to delete\nthis playlist?")),
600 (tr("Yes")), (tr("No")), 0 )){ 600 (tr("Yes")), (tr("No")), 0 )){
601 case 0: // Yes clicked, 601 case 0: // Yes clicked,
602 QFile().remove(playLists->selectedDocument().file()); 602 QFile().remove(playLists->selectedDocument().file());
603 QFile().remove(playLists->selectedDocument().linkFile()); 603 QFile().remove(playLists->selectedDocument().linkFile());
604 playLists->reread(); 604 playLists->reread();
605 break; 605 break;
606 case 1: // Cancel 606 case 1: // Cancel
607 break; 607 break;
608 }; 608 };
609} 609}
610 610
611 611
612void PlayListWidget::playSelected() { 612void PlayListWidget::playSelected() {
613 btnPlay( TRUE); 613 btnPlay( TRUE);
614} 614}
615 615
616 616
617void PlayListWidget::scanForAudio() { 617void PlayListWidget::scanForAudio() {
618// qDebug("scan for audio"); 618// qDebug("scan for audio");
619 files.detachChildren(); 619 files.detachChildren();
620 QListIterator<DocLnk> sdit( files.children() ); 620 QListIterator<DocLnk> sdit( files.children() );
621 for ( ; sdit.current(); ++sdit ) { 621 for ( ; sdit.current(); ++sdit ) {
622 delete sdit.current(); 622 delete sdit.current();
623 } 623 }
624// Global::findDocuments( &files, "audio/*"); 624// Global::findDocuments( &files, "audio/*");
625 Global::findDocuments( &files, audioMimes); 625 Global::findDocuments( &files, audioMimes);
626 audioScan = TRUE; 626 audioScan = TRUE;
627} 627}
628 628
629void PlayListWidget::scanForVideo() { 629void PlayListWidget::scanForVideo() {
630// qDebug("scan for video"); 630// qDebug("scan for video");
631 vFiles.detachChildren(); 631 vFiles.detachChildren();
632 QListIterator<DocLnk> sdit( vFiles.children() ); 632 QListIterator<DocLnk> sdit( vFiles.children() );
633 for ( ; sdit.current(); ++sdit ) { 633 for ( ; sdit.current(); ++sdit ) {
634 delete sdit.current(); 634 delete sdit.current();
635 } 635 }
636 Global::findDocuments(&vFiles, "video/*"); 636 Global::findDocuments(&vFiles, "video/*");
637 videoScan = TRUE; 637 videoScan = TRUE;
638} 638}
639 639
640void PlayListWidget::populateAudioView() { 640void PlayListWidget::populateAudioView() {
641 audioView->clear(); 641 audioView->clear();
642 StorageInfo storageInfo; 642 StorageInfo storageInfo;
643 const QList<FileSystem> &fs = storageInfo.fileSystems(); 643 const QList<FileSystem> &fs = storageInfo.fileSystems();
644 if(!audioScan) { 644 if(!audioScan) {
645 scanForAudio(); 645 scanForAudio();
646 } 646 }
647 647
648 QListIterator<DocLnk> dit( files.children() ); 648 QListIterator<DocLnk> dit( files.children() );
649 QListIterator<FileSystem> it ( fs ); 649 QListIterator<FileSystem> it ( fs );
650 650
651 QString storage; 651 QString storage;
652 for ( ; dit.current(); ++dit ) { 652 for ( ; dit.current(); ++dit ) {
653 for( ; it.current(); ++it ){ 653 for( ; it.current(); ++it ){
654 const QString name = (*it)->name(); 654 const QString name = (*it)->name();
655 const QString path = (*it)->path(); 655 const QString path = (*it)->path();
656 if(dit.current()->file().find(path) != -1 ) { 656 if(dit.current()->file().find(path) != -1 ) {
657 storage = name; 657 storage = name;
658 } 658 }
659 } 659 }
660 660
661 QListViewItem * newItem; 661 QListViewItem * newItem;
662 if ( QFile( dit.current()->file()).exists() || 662 if ( QFile( dit.current()->file()).exists() ||
663 dit.current()->file().left(4) == "http" ) { 663 dit.current()->file().left(4) == "http" ) {
664 long size; 664 long size;
665 if( dit.current()->file().left(4) == "http" ) 665 if( dit.current()->file().left(4) == "http" )
666 size=0; 666 size=0;
667 else 667 else
668 size = QFile( dit.current()->file() ).size(); 668 size = QFile( dit.current()->file() ).size();
669 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 669 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
670 QString::number(size ), storage, dit.current()->file()); 670 QString::number(size ), storage, dit.current()->file());
671 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 671 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
672 } 672 }
673 } 673 }
674} 674}
675 675
676 676
677void PlayListWidget::populateVideoView() { 677void PlayListWidget::populateVideoView() {
678 videoView->clear(); 678 videoView->clear();
679 StorageInfo storageInfo; 679 StorageInfo storageInfo;
680 const QList<FileSystem> &fs = storageInfo.fileSystems(); 680 const QList<FileSystem> &fs = storageInfo.fileSystems();
681 681
682 if(!videoScan ) { 682 if(!videoScan ) {
683 scanForVideo(); 683 scanForVideo();
684 } 684 }
685 685
686 QListIterator<DocLnk> Vdit( vFiles.children() ); 686 QListIterator<DocLnk> Vdit( vFiles.children() );
687 QListIterator<FileSystem> it ( fs ); 687 QListIterator<FileSystem> it ( fs );
688 videoView->clear(); 688 videoView->clear();
689 QString storage, pathName; 689 QString storage, pathName;
690 for ( ; Vdit.current(); ++Vdit ) { 690 for ( ; Vdit.current(); ++Vdit ) {
691 for( ; it.current(); ++it ) { 691 for( ; it.current(); ++it ) {
692 const QString name = (*it)->name(); 692 const QString name = (*it)->name();
693 const QString path = (*it)->path(); 693 const QString path = (*it)->path();
694 if( Vdit.current()->file().find(path) != -1 ) { 694 if( Vdit.current()->file().find(path) != -1 ) {
695 storage=name; 695 storage=name;
696 pathName=path; 696 pathName=path;
697 } 697 }
698 } 698 }
699 699
700 QListViewItem * newItem; 700 QListViewItem * newItem;
701 if ( QFile( Vdit.current()->file() ).exists() ) { 701 if ( QFile( Vdit.current()->file() ).exists() ) {
702 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 702 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
703 QString::number( QFile( Vdit.current()->file() ).size() ), 703 QString::number( QFile( Vdit.current()->file() ).size() ),
704 storage, Vdit.current()->file()); 704 storage, Vdit.current()->file());
705 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 705 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
706 } 706 }
707 } 707 }
708} 708}
709 709
710 710
711void PlayListWidget::openFile() { 711void PlayListWidget::openFile() {
712 // http://66.28.164.33:2080
713 // http://somafm.com/star0242.m3u
712 QString filename, name; 714 QString filename, name;
713 InputDialog *fileDlg; 715 InputDialog *fileDlg;
714 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 716 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
715 fileDlg->exec(); 717 fileDlg->exec();
716 if( fileDlg->result() == 1 ) { 718 if( fileDlg->result() == 1 ) {
717 filename = fileDlg->text(); 719 filename = fileDlg->text();
718 qDebug( "Selected filename is " + filename ); 720 qDebug( "Selected filename is " + filename );
719 Om3u *m3uList; 721 Om3u *m3uList;
720 DocLnk lnk; 722 DocLnk lnk;
721 Config cfg( "OpiePlayer" ); 723 Config cfg( "OpiePlayer" );
722 cfg.setGroup("PlayList"); 724 cfg.setGroup("PlayList");
723 725
724 if(filename.left(4) == "http") { 726 if(filename.left(4) == "http") {
725 QString m3uFile, m3uFilePath; 727 QString m3uFile, m3uFilePath;
726 if(filename.find(":",8,TRUE) != -1) { //found a port 728 if(filename.find(":",8,TRUE) != -1) { //found a port
727 m3uFile = filename.left( filename.find( ":",8,TRUE)); 729 m3uFile = filename.left( filename.find( ":",8,TRUE));
728 m3uFile = m3uFile.right( 7); 730 m3uFile = m3uFile.right( 7);
729 } else if(filename.left(4) == "http"){ 731 } else if(filename.left(4) == "http"){
730 m3uFile=filename; 732 m3uFile=filename;
731 m3uFile = m3uFile.right( m3uFile.length() - 7); 733 m3uFile = m3uFile.right( m3uFile.length() - 7);
732 } else{ 734 } else{
733 m3uFile=filename; 735 m3uFile=filename;
734 } 736 }
735 737
736// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 738// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
737 lnk.setName( filename ); //sets name 739 lnk.setName( filename ); //sets name
738 lnk.setFile( filename ); //sets file name 740 lnk.setFile( filename ); //sets file name
739 lnk.setIcon("opieplayer2/musicfile"); 741 lnk.setIcon("opieplayer2/musicfile");
740 d->selectedFiles->addToSelection( lnk ); 742 d->selectedFiles->addToSelection( lnk );
741 writeCurrentM3u(); 743 writeCurrentM3u();
742 } 744 }
743 else if( filename.right( 3) == "m3u" ) { 745 else if( filename.right( 3) == "m3u" ) {
744 readm3u( filename ); 746 readm3u( filename );
745 747
746 } else if( filename.right(3) == "pls" ) { 748 } else if( filename.right(3) == "pls" ) {
747 readPls( filename ); 749 readPls( filename );
748 } else { 750 } else {
749 d->selectedFiles->addToSelection( DocLnk(filename) ); 751 d->selectedFiles->addToSelection( DocLnk(filename) );
750 writeCurrentM3u(); 752 writeCurrentM3u();
751 } 753 }
752 } 754 }
753 755
754 if( fileDlg ) { 756 if( fileDlg ) {
755 delete fileDlg; 757 delete fileDlg;
756 } 758 }
757} 759}
758 760
759/* 761/*
760reads m3u and shows files/urls to playlist widget */ 762reads m3u and shows files/urls to playlist widget */
761void PlayListWidget::readm3u( const QString &filename ) { 763void PlayListWidget::readm3u( const QString &filename ) {
762 qDebug( "read m3u filename " + filename ); 764 qDebug( "read m3u filename " + filename );
763 765
764 Om3u *m3uList; 766 Om3u *m3uList;
765 QString s, name; 767 QString s, name;
766 m3uList = new Om3u( filename, IO_ReadOnly ); 768 m3uList = new Om3u( filename, IO_ReadOnly );
767 m3uList->readM3u(); 769 m3uList->readM3u();
768 DocLnk lnk; 770 DocLnk lnk;
769 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 771 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
770 s = *it; 772 s = *it;
771// qDebug("reading "+ s); 773// qDebug("reading "+ s);
772 if(s.left(4)=="http") { 774 if(s.left(4)=="http") {
773 lnk.setName( s ); //sets file name 775 lnk.setName( s ); //sets file name
774 lnk.setIcon("opieplayer2/musicfile"); 776 lnk.setIcon("opieplayer2/musicfile");
775 if(s.right(4) != '.' || s.right(5) != '.') 777 if(s.right(4) != '.' || s.right(5) != '.')
776 lnk.setFile( s+"/"); //if url with no extension 778 lnk.setFile( s+"/"); //if url with no extension
777 else 779 else
778 lnk.setFile( s ); //sets file name 780 lnk.setFile( s ); //sets file name
779 781
780 } else { 782 } else {
781 // if( QFileInfo( s ).exists() ) { 783 // if( QFileInfo( s ).exists() ) {
782 lnk.setName( QFileInfo(s).baseName()); 784 lnk.setName( QFileInfo(s).baseName());
783 // if(s.right(4) == '.') {//if regular file 785 // if(s.right(4) == '.') {//if regular file
784 if(s.left(1) != "/") { 786 if(s.left(1) != "/") {
785 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 787 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
786 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 788 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
787 lnk.setIcon("SoundPlayer"); 789 lnk.setIcon("SoundPlayer");
788 } else { 790 } else {
789 // qDebug("set link2 "+s); 791 // qDebug("set link2 "+s);
790 lnk.setFile( s); 792 lnk.setFile( s);
791 lnk.setIcon("SoundPlayer"); 793 lnk.setIcon("SoundPlayer");
792 } 794 }
793 } 795 }
794 d->selectedFiles->addToSelection( lnk ); 796 d->selectedFiles->addToSelection( lnk );
795 } 797 }
796 Config config( "OpiePlayer" ); 798 Config config( "OpiePlayer" );
797 config.setGroup( "PlayList" ); 799 config.setGroup( "PlayList" );
798 800
799 config.writeEntry("CurrentPlaylist",filename); 801 config.writeEntry("CurrentPlaylist",filename);
800 config.write(); 802 config.write();
801 currentPlayList=filename; 803 currentPlayList=filename;
802 804
803// m3uList->write(); 805// m3uList->write();
804 m3uList->close(); 806 m3uList->close();
805 if(m3uList) delete m3uList; 807 if(m3uList) delete m3uList;
806 808
807 d->selectedFiles->setSelectedItem( s); 809 d->selectedFiles->setSelectedItem( s);
808 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 810 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
809 811
810} 812}
811 813
812/* 814/*
813reads pls and adds files/urls to playlist */ 815reads pls and adds files/urls to playlist */
814void PlayListWidget::readPls( const QString &filename ) { 816void PlayListWidget::readPls( const QString &filename ) {
815 817
816 qDebug( "pls filename is " + filename ); 818 qDebug( "pls filename is " + filename );
817 Om3u *m3uList; 819 Om3u *m3uList;
818 QString s, name; 820 QString s, name;
819 m3uList = new Om3u( filename, IO_ReadOnly ); 821 m3uList = new Om3u( filename, IO_ReadOnly );
820 m3uList->readPls(); 822 m3uList->readPls();
821 823
822 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 824 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
823 s = *it; 825 s = *it;
824 // s.replace( QRegExp( "%20" )," " ); 826 // s.replace( QRegExp( "%20" )," " );
825 DocLnk lnk( s ); 827 DocLnk lnk( s );
826 QFileInfo f( s ); 828 QFileInfo f( s );
827 QString name = f.baseName(); 829 QString name = f.baseName();
828 830
829 if( name.left( 4 ) == "http" ) { 831 if( name.left( 4 ) == "http" ) {
830 name = s.right( s.length() - 7); 832 name = s.right( s.length() - 7);
831 } else { 833 } else {
832 name = s; 834 name = s;
833 } 835 }
834 836
835 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 837 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
836 838
837 lnk.setName( name ); 839 lnk.setName( name );
838 if( s.at( s.length() - 4) == '.') {// if this is probably a file 840 if( s.at( s.length() - 4) == '.') {// if this is probably a file
839 lnk.setFile( s ); 841 lnk.setFile( s );
840 } else { //if its a url 842 } else { //if its a url
841 if( name.right( 1 ).find( '/' ) == -1) { 843 if( name.right( 1 ).find( '/' ) == -1) {
842 s += "/"; 844 s += "/";
843 } 845 }
844 lnk.setFile( s ); 846 lnk.setFile( s );
845 } 847 }
846 lnk.setType( "audio/x-mpegurl" ); 848 lnk.setType( "audio/x-mpegurl" );
847 849
848 lnk.writeLink(); 850 lnk.writeLink();
849 d->selectedFiles->addToSelection( lnk ); 851 d->selectedFiles->addToSelection( lnk );
850 } 852 }
851 853
852 m3uList->close(); 854 m3uList->close();
853 if(m3uList) delete m3uList; 855 if(m3uList) delete m3uList;
854} 856}
855 857
856/* 858/*
857 writes current playlist to current m3u file */ 859 writes current playlist to current m3u file */
858void PlayListWidget::writeCurrentM3u() { 860void PlayListWidget::writeCurrentM3u() {
859 qDebug("writing to current m3u"); 861 qDebug("writing to current m3u");
860 Config cfg( "OpiePlayer" ); 862 Config cfg( "OpiePlayer" );
861 cfg.setGroup("PlayList"); 863 cfg.setGroup("PlayList");
862 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 864 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
863 865
864 if( d->selectedFiles->first()) { 866 if( d->selectedFiles->first()) {
865 Om3u *m3uList; 867 Om3u *m3uList;
866 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 868 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
867 869
868 do { 870 do {
869 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 871 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
870 m3uList->add( d->selectedFiles->current()->file() ); 872 m3uList->add( d->selectedFiles->current()->file() );
871 } 873 }
872 while ( d->selectedFiles->next() ); 874 while ( d->selectedFiles->next() );
873 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 875 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
874 m3uList->write(); 876 m3uList->write();
875 m3uList->close(); 877 m3uList->close();
876 878
877 if(m3uList) delete m3uList; 879 if(m3uList) delete m3uList;
878 } 880 }
879} 881}
880 882
881 /* 883 /*
882 writes current playlist to m3u file */ 884 writes current playlist to m3u file */
883void PlayListWidget::writem3u() { 885void PlayListWidget::writem3u() {
884 InputDialog *fileDlg; 886 InputDialog *fileDlg;
885 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 887 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
886 fileDlg->exec(); 888 fileDlg->exec();
887 QString name, filename, list; 889 QString name, filename, list;
888 Om3u *m3uList; 890 Om3u *m3uList;
889 891
890 if( fileDlg->result() == 1 ) { 892 if( fileDlg->result() == 1 ) {
891 name = fileDlg->text(); 893 name = fileDlg->text();
892// qDebug( filename ); 894// qDebug( filename );
893 895
894 if( name.left( 1) != "/" ) { 896 if( name.left( 1) != "/" ) {
895 filename = QPEApplication::documentDir() + "/" + name; 897 filename = QPEApplication::documentDir() + "/" + name;
896 } 898 }
897 899
898 if( name.right( 3 ) != "m3u" ) { 900 if( name.right( 3 ) != "m3u" ) {
899 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 901 filename = QPEApplication::documentDir() + "/" +name+".m3u";
900 } 902 }
901 903
902 if( d->selectedFiles->first()) { 904 if( d->selectedFiles->first()) {
903 m3uList = new Om3u(filename, IO_ReadWrite); 905 m3uList = new Om3u(filename, IO_ReadWrite);
904 906
905 do { 907 do {
906 m3uList->add( d->selectedFiles->current()->file()); 908 m3uList->add( d->selectedFiles->current()->file());
907 } 909 }
908 while ( d->selectedFiles->next() ); 910 while ( d->selectedFiles->next() );
909 // qDebug( list ); 911 // qDebug( list );
910 m3uList->write(); 912 m3uList->write();
911 m3uList->close(); 913 m3uList->close();
912 if(m3uList) delete m3uList; 914 if(m3uList) delete m3uList;
913 915
914 if(fileDlg) delete fileDlg; 916 if(fileDlg) delete fileDlg;
915 917
916 DocLnk lnk; 918 DocLnk lnk;
917 lnk.setFile( filename); 919 lnk.setFile( filename);
918 lnk.setIcon("opieplayer2/playlist2"); 920 lnk.setIcon("opieplayer2/playlist2");
919 lnk.setName( name); //sets file name 921 lnk.setName( name); //sets file name
920 922
921 // qDebug(filename); 923 // qDebug(filename);
922 Config config( "OpiePlayer" ); 924 Config config( "OpiePlayer" );
923 config.setGroup( "PlayList" ); 925 config.setGroup( "PlayList" );
924 926
925 config.writeEntry("CurrentPlaylist",filename); 927 config.writeEntry("CurrentPlaylist",filename);
926 currentPlayList=filename; 928 currentPlayList=filename;
927 929
928 if(!lnk.writeLink()) { 930 if(!lnk.writeLink()) {
929 qDebug("Writing doclink did not work"); 931 qDebug("Writing doclink did not work");
930 } 932 }
931 933
932 setCaption(tr("OpiePlayer: ") + name); 934 setCaption(tr("OpiePlayer: ") + name);
933 } 935 }
934 } 936 }
935} 937}
936 938
937void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 939void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
938 switch ( e->key() ) { 940 switch ( e->key() ) {
939 ////////////////////////////// Zaurus keys 941 ////////////////////////////// Zaurus keys
940 case Key_F9: //activity 942 case Key_F9: //activity
941 // if(audioUI->isHidden()) 943 // if(audioUI->isHidden())
942 // audioUI->showMaximized(); 944 // audioUI->showMaximized();
943 break; 945 break;
944 case Key_F10: //contacts 946 case Key_F10: //contacts
945 // if( videoUI->isHidden()) 947 // if( videoUI->isHidden())
946 // videoUI->showMaximized(); 948 // videoUI->showMaximized();
947 break; 949 break;
948 case Key_F11: //menu 950 case Key_F11: //menu
949 break; 951 break;
950 case Key_F12: //home 952 case Key_F12: //home
951 // doBlank(); 953 // doBlank();
952 break; 954 break;
953 case Key_F13: //mail 955 case Key_F13: //mail
954 // doUnblank(); 956 // doUnblank();
955 break; 957 break;
956 case Key_Q: //add to playlist 958 case Key_Q: //add to playlist
957 addSelected(); 959 addSelected();
958 break; 960 break;
959 case Key_R: //remove from playlist 961 case Key_R: //remove from playlist
960 removeSelected(); 962 removeSelected();
961 break; 963 break;
962 // case Key_P: //play 964 // case Key_P: //play
963 // qDebug("Play"); 965 // qDebug("Play");
964 // playSelected(); 966 // playSelected();
965 // break; 967 // break;
966 case Key_Space: 968 case Key_Space:
967 // playSelected(); puh 969 // playSelected(); puh
968 break; 970 break;
969 case Key_1: 971 case Key_1:
970 tabWidget->setCurrentPage( 0 ); 972 tabWidget->setCurrentPage( 0 );
971 break; 973 break;
972 case Key_2: 974 case Key_2:
973 tabWidget->setCurrentPage( 1 ); 975 tabWidget->setCurrentPage( 1 );
974 break; 976 break;
975 case Key_3: 977 case Key_3:
976 tabWidget->setCurrentPage( 2 ); 978 tabWidget->setCurrentPage( 2 );
977 break; 979 break;
978 case Key_4: 980 case Key_4:
979 tabWidget->setCurrentPage( 3 ); 981 tabWidget->setCurrentPage( 3 );
980 break; 982 break;
981 case Key_Down: 983 case Key_Down:
982 if ( !d->selectedFiles->next() ) 984 if ( !d->selectedFiles->next() )
983 d->selectedFiles->first(); 985 d->selectedFiles->first();
984 break; 986 break;
985 case Key_Up: 987 case Key_Up:
986 if ( !d->selectedFiles->prev() ) 988 if ( !d->selectedFiles->prev() )
987 // d->selectedFiles->last(); 989 // d->selectedFiles->last();
988 break; 990 break;
989 } 991 }
990} 992}
991 993
992void PlayListWidget::pmViewActivated(int index) { 994void PlayListWidget::pmViewActivated(int index) {
993// qDebug("%d", index); 995// qDebug("%d", index);
994 switch(index) { 996 switch(index) {
995 case -16: 997 case -16:
996 { 998 {
997 mediaPlayerState->toggleFullscreen(); 999 mediaPlayerState->toggleFullscreen();
998 bool b=mediaPlayerState->fullscreen(); 1000 bool b=mediaPlayerState->fullscreen();
999 pmView->setItemChecked( index, b); 1001 pmView->setItemChecked( index, b);
1000 Config cfg( "OpiePlayer" ); 1002 Config cfg( "OpiePlayer" );
1001 cfg.writeEntry( "FullScreen", b ); 1003 cfg.writeEntry( "FullScreen", b );
1002 } 1004 }
1003 break; 1005 break;
1004 }; 1006 };
1005} 1007}
1006 1008
1007void PlayListWidget::populateSkinsMenu() { 1009void PlayListWidget::populateSkinsMenu() {
1008 int item = 0; 1010 int item = 0;
1009 defaultSkinIndex = 0; 1011 defaultSkinIndex = 0;
1010 QString skinName; 1012 QString skinName;
1011 Config cfg( "OpiePlayer" ); 1013 Config cfg( "OpiePlayer" );
1012 cfg.setGroup("Options" ); 1014 cfg.setGroup("Options" );
1013 QString skin = cfg.readEntry( "Skin", "default" ); 1015 QString skin = cfg.readEntry( "Skin", "default" );
1014 1016
1015 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1017 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1016 skinsDir.setFilter( QDir::Dirs ); 1018 skinsDir.setFilter( QDir::Dirs );
1017 skinsDir.setSorting(QDir::Name ); 1019 skinsDir.setSorting(QDir::Name );
1018 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1020 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1019 QFileInfoListIterator it( *skinslist ); 1021 QFileInfoListIterator it( *skinslist );
1020 QFileInfo *fi; 1022 QFileInfo *fi;
1021 while ( ( fi = it.current() ) ) { 1023 while ( ( fi = it.current() ) ) {
1022 skinName = fi->fileName(); 1024 skinName = fi->fileName();
1023// qDebug( fi->fileName() ); 1025// qDebug( fi->fileName() );
1024 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1026 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1025 item = skinsMenu->insertItem( fi->fileName() ) ; 1027 item = skinsMenu->insertItem( fi->fileName() ) ;
1026 } 1028 }
1027 if( skinName == "default" ) { 1029 if( skinName == "default" ) {
1028 defaultSkinIndex = item; 1030 defaultSkinIndex = item;
1029 } 1031 }
1030 if( skinName == skin ) { 1032 if( skinName == skin ) {
1031 skinsMenu->setItemChecked( item, TRUE ); 1033 skinsMenu->setItemChecked( item, TRUE );
1032 } 1034 }
1033 ++it; 1035 ++it;
1034 } 1036 }
1035} 1037}
1036 1038
1037void PlayListWidget::skinsMenuActivated( int item ) { 1039void PlayListWidget::skinsMenuActivated( int item ) {
1038 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1040 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1039 skinsMenu->setItemChecked( i, FALSE ); 1041 skinsMenu->setItemChecked( i, FALSE );
1040 } 1042 }
1041 skinsMenu->setItemChecked( item, TRUE ); 1043 skinsMenu->setItemChecked( item, TRUE );
1042 1044
1043 Config cfg( "OpiePlayer" ); 1045 Config cfg( "OpiePlayer" );
1044 cfg.setGroup("Options"); 1046 cfg.setGroup("Options");
1045 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1047 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1046} 1048}
1047 1049
1048int PlayListWidget::whichList() { 1050int PlayListWidget::whichList() {
1049 return tabWidget->currentPageIndex(); 1051 return tabWidget->currentPageIndex();
1050} 1052}
1051 1053
1052QString PlayListWidget::currentFileListPathName() { 1054QString PlayListWidget::currentFileListPathName() {
1053 switch (whichList()) { 1055 switch (whichList()) {
1054 case 1: 1056 case 1: