-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index cc4be23..c0d3108 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -436,129 +436,129 @@ void PlayListWidget::addSelected() { | |||
436 | qDebug("addSelected"); | 436 | qDebug("addSelected"); |
437 | switch (whichList()) { | 437 | switch (whichList()) { |
438 | case 0: //playlist | 438 | case 0: //playlist |
439 | break; | 439 | break; |
440 | case 1: { //audio | 440 | case 1: { //audio |
441 | QListViewItemIterator it( audioView ); | 441 | QListViewItemIterator it( audioView ); |
442 | // iterate through all items of the listview | 442 | // iterate through all items of the listview |
443 | for ( ; it.current(); ++it ) { | 443 | for ( ; it.current(); ++it ) { |
444 | if ( it.current()->isSelected() ) { | 444 | if ( it.current()->isSelected() ) { |
445 | QListIterator<DocLnk> dit( files.children() ); | 445 | QListIterator<DocLnk> dit( files.children() ); |
446 | for ( ; dit.current(); ++dit ) { | 446 | for ( ; dit.current(); ++dit ) { |
447 | if( dit.current()->name() == it.current()->text(0) ) { | 447 | if( dit.current()->name() == it.current()->text(0) ) { |
448 | if( QFileInfo( dit.current()->file()).exists()) { | 448 | if( QFileInfo( dit.current()->file()).exists()) { |
449 | d->selectedFiles->addToSelection( **dit ); | 449 | d->selectedFiles->addToSelection( **dit ); |
450 | audioView->setSelected( it.current(),FALSE); | 450 | audioView->setSelected( it.current(),FALSE); |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | } | 454 | } |
455 | } | 455 | } |
456 | tabWidget->setCurrentPage(0); | 456 | tabWidget->setCurrentPage(0); |
457 | writeCurrentM3u(); | 457 | writeCurrentM3u(); |
458 | } | 458 | } |
459 | break; | 459 | break; |
460 | case 2: { // video | 460 | case 2: { // video |
461 | QListViewItemIterator it( videoView ); | 461 | QListViewItemIterator it( videoView ); |
462 | // iterate through all items of the listview | 462 | // iterate through all items of the listview |
463 | for ( ; it.current(); ++it ) { | 463 | for ( ; it.current(); ++it ) { |
464 | if ( it.current()->isSelected() ) { | 464 | if ( it.current()->isSelected() ) { |
465 | QListIterator<DocLnk> dit( vFiles.children() ); | 465 | QListIterator<DocLnk> dit( vFiles.children() ); |
466 | for ( ; dit.current(); ++dit ) { | 466 | for ( ; dit.current(); ++dit ) { |
467 | if( dit.current()->name() == it.current()->text(0) ) { | 467 | if( dit.current()->name() == it.current()->text(0) ) { |
468 | if(QFileInfo( dit.current()->file()).exists()) { | 468 | if(QFileInfo( dit.current()->file()).exists()) { |
469 | d->selectedFiles->addToSelection( **dit ); | 469 | d->selectedFiles->addToSelection( **dit ); |
470 | videoView->setSelected( it.current(),FALSE); | 470 | videoView->setSelected( it.current(),FALSE); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | } | 475 | } |
476 | tabWidget->setCurrentPage(0); | 476 | tabWidget->setCurrentPage(0); |
477 | writeCurrentM3u(); | 477 | writeCurrentM3u(); |
478 | } | 478 | } |
479 | break; | 479 | break; |
480 | }; | 480 | }; |
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void PlayListWidget::removeSelected() { | 484 | void PlayListWidget::removeSelected() { |
485 | d->selectedFiles->removeSelected( ); | 485 | d->selectedFiles->removeSelected( ); |
486 | writeCurrentM3u(); | 486 | writeCurrentM3u(); |
487 | } | 487 | } |
488 | 488 | ||
489 | 489 | ||
490 | void PlayListWidget::playIt( QListViewItem *it) { | 490 | void PlayListWidget::playIt( QListViewItem *it) { |
491 | if(!it) return; | 491 | if(!it) return; |
492 | mediaPlayerState->setPlaying(FALSE); | 492 | mediaPlayerState->setPlaying(FALSE); |
493 | mediaPlayerState->setPlaying(TRUE); | 493 | mediaPlayerState->setPlaying(TRUE); |
494 | d->selectedFiles->unSelect(); | 494 | d->selectedFiles->unSelect(); |
495 | } | 495 | } |
496 | 496 | ||
497 | 497 | ||
498 | void PlayListWidget::addToSelection( QListViewItem *it) { | 498 | void PlayListWidget::addToSelection( QListViewItem *it) { |
499 | d->setDocumentUsed = FALSE; | 499 | d->setDocumentUsed = FALSE; |
500 | qDebug("addToSelection2"); | 500 | |
501 | if(it) { | 501 | if(it) { |
502 | switch ( whichList()) { | 502 | switch ( whichList()) { |
503 | case 1: { | 503 | case 1: { |
504 | QListIterator<DocLnk> dit( files.children() ); | 504 | QListIterator<DocLnk> dit( files.children() ); |
505 | for ( ; dit.current(); ++dit ) { | 505 | for ( ; dit.current(); ++dit ) { |
506 | if( dit.current()->name() == it->text(0)) { | 506 | if( dit.current()->name() == it->text(0)) { |
507 | if(QFileInfo( dit.current()->file()).exists()) | 507 | if(QFileInfo( dit.current()->file()).exists()) |
508 | d->selectedFiles->addToSelection( **dit ); | 508 | d->selectedFiles->addToSelection( **dit ); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | writeCurrentM3u(); | 511 | writeCurrentM3u(); |
512 | } | 512 | } |
513 | break; | 513 | break; |
514 | case 2: { | 514 | case 2: { |
515 | QListIterator<DocLnk> dit( vFiles.children() ); | 515 | QListIterator<DocLnk> dit( vFiles.children() ); |
516 | for ( ; dit.current(); ++dit ) { | 516 | for ( ; dit.current(); ++dit ) { |
517 | if( dit.current()->name() == it->text(0)) { | 517 | if( dit.current()->name() == it->text(0)) { |
518 | if( QFileInfo( dit.current()->file()).exists() ) | 518 | if( QFileInfo( dit.current()->file()).exists() ) |
519 | d->selectedFiles->addToSelection( **dit ); | 519 | d->selectedFiles->addToSelection( **dit ); |
520 | } | 520 | } |
521 | } | 521 | } |
522 | writeCurrentM3u(); | 522 | writeCurrentM3u(); |
523 | 523 | ||
524 | } | 524 | } |
525 | break; | 525 | break; |
526 | case 0: | 526 | case 0: |
527 | break; | 527 | break; |
528 | }; | 528 | }; |
529 | tabWidget->setCurrentPage(0); | 529 | tabWidget->setCurrentPage(0); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | void PlayListWidget::tabChanged(QWidget *) { | 534 | void PlayListWidget::tabChanged(QWidget *) { |
535 | 535 | ||
536 | switch ( whichList()) { | 536 | switch ( whichList()) { |
537 | case 0: | 537 | case 0: |
538 | { | 538 | { |
539 | if( !tbDeletePlaylist->isHidden() ) { | 539 | if( !tbDeletePlaylist->isHidden() ) { |
540 | tbDeletePlaylist->hide(); | 540 | tbDeletePlaylist->hide(); |
541 | } | 541 | } |
542 | d->tbRemoveFromList->setEnabled(TRUE); | 542 | d->tbRemoveFromList->setEnabled(TRUE); |
543 | d->tbAddToList->setEnabled(FALSE); | 543 | d->tbAddToList->setEnabled(FALSE); |
544 | } | 544 | } |
545 | break; | 545 | break; |
546 | case 1: | 546 | case 1: |
547 | { | 547 | { |
548 | audioView->clear(); | 548 | audioView->clear(); |
549 | populateAudioView(); | 549 | populateAudioView(); |
550 | 550 | ||
551 | if( !tbDeletePlaylist->isHidden() ) { | 551 | if( !tbDeletePlaylist->isHidden() ) { |
552 | tbDeletePlaylist->hide(); | 552 | tbDeletePlaylist->hide(); |
553 | } | 553 | } |
554 | d->tbRemoveFromList->setEnabled(FALSE); | 554 | d->tbRemoveFromList->setEnabled(FALSE); |
555 | d->tbAddToList->setEnabled(TRUE); | 555 | d->tbAddToList->setEnabled(TRUE); |
556 | } | 556 | } |
557 | break; | 557 | break; |
558 | case 2: | 558 | case 2: |
559 | { | 559 | { |
560 | videoView->clear(); | 560 | videoView->clear(); |
561 | populateVideoView(); | 561 | populateVideoView(); |
562 | if( !tbDeletePlaylist->isHidden() ) { | 562 | if( !tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->hide(); | 563 | tbDeletePlaylist->hide(); |
564 | } | 564 | } |
@@ -662,286 +662,277 @@ void PlayListWidget::populateAudioView() { | |||
662 | } | 662 | } |
663 | } | 663 | } |
664 | } | 664 | } |
665 | 665 | ||
666 | 666 | ||
667 | void PlayListWidget::populateVideoView() { | 667 | void PlayListWidget::populateVideoView() { |
668 | videoView->clear(); | 668 | videoView->clear(); |
669 | StorageInfo storageInfo; | 669 | StorageInfo storageInfo; |
670 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 670 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
671 | 671 | ||
672 | if(!videoScan ) { | 672 | if(!videoScan ) { |
673 | scanForVideo(); | 673 | scanForVideo(); |
674 | } | 674 | } |
675 | 675 | ||
676 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 676 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
677 | QListIterator<FileSystem> it ( fs ); | 677 | QListIterator<FileSystem> it ( fs ); |
678 | videoView->clear(); | 678 | videoView->clear(); |
679 | QString storage, pathName; | 679 | QString storage, pathName; |
680 | for ( ; Vdit.current(); ++Vdit ) { | 680 | for ( ; Vdit.current(); ++Vdit ) { |
681 | for( ; it.current(); ++it ) { | 681 | for( ; it.current(); ++it ) { |
682 | const QString name = (*it)->name(); | 682 | const QString name = (*it)->name(); |
683 | const QString path = (*it)->path(); | 683 | const QString path = (*it)->path(); |
684 | if( Vdit.current()->file().find(path) != -1 ) { | 684 | if( Vdit.current()->file().find(path) != -1 ) { |
685 | storage=name; | 685 | storage=name; |
686 | pathName=path; | 686 | pathName=path; |
687 | } | 687 | } |
688 | } | 688 | } |
689 | 689 | ||
690 | QListViewItem * newItem; | 690 | QListViewItem * newItem; |
691 | if ( QFile( Vdit.current()->file() ).exists() ) { | 691 | if ( QFile( Vdit.current()->file() ).exists() ) { |
692 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 692 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
693 | QString::number( QFile( Vdit.current()->file() ).size() ), | 693 | QString::number( QFile( Vdit.current()->file() ).size() ), |
694 | storage, Vdit.current()->file()); | 694 | storage, Vdit.current()->file()); |
695 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 695 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
696 | } | 696 | } |
697 | } | 697 | } |
698 | } | 698 | } |
699 | 699 | ||
700 | 700 | ||
701 | void PlayListWidget::openFile() { | 701 | void PlayListWidget::openFile() { |
702 | QString filename, name; | 702 | QString filename, name; |
703 | InputDialog *fileDlg; | 703 | InputDialog *fileDlg; |
704 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 704 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
705 | fileDlg->exec(); | 705 | fileDlg->exec(); |
706 | if( fileDlg->result() == 1 ) { | 706 | if( fileDlg->result() == 1 ) { |
707 | filename = fileDlg->text(); | 707 | filename = fileDlg->text(); |
708 | qDebug( "Selected filename is " + filename ); | 708 | qDebug( "Selected filename is " + filename ); |
709 | Om3u *m3uList; | 709 | Om3u *m3uList; |
710 | DocLnk lnk; | 710 | DocLnk lnk; |
711 | Config cfg( "OpiePlayer" ); | 711 | Config cfg( "OpiePlayer" ); |
712 | cfg.setGroup("PlayList"); | 712 | cfg.setGroup("PlayList"); |
713 | 713 | ||
714 | if(filename.left(4) == "http") { | 714 | if(filename.left(4) == "http") { |
715 | QString m3uFile, m3uFilePath; | 715 | QString m3uFile, m3uFilePath; |
716 | if(filename.find(":",8,TRUE) != -1) { //found a port | 716 | if(filename.find(":",8,TRUE) != -1) { //found a port |
717 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 717 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
718 | m3uFile = m3uFile.right( 7); | 718 | m3uFile = m3uFile.right( 7); |
719 | } else if(filename.left(4) == "http"){ | 719 | } else if(filename.left(4) == "http"){ |
720 | m3uFile=filename; | 720 | m3uFile=filename; |
721 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 721 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
722 | } else{ | 722 | } else{ |
723 | m3uFile=filename; | 723 | m3uFile=filename; |
724 | } | 724 | } |
725 | 725 | ||
726 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 726 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
727 | m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite ); | ||
728 | m3uList->add( filename); | ||
729 | m3uList->write(); | ||
730 | m3uList->close(); | ||
731 | if(m3uList) delete m3uList; | ||
732 | lnk.setName( filename ); //sets name | 727 | lnk.setName( filename ); //sets name |
733 | lnk.setFile( filename ); //sets file name | 728 | lnk.setFile( filename ); //sets file name |
734 | lnk.setIcon("opieplayer2/musicfile"); | 729 | lnk.setIcon("opieplayer2/musicfile"); |
735 | d->selectedFiles->addToSelection( lnk ); | 730 | d->selectedFiles->addToSelection( lnk ); |
731 | writeCurrentM3u(); | ||
736 | } | 732 | } |
737 | else if( filename.right( 3) == "m3u" ) { | 733 | else if( filename.right( 3) == "m3u" ) { |
738 | readm3u( filename ); | 734 | readm3u( filename ); |
739 | 735 | ||
740 | } else if( filename.right(3) == "pls" ) { | 736 | } else if( filename.right(3) == "pls" ) { |
741 | readPls( filename ); | 737 | readPls( filename ); |
742 | } | 738 | } else { |
743 | else { | ||
744 | m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite ); | ||
745 | m3uList->add( filename); | ||
746 | m3uList->write(); | ||
747 | m3uList->close(); | ||
748 | if(m3uList) delete m3uList; | ||
749 | d->selectedFiles->addToSelection( DocLnk(filename) ); | 739 | d->selectedFiles->addToSelection( DocLnk(filename) ); |
740 | writeCurrentM3u(); | ||
750 | } | 741 | } |
751 | } | 742 | } |
752 | 743 | ||
753 | if( fileDlg ) { | 744 | if( fileDlg ) { |
754 | delete fileDlg; | 745 | delete fileDlg; |
755 | } | 746 | } |
756 | } | 747 | } |
757 | 748 | ||
758 | /* | 749 | /* |
759 | reads m3u and shows files/urls to playlist widget */ | 750 | reads m3u and shows files/urls to playlist widget */ |
760 | void PlayListWidget::readm3u( const QString &filename ) { | 751 | void PlayListWidget::readm3u( const QString &filename ) { |
761 | qDebug( "read m3u filename " + filename ); | 752 | qDebug( "read m3u filename " + filename ); |
762 | 753 | ||
763 | Om3u *m3uList; | 754 | Om3u *m3uList; |
764 | QString s, name; | 755 | QString s, name; |
765 | m3uList = new Om3u( filename, IO_ReadOnly ); | 756 | m3uList = new Om3u( filename, IO_ReadOnly ); |
766 | m3uList->readM3u(); | 757 | m3uList->readM3u(); |
767 | DocLnk lnk; | 758 | DocLnk lnk; |
768 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 759 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
769 | s = *it; | 760 | s = *it; |
770 | // s.replace( QRegExp( "%20" )," " ); | 761 | // s.replace( QRegExp( "%20" )," " ); |
771 | // qDebug("reading "+ s); | 762 | // qDebug("reading "+ s); |
772 | if(s.left(4)=="http") { | 763 | if(s.left(4)=="http") { |
773 | lnk.setName( s ); //sets file name | 764 | lnk.setName( s ); //sets file name |
774 | lnk.setFile( s ); //sets file name | 765 | lnk.setFile( s ); //sets file name |
775 | lnk.setIcon("opieplayer2/musicfile"); | 766 | lnk.setIcon("opieplayer2/musicfile"); |
776 | } | 767 | } |
777 | else { | 768 | else { |
778 | if( QFileInfo( s ).exists() ) { | 769 | if( QFileInfo( s ).exists() ) { |
779 | lnk.setName( QFileInfo(s).baseName()); | 770 | lnk.setName( QFileInfo(s).baseName()); |
780 | // qDebug("set link "+s); | 771 | // qDebug("set link "+s); |
781 | if(s.at(s.length()-4) == '.') //if regular file | 772 | if(s.at(s.length()-4) == '.') //if regular file |
782 | lnk.setFile( s); | 773 | lnk.setFile( s); |
783 | else | 774 | else |
784 | lnk.setFile( s+"/"); //if url with no extension | 775 | lnk.setFile( s+"/"); //if url with no extension |
785 | } | 776 | } |
786 | } | 777 | } |
787 | d->selectedFiles->addToSelection( lnk ); | 778 | d->selectedFiles->addToSelection( lnk ); |
788 | } | 779 | } |
789 | Config config( "OpiePlayer" ); | 780 | Config config( "OpiePlayer" ); |
790 | config.setGroup( "PlayList" ); | 781 | config.setGroup( "PlayList" ); |
791 | 782 | ||
792 | config.writeEntry("CurrentPlaylist",filename); | 783 | config.writeEntry("CurrentPlaylist",filename); |
793 | config.write(); | 784 | config.write(); |
794 | currentPlayList=filename; | 785 | currentPlayList=filename; |
795 | 786 | ||
796 | // m3uList->write(); | 787 | // m3uList->write(); |
797 | m3uList->close(); | 788 | m3uList->close(); |
798 | if(m3uList) delete m3uList; | 789 | if(m3uList) delete m3uList; |
799 | 790 | ||
800 | d->selectedFiles->setSelectedItem( s); | 791 | d->selectedFiles->setSelectedItem( s); |
801 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 792 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
802 | 793 | ||
803 | } | 794 | } |
804 | 795 | ||
805 | /* | 796 | /* |
806 | reads pls and adds files/urls to playlist */ | 797 | reads pls and adds files/urls to playlist */ |
807 | void PlayListWidget::readPls( const QString &filename ) { | 798 | void PlayListWidget::readPls( const QString &filename ) { |
808 | 799 | ||
809 | qDebug( "pls filename is " + filename ); | 800 | qDebug( "pls filename is " + filename ); |
810 | Om3u *m3uList; | 801 | Om3u *m3uList; |
811 | QString s, name; | 802 | QString s, name; |
812 | m3uList = new Om3u( filename, IO_ReadOnly ); | 803 | m3uList = new Om3u( filename, IO_ReadOnly ); |
813 | m3uList->readPls(); | 804 | m3uList->readPls(); |
814 | 805 | ||
815 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 806 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
816 | s = *it; | 807 | s = *it; |
817 | // s.replace( QRegExp( "%20" )," " ); | 808 | // s.replace( QRegExp( "%20" )," " ); |
818 | DocLnk lnk( s ); | 809 | DocLnk lnk( s ); |
819 | QFileInfo f( s ); | 810 | QFileInfo f( s ); |
820 | QString name = f.baseName(); | 811 | QString name = f.baseName(); |
821 | 812 | ||
822 | if( name.left( 4 ) == "http" ) { | 813 | if( name.left( 4 ) == "http" ) { |
823 | name = s.right( s.length() - 7); | 814 | name = s.right( s.length() - 7); |
824 | } else { | 815 | } else { |
825 | name = s; | 816 | name = s; |
826 | } | 817 | } |
827 | 818 | ||
828 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 819 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
829 | 820 | ||
830 | lnk.setName( name ); | 821 | lnk.setName( name ); |
831 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 822 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
832 | lnk.setFile( s ); | 823 | lnk.setFile( s ); |
833 | } else { //if its a url | 824 | } else { //if its a url |
834 | if( name.right( 1 ).find( '/' ) == -1) { | 825 | if( name.right( 1 ).find( '/' ) == -1) { |
835 | s += "/"; | 826 | s += "/"; |
836 | } | 827 | } |
837 | lnk.setFile( s ); | 828 | lnk.setFile( s ); |
838 | } | 829 | } |
839 | lnk.setType( "audio/x-mpegurl" ); | 830 | lnk.setType( "audio/x-mpegurl" ); |
840 | 831 | ||
841 | lnk.writeLink(); | 832 | lnk.writeLink(); |
842 | d->selectedFiles->addToSelection( lnk ); | 833 | d->selectedFiles->addToSelection( lnk ); |
843 | } | 834 | } |
844 | 835 | ||
845 | m3uList->close(); | 836 | m3uList->close(); |
846 | if(m3uList) delete m3uList; | 837 | if(m3uList) delete m3uList; |
847 | } | 838 | } |
848 | 839 | ||
849 | /* | 840 | /* |
850 | writes current playlist to current m3u file */ | 841 | writes current playlist to current m3u file */ |
851 | void PlayListWidget::writeCurrentM3u() { | 842 | void PlayListWidget::writeCurrentM3u() { |
852 | qDebug("writting to current m3u"); | 843 | qDebug("writing to current m3u"); |
853 | Config cfg( "OpiePlayer" ); | 844 | Config cfg( "OpiePlayer" ); |
854 | cfg.setGroup("PlayList"); | 845 | cfg.setGroup("PlayList"); |
855 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 846 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
856 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 847 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
857 | Om3u *m3uList; | 848 | Om3u *m3uList; |
858 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate ); | 849 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate ); |
859 | d->selectedFiles->first(); | 850 | d->selectedFiles->first(); |
860 | 851 | ||
861 | do { | 852 | do { |
862 | m3uList->add( d->selectedFiles->current()->file()); | 853 | m3uList->add( d->selectedFiles->current()->file()); |
863 | } | 854 | } |
864 | while ( d->selectedFiles->next() ); | 855 | while ( d->selectedFiles->next() ); |
865 | // qDebug( list ); | 856 | // qDebug( list ); |
866 | m3uList->write(); | 857 | m3uList->write(); |
867 | m3uList->close(); | 858 | m3uList->close(); |
868 | 859 | ||
869 | if(m3uList) delete m3uList; | 860 | if(m3uList) delete m3uList; |
870 | } | 861 | } |
871 | 862 | ||
872 | /* | 863 | /* |
873 | writes current playlist to m3u file */ | 864 | writes current playlist to m3u file */ |
874 | void PlayListWidget::writem3u() { | 865 | void PlayListWidget::writem3u() { |
875 | InputDialog *fileDlg; | 866 | InputDialog *fileDlg; |
876 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 867 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
877 | fileDlg->exec(); | 868 | fileDlg->exec(); |
878 | QString name, filename, list; | 869 | QString name, filename, list; |
879 | Om3u *m3uList; | 870 | Om3u *m3uList; |
880 | 871 | ||
881 | if( fileDlg->result() == 1 ) { | 872 | if( fileDlg->result() == 1 ) { |
882 | name = fileDlg->text(); | 873 | name = fileDlg->text(); |
883 | qDebug( filename ); | 874 | // qDebug( filename ); |
884 | 875 | ||
885 | if( name.left( 1) != "/" ) { | 876 | if( name.left( 1) != "/" ) { |
886 | filename = QPEApplication::documentDir() + "/" + name; | 877 | filename = QPEApplication::documentDir() + "/" + name; |
887 | } | 878 | } |
888 | 879 | ||
889 | if( name.right( 3 ) != "m3u" ) { | 880 | if( name.right( 3 ) != "m3u" ) { |
890 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 881 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
891 | } | 882 | } |
892 | 883 | ||
893 | m3uList = new Om3u(filename, IO_ReadWrite); | 884 | m3uList = new Om3u(filename, IO_ReadWrite); |
894 | 885 | ||
895 | d->selectedFiles->first(); | 886 | d->selectedFiles->first(); |
896 | 887 | ||
897 | do { | 888 | do { |
898 | m3uList->add( d->selectedFiles->current()->file()); | 889 | m3uList->add( d->selectedFiles->current()->file()); |
899 | } | 890 | } |
900 | while ( d->selectedFiles->next() ); | 891 | while ( d->selectedFiles->next() ); |
901 | // qDebug( list ); | 892 | // qDebug( list ); |
902 | m3uList->write(); | 893 | m3uList->write(); |
903 | m3uList->close(); | 894 | m3uList->close(); |
904 | 895 | ||
905 | } | 896 | } |
906 | if(m3uList) delete m3uList; | 897 | if(m3uList) delete m3uList; |
907 | if(fileDlg) delete fileDlg; | 898 | if(fileDlg) delete fileDlg; |
908 | 899 | ||
909 | DocLnk lnk; | 900 | DocLnk lnk; |
910 | lnk.setFile( filename); | 901 | lnk.setFile( filename); |
911 | lnk.setIcon("opieplayer2/playlist2"); | 902 | lnk.setIcon("opieplayer2/playlist2"); |
912 | lnk.setName( name); //sets file name | 903 | lnk.setName( name); //sets file name |
913 | 904 | ||
914 | // qDebug(filename); | 905 | // qDebug(filename); |
915 | Config config( "OpiePlayer" ); | 906 | Config config( "OpiePlayer" ); |
916 | config.setGroup( "PlayList" ); | 907 | config.setGroup( "PlayList" ); |
917 | 908 | ||
918 | config.writeEntry("CurrentPlaylist",filename); | 909 | config.writeEntry("CurrentPlaylist",filename); |
919 | currentPlayList=filename; | 910 | currentPlayList=filename; |
920 | 911 | ||
921 | if(!lnk.writeLink()) { | 912 | if(!lnk.writeLink()) { |
922 | qDebug("Writing doclink did not work"); | 913 | qDebug("Writing doclink did not work"); |
923 | } | 914 | } |
924 | 915 | ||
925 | setCaption(tr("OpiePlayer: ") + name); | 916 | setCaption(tr("OpiePlayer: ") + name); |
926 | } | 917 | } |
927 | 918 | ||
928 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 919 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
929 | switch ( e->key() ) { | 920 | switch ( e->key() ) { |
930 | ////////////////////////////// Zaurus keys | 921 | ////////////////////////////// Zaurus keys |
931 | case Key_F9: //activity | 922 | case Key_F9: //activity |
932 | // if(audioUI->isHidden()) | 923 | // if(audioUI->isHidden()) |
933 | // audioUI->showMaximized(); | 924 | // audioUI->showMaximized(); |
934 | break; | 925 | break; |
935 | case Key_F10: //contacts | 926 | case Key_F10: //contacts |
936 | // if( videoUI->isHidden()) | 927 | // if( videoUI->isHidden()) |
937 | // videoUI->showMaximized(); | 928 | // videoUI->showMaximized(); |
938 | break; | 929 | break; |
939 | case Key_F11: //menu | 930 | case Key_F11: //menu |
940 | break; | 931 | break; |
941 | case Key_F12: //home | 932 | case Key_F12: //home |
942 | // doBlank(); | 933 | // doBlank(); |
943 | break; | 934 | break; |
944 | case Key_F13: //mail | 935 | case Key_F13: //mail |
945 | // doUnblank(); | 936 | // doUnblank(); |
946 | break; | 937 | break; |
947 | case Key_Q: //add to playlist | 938 | case Key_Q: //add to playlist |