author | llornkcor <llornkcor> | 2002-11-10 17:11:25 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-10 17:11:25 (UTC) |
commit | 8b6c9588bc499d1c37a0ecf65f59de129b3924e3 (patch) (unidiff) | |
tree | 147dfeb0a09120d8e631ce6e11e0281a18d5c422 | |
parent | 8394ee8e5fc0014605256b243909709864afdc9b (diff) | |
download | opie-8b6c9588bc499d1c37a0ecf65f59de129b3924e3.zip opie-8b6c9588bc499d1c37a0ecf65f59de129b3924e3.tar.gz opie-8b6c9588bc499d1c37a0ecf65f59de129b3924e3.tar.bz2 |
should be selected after adding file
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 0825eed..60eb0c8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -455,151 +455,158 @@ void PlayListWidget::addSelected() { | |||
455 | QListIterator<DocLnk> dit( files.children() ); | 455 | QListIterator<DocLnk> dit( files.children() ); |
456 | for ( ; dit.current(); ++dit ) { | 456 | for ( ; dit.current(); ++dit ) { |
457 | if( dit.current()->name() == it.current()->text(0) ) { | 457 | if( dit.current()->name() == it.current()->text(0) ) { |
458 | if( QFileInfo( dit.current()->file()).exists()) { | 458 | if( QFileInfo( dit.current()->file()).exists()) { |
459 | d->selectedFiles->addToSelection( **dit ); | 459 | d->selectedFiles->addToSelection( **dit ); |
460 | audioView->setSelected( it.current(),FALSE); | 460 | audioView->setSelected( it.current(),FALSE); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | // tabWidget->setCurrentPage(0); | 466 | // tabWidget->setCurrentPage(0); |
467 | writeCurrentM3u(); | 467 | writeCurrentM3u(); |
468 | d->selectedFiles->next(); | 468 | d->selectedFiles->next(); |
469 | } | 469 | } |
470 | break; | 470 | break; |
471 | case 2: { // video | 471 | case 2: { // video |
472 | QListViewItemIterator it( videoView ); | 472 | QListViewItemIterator it( videoView ); |
473 | // iterate through all items of the listview | 473 | // iterate through all items of the listview |
474 | for ( ; it.current(); ++it ) { | 474 | for ( ; it.current(); ++it ) { |
475 | if ( it.current()->isSelected() ) { | 475 | if ( it.current()->isSelected() ) { |
476 | QListIterator<DocLnk> dit( vFiles.children() ); | 476 | QListIterator<DocLnk> dit( vFiles.children() ); |
477 | for ( ; dit.current(); ++dit ) { | 477 | for ( ; dit.current(); ++dit ) { |
478 | if( dit.current()->name() == it.current()->text(0) ) { | 478 | if( dit.current()->name() == it.current()->text(0) ) { |
479 | if(QFileInfo( dit.current()->file()).exists()) { | 479 | if(QFileInfo( dit.current()->file()).exists()) { |
480 | d->selectedFiles->addToSelection( **dit ); | 480 | d->selectedFiles->addToSelection( **dit ); |
481 | videoView->setSelected( it.current(),FALSE); | 481 | videoView->setSelected( it.current(),FALSE); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | // tabWidget->setCurrentPage(0); | 487 | // tabWidget->setCurrentPage(0); |
488 | writeCurrentM3u(); | 488 | writeCurrentM3u(); |
489 | 489 | ||
490 | } | 490 | } |
491 | break; | 491 | break; |
492 | }; | 492 | }; |
493 | } | 493 | } |
494 | 494 | ||
495 | 495 | ||
496 | void PlayListWidget::removeSelected() { | 496 | void PlayListWidget::removeSelected() { |
497 | d->selectedFiles->removeSelected( ); | 497 | d->selectedFiles->removeSelected( ); |
498 | writeCurrentM3u(); | 498 | writeCurrentM3u(); |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | void PlayListWidget::playIt( QListViewItem *it) { | 502 | void PlayListWidget::playIt( QListViewItem *it) { |
503 | if(!it) return; | 503 | if(!it) return; |
504 | mediaPlayerState->setPlaying(FALSE); | 504 | mediaPlayerState->setPlaying(FALSE); |
505 | mediaPlayerState->setPlaying(TRUE); | 505 | mediaPlayerState->setPlaying(TRUE); |
506 | d->selectedFiles->unSelect(); | 506 | d->selectedFiles->unSelect(); |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | void PlayListWidget::addToSelection( QListViewItem *it) { | 510 | void PlayListWidget::addToSelection( QListViewItem *it) { |
511 | d->setDocumentUsed = FALSE; | 511 | d->setDocumentUsed = FALSE; |
512 | 512 | ||
513 | if(it) { | 513 | if(it) { |
514 | switch ( whichList()) { | 514 | switch ( whichList()) { |
515 | case 1: { | 515 | case 1: { |
516 | QListIterator<DocLnk> dit( files.children() ); | 516 | QListIterator<DocLnk> dit( files.children() ); |
517 | for ( ; dit.current(); ++dit ) { | 517 | for ( ; dit.current(); ++dit ) { |
518 | if( dit.current()->name() == it->text(0)) { | 518 | if( dit.current()->name() == it->text(0)) { |
519 | if(QFileInfo( dit.current()->file()).exists()) | 519 | if(QFileInfo( dit.current()->file()).exists()) { |
520 | d->selectedFiles->addToSelection( **dit ); | 520 | d->selectedFiles->addToSelection( **dit ); |
521 | qDebug("blah "+ dit.current()->name()); | ||
522 | d->selectedFiles->setSelectedItem( dit.current()->name()); | ||
523 | } | ||
521 | } | 524 | } |
522 | } | 525 | } |
523 | writeCurrentM3u(); | 526 | writeCurrentM3u(); |
524 | } | 527 | } |
525 | break; | 528 | break; |
526 | case 2: { | 529 | case 2: { |
527 | QListIterator<DocLnk> dit( vFiles.children() ); | 530 | QListIterator<DocLnk> dit( vFiles.children() ); |
528 | for ( ; dit.current(); ++dit ) { | 531 | for ( ; dit.current(); ++dit ) { |
529 | if( dit.current()->name() == it->text(0)) { | 532 | if( dit.current()->name() == it->text(0)) { |
530 | if( QFileInfo( dit.current()->file()).exists() ) | 533 | if( QFileInfo( dit.current()->file()).exists() ) { |
531 | d->selectedFiles->addToSelection( **dit ); | 534 | d->selectedFiles->addToSelection( **dit ); |
535 | qDebug("blah "+ dit.current()->name()); | ||
536 | d->selectedFiles->setSelectedItem( dit.current()->name()); | ||
537 | } | ||
532 | } | 538 | } |
533 | } | 539 | } |
534 | writeCurrentM3u(); | 540 | writeCurrentM3u(); |
535 | 541 | ||
536 | } | 542 | } |
537 | break; | 543 | break; |
538 | case 0: | 544 | case 0: |
539 | break; | 545 | break; |
540 | }; | 546 | }; |
541 | tabWidget->setCurrentPage(0); | 547 | tabWidget->setCurrentPage(0); |
548 | |||
542 | } | 549 | } |
543 | } | 550 | } |
544 | 551 | ||
545 | 552 | ||
546 | void PlayListWidget::tabChanged(QWidget *) { | 553 | void PlayListWidget::tabChanged(QWidget *) { |
547 | 554 | ||
548 | switch ( whichList()) { | 555 | switch ( whichList()) { |
549 | case 0: | 556 | case 0: |
550 | { | 557 | { |
551 | if( !tbDeletePlaylist->isHidden() ) { | 558 | if( !tbDeletePlaylist->isHidden() ) { |
552 | tbDeletePlaylist->hide(); | 559 | tbDeletePlaylist->hide(); |
553 | } | 560 | } |
554 | d->tbRemoveFromList->setEnabled(TRUE); | 561 | d->tbRemoveFromList->setEnabled(TRUE); |
555 | d->tbAddToList->setEnabled(FALSE); | 562 | d->tbAddToList->setEnabled(FALSE); |
556 | } | 563 | } |
557 | break; | 564 | break; |
558 | case 1: | 565 | case 1: |
559 | { | 566 | { |
560 | audioView->clear(); | 567 | audioView->clear(); |
561 | populateAudioView(); | 568 | populateAudioView(); |
562 | 569 | ||
563 | if( !tbDeletePlaylist->isHidden() ) { | 570 | if( !tbDeletePlaylist->isHidden() ) { |
564 | tbDeletePlaylist->hide(); | 571 | tbDeletePlaylist->hide(); |
565 | } | 572 | } |
566 | d->tbRemoveFromList->setEnabled(FALSE); | 573 | d->tbRemoveFromList->setEnabled(FALSE); |
567 | d->tbAddToList->setEnabled(TRUE); | 574 | d->tbAddToList->setEnabled(TRUE); |
568 | } | 575 | } |
569 | break; | 576 | break; |
570 | case 2: | 577 | case 2: |
571 | { | 578 | { |
572 | videoView->clear(); | 579 | videoView->clear(); |
573 | populateVideoView(); | 580 | populateVideoView(); |
574 | if( !tbDeletePlaylist->isHidden() ) { | 581 | if( !tbDeletePlaylist->isHidden() ) { |
575 | tbDeletePlaylist->hide(); | 582 | tbDeletePlaylist->hide(); |
576 | } | 583 | } |
577 | d->tbRemoveFromList->setEnabled(FALSE); | 584 | d->tbRemoveFromList->setEnabled(FALSE); |
578 | d->tbAddToList->setEnabled(TRUE); | 585 | d->tbAddToList->setEnabled(TRUE); |
579 | } | 586 | } |
580 | break; | 587 | break; |
581 | case 3: | 588 | case 3: |
582 | { | 589 | { |
583 | if( tbDeletePlaylist->isHidden() ) { | 590 | if( tbDeletePlaylist->isHidden() ) { |
584 | tbDeletePlaylist->show(); | 591 | tbDeletePlaylist->show(); |
585 | } | 592 | } |
586 | playLists->reread(); | 593 | playLists->reread(); |
587 | } | 594 | } |
588 | break; | 595 | break; |
589 | }; | 596 | }; |
590 | } | 597 | } |
591 | 598 | ||
592 | 599 | ||
593 | void PlayListWidget::btnPlay(bool b) { | 600 | void PlayListWidget::btnPlay(bool b) { |
594 | // mediaPlayerState->setPlaying(false); | 601 | // mediaPlayerState->setPlaying(false); |
595 | mediaPlayerState->setPlaying(b); | 602 | mediaPlayerState->setPlaying(b); |
596 | insanityBool=FALSE; | 603 | insanityBool=FALSE; |
597 | } | 604 | } |
598 | 605 | ||
599 | void PlayListWidget::deletePlaylist() { | 606 | void PlayListWidget::deletePlaylist() { |
600 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 607 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
601 | (tr("You really want to delete\nthis playlist?")), | 608 | (tr("You really want to delete\nthis playlist?")), |
602 | (tr("Yes")), (tr("No")), 0 )){ | 609 | (tr("Yes")), (tr("No")), 0 )){ |
603 | case 0: // Yes clicked, | 610 | case 0: // Yes clicked, |
604 | QFile().remove(playLists->selectedDocument().file()); | 611 | QFile().remove(playLists->selectedDocument().file()); |
605 | QFile().remove(playLists->selectedDocument().linkFile()); | 612 | QFile().remove(playLists->selectedDocument().linkFile()); |
@@ -684,139 +691,141 @@ void PlayListWidget::populateVideoView() { | |||
684 | if(!videoScan ) { | 691 | if(!videoScan ) { |
685 | scanForVideo(); | 692 | scanForVideo(); |
686 | } | 693 | } |
687 | 694 | ||
688 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 695 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
689 | QListIterator<FileSystem> it ( fs ); | 696 | QListIterator<FileSystem> it ( fs ); |
690 | videoView->clear(); | 697 | videoView->clear(); |
691 | QString storage, pathName; | 698 | QString storage, pathName; |
692 | for ( ; Vdit.current(); ++Vdit ) { | 699 | for ( ; Vdit.current(); ++Vdit ) { |
693 | for( ; it.current(); ++it ) { | 700 | for( ; it.current(); ++it ) { |
694 | const QString name = (*it)->name(); | 701 | const QString name = (*it)->name(); |
695 | const QString path = (*it)->path(); | 702 | const QString path = (*it)->path(); |
696 | if( Vdit.current()->file().find(path) != -1 ) { | 703 | if( Vdit.current()->file().find(path) != -1 ) { |
697 | storage=name; | 704 | storage=name; |
698 | pathName=path; | 705 | pathName=path; |
699 | } | 706 | } |
700 | } | 707 | } |
701 | 708 | ||
702 | QListViewItem * newItem; | 709 | QListViewItem * newItem; |
703 | if ( QFile( Vdit.current()->file() ).exists() ) { | 710 | if ( QFile( Vdit.current()->file() ).exists() ) { |
704 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 711 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
705 | QString::number( QFile( Vdit.current()->file() ).size() ), | 712 | QString::number( QFile( Vdit.current()->file() ).size() ), |
706 | storage, Vdit.current()->file()); | 713 | storage, Vdit.current()->file()); |
707 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 714 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
708 | } | 715 | } |
709 | } | 716 | } |
710 | } | 717 | } |
711 | 718 | ||
712 | 719 | ||
713 | void PlayListWidget::openFile() { | 720 | void PlayListWidget::openFile() { |
714 | // http://66.28.164.33:2080 | 721 | // http://66.28.164.33:2080 |
715 | // http://somafm.com/star0242.m3u | 722 | // http://somafm.com/star0242.m3u |
716 | QString filename, name; | 723 | QString filename, name; |
717 | InputDialog *fileDlg; | 724 | InputDialog *fileDlg; |
718 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 725 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
719 | fileDlg->exec(); | 726 | fileDlg->exec(); |
720 | if( fileDlg->result() == 1 ) { | 727 | if( fileDlg->result() == 1 ) { |
721 | filename = fileDlg->text(); | 728 | filename = fileDlg->text(); |
722 | qDebug( "Selected filename is " + filename ); | 729 | qDebug( "Selected filename is " + filename ); |
723 | Om3u *m3uList; | 730 | Om3u *m3uList; |
724 | DocLnk lnk; | 731 | DocLnk lnk; |
725 | Config cfg( "OpiePlayer" ); | 732 | Config cfg( "OpiePlayer" ); |
726 | cfg.setGroup("PlayList"); | 733 | cfg.setGroup("PlayList"); |
727 | 734 | ||
728 | if(filename.left(4) == "http") { | 735 | if(filename.left(4) == "http") { |
729 | QString m3uFile, m3uFilePath; | 736 | QString m3uFile, m3uFilePath; |
730 | if(filename.find(":",8,TRUE) != -1) { //found a port | 737 | if(filename.find(":",8,TRUE) != -1) { //found a port |
731 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 738 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
732 | m3uFile = m3uFile.right( 7); | 739 | m3uFile = m3uFile.right( 7); |
733 | } else if(filename.left(4) == "http"){ | 740 | } else if(filename.left(4) == "http"){ |
734 | m3uFile=filename; | 741 | m3uFile=filename; |
735 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 742 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
736 | } else{ | 743 | } else{ |
737 | m3uFile=filename; | 744 | m3uFile=filename; |
738 | } | 745 | } |
739 | 746 | ||
740 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 747 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
741 | lnk.setName( filename ); //sets name | 748 | lnk.setName( filename ); //sets name |
742 | lnk.setFile( filename ); //sets file name | 749 | lnk.setFile( filename ); //sets file name |
743 | 750 | ||
744 | // lnk.setIcon("opieplayer2/musicfile"); | 751 | // lnk.setIcon("opieplayer2/musicfile"); |
745 | 752 | ||
746 | d->selectedFiles->addToSelection( lnk ); | 753 | d->selectedFiles->addToSelection( lnk ); |
747 | writeCurrentM3u(); | 754 | writeCurrentM3u(); |
755 | d->selectedFiles->setSelectedItem( lnk->name()); | ||
748 | } | 756 | } |
749 | else if( filename.right( 3) == "m3u" ) { | 757 | else if( filename.right( 3) == "m3u" ) { |
750 | readm3u( filename ); | 758 | readm3u( filename ); |
751 | 759 | ||
752 | } else if( filename.right(3) == "pls" ) { | 760 | } else if( filename.right(3) == "pls" ) { |
753 | readPls( filename ); | 761 | readPls( filename ); |
754 | } else { | 762 | } else { |
755 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 763 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
756 | lnk.setFile( filename ); //sets file name | 764 | lnk.setFile( filename ); //sets file name |
757 | d->selectedFiles->addToSelection( lnk); | 765 | d->selectedFiles->addToSelection( lnk); |
758 | writeCurrentM3u(); | 766 | writeCurrentM3u(); |
767 | d->selectedFiles->setSelectedItem( lnk.name()); | ||
759 | } | 768 | } |
760 | } | 769 | } |
761 | 770 | ||
762 | if( fileDlg ) { | 771 | if( fileDlg ) { |
763 | delete fileDlg; | 772 | delete fileDlg; |
764 | } | 773 | } |
765 | } | 774 | } |
766 | 775 | ||
767 | /* | 776 | /* |
768 | reads m3u and shows files/urls to playlist widget */ | 777 | reads m3u and shows files/urls to playlist widget */ |
769 | void PlayListWidget::readm3u( const QString &filename ) { | 778 | void PlayListWidget::readm3u( const QString &filename ) { |
770 | qDebug( "read m3u filename " + filename ); | 779 | qDebug( "read m3u filename " + filename ); |
771 | 780 | ||
772 | Om3u *m3uList; | 781 | Om3u *m3uList; |
773 | QString s, name; | 782 | QString s, name; |
774 | m3uList = new Om3u( filename, IO_ReadOnly ); | 783 | m3uList = new Om3u( filename, IO_ReadOnly ); |
775 | m3uList->readM3u(); | 784 | m3uList->readM3u(); |
776 | DocLnk lnk; | 785 | DocLnk lnk; |
777 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 786 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
778 | s = *it; | 787 | s = *it; |
779 | // qDebug("reading "+ s); | 788 | // qDebug("reading "+ s); |
780 | if(s.left(4)=="http") { | 789 | if(s.left(4)=="http") { |
781 | lnk.setName( s ); //sets file name | 790 | lnk.setName( s ); //sets file name |
782 | lnk.setIcon("opieplayer2/musicfile"); | 791 | lnk.setIcon("opieplayer2/musicfile"); |
783 | // if(s.right(4) != '.' || s.right(5) != '.') | 792 | // if(s.right(4) != '.' || s.right(5) != '.') |
784 | // lnk.setFile( s+"/"); //if url with no extension | 793 | // lnk.setFile( s+"/"); //if url with no extension |
785 | // else | 794 | // else |
786 | lnk.setFile( s ); //sets file name | 795 | lnk.setFile( s ); //sets file name |
787 | 796 | ||
788 | } else { | 797 | } else { |
789 | // if( QFileInfo( s ).exists() ) { | 798 | // if( QFileInfo( s ).exists() ) { |
790 | lnk.setName( QFileInfo(s).baseName()); | 799 | lnk.setName( QFileInfo(s).baseName()); |
791 | // if(s.right(4) == '.') {//if regular file | 800 | // if(s.right(4) == '.') {//if regular file |
792 | if(s.left(1) != "/") { | 801 | if(s.left(1) != "/") { |
793 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 802 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
794 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 803 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
795 | // lnk.setIcon(MimeType(s).pixmap() ); | 804 | // lnk.setIcon(MimeType(s).pixmap() ); |
796 | // lnk.setIcon("SoundPlayer"); | 805 | // lnk.setIcon("SoundPlayer"); |
797 | } else { | 806 | } else { |
798 | // qDebug("set link2 "+s); | 807 | // qDebug("set link2 "+s); |
799 | lnk.setFile( s); | 808 | lnk.setFile( s); |
800 | // lnk.setIcon(MimeType(s).pixmap() ); | 809 | // lnk.setIcon(MimeType(s).pixmap() ); |
801 | // lnk.setIcon("SoundPlayer"); | 810 | // lnk.setIcon("SoundPlayer"); |
802 | } | 811 | } |
803 | } | 812 | } |
804 | d->selectedFiles->addToSelection( lnk ); | 813 | d->selectedFiles->addToSelection( lnk ); |
805 | } | 814 | } |
806 | Config config( "OpiePlayer" ); | 815 | Config config( "OpiePlayer" ); |
807 | config.setGroup( "PlayList" ); | 816 | config.setGroup( "PlayList" ); |
808 | 817 | ||
809 | config.writeEntry("CurrentPlaylist",filename); | 818 | config.writeEntry("CurrentPlaylist",filename); |
810 | config.write(); | 819 | config.write(); |
811 | currentPlayList=filename; | 820 | currentPlayList=filename; |
812 | 821 | ||
813 | // m3uList->write(); | 822 | // m3uList->write(); |
814 | m3uList->close(); | 823 | m3uList->close(); |
815 | if(m3uList) delete m3uList; | 824 | if(m3uList) delete m3uList; |
816 | 825 | ||
817 | d->selectedFiles->setSelectedItem( s); | 826 | d->selectedFiles->setSelectedItem( s); |
818 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 827 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
819 | 828 | ||
820 | } | 829 | } |
821 | 830 | ||
822 | /* | 831 | /* |
@@ -825,128 +834,129 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
825 | 834 | ||
826 | qDebug( "pls filename is " + filename ); | 835 | qDebug( "pls filename is " + filename ); |
827 | Om3u *m3uList; | 836 | Om3u *m3uList; |
828 | QString s, name; | 837 | QString s, name; |
829 | m3uList = new Om3u( filename, IO_ReadOnly ); | 838 | m3uList = new Om3u( filename, IO_ReadOnly ); |
830 | m3uList->readPls(); | 839 | m3uList->readPls(); |
831 | 840 | ||
832 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 841 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
833 | s = *it; | 842 | s = *it; |
834 | // s.replace( QRegExp( "%20" )," " ); | 843 | // s.replace( QRegExp( "%20" )," " ); |
835 | DocLnk lnk( s ); | 844 | DocLnk lnk( s ); |
836 | QFileInfo f( s ); | 845 | QFileInfo f( s ); |
837 | QString name = f.baseName(); | 846 | QString name = f.baseName(); |
838 | 847 | ||
839 | if( name.left( 4 ) == "http" ) { | 848 | if( name.left( 4 ) == "http" ) { |
840 | name = s.right( s.length() - 7); | 849 | name = s.right( s.length() - 7); |
841 | } else { | 850 | } else { |
842 | name = s; | 851 | name = s; |
843 | } | 852 | } |
844 | 853 | ||
845 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 854 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
846 | 855 | ||
847 | lnk.setName( name ); | 856 | lnk.setName( name ); |
848 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 857 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
849 | lnk.setFile( s ); | 858 | lnk.setFile( s ); |
850 | } else { //if its a url | 859 | } else { //if its a url |
851 | // if( name.right( 1 ).find( '/' ) == -1) { | 860 | // if( name.right( 1 ).find( '/' ) == -1) { |
852 | // s += "/"; | 861 | // s += "/"; |
853 | // } | 862 | // } |
854 | lnk.setFile( s ); | 863 | lnk.setFile( s ); |
855 | } | 864 | } |
856 | lnk.setType( "audio/x-mpegurl" ); | 865 | lnk.setType( "audio/x-mpegurl" ); |
857 | 866 | ||
858 | lnk.writeLink(); | 867 | lnk.writeLink(); |
859 | d->selectedFiles->addToSelection( lnk ); | 868 | d->selectedFiles->addToSelection( lnk ); |
860 | } | 869 | } |
861 | 870 | ||
862 | m3uList->close(); | 871 | m3uList->close(); |
863 | if(m3uList) delete m3uList; | 872 | if(m3uList) delete m3uList; |
864 | } | 873 | } |
865 | 874 | ||
866 | /* | 875 | /* |
867 | writes current playlist to current m3u file */ | 876 | writes current playlist to current m3u file */ |
868 | void PlayListWidget::writeCurrentM3u() { | 877 | void PlayListWidget::writeCurrentM3u() { |
869 | qDebug("writing to current m3u"); | 878 | qDebug("writing to current m3u"); |
870 | Config cfg( "OpiePlayer" ); | 879 | Config cfg( "OpiePlayer" ); |
871 | cfg.setGroup("PlayList"); | 880 | cfg.setGroup("PlayList"); |
872 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 881 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
873 | 882 | ||
874 | Om3u *m3uList; | 883 | Om3u *m3uList; |
875 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 884 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
876 | if( d->selectedFiles->first()) { | 885 | if( d->selectedFiles->first()) { |
877 | 886 | ||
878 | do { | 887 | do { |
879 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 888 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
880 | m3uList->add( d->selectedFiles->current()->file() ); | 889 | m3uList->add( d->selectedFiles->current()->file() ); |
881 | } | 890 | } |
882 | while ( d->selectedFiles->next() ); | 891 | while ( d->selectedFiles->next() ); |
883 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 892 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
884 | m3uList->write(); | 893 | m3uList->write(); |
885 | m3uList->close(); | 894 | m3uList->close(); |
886 | 895 | ||
887 | if(m3uList) delete m3uList; | 896 | if(m3uList) delete m3uList; |
888 | } | 897 | } |
898 | |||
889 | } | 899 | } |
890 | 900 | ||
891 | /* | 901 | /* |
892 | writes current playlist to m3u file */ | 902 | writes current playlist to m3u file */ |
893 | void PlayListWidget::writem3u() { | 903 | void PlayListWidget::writem3u() { |
894 | InputDialog *fileDlg; | 904 | InputDialog *fileDlg; |
895 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 905 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
896 | fileDlg->exec(); | 906 | fileDlg->exec(); |
897 | QString name, filename, list; | 907 | QString name, filename, list; |
898 | Om3u *m3uList; | 908 | Om3u *m3uList; |
899 | 909 | ||
900 | if( fileDlg->result() == 1 ) { | 910 | if( fileDlg->result() == 1 ) { |
901 | name = fileDlg->text(); | 911 | name = fileDlg->text(); |
902 | // qDebug( filename ); | 912 | // qDebug( filename ); |
903 | 913 | ||
904 | if( name.left( 1) != "/" ) { | 914 | if( name.left( 1) != "/" ) { |
905 | filename = QPEApplication::documentDir() + "/" + name; | 915 | filename = QPEApplication::documentDir() + "/" + name; |
906 | } | 916 | } |
907 | 917 | ||
908 | if( name.right( 3 ) != "m3u" ) { | 918 | if( name.right( 3 ) != "m3u" ) { |
909 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 919 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
910 | } | 920 | } |
911 | 921 | ||
912 | if( d->selectedFiles->first()) { | 922 | if( d->selectedFiles->first()) { |
913 | m3uList = new Om3u(filename, IO_ReadWrite); | 923 | m3uList = new Om3u(filename, IO_ReadWrite); |
914 | 924 | ||
915 | do { | 925 | do { |
916 | m3uList->add( d->selectedFiles->current()->file()); | 926 | m3uList->add( d->selectedFiles->current()->file()); |
917 | } | 927 | } |
918 | while ( d->selectedFiles->next() ); | 928 | while ( d->selectedFiles->next() ); |
919 | // qDebug( list ); | 929 | // qDebug( list ); |
920 | m3uList->write(); | 930 | m3uList->write(); |
921 | m3uList->close(); | 931 | m3uList->close(); |
922 | if(m3uList) delete m3uList; | 932 | if(m3uList) delete m3uList; |
923 | 933 | ||
924 | if(fileDlg) delete fileDlg; | 934 | if(fileDlg) delete fileDlg; |
925 | 935 | ||
926 | DocLnk lnk; | 936 | DocLnk lnk; |
927 | lnk.setFile( filename); | 937 | lnk.setFile( filename); |
928 | // lnk.setIcon("opieplayer2/playlist2"); | 938 | // lnk.setIcon("opieplayer2/playlist2"); |
929 | lnk.setName( name); //sets file name | 939 | lnk.setName( name); //sets file name |
930 | 940 | ||
931 | // qDebug(filename); | 941 | // qDebug(filename); |
932 | Config config( "OpiePlayer" ); | 942 | Config config( "OpiePlayer" ); |
933 | config.setGroup( "PlayList" ); | 943 | config.setGroup( "PlayList" ); |
934 | 944 | ||
935 | config.writeEntry("CurrentPlaylist",filename); | 945 | config.writeEntry("CurrentPlaylist",filename); |
936 | currentPlayList=filename; | 946 | currentPlayList=filename; |
937 | 947 | ||
938 | if(!lnk.writeLink()) { | 948 | if(!lnk.writeLink()) { |
939 | qDebug("Writing doclink did not work"); | 949 | qDebug("Writing doclink did not work"); |
940 | } | 950 | } |
941 | 951 | ||
942 | setCaption(tr("OpiePlayer: ") + name); | 952 | setCaption(tr("OpiePlayer: ") + name); |
943 | } | 953 | } |
944 | } | 954 | } |
945 | } | 955 | } |
946 | 956 | ||
947 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 957 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
948 | switch ( e->key() ) { | 958 | switch ( e->key() ) { |
949 | ////////////////////////////// Zaurus keys | 959 | ////////////////////////////// Zaurus keys |
950 | case Key_F9: //activity | 960 | case Key_F9: //activity |
951 | // if(audioUI->isHidden()) | 961 | // if(audioUI->isHidden()) |
952 | // audioUI->showMaximized(); | 962 | // audioUI->showMaximized(); |