-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 9373f6b..cd53748 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -446,772 +446,767 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
446 | { | 446 | { |
447 | qDebug("playlist"); | 447 | qDebug("playlist"); |
448 | if ( mediaPlayerState->playlist() ) { | 448 | if ( mediaPlayerState->playlist() ) { |
449 | return d->selectedFiles->current(); | 449 | return d->selectedFiles->current(); |
450 | } else if ( d->setDocumentUsed && d->current ) { | 450 | } else if ( d->setDocumentUsed && d->current ) { |
451 | return d->current; | 451 | return d->current; |
452 | } else { | 452 | } else { |
453 | return d->files->selected(); | 453 | return d->files->selected(); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | break; | 456 | break; |
457 | case 1://audio | 457 | case 1://audio |
458 | { | 458 | { |
459 | qDebug("audioView"); | 459 | qDebug("audioView"); |
460 | QListIterator<DocLnk> dit( files.children() ); | 460 | QListIterator<DocLnk> dit( files.children() ); |
461 | for ( ; dit.current(); ++dit ) { | 461 | for ( ; dit.current(); ++dit ) { |
462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
463 | qDebug("here"); | 463 | qDebug("here"); |
464 | insanityBool=TRUE; | 464 | insanityBool=TRUE; |
465 | return dit; | 465 | return dit; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | } | 468 | } |
469 | break; | 469 | break; |
470 | case 2: // video | 470 | case 2: // video |
471 | { | 471 | { |
472 | qDebug("videoView"); | 472 | qDebug("videoView"); |
473 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 473 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
474 | for ( ; Vdit.current(); ++Vdit ) { | 474 | for ( ; Vdit.current(); ++Vdit ) { |
475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
476 | insanityBool=TRUE; | 476 | insanityBool=TRUE; |
477 | return Vdit; | 477 | return Vdit; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | break; | 481 | break; |
482 | }; | 482 | }; |
483 | return 0; | 483 | return 0; |
484 | } | 484 | } |
485 | 485 | ||
486 | bool PlayListWidget::prev() { | 486 | bool PlayListWidget::prev() { |
487 | if ( mediaPlayerState->playlist() ) { | 487 | if ( mediaPlayerState->playlist() ) { |
488 | if ( mediaPlayerState->shuffled() ) { | 488 | if ( mediaPlayerState->shuffled() ) { |
489 | const DocLnk *cur = current(); | 489 | const DocLnk *cur = current(); |
490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
491 | for ( int i = 0; i < j; i++ ) { | 491 | for ( int i = 0; i < j; i++ ) { |
492 | if ( !d->selectedFiles->next() ) | 492 | if ( !d->selectedFiles->next() ) |
493 | d->selectedFiles->first(); | 493 | d->selectedFiles->first(); |
494 | } | 494 | } |
495 | if ( cur == current() ) | 495 | if ( cur == current() ) |
496 | if ( !d->selectedFiles->next() ) | 496 | if ( !d->selectedFiles->next() ) |
497 | d->selectedFiles->first(); | 497 | d->selectedFiles->first(); |
498 | return TRUE; | 498 | return TRUE; |
499 | } else { | 499 | } else { |
500 | if ( !d->selectedFiles->prev() ) { | 500 | if ( !d->selectedFiles->prev() ) { |
501 | if ( mediaPlayerState->looping() ) { | 501 | if ( mediaPlayerState->looping() ) { |
502 | return d->selectedFiles->last(); | 502 | return d->selectedFiles->last(); |
503 | } else { | 503 | } else { |
504 | return FALSE; | 504 | return FALSE; |
505 | } | 505 | } |
506 | } | 506 | } |
507 | return TRUE; | 507 | return TRUE; |
508 | } | 508 | } |
509 | } else { | 509 | } else { |
510 | return mediaPlayerState->looping(); | 510 | return mediaPlayerState->looping(); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
515 | bool PlayListWidget::next() { | 515 | bool PlayListWidget::next() { |
516 | if ( mediaPlayerState->playlist() ) { | 516 | if ( mediaPlayerState->playlist() ) { |
517 | if ( mediaPlayerState->shuffled() ) { | 517 | if ( mediaPlayerState->shuffled() ) { |
518 | return prev(); | 518 | return prev(); |
519 | } else { | 519 | } else { |
520 | if ( !d->selectedFiles->next() ) { | 520 | if ( !d->selectedFiles->next() ) { |
521 | if ( mediaPlayerState->looping() ) { | 521 | if ( mediaPlayerState->looping() ) { |
522 | return d->selectedFiles->first(); | 522 | return d->selectedFiles->first(); |
523 | } else { | 523 | } else { |
524 | return FALSE; | 524 | return FALSE; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | return TRUE; | 527 | return TRUE; |
528 | } | 528 | } |
529 | } else { | 529 | } else { |
530 | return mediaPlayerState->looping(); | 530 | return mediaPlayerState->looping(); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | bool PlayListWidget::first() { | 535 | bool PlayListWidget::first() { |
536 | if ( mediaPlayerState->playlist() ) | 536 | if ( mediaPlayerState->playlist() ) |
537 | return d->selectedFiles->first(); | 537 | return d->selectedFiles->first(); |
538 | else | 538 | else |
539 | return mediaPlayerState->looping(); | 539 | return mediaPlayerState->looping(); |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | bool PlayListWidget::last() { | 543 | bool PlayListWidget::last() { |
544 | if ( mediaPlayerState->playlist() ) | 544 | if ( mediaPlayerState->playlist() ) |
545 | return d->selectedFiles->last(); | 545 | return d->selectedFiles->last(); |
546 | else | 546 | else |
547 | return mediaPlayerState->looping(); | 547 | return mediaPlayerState->looping(); |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | void PlayListWidget::saveList() { | 551 | void PlayListWidget::saveList() { |
552 | 552 | ||
553 | QString filename; | 553 | QString filename; |
554 | InputDialog *fileDlg; | 554 | InputDialog *fileDlg; |
555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
556 | fileDlg->exec(); | 556 | fileDlg->exec(); |
557 | if( fileDlg->result() == 1 ) { | 557 | if( fileDlg->result() == 1 ) { |
558 | if ( d->current ) | 558 | if ( d->current ) |
559 | delete d->current; | 559 | delete d->current; |
560 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 560 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
561 | // qDebug("saving playlist "+filename+".playlist"); | 561 | // qDebug("saving playlist "+filename+".playlist"); |
562 | Config cfg( filename +".playlist"); | 562 | Config cfg( filename +".playlist"); |
563 | writeConfig( cfg ); | 563 | writeConfig( cfg ); |
564 | 564 | ||
565 | DocLnk lnk; | 565 | DocLnk lnk; |
566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
568 | lnk.setIcon("opieplayer/playlist2"); | 568 | lnk.setIcon("opieplayer/playlist2"); |
569 | lnk.setName( filename); //sets file name | 569 | lnk.setName( filename); //sets file name |
570 | // qDebug(filename); | 570 | // qDebug(filename); |
571 | if(!lnk.writeLink()) { | 571 | if(!lnk.writeLink()) { |
572 | qDebug("Writing doclink did not work"); | 572 | qDebug("Writing doclink did not work"); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | Config config( "OpiePlayer" ); | 575 | Config config( "OpiePlayer" ); |
576 | config.writeEntry("CurrentPlaylist",filename); | 576 | config.writeEntry("CurrentPlaylist",filename); |
577 | setCaption(tr("OpiePlayer: ")+filename); | 577 | setCaption(tr("OpiePlayer: ")+filename); |
578 | d->selectedFiles->first(); | 578 | d->selectedFiles->first(); |
579 | if(fileDlg) { | 579 | if(fileDlg) { |
580 | delete fileDlg; | 580 | delete fileDlg; |
581 | } | 581 | } |
582 | } | 582 | } |
583 | 583 | ||
584 | void PlayListWidget::loadList( const DocLnk & lnk) { | 584 | void PlayListWidget::loadList( const DocLnk & lnk) { |
585 | QString name= lnk.name(); | 585 | QString name= lnk.name(); |
586 | // qDebug("currentList is "+name); | 586 | // qDebug("currentList is "+name); |
587 | if( name.length()>1) { | 587 | if( name.length()>1) { |
588 | setCaption("OpiePlayer: "+name); | 588 | setCaption("OpiePlayer: "+name); |
589 | // qDebug("load list "+ name+".playlist"); | 589 | // qDebug("load list "+ name+".playlist"); |
590 | clearList(); | 590 | clearList(); |
591 | Config cfg( name+".playlist"); | 591 | Config cfg( name+".playlist"); |
592 | readConfig(cfg); | 592 | readConfig(cfg); |
593 | 593 | ||
594 | tabWidget->setCurrentPage(0); | 594 | tabWidget->setCurrentPage(0); |
595 | 595 | ||
596 | Config config( "OpiePlayer" ); | 596 | Config config( "OpiePlayer" ); |
597 | config.writeEntry("CurrentPlaylist", name); | 597 | config.writeEntry("CurrentPlaylist", name); |
598 | // d->selectedFiles->first(); | 598 | // d->selectedFiles->first(); |
599 | } | 599 | } |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void PlayListWidget::setPlaylist( bool shown ) { | 603 | void PlayListWidget::setPlaylist( bool shown ) { |
604 | if ( shown ) { | 604 | if ( shown ) { |
605 | d->playListFrame->show(); | 605 | d->playListFrame->show(); |
606 | } else { | 606 | } else { |
607 | d->playListFrame->hide(); | 607 | d->playListFrame->hide(); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | 610 | ||
611 | void PlayListWidget::setView( char view ) { | 611 | void PlayListWidget::setView( char view ) { |
612 | if ( view == 'l' ) | 612 | if ( view == 'l' ) |
613 | showMaximized(); | 613 | showMaximized(); |
614 | else | 614 | else |
615 | hide(); | 615 | hide(); |
616 | } | 616 | } |
617 | 617 | ||
618 | void PlayListWidget::addSelected() { | 618 | void PlayListWidget::addSelected() { |
619 | 619 | ||
620 | Config cfg( "OpiePlayer" ); | 620 | Config cfg( "OpiePlayer" ); |
621 | cfg.setGroup("PlayList"); | 621 | cfg.setGroup("PlayList"); |
622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
624 | 624 | ||
625 | switch (tabWidget->currentPageIndex()) { | 625 | switch (tabWidget->currentPageIndex()) { |
626 | case 0: //playlist | 626 | case 0: //playlist |
627 | break; | 627 | break; |
628 | case 1: { //audio | 628 | case 1: { //audio |
629 | QListViewItemIterator it( audioView ); | 629 | QListViewItemIterator it( audioView ); |
630 | // iterate through all items of the listview | 630 | // iterate through all items of the listview |
631 | for ( ; it.current(); ++it ) { | 631 | for ( ; it.current(); ++it ) { |
632 | if ( it.current()->isSelected() ) { | 632 | if ( it.current()->isSelected() ) { |
633 | QListIterator<DocLnk> dit( files.children() ); | 633 | QListIterator<DocLnk> dit( files.children() ); |
634 | for ( ; dit.current(); ++dit ) { | 634 | for ( ; dit.current(); ++dit ) { |
635 | if( dit.current()->name() == it.current()->text(0) ) { | 635 | if( dit.current()->name() == it.current()->text(0) ) { |
636 | d->selectedFiles->addToSelection( **dit ); | 636 | d->selectedFiles->addToSelection( **dit ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | audioView->setSelected( it.current(),FALSE); | 639 | audioView->setSelected( it.current(),FALSE); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | tabWidget->setCurrentPage(0); | 642 | tabWidget->setCurrentPage(0); |
643 | } | 643 | } |
644 | break; | 644 | break; |
645 | case 2: { // video | 645 | case 2: { // video |
646 | QListViewItemIterator it( videoView ); | 646 | QListViewItemIterator it( videoView ); |
647 | // iterate through all items of the listview | 647 | // iterate through all items of the listview |
648 | for ( ; it.current(); ++it ) { | 648 | for ( ; it.current(); ++it ) { |
649 | if ( it.current()->isSelected() ) { | 649 | if ( it.current()->isSelected() ) { |
650 | QListIterator<DocLnk> dit( vFiles.children() ); | 650 | QListIterator<DocLnk> dit( vFiles.children() ); |
651 | for ( ; dit.current(); ++dit ) { | 651 | for ( ; dit.current(); ++dit ) { |
652 | if( dit.current()->name() == it.current()->text(0) ) { | 652 | if( dit.current()->name() == it.current()->text(0) ) { |
653 | d->selectedFiles->addToSelection( **dit ); | 653 | d->selectedFiles->addToSelection( **dit ); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | videoView->setSelected( it.current(),FALSE); | 656 | videoView->setSelected( it.current(),FALSE); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | tabWidget->setCurrentPage(0); | 659 | tabWidget->setCurrentPage(0); |
660 | } | 660 | } |
661 | break; | 661 | break; |
662 | }; | 662 | }; |
663 | } | 663 | } |
664 | 664 | ||
665 | void PlayListWidget::removeSelected() { | 665 | void PlayListWidget::removeSelected() { |
666 | d->selectedFiles->removeSelected( ); | 666 | d->selectedFiles->removeSelected( ); |
667 | } | 667 | } |
668 | 668 | ||
669 | void PlayListWidget::playIt( QListViewItem *it) { | 669 | void PlayListWidget::playIt( QListViewItem *it) { |
670 | qDebug("playIt"); | 670 | qDebug("playIt"); |
671 | mediaPlayerState->setPlaying(FALSE); | 671 | mediaPlayerState->setPlaying(FALSE); |
672 | mediaPlayerState->setPlaying(TRUE); | 672 | mediaPlayerState->setPlaying(TRUE); |
673 | d->selectedFiles->unSelect(); | 673 | d->selectedFiles->unSelect(); |
674 | } | 674 | } |
675 | 675 | ||
676 | void PlayListWidget::addToSelection( QListViewItem *it) { | 676 | void PlayListWidget::addToSelection( QListViewItem *it) { |
677 | d->setDocumentUsed = FALSE; | 677 | d->setDocumentUsed = FALSE; |
678 | 678 | ||
679 | if(it) { | 679 | if(it) { |
680 | switch (tabWidget->currentPageIndex()) { | 680 | switch (tabWidget->currentPageIndex()) { |
681 | case 1: { | 681 | case 1: { |
682 | QListIterator<DocLnk> dit( files.children() ); | 682 | QListIterator<DocLnk> dit( files.children() ); |
683 | for ( ; dit.current(); ++dit ) { | 683 | for ( ; dit.current(); ++dit ) { |
684 | if( dit.current()->name() == it->text(0)) { | 684 | if( dit.current()->name() == it->text(0)) { |
685 | d->selectedFiles->addToSelection( **dit ); | 685 | d->selectedFiles->addToSelection( **dit ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | } | 688 | } |
689 | break; | 689 | break; |
690 | case 2: { | 690 | case 2: { |
691 | QListIterator<DocLnk> dit( vFiles.children() ); | 691 | QListIterator<DocLnk> dit( vFiles.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 692 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it->text(0)) { | 693 | if( dit.current()->name() == it->text(0)) { |
694 | d->selectedFiles->addToSelection( **dit ); | 694 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 695 | } |
696 | } | 696 | } |
697 | } | 697 | } |
698 | break; | 698 | break; |
699 | case 0: | 699 | case 0: |
700 | break; | 700 | break; |
701 | }; | 701 | }; |
702 | tabWidget->setCurrentPage(0); | 702 | tabWidget->setCurrentPage(0); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | void PlayListWidget::tabChanged(QWidget *widg) { | 706 | void PlayListWidget::tabChanged(QWidget *widg) { |
707 | 707 | ||
708 | switch ( tabWidget->currentPageIndex()) { | 708 | switch ( tabWidget->currentPageIndex()) { |
709 | case 0: | 709 | case 0: |
710 | { | 710 | { |
711 | if( !tbDeletePlaylist->isHidden()) | 711 | if( !tbDeletePlaylist->isHidden()) |
712 | tbDeletePlaylist->hide(); | 712 | tbDeletePlaylist->hide(); |
713 | d->tbRemoveFromList->setEnabled(TRUE); | 713 | d->tbRemoveFromList->setEnabled(TRUE); |
714 | d->tbAddToList->setEnabled(FALSE); | 714 | d->tbAddToList->setEnabled(FALSE); |
715 | } | 715 | } |
716 | break; | 716 | break; |
717 | case 1: | 717 | case 1: |
718 | { | 718 | { |
719 | audioView->clear(); | 719 | audioView->clear(); |
720 | populateAudioView(); | 720 | populateAudioView(); |
721 | 721 | ||
722 | if( !tbDeletePlaylist->isHidden()) | 722 | if( !tbDeletePlaylist->isHidden()) |
723 | tbDeletePlaylist->hide(); | 723 | tbDeletePlaylist->hide(); |
724 | d->tbRemoveFromList->setEnabled(FALSE); | 724 | d->tbRemoveFromList->setEnabled(FALSE); |
725 | d->tbAddToList->setEnabled(TRUE); | 725 | d->tbAddToList->setEnabled(TRUE); |
726 | } | 726 | } |
727 | break; | 727 | break; |
728 | case 2: | 728 | case 2: |
729 | { | 729 | { |
730 | videoView->clear(); | 730 | videoView->clear(); |
731 | populateVideoView(); | 731 | populateVideoView(); |
732 | if( !tbDeletePlaylist->isHidden()) | 732 | if( !tbDeletePlaylist->isHidden()) |
733 | tbDeletePlaylist->hide(); | 733 | tbDeletePlaylist->hide(); |
734 | d->tbRemoveFromList->setEnabled(FALSE); | 734 | d->tbRemoveFromList->setEnabled(FALSE); |
735 | d->tbAddToList->setEnabled(TRUE); | 735 | d->tbAddToList->setEnabled(TRUE); |
736 | } | 736 | } |
737 | break; | 737 | break; |
738 | case 3: | 738 | case 3: |
739 | { | 739 | { |
740 | if( tbDeletePlaylist->isHidden()) | 740 | if( tbDeletePlaylist->isHidden()) |
741 | tbDeletePlaylist->show(); | 741 | tbDeletePlaylist->show(); |
742 | playLists->reread(); | 742 | playLists->reread(); |
743 | } | 743 | } |
744 | break; | 744 | break; |
745 | }; | 745 | }; |
746 | } | 746 | } |
747 | 747 | ||
748 | void PlayListWidget::btnPlay(bool b) { | 748 | void PlayListWidget::btnPlay(bool b) { |
749 | 749 | ||
750 | // mediaPlayerState->setPlaying(b); | 750 | // mediaPlayerState->setPlaying(b); |
751 | switch ( tabWidget->currentPageIndex()) { | 751 | switch ( tabWidget->currentPageIndex()) { |
752 | case 0: | 752 | case 0: |
753 | { | 753 | { |
754 | mediaPlayerState->setPlaying(b); | 754 | mediaPlayerState->setPlaying(b); |
755 | } | 755 | } |
756 | break; | 756 | break; |
757 | case 1: | 757 | case 1: |
758 | { | 758 | { |
759 | addToSelection( audioView->currentItem() ); | 759 | addToSelection( audioView->currentItem() ); |
760 | mediaPlayerState->setPlaying(b); | 760 | mediaPlayerState->setPlaying(b); |
761 | d->selectedFiles->removeSelected( ); | 761 | d->selectedFiles->removeSelected( ); |
762 | tabWidget->setCurrentPage(1); | 762 | tabWidget->setCurrentPage(1); |
763 | d->selectedFiles->unSelect(); | 763 | d->selectedFiles->unSelect(); |
764 | insanityBool=FALSE; | 764 | insanityBool=FALSE; |
765 | }// audioView->clearSelection(); | 765 | }// audioView->clearSelection(); |
766 | break; | 766 | break; |
767 | case 2: | 767 | case 2: |
768 | { | 768 | { |
769 | addToSelection( videoView->currentItem() ); | 769 | addToSelection( videoView->currentItem() ); |
770 | mediaPlayerState->setPlaying(b); | 770 | mediaPlayerState->setPlaying(b); |
771 | qApp->processEvents(); | 771 | qApp->processEvents(); |
772 | d->selectedFiles->removeSelected( ); | 772 | d->selectedFiles->removeSelected( ); |
773 | tabWidget->setCurrentPage(2); | 773 | tabWidget->setCurrentPage(2); |
774 | d->selectedFiles->unSelect(); | 774 | d->selectedFiles->unSelect(); |
775 | insanityBool=FALSE; | 775 | insanityBool=FALSE; |
776 | }// videoView->clearSelection(); | 776 | }// videoView->clearSelection(); |
777 | break; | 777 | break; |
778 | }; | 778 | }; |
779 | 779 | ||
780 | } | 780 | } |
781 | 781 | ||
782 | void PlayListWidget::deletePlaylist() { | 782 | void PlayListWidget::deletePlaylist() { |
783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
784 | (tr("You really want to delete\nthis playlist?")), | 784 | (tr("You really want to delete\nthis playlist?")), |
785 | (tr("Yes")), (tr("No")), 0 )){ | 785 | (tr("Yes")), (tr("No")), 0 )){ |
786 | case 0: // Yes clicked, | 786 | case 0: // Yes clicked, |
787 | QFile().remove(playLists->selected()->file()); | 787 | QFile().remove(playLists->selected()->file()); |
788 | QFile().remove(playLists->selected()->linkFile()); | 788 | QFile().remove(playLists->selected()->linkFile()); |
789 | playLists->reread(); | 789 | playLists->reread(); |
790 | break; | 790 | break; |
791 | case 1: // Cancel | 791 | case 1: // Cancel |
792 | break; | 792 | break; |
793 | }; | 793 | }; |
794 | } | 794 | } |
795 | 795 | ||
796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
797 | switch (mouse) { | 797 | switch (mouse) { |
798 | case 1: | 798 | case 1: |
799 | break; | 799 | break; |
800 | case 2:{ | 800 | case 2:{ |
801 | QPopupMenu m; | 801 | QPopupMenu m; |
802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
804 | m.insertSeparator(); | 804 | m.insertSeparator(); |
805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
806 | m.exec( QCursor::pos() ); | 806 | m.exec( QCursor::pos() ); |
807 | } | 807 | } |
808 | break; | 808 | break; |
809 | }; | 809 | }; |
810 | } | 810 | } |
811 | 811 | ||
812 | void PlayListWidget::playSelected() { | 812 | void PlayListWidget::playSelected() { |
813 | btnPlay( TRUE); | 813 | btnPlay( TRUE); |
814 | } | 814 | } |
815 | 815 | ||
816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
817 | switch (mouse) { | 817 | switch (mouse) { |
818 | case 1: | 818 | case 1: |
819 | 819 | ||
820 | break; | 820 | break; |
821 | case 2: | 821 | case 2: |
822 | { | 822 | { |
823 | QPopupMenu m; | 823 | QPopupMenu m; |
824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
826 | m.exec( QCursor::pos() ); | 826 | m.exec( QCursor::pos() ); |
827 | } | 827 | } |
828 | break; | 828 | break; |
829 | }; | 829 | }; |
830 | } | 830 | } |
831 | 831 | ||
832 | void PlayListWidget::listDelete() { | 832 | void PlayListWidget::listDelete() { |
833 | Config cfg( "OpiePlayer" ); | 833 | Config cfg( "OpiePlayer" ); |
834 | cfg.setGroup("PlayList"); | 834 | cfg.setGroup("PlayList"); |
835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
836 | QString file; | 836 | QString file; |
837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
838 | switch ( tabWidget->currentPageIndex()) { | 838 | switch ( tabWidget->currentPageIndex()) { |
839 | case 0: | 839 | case 0: |
840 | break; | 840 | break; |
841 | case 1: | 841 | case 1: |
842 | { | 842 | { |
843 | file = audioView->selectedItem()->text(0); | 843 | file = audioView->selectedItem()->text(0); |
844 | QListIterator<DocLnk> dit( files.children() ); | 844 | QListIterator<DocLnk> dit( files.children() ); |
845 | for ( ; dit.current(); ++dit ) { | 845 | for ( ; dit.current(); ++dit ) { |
846 | if( dit.current()->name() == file) { | 846 | if( dit.current()->name() == file) { |
847 | // qDebug(file); | 847 | // qDebug(file); |
848 | LnkProperties prop( dit.current() ); | 848 | LnkProperties prop( dit.current() ); |
849 | prop.showMaximized(); | 849 | prop.showMaximized(); |
850 | prop.exec(); | 850 | prop.exec(); |
851 | } | 851 | } |
852 | } | 852 | } |
853 | populateAudioView(); | 853 | populateAudioView(); |
854 | } | 854 | } |
855 | break; | 855 | break; |
856 | case 2: | 856 | case 2: |
857 | { | 857 | { |
858 | 858 | ||
859 | } | 859 | } |
860 | break; | 860 | break; |
861 | }; | 861 | }; |
862 | } | 862 | } |
863 | 863 | ||
864 | void PlayListWidget::scanForAudio() { | 864 | void PlayListWidget::scanForAudio() { |
865 | qDebug("scan for audio"); | 865 | qDebug("scan for audio"); |
866 | files.detachChildren(); | 866 | files.detachChildren(); |
867 | QListIterator<DocLnk> sdit( files.children() ); | 867 | QListIterator<DocLnk> sdit( files.children() ); |
868 | for ( ; sdit.current(); ++sdit ) { | 868 | for ( ; sdit.current(); ++sdit ) { |
869 | delete sdit.current(); | 869 | delete sdit.current(); |
870 | } | 870 | } |
871 | Global::findDocuments(&files, "audio/*"); | 871 | Global::findDocuments(&files, "audio/*"); |
872 | audioScan = TRUE; | 872 | audioScan = TRUE; |
873 | } | 873 | } |
874 | void PlayListWidget::scanForVideo() { | 874 | void PlayListWidget::scanForVideo() { |
875 | qDebug("scan for video"); | 875 | qDebug("scan for video"); |
876 | vFiles.detachChildren(); | 876 | vFiles.detachChildren(); |
877 | QListIterator<DocLnk> sdit( vFiles.children() ); | 877 | QListIterator<DocLnk> sdit( vFiles.children() ); |
878 | for ( ; sdit.current(); ++sdit ) { | 878 | for ( ; sdit.current(); ++sdit ) { |
879 | delete sdit.current(); | 879 | delete sdit.current(); |
880 | } | 880 | } |
881 | Global::findDocuments(&vFiles, "video/*"); | 881 | Global::findDocuments(&vFiles, "video/*"); |
882 | videoScan = TRUE; | 882 | videoScan = TRUE; |
883 | } | 883 | } |
884 | 884 | ||
885 | void PlayListWidget::populateAudioView() { | 885 | void PlayListWidget::populateAudioView() { |
886 | 886 | ||
887 | audioView->clear(); | 887 | audioView->clear(); |
888 | StorageInfo storageInfo; | 888 | StorageInfo storageInfo; |
889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
890 | if(!audioScan) scanForAudio(); | 890 | if(!audioScan) scanForAudio(); |
891 | 891 | ||
892 | QListIterator<DocLnk> dit( files.children() ); | 892 | QListIterator<DocLnk> dit( files.children() ); |
893 | QListIterator<FileSystem> it ( fs ); | 893 | QListIterator<FileSystem> it ( fs ); |
894 | 894 | ||
895 | QString storage; | 895 | QString storage; |
896 | for ( ; dit.current(); ++dit ) { | 896 | for ( ; dit.current(); ++dit ) { |
897 | for( ; it.current(); ++it ){ | 897 | for( ; it.current(); ++it ){ |
898 | const QString name = (*it)->name(); | 898 | const QString name = (*it)->name(); |
899 | const QString path = (*it)->path(); | 899 | const QString path = (*it)->path(); |
900 | if(dit.current()->file().find(path) != -1 ) storage=name; | 900 | if(dit.current()->file().find(path) != -1 ) storage=name; |
901 | } | 901 | } |
902 | 902 | ||
903 | QListViewItem * newItem; | 903 | QListViewItem * newItem; |
904 | if ( QFile( dit.current()->file()).exists() ) { | 904 | if ( QFile( dit.current()->file()).exists() ) { |
905 | // qDebug(dit.current()->name()); | 905 | // qDebug(dit.current()->name()); |
906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
907 | QString::number( QFile( dit.current()->file()).size() ), storage); | 907 | QString::number( QFile( dit.current()->file()).size() ), storage); |
908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | void PlayListWidget::populateVideoView() { | 914 | void PlayListWidget::populateVideoView() { |
915 | videoView->clear(); | 915 | videoView->clear(); |
916 | StorageInfo storageInfo; | 916 | StorageInfo storageInfo; |
917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
918 | 918 | ||
919 | if(!videoScan ) scanForVideo(); | 919 | if(!videoScan ) scanForVideo(); |
920 | 920 | ||
921 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 921 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
922 | QListIterator<FileSystem> it ( fs ); | 922 | QListIterator<FileSystem> it ( fs ); |
923 | videoView->clear(); | 923 | videoView->clear(); |
924 | QString storage; | 924 | QString storage; |
925 | for ( ; Vdit.current(); ++Vdit ) { | 925 | for ( ; Vdit.current(); ++Vdit ) { |
926 | for( ; it.current(); ++it ){ | 926 | for( ; it.current(); ++it ){ |
927 | const QString name = (*it)->name(); | 927 | const QString name = (*it)->name(); |
928 | const QString path = (*it)->path(); | 928 | const QString path = (*it)->path(); |
929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
930 | } | 930 | } |
931 | 931 | ||
932 | QListViewItem * newItem; | 932 | QListViewItem * newItem; |
933 | if ( QFile( Vdit.current()->file()).exists() ) { | 933 | if ( QFile( Vdit.current()->file()).exists() ) { |
934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | void PlayListWidget::openFile() { | 941 | void PlayListWidget::openFile() { |
942 | QString filename, name; | 942 | QString filename, name; |
943 | InputDialog *fileDlg; | 943 | InputDialog *fileDlg; |
944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
945 | fileDlg->exec(); | 945 | fileDlg->exec(); |
946 | if( fileDlg->result() == 1 ) { | 946 | if( fileDlg->result() == 1 ) { |
947 | filename = fileDlg->LineEdit1->text(); | 947 | filename = fileDlg->LineEdit1->text(); |
948 | 948 | ||
949 | qDebug("Selected filename is "+filename); | 949 | qDebug("Selected filename is "+filename); |
950 | if(filename.right(3) == "m3u") { | 950 | if(filename.right(3) == "m3u") { |
951 | readm3u( filename ); | 951 | readm3u( filename ); |
952 | } else if(filename.right(3) == "pls") { | 952 | } else if(filename.right(3) == "pls") { |
953 | readPls( filename ); | 953 | readPls( filename ); |
954 | } else { | 954 | } else { |
955 | DocLnk lnk; | 955 | DocLnk lnk; |
956 | 956 | ||
957 | lnk.setName(filename); //sets file name | 957 | lnk.setName(filename); //sets file name |
958 | // probably not needed anymore either | ||
959 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") { | ||
960 | filename += "/"; | ||
961 | } | ||
962 | lnk.setFile(filename); //sets File property | 958 | lnk.setFile(filename); //sets File property |
963 | |||
964 | lnk.setType("audio/x-mpegurl"); | 959 | lnk.setType("audio/x-mpegurl"); |
965 | lnk.setExec("opieplayer"); | 960 | lnk.setExec("opieplayer"); |
966 | lnk.setIcon("opieplayer/MPEGPlayer"); | 961 | lnk.setIcon("opieplayer/MPEGPlayer"); |
967 | 962 | ||
968 | if(!lnk.writeLink()) { | 963 | if(!lnk.writeLink()) { |
969 | qDebug("Writing doclink did not work"); | 964 | qDebug("Writing doclink did not work"); |
970 | } | 965 | } |
971 | d->selectedFiles->addToSelection( lnk); | 966 | d->selectedFiles->addToSelection( lnk); |
972 | } | 967 | } |
973 | } | 968 | } |
974 | if(fileDlg) { | 969 | if(fileDlg) { |
975 | delete fileDlg; | 970 | delete fileDlg; |
976 | } | 971 | } |
977 | } | 972 | } |
978 | 973 | ||
979 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 974 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
980 | { | 975 | { |
981 | switch ( e->key() ) { | 976 | switch ( e->key() ) { |
982 | ////////////////////////////// Zaurus keys | 977 | ////////////////////////////// Zaurus keys |
983 | case Key_F9: //activity | 978 | case Key_F9: //activity |
984 | // if(audioUI->isHidden()) | 979 | // if(audioUI->isHidden()) |
985 | // audioUI->showMaximized(); | 980 | // audioUI->showMaximized(); |
986 | break; | 981 | break; |
987 | case Key_F10: //contacts | 982 | case Key_F10: //contacts |
988 | // if( videoUI->isHidden()) | 983 | // if( videoUI->isHidden()) |
989 | // videoUI->showMaximized(); | 984 | // videoUI->showMaximized(); |
990 | break; | 985 | break; |
991 | case Key_F11: //menu | 986 | case Key_F11: //menu |
992 | break; | 987 | break; |
993 | case Key_F12: //home | 988 | case Key_F12: //home |
994 | // doBlank(); | 989 | // doBlank(); |
995 | break; | 990 | break; |
996 | case Key_F13: //mail | 991 | case Key_F13: //mail |
997 | // doUnblank(); | 992 | // doUnblank(); |
998 | break; | 993 | break; |
999 | case Key_Q: //add to playlist | 994 | case Key_Q: //add to playlist |
1000 | qDebug("Add"); | 995 | qDebug("Add"); |
1001 | addSelected(); | 996 | addSelected(); |
1002 | break; | 997 | break; |
1003 | case Key_R: //remove from playlist | 998 | case Key_R: //remove from playlist |
1004 | removeSelected(); | 999 | removeSelected(); |
1005 | break; | 1000 | break; |
1006 | // case Key_P: //play | 1001 | // case Key_P: //play |
1007 | // qDebug("Play"); | 1002 | // qDebug("Play"); |
1008 | // playSelected(); | 1003 | // playSelected(); |
1009 | // break; | 1004 | // break; |
1010 | case Key_Space: | 1005 | case Key_Space: |
1011 | qDebug("Play"); | 1006 | qDebug("Play"); |
1012 | // playSelected(); puh | 1007 | // playSelected(); puh |
1013 | break; | 1008 | break; |
1014 | case Key_1: | 1009 | case Key_1: |
1015 | tabWidget->setCurrentPage(0); | 1010 | tabWidget->setCurrentPage(0); |
1016 | break; | 1011 | break; |
1017 | case Key_2: | 1012 | case Key_2: |
1018 | tabWidget->setCurrentPage(1); | 1013 | tabWidget->setCurrentPage(1); |
1019 | break; | 1014 | break; |
1020 | case Key_3: | 1015 | case Key_3: |
1021 | tabWidget->setCurrentPage(2); | 1016 | tabWidget->setCurrentPage(2); |
1022 | break; | 1017 | break; |
1023 | case Key_4: | 1018 | case Key_4: |
1024 | tabWidget->setCurrentPage(3); | 1019 | tabWidget->setCurrentPage(3); |
1025 | break; | 1020 | break; |
1026 | case Key_Down: | 1021 | case Key_Down: |
1027 | if ( !d->selectedFiles->next() ) | 1022 | if ( !d->selectedFiles->next() ) |
1028 | d->selectedFiles->first(); | 1023 | d->selectedFiles->first(); |
1029 | 1024 | ||
1030 | break; | 1025 | break; |
1031 | case Key_Up: | 1026 | case Key_Up: |
1032 | if ( !d->selectedFiles->prev() ) | 1027 | if ( !d->selectedFiles->prev() ) |
1033 | // d->selectedFiles->last(); | 1028 | // d->selectedFiles->last(); |
1034 | 1029 | ||
1035 | break; | 1030 | break; |
1036 | 1031 | ||
1037 | } | 1032 | } |
1038 | } | 1033 | } |
1039 | 1034 | ||
1040 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1035 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1041 | { | 1036 | { |
1042 | // qDebug("Key press"); | 1037 | // qDebug("Key press"); |
1043 | // switch ( e->key() ) { | 1038 | // switch ( e->key() ) { |
1044 | // ////////////////////////////// Zaurus keys | 1039 | // ////////////////////////////// Zaurus keys |
1045 | // case Key_A: //add to playlist | 1040 | // case Key_A: //add to playlist |
1046 | // qDebug("Add"); | 1041 | // qDebug("Add"); |
1047 | // addSelected(); | 1042 | // addSelected(); |
1048 | // break; | 1043 | // break; |
1049 | // case Key_R: //remove from playlist | 1044 | // case Key_R: //remove from playlist |
1050 | // removeSelected(); | 1045 | // removeSelected(); |
1051 | // break; | 1046 | // break; |
1052 | // case Key_P: //play | 1047 | // case Key_P: //play |
1053 | // qDebug("Play"); | 1048 | // qDebug("Play"); |
1054 | // playSelected(); | 1049 | // playSelected(); |
1055 | // break; | 1050 | // break; |
1056 | // case Key_Space: | 1051 | // case Key_Space: |
1057 | // qDebug("Play"); | 1052 | // qDebug("Play"); |
1058 | // playSelected(); | 1053 | // playSelected(); |
1059 | // break; | 1054 | // break; |
1060 | // } | 1055 | // } |
1061 | } | 1056 | } |
1062 | 1057 | ||
1063 | void PlayListWidget::doBlank() { | 1058 | void PlayListWidget::doBlank() { |
1064 | qDebug("do blanking"); | 1059 | qDebug("do blanking"); |
1065 | fd=open("/dev/fb0",O_RDWR); | 1060 | fd=open("/dev/fb0",O_RDWR); |
1066 | if (fd != -1) { | 1061 | if (fd != -1) { |
1067 | ioctl(fd,FBIOBLANK,1); | 1062 | ioctl(fd,FBIOBLANK,1); |
1068 | // close(fd); | 1063 | // close(fd); |
1069 | } | 1064 | } |
1070 | } | 1065 | } |
1071 | 1066 | ||
1072 | void PlayListWidget::doUnblank() { | 1067 | void PlayListWidget::doUnblank() { |
1073 | // this crashes opieplayer with a segfault | 1068 | // this crashes opieplayer with a segfault |
1074 | // int fd; | 1069 | // int fd; |
1075 | // fd=open("/dev/fb0",O_RDWR); | 1070 | // fd=open("/dev/fb0",O_RDWR); |
1076 | qDebug("do unblanking"); | 1071 | qDebug("do unblanking"); |
1077 | if (fd != -1) { | 1072 | if (fd != -1) { |
1078 | ioctl(fd,FBIOBLANK,0); | 1073 | ioctl(fd,FBIOBLANK,0); |
1079 | close(fd); | 1074 | close(fd); |
1080 | } | 1075 | } |
1081 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1076 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1082 | h <<-3;// v[1]; // -3 Force on | 1077 | h <<-3;// v[1]; // -3 Force on |
1083 | } | 1078 | } |
1084 | 1079 | ||
1085 | void PlayListWidget::readm3u(const QString &filename) { | 1080 | void PlayListWidget::readm3u(const QString &filename) { |
1086 | 1081 | ||
1087 | qDebug("m3u filename is "+filename); | 1082 | qDebug("m3u filename is "+filename); |
1088 | QFile f(filename); | 1083 | QFile f(filename); |
1089 | 1084 | ||
1090 | if(f.open(IO_ReadOnly)) { | 1085 | if(f.open(IO_ReadOnly)) { |
1091 | QTextStream t(&f); | 1086 | QTextStream t(&f); |
1092 | QString s;//, first, second; | 1087 | QString s;//, first, second; |
1093 | int i=0; | 1088 | int i=0; |
1094 | while ( !t.atEnd()) { | 1089 | while ( !t.atEnd()) { |
1095 | s=t.readLine(); | 1090 | s=t.readLine(); |
1096 | 1091 | ||
1097 | if(s.find("#",0,TRUE) == -1) { | 1092 | if(s.find("#",0,TRUE) == -1) { |
1098 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1093 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1099 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1094 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1100 | s=s.right(s.length()-2); | 1095 | s=s.right(s.length()-2); |
1101 | DocLnk lnk( s ); | 1096 | DocLnk lnk( s ); |
1102 | QFileInfo f(s); | 1097 | QFileInfo f(s); |
1103 | QString name = f.baseName(); | 1098 | QString name = f.baseName(); |
1104 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1099 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1105 | lnk.setName( name ); | 1100 | lnk.setName( name ); |
1106 | s=s.replace( QRegExp("\\"),"/"); | 1101 | s=s.replace( QRegExp("\\"),"/"); |
1107 | lnk.setFile( s ); | 1102 | lnk.setFile( s ); |
1108 | lnk.writeLink(); | 1103 | lnk.writeLink(); |
1109 | qDebug("add "+name); | 1104 | qDebug("add "+name); |
1110 | d->selectedFiles->addToSelection( lnk); | 1105 | d->selectedFiles->addToSelection( lnk); |
1111 | } else { // is url | 1106 | } else { // is url |
1112 | s.replace(QRegExp("%20")," "); | 1107 | s.replace(QRegExp("%20")," "); |
1113 | DocLnk lnk( s ); | 1108 | DocLnk lnk( s ); |
1114 | QString name; | 1109 | QString name; |
1115 | if(name.left(4)=="http") { | 1110 | if(name.left(4)=="http") { |
1116 | name = s.right( s.length() - 7); | 1111 | name = s.right( s.length() - 7); |
1117 | } else { | 1112 | } else { |
1118 | name = s; | 1113 | name = s; |
1119 | } | 1114 | } |
1120 | lnk.setName(name); | 1115 | lnk.setName(name); |
1121 | if(s.at(s.length()-4) == '.') { | 1116 | if(s.at(s.length()-4) == '.') { |
1122 | lnk.setFile( s); | 1117 | lnk.setFile( s); |
1123 | } else { | 1118 | } else { |
1124 | lnk.setFile( s+"/"); | 1119 | lnk.setFile( s+"/"); |
1125 | } | 1120 | } |
1126 | lnk.setType("audio/x-mpegurl"); | 1121 | lnk.setType("audio/x-mpegurl"); |
1127 | lnk.writeLink(); | 1122 | lnk.writeLink(); |
1128 | d->selectedFiles->addToSelection( lnk); | 1123 | d->selectedFiles->addToSelection( lnk); |
1129 | } | 1124 | } |
1130 | i++; | 1125 | i++; |
1131 | } | 1126 | } |
1132 | } | 1127 | } |
1133 | } | 1128 | } |
1134 | } | 1129 | } |
1135 | f.close(); | 1130 | f.close(); |
1136 | } | 1131 | } |
1137 | 1132 | ||
1138 | void PlayListWidget::writem3u() { | 1133 | void PlayListWidget::writem3u() { |
1139 | 1134 | ||
1140 | InputDialog *fileDlg; | 1135 | InputDialog *fileDlg; |
1141 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1136 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1142 | fileDlg->exec(); | 1137 | fileDlg->exec(); |
1143 | QString filename,list; | 1138 | QString filename,list; |
1144 | if( fileDlg->result() == 1 ) { | 1139 | if( fileDlg->result() == 1 ) { |
1145 | filename = fileDlg->LineEdit1->text(); | 1140 | filename = fileDlg->LineEdit1->text(); |
1146 | qDebug(filename); | 1141 | qDebug(filename); |
1147 | int noOfFiles = 0; | 1142 | int noOfFiles = 0; |
1148 | d->selectedFiles->first(); | 1143 | d->selectedFiles->first(); |
1149 | do { | 1144 | do { |
1150 | // we dont check for existance because of url's | 1145 | // we dont check for existance because of url's |
1151 | // qDebug(d->selectedFiles->current()->file()); | 1146 | // qDebug(d->selectedFiles->current()->file()); |
1152 | list += d->selectedFiles->current()->file()+"\n"; | 1147 | list += d->selectedFiles->current()->file()+"\n"; |
1153 | noOfFiles++; | 1148 | noOfFiles++; |
1154 | } | 1149 | } |
1155 | while ( d->selectedFiles->next() ); | 1150 | while ( d->selectedFiles->next() ); |
1156 | qDebug(list); | 1151 | qDebug(list); |
1157 | if(filename.left(1) != "/") | 1152 | if(filename.left(1) != "/") |
1158 | filename=QPEApplication::documentDir()+"/"+filename; | 1153 | filename=QPEApplication::documentDir()+"/"+filename; |
1159 | if(filename.right(3) != "m3u") | 1154 | if(filename.right(3) != "m3u") |
1160 | filename=filename+".m3u"; | 1155 | filename=filename+".m3u"; |
1161 | 1156 | ||
1162 | QFile f(filename); | 1157 | QFile f(filename); |
1163 | f.open(IO_WriteOnly); | 1158 | f.open(IO_WriteOnly); |
1164 | f.writeBlock(list, list.length()); | 1159 | f.writeBlock(list, list.length()); |
1165 | f.close(); | 1160 | f.close(); |
1166 | } | 1161 | } |
1167 | if(fileDlg) delete fileDlg; | 1162 | if(fileDlg) delete fileDlg; |
1168 | } | 1163 | } |
1169 | 1164 | ||
1170 | void PlayListWidget::readPls(const QString &filename) { | 1165 | void PlayListWidget::readPls(const QString &filename) { |
1171 | 1166 | ||
1172 | qDebug("pls filename is "+filename); | 1167 | qDebug("pls filename is "+filename); |
1173 | QFile f(filename); | 1168 | QFile f(filename); |
1174 | 1169 | ||
1175 | if(f.open(IO_ReadOnly)) { | 1170 | if(f.open(IO_ReadOnly)) { |
1176 | QTextStream t(&f); | 1171 | QTextStream t(&f); |
1177 | QString s;//, first, second; | 1172 | QString s;//, first, second; |
1178 | int i=0; | 1173 | int i=0; |
1179 | while ( !t.atEnd()) { | 1174 | while ( !t.atEnd()) { |
1180 | s=t.readLine(); | 1175 | s=t.readLine(); |
1181 | if(s.left(4) == "File") { | 1176 | if(s.left(4) == "File") { |
1182 | s=s.right(s.length() - 6); | 1177 | s=s.right(s.length() - 6); |
1183 | s.replace(QRegExp("%20")," "); | 1178 | s.replace(QRegExp("%20")," "); |
1184 | qDebug("adding "+s+" to playlist"); | 1179 | qDebug("adding "+s+" to playlist"); |
1185 | // numberofentries=2 | 1180 | // numberofentries=2 |
1186 | // File1=http | 1181 | // File1=http |
1187 | // Title | 1182 | // Title |
1188 | // Length | 1183 | // Length |
1189 | // Version | 1184 | // Version |
1190 | // File2=http | 1185 | // File2=http |
1191 | s=s.replace( QRegExp("\\"),"/"); | 1186 | s=s.replace( QRegExp("\\"),"/"); |
1192 | DocLnk lnk( s ); | 1187 | DocLnk lnk( s ); |
1193 | QFileInfo f(s); | 1188 | QFileInfo f(s); |
1194 | QString name = f.baseName(); | 1189 | QString name = f.baseName(); |
1195 | if(name.left(4)=="http") | 1190 | if(name.left(4)=="http") |
1196 | name = s.right( s.length() - 7); | 1191 | name = s.right( s.length() - 7); |
1197 | else | 1192 | else |
1198 | name=s; | 1193 | name=s; |
1199 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1194 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1200 | lnk.setName( name); | 1195 | lnk.setName( name); |
1201 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1196 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1202 | lnk.setFile( s); | 1197 | lnk.setFile( s); |
1203 | else { //if its a url | 1198 | else { //if its a url |
1204 | if( name.right(1).find('/') == -1) | 1199 | if( name.right(1).find('/') == -1) |
1205 | s+="/"; | 1200 | s+="/"; |
1206 | lnk.setFile( s); | 1201 | lnk.setFile( s); |
1207 | } | 1202 | } |
1208 | lnk.setType("audio/x-mpegurl"); | 1203 | lnk.setType("audio/x-mpegurl"); |
1209 | 1204 | ||
1210 | qDebug("DocLnk add "+name); | 1205 | qDebug("DocLnk add "+name); |
1211 | d->selectedFiles->addToSelection( lnk); | 1206 | d->selectedFiles->addToSelection( lnk); |
1212 | } | 1207 | } |
1213 | } | 1208 | } |
1214 | i++; | 1209 | i++; |
1215 | } | 1210 | } |
1216 | } | 1211 | } |
1217 | 1212 | ||