author | llornkcor <llornkcor> | 2002-11-10 15:26:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-10 15:26:11 (UTC) |
commit | 804e08f4642353af836bab921d8f732709051de0 (patch) (unidiff) | |
tree | 8e3ee2f1e519ef018a51cc32436ca24ff9d47da9 | |
parent | 1486b6f940adde3cd80592e436e8e025045d7f8e (diff) | |
download | opie-804e08f4642353af836bab921d8f732709051de0.zip opie-804e08f4642353af836bab921d8f732709051de0.tar.gz opie-804e08f4642353af836bab921d8f732709051de0.tar.bz2 |
no extras here either
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 75c7332..b15f95e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -372,212 +372,214 @@ bool PlayListWidget::prev() { | |||
372 | return TRUE; | 372 | return TRUE; |
373 | } | 373 | } |
374 | } else { | 374 | } else { |
375 | return mediaPlayerState->looping(); | 375 | return mediaPlayerState->looping(); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | bool PlayListWidget::next() { | 380 | bool PlayListWidget::next() { |
381 | //qDebug("<<<<<<<<<<<<next()"); | 381 | //qDebug("<<<<<<<<<<<<next()"); |
382 | if ( mediaPlayerState->playlist() ) { | 382 | if ( mediaPlayerState->playlist() ) { |
383 | if ( mediaPlayerState->shuffled() ) { | 383 | if ( mediaPlayerState->shuffled() ) { |
384 | return prev(); | 384 | return prev(); |
385 | } else { | 385 | } else { |
386 | if ( !d->selectedFiles->next() ) { | 386 | if ( !d->selectedFiles->next() ) { |
387 | if ( mediaPlayerState->looping() ) { | 387 | if ( mediaPlayerState->looping() ) { |
388 | return d->selectedFiles->first(); | 388 | return d->selectedFiles->first(); |
389 | } else { | 389 | } else { |
390 | return FALSE; | 390 | return FALSE; |
391 | } | 391 | } |
392 | } | 392 | } |
393 | return TRUE; | 393 | return TRUE; |
394 | } | 394 | } |
395 | } else { | 395 | } else { |
396 | return mediaPlayerState->looping(); | 396 | return mediaPlayerState->looping(); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | bool PlayListWidget::first() { | 401 | bool PlayListWidget::first() { |
402 | if ( mediaPlayerState->playlist() ) | 402 | if ( mediaPlayerState->playlist() ) |
403 | return d->selectedFiles->first(); | 403 | return d->selectedFiles->first(); |
404 | else | 404 | else |
405 | return mediaPlayerState->looping(); | 405 | return mediaPlayerState->looping(); |
406 | } | 406 | } |
407 | 407 | ||
408 | 408 | ||
409 | bool PlayListWidget::last() { | 409 | bool PlayListWidget::last() { |
410 | if ( mediaPlayerState->playlist() ) | 410 | if ( mediaPlayerState->playlist() ) |
411 | return d->selectedFiles->last(); | 411 | return d->selectedFiles->last(); |
412 | else | 412 | else |
413 | return mediaPlayerState->looping(); | 413 | return mediaPlayerState->looping(); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PlayListWidget::saveList() { | 417 | void PlayListWidget::saveList() { |
418 | writem3u(); | 418 | writem3u(); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void PlayListWidget::loadList( const DocLnk & lnk) { | 422 | void PlayListWidget::loadList( const DocLnk & lnk) { |
423 | QString name = lnk.name(); | 423 | QString name = lnk.name(); |
424 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 424 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
425 | 425 | ||
426 | if( name.length()>0) { | 426 | if( name.length()>0) { |
427 | setCaption("OpiePlayer: "+name); | 427 | setCaption("OpiePlayer: "+name); |
428 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 428 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
429 | clearList(); | 429 | clearList(); |
430 | readm3u(lnk.file()); | 430 | readm3u(lnk.file()); |
431 | tabWidget->setCurrentPage(0); | 431 | tabWidget->setCurrentPage(0); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void PlayListWidget::setPlaylist( bool shown ) { | 436 | void PlayListWidget::setPlaylist( bool shown ) { |
437 | if ( shown ) { | 437 | if ( shown ) { |
438 | d->playListFrame->show(); | 438 | d->playListFrame->show(); |
439 | } else { | 439 | } else { |
440 | d->playListFrame->hide(); | 440 | d->playListFrame->hide(); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
445 | void PlayListWidget::addSelected() { | 445 | void PlayListWidget::addSelected() { |
446 | qDebug("addSelected"); | 446 | qDebug("addSelected"); |
447 | switch (whichList()) { | 447 | switch (whichList()) { |
448 | case 0: //playlist | 448 | case 0: //playlist |
449 | break; | 449 | break; |
450 | case 1: { //audio | 450 | case 1: { //audio |
451 | QListViewItemIterator it( audioView ); | 451 | QListViewItemIterator it( audioView ); |
452 | // iterate through all items of the listview | 452 | // iterate through all items of the listview |
453 | for ( ; it.current(); ++it ) { | 453 | for ( ; it.current(); ++it ) { |
454 | if ( it.current()->isSelected() ) { | 454 | if ( it.current()->isSelected() ) { |
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 | } | 469 | } |
469 | break; | 470 | break; |
470 | case 2: { // video | 471 | case 2: { // video |
471 | QListViewItemIterator it( videoView ); | 472 | QListViewItemIterator it( videoView ); |
472 | // iterate through all items of the listview | 473 | // iterate through all items of the listview |
473 | for ( ; it.current(); ++it ) { | 474 | for ( ; it.current(); ++it ) { |
474 | if ( it.current()->isSelected() ) { | 475 | if ( it.current()->isSelected() ) { |
475 | QListIterator<DocLnk> dit( vFiles.children() ); | 476 | QListIterator<DocLnk> dit( vFiles.children() ); |
476 | for ( ; dit.current(); ++dit ) { | 477 | for ( ; dit.current(); ++dit ) { |
477 | if( dit.current()->name() == it.current()->text(0) ) { | 478 | if( dit.current()->name() == it.current()->text(0) ) { |
478 | if(QFileInfo( dit.current()->file()).exists()) { | 479 | if(QFileInfo( dit.current()->file()).exists()) { |
479 | d->selectedFiles->addToSelection( **dit ); | 480 | d->selectedFiles->addToSelection( **dit ); |
480 | videoView->setSelected( it.current(),FALSE); | 481 | videoView->setSelected( it.current(),FALSE); |
481 | } | 482 | } |
482 | } | 483 | } |
483 | } | 484 | } |
484 | } | 485 | } |
485 | } | 486 | } |
486 | // tabWidget->setCurrentPage(0); | 487 | // tabWidget->setCurrentPage(0); |
487 | writeCurrentM3u(); | 488 | writeCurrentM3u(); |
489 | |||
488 | } | 490 | } |
489 | break; | 491 | break; |
490 | }; | 492 | }; |
491 | } | 493 | } |
492 | 494 | ||
493 | 495 | ||
494 | void PlayListWidget::removeSelected() { | 496 | void PlayListWidget::removeSelected() { |
495 | d->selectedFiles->removeSelected( ); | 497 | d->selectedFiles->removeSelected( ); |
496 | writeCurrentM3u(); | 498 | writeCurrentM3u(); |
497 | } | 499 | } |
498 | 500 | ||
499 | 501 | ||
500 | void PlayListWidget::playIt( QListViewItem *it) { | 502 | void PlayListWidget::playIt( QListViewItem *it) { |
501 | if(!it) return; | 503 | if(!it) return; |
502 | mediaPlayerState->setPlaying(FALSE); | 504 | mediaPlayerState->setPlaying(FALSE); |
503 | mediaPlayerState->setPlaying(TRUE); | 505 | mediaPlayerState->setPlaying(TRUE); |
504 | d->selectedFiles->unSelect(); | 506 | d->selectedFiles->unSelect(); |
505 | } | 507 | } |
506 | 508 | ||
507 | 509 | ||
508 | void PlayListWidget::addToSelection( QListViewItem *it) { | 510 | void PlayListWidget::addToSelection( QListViewItem *it) { |
509 | d->setDocumentUsed = FALSE; | 511 | d->setDocumentUsed = FALSE; |
510 | 512 | ||
511 | if(it) { | 513 | if(it) { |
512 | switch ( whichList()) { | 514 | switch ( whichList()) { |
513 | case 1: { | 515 | case 1: { |
514 | QListIterator<DocLnk> dit( files.children() ); | 516 | QListIterator<DocLnk> dit( files.children() ); |
515 | for ( ; dit.current(); ++dit ) { | 517 | for ( ; dit.current(); ++dit ) { |
516 | if( dit.current()->name() == it->text(0)) { | 518 | if( dit.current()->name() == it->text(0)) { |
517 | if(QFileInfo( dit.current()->file()).exists()) | 519 | if(QFileInfo( dit.current()->file()).exists()) |
518 | d->selectedFiles->addToSelection( **dit ); | 520 | d->selectedFiles->addToSelection( **dit ); |
519 | } | 521 | } |
520 | } | 522 | } |
521 | writeCurrentM3u(); | 523 | writeCurrentM3u(); |
522 | } | 524 | } |
523 | break; | 525 | break; |
524 | case 2: { | 526 | case 2: { |
525 | QListIterator<DocLnk> dit( vFiles.children() ); | 527 | QListIterator<DocLnk> dit( vFiles.children() ); |
526 | for ( ; dit.current(); ++dit ) { | 528 | for ( ; dit.current(); ++dit ) { |
527 | if( dit.current()->name() == it->text(0)) { | 529 | if( dit.current()->name() == it->text(0)) { |
528 | if( QFileInfo( dit.current()->file()).exists() ) | 530 | if( QFileInfo( dit.current()->file()).exists() ) |
529 | d->selectedFiles->addToSelection( **dit ); | 531 | d->selectedFiles->addToSelection( **dit ); |
530 | } | 532 | } |
531 | } | 533 | } |
532 | writeCurrentM3u(); | 534 | writeCurrentM3u(); |
533 | 535 | ||
534 | } | 536 | } |
535 | break; | 537 | break; |
536 | case 0: | 538 | case 0: |
537 | break; | 539 | break; |
538 | }; | 540 | }; |
539 | tabWidget->setCurrentPage(0); | 541 | tabWidget->setCurrentPage(0); |
540 | } | 542 | } |
541 | } | 543 | } |
542 | 544 | ||
543 | 545 | ||
544 | void PlayListWidget::tabChanged(QWidget *) { | 546 | void PlayListWidget::tabChanged(QWidget *) { |
545 | 547 | ||
546 | switch ( whichList()) { | 548 | switch ( whichList()) { |
547 | case 0: | 549 | case 0: |
548 | { | 550 | { |
549 | if( !tbDeletePlaylist->isHidden() ) { | 551 | if( !tbDeletePlaylist->isHidden() ) { |
550 | tbDeletePlaylist->hide(); | 552 | tbDeletePlaylist->hide(); |
551 | } | 553 | } |
552 | d->tbRemoveFromList->setEnabled(TRUE); | 554 | d->tbRemoveFromList->setEnabled(TRUE); |
553 | d->tbAddToList->setEnabled(FALSE); | 555 | d->tbAddToList->setEnabled(FALSE); |
554 | } | 556 | } |
555 | break; | 557 | break; |
556 | case 1: | 558 | case 1: |
557 | { | 559 | { |
558 | audioView->clear(); | 560 | audioView->clear(); |
559 | populateAudioView(); | 561 | populateAudioView(); |
560 | 562 | ||
561 | if( !tbDeletePlaylist->isHidden() ) { | 563 | if( !tbDeletePlaylist->isHidden() ) { |
562 | tbDeletePlaylist->hide(); | 564 | tbDeletePlaylist->hide(); |
563 | } | 565 | } |
564 | d->tbRemoveFromList->setEnabled(FALSE); | 566 | d->tbRemoveFromList->setEnabled(FALSE); |
565 | d->tbAddToList->setEnabled(TRUE); | 567 | d->tbAddToList->setEnabled(TRUE); |
566 | } | 568 | } |
567 | break; | 569 | break; |
568 | case 2: | 570 | case 2: |
569 | { | 571 | { |
570 | videoView->clear(); | 572 | videoView->clear(); |
571 | populateVideoView(); | 573 | populateVideoView(); |
572 | if( !tbDeletePlaylist->isHidden() ) { | 574 | if( !tbDeletePlaylist->isHidden() ) { |
573 | tbDeletePlaylist->hide(); | 575 | tbDeletePlaylist->hide(); |
574 | } | 576 | } |
575 | d->tbRemoveFromList->setEnabled(FALSE); | 577 | d->tbRemoveFromList->setEnabled(FALSE); |
576 | d->tbAddToList->setEnabled(TRUE); | 578 | d->tbAddToList->setEnabled(TRUE); |
577 | } | 579 | } |
578 | break; | 580 | break; |
579 | case 3: | 581 | case 3: |
580 | { | 582 | { |
581 | if( tbDeletePlaylist->isHidden() ) { | 583 | if( tbDeletePlaylist->isHidden() ) { |
582 | tbDeletePlaylist->show(); | 584 | tbDeletePlaylist->show(); |
583 | } | 585 | } |
@@ -681,195 +683,195 @@ void PlayListWidget::populateVideoView() { | |||
681 | 683 | ||
682 | if(!videoScan ) { | 684 | if(!videoScan ) { |
683 | scanForVideo(); | 685 | scanForVideo(); |
684 | } | 686 | } |
685 | 687 | ||
686 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 688 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
687 | QListIterator<FileSystem> it ( fs ); | 689 | QListIterator<FileSystem> it ( fs ); |
688 | videoView->clear(); | 690 | videoView->clear(); |
689 | QString storage, pathName; | 691 | QString storage, pathName; |
690 | for ( ; Vdit.current(); ++Vdit ) { | 692 | for ( ; Vdit.current(); ++Vdit ) { |
691 | for( ; it.current(); ++it ) { | 693 | for( ; it.current(); ++it ) { |
692 | const QString name = (*it)->name(); | 694 | const QString name = (*it)->name(); |
693 | const QString path = (*it)->path(); | 695 | const QString path = (*it)->path(); |
694 | if( Vdit.current()->file().find(path) != -1 ) { | 696 | if( Vdit.current()->file().find(path) != -1 ) { |
695 | storage=name; | 697 | storage=name; |
696 | pathName=path; | 698 | pathName=path; |
697 | } | 699 | } |
698 | } | 700 | } |
699 | 701 | ||
700 | QListViewItem * newItem; | 702 | QListViewItem * newItem; |
701 | if ( QFile( Vdit.current()->file() ).exists() ) { | 703 | if ( QFile( Vdit.current()->file() ).exists() ) { |
702 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 704 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
703 | QString::number( QFile( Vdit.current()->file() ).size() ), | 705 | QString::number( QFile( Vdit.current()->file() ).size() ), |
704 | storage, Vdit.current()->file()); | 706 | storage, Vdit.current()->file()); |
705 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 707 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
706 | } | 708 | } |
707 | } | 709 | } |
708 | } | 710 | } |
709 | 711 | ||
710 | 712 | ||
711 | void PlayListWidget::openFile() { | 713 | void PlayListWidget::openFile() { |
712 | // http://66.28.164.33:2080 | 714 | // http://66.28.164.33:2080 |
713 | // http://somafm.com/star0242.m3u | 715 | // http://somafm.com/star0242.m3u |
714 | QString filename, name; | 716 | QString filename, name; |
715 | InputDialog *fileDlg; | 717 | InputDialog *fileDlg; |
716 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 718 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
717 | fileDlg->exec(); | 719 | fileDlg->exec(); |
718 | if( fileDlg->result() == 1 ) { | 720 | if( fileDlg->result() == 1 ) { |
719 | filename = fileDlg->text(); | 721 | filename = fileDlg->text(); |
720 | qDebug( "Selected filename is " + filename ); | 722 | qDebug( "Selected filename is " + filename ); |
721 | Om3u *m3uList; | 723 | Om3u *m3uList; |
722 | DocLnk lnk; | 724 | DocLnk lnk; |
723 | Config cfg( "OpiePlayer" ); | 725 | Config cfg( "OpiePlayer" ); |
724 | cfg.setGroup("PlayList"); | 726 | cfg.setGroup("PlayList"); |
725 | 727 | ||
726 | if(filename.left(4) == "http") { | 728 | if(filename.left(4) == "http") { |
727 | QString m3uFile, m3uFilePath; | 729 | QString m3uFile, m3uFilePath; |
728 | if(filename.find(":",8,TRUE) != -1) { //found a port | 730 | if(filename.find(":",8,TRUE) != -1) { //found a port |
729 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 731 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
730 | m3uFile = m3uFile.right( 7); | 732 | m3uFile = m3uFile.right( 7); |
731 | } else if(filename.left(4) == "http"){ | 733 | } else if(filename.left(4) == "http"){ |
732 | m3uFile=filename; | 734 | m3uFile=filename; |
733 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 735 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
734 | } else{ | 736 | } else{ |
735 | m3uFile=filename; | 737 | m3uFile=filename; |
736 | } | 738 | } |
737 | 739 | ||
738 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 740 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
739 | lnk.setName( filename ); //sets name | 741 | lnk.setName( filename ); //sets name |
740 | lnk.setFile( filename ); //sets file name | 742 | lnk.setFile( filename ); //sets file name |
741 | lnk.setIcon("opieplayer2/musicfile"); | 743 | lnk.setIcon("opieplayer2/musicfile"); |
742 | d->selectedFiles->addToSelection( lnk ); | 744 | d->selectedFiles->addToSelection( lnk ); |
743 | writeCurrentM3u(); | 745 | writeCurrentM3u(); |
744 | } | 746 | } |
745 | else if( filename.right( 3) == "m3u" ) { | 747 | else if( filename.right( 3) == "m3u" ) { |
746 | readm3u( filename ); | 748 | readm3u( filename ); |
747 | 749 | ||
748 | } else if( filename.right(3) == "pls" ) { | 750 | } else if( filename.right(3) == "pls" ) { |
749 | readPls( filename ); | 751 | readPls( filename ); |
750 | } else { | 752 | } else { |
751 | d->selectedFiles->addToSelection( DocLnk(filename) ); | 753 | d->selectedFiles->addToSelection( DocLnk(filename) ); |
752 | writeCurrentM3u(); | 754 | writeCurrentM3u(); |
753 | } | 755 | } |
754 | } | 756 | } |
755 | 757 | ||
756 | if( fileDlg ) { | 758 | if( fileDlg ) { |
757 | delete fileDlg; | 759 | delete fileDlg; |
758 | } | 760 | } |
759 | } | 761 | } |
760 | 762 | ||
761 | /* | 763 | /* |
762 | reads m3u and shows files/urls to playlist widget */ | 764 | reads m3u and shows files/urls to playlist widget */ |
763 | void PlayListWidget::readm3u( const QString &filename ) { | 765 | void PlayListWidget::readm3u( const QString &filename ) { |
764 | qDebug( "read m3u filename " + filename ); | 766 | qDebug( "read m3u filename " + filename ); |
765 | 767 | ||
766 | Om3u *m3uList; | 768 | Om3u *m3uList; |
767 | QString s, name; | 769 | QString s, name; |
768 | m3uList = new Om3u( filename, IO_ReadOnly ); | 770 | m3uList = new Om3u( filename, IO_ReadOnly ); |
769 | m3uList->readM3u(); | 771 | m3uList->readM3u(); |
770 | DocLnk lnk; | 772 | DocLnk lnk; |
771 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 773 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
772 | s = *it; | 774 | s = *it; |
773 | // qDebug("reading "+ s); | 775 | // qDebug("reading "+ s); |
774 | if(s.left(4)=="http") { | 776 | if(s.left(4)=="http") { |
775 | lnk.setName( s ); //sets file name | 777 | lnk.setName( s ); //sets file name |
776 | lnk.setIcon("opieplayer2/musicfile"); | 778 | lnk.setIcon("opieplayer2/musicfile"); |
777 | if(s.right(4) != '.' || s.right(5) != '.') | 779 | // if(s.right(4) != '.' || s.right(5) != '.') |
778 | lnk.setFile( s+"/"); //if url with no extension | 780 | // lnk.setFile( s+"/"); //if url with no extension |
779 | else | 781 | // else |
780 | lnk.setFile( s ); //sets file name | 782 | lnk.setFile( s ); //sets file name |
781 | 783 | ||
782 | } else { | 784 | } else { |
783 | // if( QFileInfo( s ).exists() ) { | 785 | // if( QFileInfo( s ).exists() ) { |
784 | lnk.setName( QFileInfo(s).baseName()); | 786 | lnk.setName( QFileInfo(s).baseName()); |
785 | // if(s.right(4) == '.') {//if regular file | 787 | // if(s.right(4) == '.') {//if regular file |
786 | if(s.left(1) != "/") { | 788 | if(s.left(1) != "/") { |
787 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 789 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
788 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 790 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
789 | lnk.setIcon("SoundPlayer"); | 791 | lnk.setIcon("SoundPlayer"); |
790 | } else { | 792 | } else { |
791 | // qDebug("set link2 "+s); | 793 | // qDebug("set link2 "+s); |
792 | lnk.setFile( s); | 794 | lnk.setFile( s); |
793 | lnk.setIcon("SoundPlayer"); | 795 | lnk.setIcon("SoundPlayer"); |
794 | } | 796 | } |
795 | } | 797 | } |
796 | d->selectedFiles->addToSelection( lnk ); | 798 | d->selectedFiles->addToSelection( lnk ); |
797 | } | 799 | } |
798 | Config config( "OpiePlayer" ); | 800 | Config config( "OpiePlayer" ); |
799 | config.setGroup( "PlayList" ); | 801 | config.setGroup( "PlayList" ); |
800 | 802 | ||
801 | config.writeEntry("CurrentPlaylist",filename); | 803 | config.writeEntry("CurrentPlaylist",filename); |
802 | config.write(); | 804 | config.write(); |
803 | currentPlayList=filename; | 805 | currentPlayList=filename; |
804 | 806 | ||
805 | // m3uList->write(); | 807 | // m3uList->write(); |
806 | m3uList->close(); | 808 | m3uList->close(); |
807 | if(m3uList) delete m3uList; | 809 | if(m3uList) delete m3uList; |
808 | 810 | ||
809 | d->selectedFiles->setSelectedItem( s); | 811 | d->selectedFiles->setSelectedItem( s); |
810 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 812 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
811 | 813 | ||
812 | } | 814 | } |
813 | 815 | ||
814 | /* | 816 | /* |
815 | reads pls and adds files/urls to playlist */ | 817 | reads pls and adds files/urls to playlist */ |
816 | void PlayListWidget::readPls( const QString &filename ) { | 818 | void PlayListWidget::readPls( const QString &filename ) { |
817 | 819 | ||
818 | qDebug( "pls filename is " + filename ); | 820 | qDebug( "pls filename is " + filename ); |
819 | Om3u *m3uList; | 821 | Om3u *m3uList; |
820 | QString s, name; | 822 | QString s, name; |
821 | m3uList = new Om3u( filename, IO_ReadOnly ); | 823 | m3uList = new Om3u( filename, IO_ReadOnly ); |
822 | m3uList->readPls(); | 824 | m3uList->readPls(); |
823 | 825 | ||
824 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 826 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
825 | s = *it; | 827 | s = *it; |
826 | // s.replace( QRegExp( "%20" )," " ); | 828 | // s.replace( QRegExp( "%20" )," " ); |
827 | DocLnk lnk( s ); | 829 | DocLnk lnk( s ); |
828 | QFileInfo f( s ); | 830 | QFileInfo f( s ); |
829 | QString name = f.baseName(); | 831 | QString name = f.baseName(); |
830 | 832 | ||
831 | if( name.left( 4 ) == "http" ) { | 833 | if( name.left( 4 ) == "http" ) { |
832 | name = s.right( s.length() - 7); | 834 | name = s.right( s.length() - 7); |
833 | } else { | 835 | } else { |
834 | name = s; | 836 | name = s; |
835 | } | 837 | } |
836 | 838 | ||
837 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 839 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
838 | 840 | ||
839 | lnk.setName( name ); | 841 | lnk.setName( name ); |
840 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 842 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
841 | lnk.setFile( s ); | 843 | lnk.setFile( s ); |
842 | } else { //if its a url | 844 | } else { //if its a url |
843 | if( name.right( 1 ).find( '/' ) == -1) { | 845 | if( name.right( 1 ).find( '/' ) == -1) { |
844 | s += "/"; | 846 | s += "/"; |
845 | } | 847 | } |
846 | lnk.setFile( s ); | 848 | lnk.setFile( s ); |
847 | } | 849 | } |
848 | lnk.setType( "audio/x-mpegurl" ); | 850 | lnk.setType( "audio/x-mpegurl" ); |
849 | 851 | ||
850 | lnk.writeLink(); | 852 | lnk.writeLink(); |
851 | d->selectedFiles->addToSelection( lnk ); | 853 | d->selectedFiles->addToSelection( lnk ); |
852 | } | 854 | } |
853 | 855 | ||
854 | m3uList->close(); | 856 | m3uList->close(); |
855 | if(m3uList) delete m3uList; | 857 | if(m3uList) delete m3uList; |
856 | } | 858 | } |
857 | 859 | ||
858 | /* | 860 | /* |
859 | writes current playlist to current m3u file */ | 861 | writes current playlist to current m3u file */ |
860 | void PlayListWidget::writeCurrentM3u() { | 862 | void PlayListWidget::writeCurrentM3u() { |
861 | qDebug("writing to current m3u"); | 863 | qDebug("writing to current m3u"); |
862 | Config cfg( "OpiePlayer" ); | 864 | Config cfg( "OpiePlayer" ); |
863 | cfg.setGroup("PlayList"); | 865 | cfg.setGroup("PlayList"); |
864 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 866 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
865 | 867 | ||
866 | if( d->selectedFiles->first()) { | 868 | if( d->selectedFiles->first()) { |
867 | Om3u *m3uList; | 869 | Om3u *m3uList; |
868 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 870 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
869 | 871 | ||
870 | do { | 872 | do { |
871 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 873 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
872 | m3uList->add( d->selectedFiles->current()->file() ); | 874 | m3uList->add( d->selectedFiles->current()->file() ); |
873 | } | 875 | } |
874 | while ( d->selectedFiles->next() ); | 876 | while ( d->selectedFiles->next() ); |
875 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 877 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |