-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 4926287..b9b63c7 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -388,970 +388,979 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
388 | do { | 388 | do { |
389 | const DocLnk *lnk = d->selectedFiles->current(); | 389 | const DocLnk *lnk = d->selectedFiles->current(); |
390 | if ( lnk ) { | 390 | if ( lnk ) { |
391 | QString entryName; | 391 | QString entryName; |
392 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 392 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
393 | // qDebug(entryName); | 393 | // qDebug(entryName); |
394 | cfg.writeEntry( entryName, lnk->linkFile() ); | 394 | cfg.writeEntry( entryName, lnk->linkFile() ); |
395 | // if this link does exist, add it so we have the file | 395 | // if this link does exist, add it so we have the file |
396 | // next time... | 396 | // next time... |
397 | if ( !QFile::exists( lnk->linkFile() ) ) { | 397 | if ( !QFile::exists( lnk->linkFile() ) ) { |
398 | // the way writing lnks doesn't really check for out | 398 | // the way writing lnks doesn't really check for out |
399 | // of disk space, but check it anyway. | 399 | // of disk space, but check it anyway. |
400 | if ( !lnk->writeLink() ) { | 400 | if ( !lnk->writeLink() ) { |
401 | QMessageBox::critical( 0, tr("Out of space"), | 401 | QMessageBox::critical( 0, tr("Out of space"), |
402 | tr( "There was a problem saving " | 402 | tr( "There was a problem saving " |
403 | "the playlist.\n" | 403 | "the playlist.\n" |
404 | "Your playlist " | 404 | "Your playlist " |
405 | "may be missing some entries\n" | 405 | "may be missing some entries\n" |
406 | "the next time you start it." ) | 406 | "the next time you start it." ) |
407 | ); | 407 | ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | noOfFiles++; | 410 | noOfFiles++; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | while ( d->selectedFiles->next() ); | 413 | while ( d->selectedFiles->next() ); |
414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
419 | // qDebug("add"); | 419 | // qDebug("add"); |
420 | // if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { | 420 | // if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { |
421 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 421 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
422 | 422 | ||
423 | // } else { | 423 | // } else { |
424 | 424 | ||
425 | d->setDocumentUsed = FALSE; | 425 | d->setDocumentUsed = FALSE; |
426 | if ( mediaPlayerState->playlist() ) { | 426 | if ( mediaPlayerState->playlist() ) { |
427 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 427 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
428 | d->selectedFiles->addToSelection( lnk ); | 428 | d->selectedFiles->addToSelection( lnk ); |
429 | } | 429 | } |
430 | else | 430 | else |
431 | mediaPlayerState->setPlaying( TRUE ); | 431 | mediaPlayerState->setPlaying( TRUE ); |
432 | // } | 432 | // } |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void PlayListWidget::clearList() { | 436 | void PlayListWidget::clearList() { |
437 | while ( first() ) | 437 | while ( first() ) |
438 | d->selectedFiles->removeSelected(); | 438 | d->selectedFiles->removeSelected(); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | void PlayListWidget::addAllToList() { | 442 | void PlayListWidget::addAllToList() { |
443 | DocLnkSet filesAll; | 443 | DocLnkSet filesAll; |
444 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 444 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
445 | QListIterator<DocLnk> Adit( filesAll.children() ); | 445 | QListIterator<DocLnk> Adit( filesAll.children() ); |
446 | for ( ; Adit.current(); ++Adit ) | 446 | for ( ; Adit.current(); ++Adit ) |
447 | if(QFileInfo(Adit.current()->file()).exists()) | 447 | if(QFileInfo(Adit.current()->file()).exists()) |
448 | d->selectedFiles->addToSelection( **Adit ); | 448 | d->selectedFiles->addToSelection( **Adit ); |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void PlayListWidget::addAllMusicToList() { | 452 | void PlayListWidget::addAllMusicToList() { |
453 | QListIterator<DocLnk> dit( files.children() ); | 453 | QListIterator<DocLnk> dit( files.children() ); |
454 | for ( ; dit.current(); ++dit ) | 454 | for ( ; dit.current(); ++dit ) |
455 | if(QFileInfo(dit.current()->file()).exists()) | 455 | if(QFileInfo(dit.current()->file()).exists()) |
456 | d->selectedFiles->addToSelection( **dit ); | 456 | d->selectedFiles->addToSelection( **dit ); |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | void PlayListWidget::addAllVideoToList() { | 460 | void PlayListWidget::addAllVideoToList() { |
461 | QListIterator<DocLnk> dit( vFiles.children() ); | 461 | QListIterator<DocLnk> dit( vFiles.children() ); |
462 | for ( ; dit.current(); ++dit ) | 462 | for ( ; dit.current(); ++dit ) |
463 | if(QFileInfo( dit.current()->file()).exists()) | 463 | if(QFileInfo( dit.current()->file()).exists()) |
464 | d->selectedFiles->addToSelection( **dit ); | 464 | d->selectedFiles->addToSelection( **dit ); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | void PlayListWidget::setDocument(const QString& fileref) { | 468 | void PlayListWidget::setDocument(const QString& fileref) { |
469 | qDebug(fileref); | 469 | qDebug(fileref); |
470 | fromSetDocument = TRUE; | 470 | fromSetDocument = TRUE; |
471 | if ( fileref.isNull() ) { | 471 | if ( fileref.isNull() ) { |
472 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 472 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
473 | return; | 473 | return; |
474 | } | 474 | } |
475 | // qDebug("setDocument "+fileref); | 475 | // qDebug("setDocument "+fileref); |
476 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 476 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
477 | readm3u( fileref); | 477 | readm3u( fileref); |
478 | } | 478 | } |
479 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 479 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
480 | readPls( fileref); | 480 | readPls( fileref); |
481 | } | 481 | } |
482 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 482 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
483 | clearList(); | 483 | clearList(); |
484 | loadList(DocLnk(fileref)); | 484 | loadList(DocLnk(fileref)); |
485 | d->selectedFiles->first(); | 485 | d->selectedFiles->first(); |
486 | } else { | 486 | } else { |
487 | clearList(); | 487 | clearList(); |
488 | addToSelection( DocLnk( fileref ) ); | 488 | addToSelection( DocLnk( fileref ) ); |
489 | d->setDocumentUsed = TRUE; | 489 | d->setDocumentUsed = TRUE; |
490 | mediaPlayerState->setPlaying( FALSE ); | 490 | mediaPlayerState->setPlaying( FALSE ); |
491 | qApp->processEvents(); | 491 | qApp->processEvents(); |
492 | mediaPlayerState->setPlaying( TRUE ); | 492 | mediaPlayerState->setPlaying( TRUE ); |
493 | qApp->processEvents(); | 493 | qApp->processEvents(); |
494 | setCaption(tr("OpiePlayer")); | 494 | setCaption(tr("OpiePlayer")); |
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | void PlayListWidget::setActiveWindow() { | 499 | void PlayListWidget::setActiveWindow() { |
500 | // When we get raised we need to ensure that it switches views | 500 | // When we get raised we need to ensure that it switches views |
501 | char origView = mediaPlayerState->view(); | 501 | char origView = mediaPlayerState->view(); |
502 | mediaPlayerState->setView( 'l' ); // invalidate | 502 | mediaPlayerState->setView( 'l' ); // invalidate |
503 | mediaPlayerState->setView( origView ); // now switch back | 503 | mediaPlayerState->setView( origView ); // now switch back |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void PlayListWidget::useSelectedDocument() { | 507 | void PlayListWidget::useSelectedDocument() { |
508 | d->setDocumentUsed = FALSE; | 508 | d->setDocumentUsed = FALSE; |
509 | } | 509 | } |
510 | 510 | ||
511 | 511 | ||
512 | const DocLnk *PlayListWidget::current() { // this is fugly | 512 | const DocLnk *PlayListWidget::current() { // this is fugly |
513 | 513 | ||
514 | // if( fromSetDocument) { | 514 | // if( fromSetDocument) { |
515 | // qDebug("from setDoc"); | 515 | // qDebug("from setDoc"); |
516 | // DocLnkSet files; | 516 | // DocLnkSet files; |
517 | // Global::findDocuments(&files, "video/*;audio/*"); | 517 | // Global::findDocuments(&files, "video/*;audio/*"); |
518 | // QListIterator<DocLnk> dit( files.children() ); | 518 | // QListIterator<DocLnk> dit( files.children() ); |
519 | // for ( ; dit.current(); ++dit ) { | 519 | // for ( ; dit.current(); ++dit ) { |
520 | // if(dit.current()->linkFile() == setDocFileRef) { | 520 | // if(dit.current()->linkFile() == setDocFileRef) { |
521 | // qDebug(setDocFileRef); | 521 | // qDebug(setDocFileRef); |
522 | // return dit; | 522 | // return dit; |
523 | // } | 523 | // } |
524 | // } | 524 | // } |
525 | // } else | 525 | // } else |
526 | 526 | ||
527 | 527 | ||
528 | switch (tabWidget->currentPageIndex()) { | 528 | switch (tabWidget->currentPageIndex()) { |
529 | case 0: //playlist | 529 | case 0: //playlist |
530 | { | 530 | { |
531 | qDebug("playlist"); | 531 | qDebug("playlist"); |
532 | if ( mediaPlayerState->playlist() ) { | 532 | if ( mediaPlayerState->playlist() ) { |
533 | return d->selectedFiles->current(); | 533 | return d->selectedFiles->current(); |
534 | } | 534 | } |
535 | else if ( d->setDocumentUsed && d->current ) { | 535 | else if ( d->setDocumentUsed && d->current ) { |
536 | return d->current; | 536 | return d->current; |
537 | } else { | 537 | } else { |
538 | return d->files->selected(); | 538 | return d->files->selected(); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | break; | 541 | break; |
542 | case 1://audio | 542 | case 1://audio |
543 | { | 543 | { |
544 | qDebug("audioView"); | 544 | qDebug("audioView"); |
545 | QListIterator<DocLnk> dit( files.children() ); | 545 | QListIterator<DocLnk> dit( files.children() ); |
546 | for ( ; dit.current(); ++dit ) { | 546 | for ( ; dit.current(); ++dit ) { |
547 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 547 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
548 | qDebug("here"); | 548 | qDebug("here"); |
549 | insanityBool=TRUE; | 549 | insanityBool=TRUE; |
550 | return dit; | 550 | return dit; |
551 | } | 551 | } |
552 | } | 552 | } |
553 | } | 553 | } |
554 | break; | 554 | break; |
555 | case 2: // video | 555 | case 2: // video |
556 | { | 556 | { |
557 | qDebug("videoView"); | 557 | qDebug("videoView"); |
558 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 558 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
559 | for ( ; Vdit.current(); ++Vdit ) { | 559 | for ( ; Vdit.current(); ++Vdit ) { |
560 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 560 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
561 | insanityBool=TRUE; | 561 | insanityBool=TRUE; |
562 | return Vdit; | 562 | return Vdit; |
563 | } | 563 | } |
564 | } | 564 | } |
565 | } | 565 | } |
566 | break; | 566 | break; |
567 | }; | 567 | }; |
568 | return 0; | 568 | return 0; |
569 | } | 569 | } |
570 | 570 | ||
571 | bool PlayListWidget::prev() { | 571 | bool PlayListWidget::prev() { |
572 | if ( mediaPlayerState->playlist() ) { | 572 | if ( mediaPlayerState->playlist() ) { |
573 | if ( mediaPlayerState->shuffled() ) { | 573 | if ( mediaPlayerState->shuffled() ) { |
574 | const DocLnk *cur = current(); | 574 | const DocLnk *cur = current(); |
575 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 575 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
576 | for ( int i = 0; i < j; i++ ) { | 576 | for ( int i = 0; i < j; i++ ) { |
577 | if ( !d->selectedFiles->next() ) | 577 | if ( !d->selectedFiles->next() ) |
578 | d->selectedFiles->first(); | 578 | d->selectedFiles->first(); |
579 | } | 579 | } |
580 | if ( cur == current() ) | 580 | if ( cur == current() ) |
581 | if ( !d->selectedFiles->next() ) | 581 | if ( !d->selectedFiles->next() ) |
582 | d->selectedFiles->first(); | 582 | d->selectedFiles->first(); |
583 | return TRUE; | 583 | return TRUE; |
584 | } else { | 584 | } else { |
585 | if ( !d->selectedFiles->prev() ) { | 585 | if ( !d->selectedFiles->prev() ) { |
586 | if ( mediaPlayerState->looping() ) { | 586 | if ( mediaPlayerState->looping() ) { |
587 | return d->selectedFiles->last(); | 587 | return d->selectedFiles->last(); |
588 | } else { | 588 | } else { |
589 | return FALSE; | 589 | return FALSE; |
590 | } | 590 | } |
591 | } | 591 | } |
592 | return TRUE; | 592 | return TRUE; |
593 | } | 593 | } |
594 | } else { | 594 | } else { |
595 | return mediaPlayerState->looping(); | 595 | return mediaPlayerState->looping(); |
596 | } | 596 | } |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | bool PlayListWidget::next() { | 600 | bool PlayListWidget::next() { |
601 | if ( mediaPlayerState->playlist() ) { | 601 | if ( mediaPlayerState->playlist() ) { |
602 | if ( mediaPlayerState->shuffled() ) { | 602 | if ( mediaPlayerState->shuffled() ) { |
603 | return prev(); | 603 | return prev(); |
604 | } else { | 604 | } else { |
605 | if ( !d->selectedFiles->next() ) { | 605 | if ( !d->selectedFiles->next() ) { |
606 | if ( mediaPlayerState->looping() ) { | 606 | if ( mediaPlayerState->looping() ) { |
607 | return d->selectedFiles->first(); | 607 | return d->selectedFiles->first(); |
608 | } else { | 608 | } else { |
609 | return FALSE; | 609 | return FALSE; |
610 | } | 610 | } |
611 | } | 611 | } |
612 | return TRUE; | 612 | return TRUE; |
613 | } | 613 | } |
614 | } else { | 614 | } else { |
615 | return mediaPlayerState->looping(); | 615 | return mediaPlayerState->looping(); |
616 | } | 616 | } |
617 | } | 617 | } |
618 | 618 | ||
619 | 619 | ||
620 | bool PlayListWidget::first() { | 620 | bool PlayListWidget::first() { |
621 | if ( mediaPlayerState->playlist() ) | 621 | if ( mediaPlayerState->playlist() ) |
622 | return d->selectedFiles->first(); | 622 | return d->selectedFiles->first(); |
623 | else | 623 | else |
624 | return mediaPlayerState->looping(); | 624 | return mediaPlayerState->looping(); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | bool PlayListWidget::last() { | 628 | bool PlayListWidget::last() { |
629 | if ( mediaPlayerState->playlist() ) | 629 | if ( mediaPlayerState->playlist() ) |
630 | return d->selectedFiles->last(); | 630 | return d->selectedFiles->last(); |
631 | else | 631 | else |
632 | return mediaPlayerState->looping(); | 632 | return mediaPlayerState->looping(); |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | void PlayListWidget::saveList() { | 636 | void PlayListWidget::saveList() { |
637 | 637 | ||
638 | QString filename; | 638 | QString filename; |
639 | InputDialog *fileDlg; | 639 | InputDialog *fileDlg; |
640 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 640 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
641 | fileDlg->exec(); | 641 | fileDlg->exec(); |
642 | if( fileDlg->result() == 1 ) { | 642 | if( fileDlg->result() == 1 ) { |
643 | if ( d->current ) | 643 | if ( d->current ) |
644 | delete d->current; | 644 | delete d->current; |
645 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 645 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
646 | // qDebug("saving playlist "+filename+".playlist"); | 646 | // qDebug("saving playlist "+filename+".playlist"); |
647 | Config cfg( filename +".playlist"); | 647 | Config cfg( filename +".playlist"); |
648 | writeConfig( cfg ); | 648 | writeConfig( cfg ); |
649 | 649 | ||
650 | DocLnk lnk; | 650 | DocLnk lnk; |
651 | // lnk.setComment( ""); | 651 | // lnk.setComment( ""); |
652 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 652 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
653 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 653 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
654 | lnk.setIcon("opieplayer/playlist2"); | 654 | lnk.setIcon("opieplayer/playlist2"); |
655 | lnk.setName( filename); //sets file name | 655 | lnk.setName( filename); //sets file name |
656 | // qDebug(filename); | 656 | // qDebug(filename); |
657 | if(!lnk.writeLink()) | 657 | if(!lnk.writeLink()) |
658 | qDebug("Writing doclink did not work"); | 658 | qDebug("Writing doclink did not work"); |
659 | } | 659 | } |
660 | Config config( "OpiePlayer" ); | 660 | Config config( "OpiePlayer" ); |
661 | config.writeEntry("CurrentPlaylist",filename); | 661 | config.writeEntry("CurrentPlaylist",filename); |
662 | setCaption(tr("OpiePlayer: ")+filename); | 662 | setCaption(tr("OpiePlayer: ")+filename); |
663 | d->selectedFiles->first(); | 663 | d->selectedFiles->first(); |
664 | if(fileDlg) | 664 | if(fileDlg) |
665 | delete fileDlg; | 665 | delete fileDlg; |
666 | } | 666 | } |
667 | 667 | ||
668 | void PlayListWidget::loadList( const DocLnk & lnk) { | 668 | void PlayListWidget::loadList( const DocLnk & lnk) { |
669 | QString name= lnk.name(); | 669 | QString name= lnk.name(); |
670 | // qDebug("currentList is "+name); | 670 | // qDebug("currentList is "+name); |
671 | if( name.length()>1) { | 671 | if( name.length()>1) { |
672 | setCaption("OpiePlayer: "+name); | 672 | setCaption("OpiePlayer: "+name); |
673 | // qDebug("load list "+ name+".playlist"); | 673 | // qDebug("load list "+ name+".playlist"); |
674 | clearList(); | 674 | clearList(); |
675 | Config cfg( name+".playlist"); | 675 | Config cfg( name+".playlist"); |
676 | readConfig(cfg); | 676 | readConfig(cfg); |
677 | 677 | ||
678 | tabWidget->setCurrentPage(0); | 678 | tabWidget->setCurrentPage(0); |
679 | 679 | ||
680 | Config config( "OpiePlayer" ); | 680 | Config config( "OpiePlayer" ); |
681 | config.writeEntry("CurrentPlaylist", name); | 681 | config.writeEntry("CurrentPlaylist", name); |
682 | // d->selectedFiles->first(); | 682 | // d->selectedFiles->first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | } | 685 | } |
686 | 686 | ||
687 | void PlayListWidget::setPlaylist( bool shown ) { | 687 | void PlayListWidget::setPlaylist( bool shown ) { |
688 | if ( shown ) | 688 | if ( shown ) |
689 | d->playListFrame->show(); | 689 | d->playListFrame->show(); |
690 | else | 690 | else |
691 | d->playListFrame->hide(); | 691 | d->playListFrame->hide(); |
692 | } | 692 | } |
693 | 693 | ||
694 | void PlayListWidget::setView( char view ) { | 694 | void PlayListWidget::setView( char view ) { |
695 | if ( view == 'l' ) | 695 | if ( view == 'l' ) |
696 | showMaximized(); | 696 | showMaximized(); |
697 | else | 697 | else |
698 | hide(); | 698 | hide(); |
699 | } | 699 | } |
700 | 700 | ||
701 | void PlayListWidget::addSelected() { | 701 | void PlayListWidget::addSelected() { |
702 | 702 | ||
703 | Config cfg( "OpiePlayer" ); | 703 | Config cfg( "OpiePlayer" ); |
704 | cfg.setGroup("PlayList"); | 704 | cfg.setGroup("PlayList"); |
705 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 705 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
706 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 706 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
707 | 707 | ||
708 | switch (tabWidget->currentPageIndex()) { | 708 | switch (tabWidget->currentPageIndex()) { |
709 | case 0: //playlist | 709 | case 0: //playlist |
710 | break; | 710 | break; |
711 | case 1: { //audio | 711 | case 1: { //audio |
712 | // QString entryName; | 712 | // QString entryName; |
713 | // entryName.sprintf( "File%i", i + 1 ); | 713 | // entryName.sprintf( "File%i", i + 1 ); |
714 | // QString linkFile = cfg.readEntry( entryName ); | 714 | // QString linkFile = cfg.readEntry( entryName ); |
715 | QListViewItemIterator it( audioView ); | 715 | QListViewItemIterator it( audioView ); |
716 | // iterate through all items of the listview | 716 | // iterate through all items of the listview |
717 | for ( ; it.current(); ++it ) { | 717 | for ( ; it.current(); ++it ) { |
718 | if ( it.current()->isSelected() ) { | 718 | if ( it.current()->isSelected() ) { |
719 | QListIterator<DocLnk> dit( files.children() ); | 719 | QListIterator<DocLnk> dit( files.children() ); |
720 | for ( ; dit.current(); ++dit ) { | 720 | for ( ; dit.current(); ++dit ) { |
721 | if( dit.current()->name() == it.current()->text(0) ) { | 721 | if( dit.current()->name() == it.current()->text(0) ) { |
722 | d->selectedFiles->addToSelection( **dit ); | 722 | d->selectedFiles->addToSelection( **dit ); |
723 | } | 723 | } |
724 | } | 724 | } |
725 | audioView->setSelected( it.current(),FALSE); | 725 | audioView->setSelected( it.current(),FALSE); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | tabWidget->setCurrentPage(0); | 728 | tabWidget->setCurrentPage(0); |
729 | } | 729 | } |
730 | break; | 730 | break; |
731 | case 2: { // video | 731 | case 2: { // video |
732 | QListViewItemIterator it( videoView ); | 732 | QListViewItemIterator it( videoView ); |
733 | // iterate through all items of the listview | 733 | // iterate through all items of the listview |
734 | for ( ; it.current(); ++it ) { | 734 | for ( ; it.current(); ++it ) { |
735 | if ( it.current()->isSelected() ) { | 735 | if ( it.current()->isSelected() ) { |
736 | QListIterator<DocLnk> dit( vFiles.children() ); | 736 | QListIterator<DocLnk> dit( vFiles.children() ); |
737 | for ( ; dit.current(); ++dit ) { | 737 | for ( ; dit.current(); ++dit ) { |
738 | if( dit.current()->name() == it.current()->text(0) ) { | 738 | if( dit.current()->name() == it.current()->text(0) ) { |
739 | d->selectedFiles->addToSelection( **dit ); | 739 | d->selectedFiles->addToSelection( **dit ); |
740 | } | 740 | } |
741 | } | 741 | } |
742 | 742 | ||
743 | videoView->setSelected( it.current(),FALSE); | 743 | videoView->setSelected( it.current(),FALSE); |
744 | } | 744 | } |
745 | } | 745 | } |
746 | // for ( int i = 0; i < noOfFiles; i++ ) { | 746 | // for ( int i = 0; i < noOfFiles; i++ ) { |
747 | // QString entryName; | 747 | // QString entryName; |
748 | // entryName.sprintf( "File%i", i + 1 ); | 748 | // entryName.sprintf( "File%i", i + 1 ); |
749 | // QString linkFile = cfg.readEntry( entryName ); | 749 | // QString linkFile = cfg.readEntry( entryName ); |
750 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 750 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
751 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | 751 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), |
752 | // tr("This is all ready in your playlist.\nContinue?"), | 752 | // tr("This is all ready in your playlist.\nContinue?"), |
753 | // tr("Yes"),tr("No"),0,0,1); | 753 | // tr("Yes"),tr("No"),0,0,1); |
754 | // if (result !=0) | 754 | // if (result !=0) |
755 | // return; | 755 | // return; |
756 | // } | 756 | // } |
757 | // } | 757 | // } |
758 | // addToSelection( videoView->selectedItem() ); | 758 | // addToSelection( videoView->selectedItem() ); |
759 | tabWidget->setCurrentPage(0); | 759 | tabWidget->setCurrentPage(0); |
760 | } | 760 | } |
761 | break; | 761 | break; |
762 | }; | 762 | }; |
763 | } | 763 | } |
764 | 764 | ||
765 | void PlayListWidget::removeSelected() { | 765 | void PlayListWidget::removeSelected() { |
766 | d->selectedFiles->removeSelected( ); | 766 | d->selectedFiles->removeSelected( ); |
767 | } | 767 | } |
768 | 768 | ||
769 | void PlayListWidget::playIt( QListViewItem *it) { | 769 | void PlayListWidget::playIt( QListViewItem *it) { |
770 | // d->setDocumentUsed = FALSE; | 770 | // d->setDocumentUsed = FALSE; |
771 | // mediaPlayerState->curPosition =0; | 771 | // mediaPlayerState->curPosition =0; |
772 | qDebug("playIt"); | 772 | qDebug("playIt"); |
773 | mediaPlayerState->setPlaying(FALSE); | 773 | mediaPlayerState->setPlaying(FALSE); |
774 | mediaPlayerState->setPlaying(TRUE); | 774 | mediaPlayerState->setPlaying(TRUE); |
775 | d->selectedFiles->unSelect(); | 775 | d->selectedFiles->unSelect(); |
776 | } | 776 | } |
777 | 777 | ||
778 | void PlayListWidget::addToSelection( QListViewItem *it) { | 778 | void PlayListWidget::addToSelection( QListViewItem *it) { |
779 | d->setDocumentUsed = FALSE; | 779 | d->setDocumentUsed = FALSE; |
780 | 780 | ||
781 | if(it) { | 781 | if(it) { |
782 | switch (tabWidget->currentPageIndex()) { | 782 | switch (tabWidget->currentPageIndex()) { |
783 | case 1: { | 783 | case 1: { |
784 | QListIterator<DocLnk> dit( files.children() ); | 784 | QListIterator<DocLnk> dit( files.children() ); |
785 | for ( ; dit.current(); ++dit ) { | 785 | for ( ; dit.current(); ++dit ) { |
786 | if( dit.current()->name() == it->text(0)) { | 786 | if( dit.current()->name() == it->text(0)) { |
787 | d->selectedFiles->addToSelection( **dit ); | 787 | d->selectedFiles->addToSelection( **dit ); |
788 | } | 788 | } |
789 | } | 789 | } |
790 | } | 790 | } |
791 | break; | 791 | break; |
792 | case 2: { | 792 | case 2: { |
793 | QListIterator<DocLnk> dit( vFiles.children() ); | 793 | QListIterator<DocLnk> dit( vFiles.children() ); |
794 | for ( ; dit.current(); ++dit ) { | 794 | for ( ; dit.current(); ++dit ) { |
795 | if( dit.current()->name() == it->text(0)) { | 795 | if( dit.current()->name() == it->text(0)) { |
796 | d->selectedFiles->addToSelection( **dit ); | 796 | d->selectedFiles->addToSelection( **dit ); |
797 | } | 797 | } |
798 | } | 798 | } |
799 | } | 799 | } |
800 | break; | 800 | break; |
801 | case 0: | 801 | case 0: |
802 | break; | 802 | break; |
803 | }; | 803 | }; |
804 | tabWidget->setCurrentPage(0); | 804 | tabWidget->setCurrentPage(0); |
805 | } | 805 | } |
806 | } | 806 | } |
807 | 807 | ||
808 | void PlayListWidget::tabChanged(QWidget *widg) { | 808 | void PlayListWidget::tabChanged(QWidget *widg) { |
809 | 809 | ||
810 | switch ( tabWidget->currentPageIndex()) { | 810 | switch ( tabWidget->currentPageIndex()) { |
811 | case 0: | 811 | case 0: |
812 | { | 812 | { |
813 | if( !tbDeletePlaylist->isHidden()) | 813 | if( !tbDeletePlaylist->isHidden()) |
814 | tbDeletePlaylist->hide(); | 814 | tbDeletePlaylist->hide(); |
815 | d->tbRemoveFromList->setEnabled(TRUE); | 815 | d->tbRemoveFromList->setEnabled(TRUE); |
816 | d->tbAddToList->setEnabled(FALSE); | 816 | d->tbAddToList->setEnabled(FALSE); |
817 | } | 817 | } |
818 | break; | 818 | break; |
819 | case 1: | 819 | case 1: |
820 | { | 820 | { |
821 | audioView->clear(); | 821 | audioView->clear(); |
822 | populateAudioView(); | 822 | populateAudioView(); |
823 | 823 | ||
824 | if( !tbDeletePlaylist->isHidden()) | 824 | if( !tbDeletePlaylist->isHidden()) |
825 | tbDeletePlaylist->hide(); | 825 | tbDeletePlaylist->hide(); |
826 | d->tbRemoveFromList->setEnabled(FALSE); | 826 | d->tbRemoveFromList->setEnabled(FALSE); |
827 | d->tbAddToList->setEnabled(TRUE); | 827 | d->tbAddToList->setEnabled(TRUE); |
828 | } | 828 | } |
829 | break; | 829 | break; |
830 | case 2: | 830 | case 2: |
831 | { | 831 | { |
832 | videoView->clear(); | 832 | videoView->clear(); |
833 | populateVideoView(); | 833 | populateVideoView(); |
834 | if( !tbDeletePlaylist->isHidden()) | 834 | if( !tbDeletePlaylist->isHidden()) |
835 | tbDeletePlaylist->hide(); | 835 | tbDeletePlaylist->hide(); |
836 | d->tbRemoveFromList->setEnabled(FALSE); | 836 | d->tbRemoveFromList->setEnabled(FALSE); |
837 | d->tbAddToList->setEnabled(TRUE); | 837 | d->tbAddToList->setEnabled(TRUE); |
838 | } | 838 | } |
839 | break; | 839 | break; |
840 | case 3: | 840 | case 3: |
841 | { | 841 | { |
842 | if( tbDeletePlaylist->isHidden()) | 842 | if( tbDeletePlaylist->isHidden()) |
843 | tbDeletePlaylist->show(); | 843 | tbDeletePlaylist->show(); |
844 | playLists->reread(); | 844 | playLists->reread(); |
845 | } | 845 | } |
846 | break; | 846 | break; |
847 | }; | 847 | }; |
848 | } | 848 | } |
849 | 849 | ||
850 | void PlayListWidget::btnPlay(bool b) { | 850 | void PlayListWidget::btnPlay(bool b) { |
851 | 851 | ||
852 | // mediaPlayerState->setPlaying(b); | 852 | // mediaPlayerState->setPlaying(b); |
853 | switch ( tabWidget->currentPageIndex()) { | 853 | switch ( tabWidget->currentPageIndex()) { |
854 | case 0: | 854 | case 0: |
855 | { | 855 | { |
856 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 856 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
857 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 857 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
858 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 858 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
859 | // } else { | 859 | // } else { |
860 | mediaPlayerState->setPlaying(b); | 860 | mediaPlayerState->setPlaying(b); |
861 | // } | 861 | // } |
862 | } | 862 | } |
863 | break; | 863 | break; |
864 | case 1: | 864 | case 1: |
865 | { | 865 | { |
866 | addToSelection( audioView->currentItem() ); | 866 | addToSelection( audioView->currentItem() ); |
867 | mediaPlayerState->setPlaying(b); | 867 | mediaPlayerState->setPlaying(b); |
868 | d->selectedFiles->removeSelected( ); | 868 | d->selectedFiles->removeSelected( ); |
869 | tabWidget->setCurrentPage(1); | 869 | tabWidget->setCurrentPage(1); |
870 | d->selectedFiles->unSelect(); | 870 | d->selectedFiles->unSelect(); |
871 | insanityBool=FALSE; | 871 | insanityBool=FALSE; |
872 | }// audioView->clearSelection(); | 872 | }// audioView->clearSelection(); |
873 | break; | 873 | break; |
874 | case 2: | 874 | case 2: |
875 | { | 875 | { |
876 | addToSelection( videoView->currentItem() ); | 876 | addToSelection( videoView->currentItem() ); |
877 | mediaPlayerState->setPlaying(b); | 877 | mediaPlayerState->setPlaying(b); |
878 | qApp->processEvents(); | 878 | qApp->processEvents(); |
879 | d->selectedFiles->removeSelected( ); | 879 | d->selectedFiles->removeSelected( ); |
880 | tabWidget->setCurrentPage(2); | 880 | tabWidget->setCurrentPage(2); |
881 | d->selectedFiles->unSelect(); | 881 | d->selectedFiles->unSelect(); |
882 | insanityBool=FALSE; | 882 | insanityBool=FALSE; |
883 | }// videoView->clearSelection(); | 883 | }// videoView->clearSelection(); |
884 | break; | 884 | break; |
885 | }; | 885 | }; |
886 | 886 | ||
887 | } | 887 | } |
888 | 888 | ||
889 | void PlayListWidget::deletePlaylist() { | 889 | void PlayListWidget::deletePlaylist() { |
890 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 890 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
891 | (tr("You really want to delete\nthis playlist?")), | 891 | (tr("You really want to delete\nthis playlist?")), |
892 | (tr("Yes")), (tr("No")), 0 )){ | 892 | (tr("Yes")), (tr("No")), 0 )){ |
893 | case 0: // Yes clicked, | 893 | case 0: // Yes clicked, |
894 | QFile().remove(playLists->selected()->file()); | 894 | QFile().remove(playLists->selected()->file()); |
895 | QFile().remove(playLists->selected()->linkFile()); | 895 | QFile().remove(playLists->selected()->linkFile()); |
896 | playLists->reread(); | 896 | playLists->reread(); |
897 | break; | 897 | break; |
898 | case 1: // Cancel | 898 | case 1: // Cancel |
899 | break; | 899 | break; |
900 | }; | 900 | }; |
901 | } | 901 | } |
902 | 902 | ||
903 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 903 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
904 | { | 904 | { |
905 | switch (mouse) { | 905 | switch (mouse) { |
906 | case 1: | 906 | case 1: |
907 | break; | 907 | break; |
908 | case 2:{ | 908 | case 2:{ |
909 | 909 | ||
910 | QPopupMenu m; | 910 | QPopupMenu m; |
911 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 911 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
912 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 912 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
913 | m.insertSeparator(); | 913 | m.insertSeparator(); |
914 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 914 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
915 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 915 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
916 | 916 | ||
917 | m.exec( QCursor::pos() ); | 917 | m.exec( QCursor::pos() ); |
918 | } | 918 | } |
919 | break; | 919 | break; |
920 | }; | 920 | }; |
921 | } | 921 | } |
922 | 922 | ||
923 | void PlayListWidget::playSelected() | 923 | void PlayListWidget::playSelected() |
924 | { | 924 | { |
925 | btnPlay( TRUE); | 925 | btnPlay( TRUE); |
926 | // d->selectedFiles->unSelect(); | 926 | // d->selectedFiles->unSelect(); |
927 | } | 927 | } |
928 | 928 | ||
929 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 929 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
930 | { | 930 | { |
931 | switch (mouse) { | 931 | switch (mouse) { |
932 | case 1: | 932 | case 1: |
933 | 933 | ||
934 | break; | 934 | break; |
935 | case 2:{ | 935 | case 2:{ |
936 | QPopupMenu m; | 936 | QPopupMenu m; |
937 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 937 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
938 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 938 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
939 | // m.insertSeparator(); | 939 | // m.insertSeparator(); |
940 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 940 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
941 | m.exec( QCursor::pos() ); | 941 | m.exec( QCursor::pos() ); |
942 | } | 942 | } |
943 | break; | 943 | break; |
944 | }; | 944 | }; |
945 | 945 | ||
946 | } | 946 | } |
947 | 947 | ||
948 | void PlayListWidget::listDelete() { | 948 | void PlayListWidget::listDelete() { |
949 | Config cfg( "OpiePlayer" ); | 949 | Config cfg( "OpiePlayer" ); |
950 | cfg.setGroup("PlayList"); | 950 | cfg.setGroup("PlayList"); |
951 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 951 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
952 | QString file; | 952 | QString file; |
953 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 953 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
954 | switch ( tabWidget->currentPageIndex()) { | 954 | switch ( tabWidget->currentPageIndex()) { |
955 | case 0: | 955 | case 0: |
956 | break; | 956 | break; |
957 | case 1: | 957 | case 1: |
958 | { | 958 | { |
959 | file = audioView->selectedItem()->text(0); | 959 | file = audioView->selectedItem()->text(0); |
960 | // Global::findDocuments(&files, "audio/*"); | 960 | // Global::findDocuments(&files, "audio/*"); |
961 | // AppLnkSet appFiles; | 961 | // AppLnkSet appFiles; |
962 | QListIterator<DocLnk> dit( files.children() ); | 962 | QListIterator<DocLnk> dit( files.children() ); |
963 | for ( ; dit.current(); ++dit ) { | 963 | for ( ; dit.current(); ++dit ) { |
964 | if( dit.current()->name() == file) { | 964 | if( dit.current()->name() == file) { |
965 | // qDebug(file); | 965 | // qDebug(file); |
966 | LnkProperties prop( dit.current() ); | 966 | LnkProperties prop( dit.current() ); |
967 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 967 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
968 | prop.showMaximized(); | 968 | prop.showMaximized(); |
969 | prop.exec(); | 969 | prop.exec(); |
970 | } | 970 | } |
971 | } | 971 | } |
972 | populateAudioView(); | 972 | populateAudioView(); |
973 | } | 973 | } |
974 | break; | 974 | break; |
975 | case 2: | 975 | case 2: |
976 | { | 976 | { |
977 | // file = videoView->selectedItem()->text(0); | 977 | // file = videoView->selectedItem()->text(0); |
978 | // for ( int i = 0; i < noOfFiles; i++ ) { | 978 | // for ( int i = 0; i < noOfFiles; i++ ) { |
979 | // QString entryName; | 979 | // QString entryName; |
980 | // entryName.sprintf( "File%i", i + 1 ); | 980 | // entryName.sprintf( "File%i", i + 1 ); |
981 | // QString linkFile = cfg.readEntry( entryName ); | 981 | // QString linkFile = cfg.readEntry( entryName ); |
982 | // AppLnk lnk( AppLnk(linkFile)); | 982 | // AppLnk lnk( AppLnk(linkFile)); |
983 | // if( lnk.name() == file ) { | 983 | // if( lnk.name() == file ) { |
984 | // LnkProperties prop( &lnk); | 984 | // LnkProperties prop( &lnk); |
985 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 985 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
986 | // prop.showMaximized(); | 986 | // prop.showMaximized(); |
987 | // prop.exec(); | 987 | // prop.exec(); |
988 | // } | 988 | // } |
989 | // } | 989 | // } |
990 | } | 990 | } |
991 | break; | 991 | break; |
992 | }; | 992 | }; |
993 | } | 993 | } |
994 | 994 | ||
995 | void PlayListWidget::scanForAudio() { | 995 | void PlayListWidget::scanForAudio() { |
996 | qDebug("scan for audio"); | 996 | qDebug("scan for audio"); |
997 | files.detachChildren(); | 997 | files.detachChildren(); |
998 | QListIterator<DocLnk> sdit( files.children() ); | 998 | QListIterator<DocLnk> sdit( files.children() ); |
999 | for ( ; sdit.current(); ++sdit ) { | 999 | for ( ; sdit.current(); ++sdit ) { |
1000 | delete sdit.current(); | 1000 | delete sdit.current(); |
1001 | } | 1001 | } |
1002 | Global::findDocuments(&files, "audio/*"); | 1002 | Global::findDocuments(&files, "audio/*"); |
1003 | audioScan = TRUE; | 1003 | audioScan = TRUE; |
1004 | } | 1004 | } |
1005 | void PlayListWidget::scanForVideo() { | 1005 | void PlayListWidget::scanForVideo() { |
1006 | qDebug("scan for video"); | 1006 | qDebug("scan for video"); |
1007 | vFiles.detachChildren(); | 1007 | vFiles.detachChildren(); |
1008 | QListIterator<DocLnk> sdit( vFiles.children() ); | 1008 | QListIterator<DocLnk> sdit( vFiles.children() ); |
1009 | for ( ; sdit.current(); ++sdit ) { | 1009 | for ( ; sdit.current(); ++sdit ) { |
1010 | delete sdit.current(); | 1010 | delete sdit.current(); |
1011 | } | 1011 | } |
1012 | Global::findDocuments(&vFiles, "video/*"); | 1012 | Global::findDocuments(&vFiles, "video/*"); |
1013 | videoScan = TRUE; | 1013 | videoScan = TRUE; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | void PlayListWidget::populateAudioView() { | 1016 | void PlayListWidget::populateAudioView() { |
1017 | 1017 | ||
1018 | audioView->clear(); | 1018 | audioView->clear(); |
1019 | StorageInfo storageInfo; | 1019 | StorageInfo storageInfo; |
1020 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1020 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1021 | if(!audioScan) scanForAudio(); | 1021 | if(!audioScan) scanForAudio(); |
1022 | 1022 | ||
1023 | QListIterator<DocLnk> dit( files.children() ); | 1023 | QListIterator<DocLnk> dit( files.children() ); |
1024 | QListIterator<FileSystem> it ( fs ); | 1024 | QListIterator<FileSystem> it ( fs ); |
1025 | 1025 | ||
1026 | QString storage; | 1026 | QString storage; |
1027 | for ( ; dit.current(); ++dit ) { | 1027 | for ( ; dit.current(); ++dit ) { |
1028 | for( ; it.current(); ++it ){ | 1028 | for( ; it.current(); ++it ){ |
1029 | const QString name = (*it)->name(); | 1029 | const QString name = (*it)->name(); |
1030 | const QString path = (*it)->path(); | 1030 | const QString path = (*it)->path(); |
1031 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1031 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | QListViewItem * newItem; | 1034 | QListViewItem * newItem; |
1035 | if ( QFile( dit.current()->file()).exists() ) { | 1035 | if ( QFile( dit.current()->file()).exists() ) { |
1036 | // qDebug(dit.current()->name()); | 1036 | // qDebug(dit.current()->name()); |
1037 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1037 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1038 | QString::number( QFile( dit.current()->file()).size() ), storage); | 1038 | QString::number( QFile( dit.current()->file()).size() ), storage); |
1039 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1039 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void PlayListWidget::populateVideoView() { | 1045 | void PlayListWidget::populateVideoView() { |
1046 | videoView->clear(); | 1046 | videoView->clear(); |
1047 | StorageInfo storageInfo; | 1047 | StorageInfo storageInfo; |
1048 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1048 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1049 | 1049 | ||
1050 | if(!videoScan ) scanForVideo(); | 1050 | if(!videoScan ) scanForVideo(); |
1051 | 1051 | ||
1052 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1052 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1053 | QListIterator<FileSystem> it ( fs ); | 1053 | QListIterator<FileSystem> it ( fs ); |
1054 | videoView->clear(); | 1054 | videoView->clear(); |
1055 | QString storage; | 1055 | QString storage; |
1056 | for ( ; Vdit.current(); ++Vdit ) { | 1056 | for ( ; Vdit.current(); ++Vdit ) { |
1057 | for( ; it.current(); ++it ){ | 1057 | for( ; it.current(); ++it ){ |
1058 | const QString name = (*it)->name(); | 1058 | const QString name = (*it)->name(); |
1059 | const QString path = (*it)->path(); | 1059 | const QString path = (*it)->path(); |
1060 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1060 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | QListViewItem * newItem; | 1063 | QListViewItem * newItem; |
1064 | if ( QFile( Vdit.current()->file()).exists() ) { | 1064 | if ( QFile( Vdit.current()->file()).exists() ) { |
1065 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1065 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1066 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1066 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1067 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1067 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void PlayListWidget::openFile() { | 1072 | void PlayListWidget::openFile() { |
1073 | QString filename, name; | 1073 | QString filename, name; |
1074 | InputDialog *fileDlg; | 1074 | InputDialog *fileDlg; |
1075 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1075 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1076 | fileDlg->exec(); | 1076 | fileDlg->exec(); |
1077 | if( fileDlg->result() == 1 ) { | 1077 | if( fileDlg->result() == 1 ) { |
1078 | filename = fileDlg->LineEdit1->text(); | 1078 | filename = fileDlg->LineEdit1->text(); |
1079 | // http://205.188.234.129:8030 | 1079 | // http://205.188.234.129:8030 |
1080 | // http://66.28.68.70:8000 | 1080 | // http://66.28.68.70:8000 |
1081 | // filename.replace(QRegExp("%20")," "); | 1081 | // filename.replace(QRegExp("%20")," "); |
1082 | if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) { | 1082 | if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) { |
1083 | QMessageBox::message("Note","Spaces in urls are not allowed."); | 1083 | QMessageBox::message("Note","Spaces in urls are not allowed."); |
1084 | return; | 1084 | return; |
1085 | } else { | 1085 | } else { |
1086 | qDebug("Selected filename is "+filename); | 1086 | qDebug("Selected filename is "+filename); |
1087 | if(filename.right(3) == "m3u") | 1087 | if(filename.right(3) == "m3u") |
1088 | readm3u( filename); | 1088 | readm3u( filename); |
1089 | else if(filename.right(3) == "pls") | 1089 | else if(filename.right(3) == "pls") |
1090 | readPls( filename); | 1090 | readPls( filename); |
1091 | else { | 1091 | else { |
1092 | DocLnk lnk; | 1092 | DocLnk lnk; |
1093 | 1093 | ||
1094 | lnk.setName(filename); //sets file name | 1094 | lnk.setName(filename); //sets file name |
1095 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1095 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1096 | filename += "/"; | 1096 | filename += "/"; |
1097 | lnk.setFile(filename); //sets File property | 1097 | lnk.setFile(filename); //sets File property |
1098 | 1098 | ||
1099 | lnk.setType("audio/x-mpegurl"); | 1099 | lnk.setType("audio/x-mpegurl"); |
1100 | lnk.setExec("opieplayer"); | 1100 | lnk.setExec("opieplayer"); |
1101 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1101 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1102 | 1102 | ||
1103 | if(!lnk.writeLink()) | 1103 | if(!lnk.writeLink()) |
1104 | qDebug("Writing doclink did not work"); | 1104 | qDebug("Writing doclink did not work"); |
1105 | d->selectedFiles->addToSelection( lnk); | 1105 | d->selectedFiles->addToSelection( lnk); |
1106 | // if(fileDlg2) | 1106 | // if(fileDlg2) |
1107 | // delete fileDlg2; | 1107 | // delete fileDlg2; |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | } | 1110 | } |
1111 | if(fileDlg) | 1111 | if(fileDlg) |
1112 | delete fileDlg; | 1112 | delete fileDlg; |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1115 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1116 | { | 1116 | { |
1117 | switch ( e->key() ) { | 1117 | switch ( e->key() ) { |
1118 | ////////////////////////////// Zaurus keys | 1118 | ////////////////////////////// Zaurus keys |
1119 | case Key_F9: //activity | 1119 | case Key_F9: //activity |
1120 | // if(audioUI->isHidden()) | 1120 | // if(audioUI->isHidden()) |
1121 | // audioUI->showMaximized(); | 1121 | // audioUI->showMaximized(); |
1122 | break; | 1122 | break; |
1123 | case Key_F10: //contacts | 1123 | case Key_F10: //contacts |
1124 | // if( videoUI->isHidden()) | 1124 | // if( videoUI->isHidden()) |
1125 | // videoUI->showMaximized(); | 1125 | // videoUI->showMaximized(); |
1126 | break; | 1126 | break; |
1127 | case Key_F11: //menu | 1127 | case Key_F11: //menu |
1128 | break; | 1128 | break; |
1129 | case Key_F12: //home | 1129 | case Key_F12: //home |
1130 | // doBlank(); | 1130 | // doBlank(); |
1131 | break; | 1131 | break; |
1132 | case Key_F13: //mail | 1132 | case Key_F13: //mail |
1133 | // doUnblank(); | 1133 | // doUnblank(); |
1134 | break; | 1134 | break; |
1135 | case Key_Q: //add to playlist | 1135 | case Key_Q: //add to playlist |
1136 | qDebug("Add"); | 1136 | qDebug("Add"); |
1137 | addSelected(); | 1137 | addSelected(); |
1138 | break; | 1138 | break; |
1139 | case Key_R: //remove from playlist | 1139 | case Key_R: //remove from playlist |
1140 | removeSelected(); | 1140 | removeSelected(); |
1141 | break; | 1141 | break; |
1142 | // case Key_P: //play | 1142 | // case Key_P: //play |
1143 | // qDebug("Play"); | 1143 | // qDebug("Play"); |
1144 | // playSelected(); | 1144 | // playSelected(); |
1145 | // break; | 1145 | // break; |
1146 | case Key_Space: | 1146 | case Key_Space: |
1147 | qDebug("Play"); | 1147 | qDebug("Play"); |
1148 | // playSelected(); puh | 1148 | // playSelected(); puh |
1149 | break; | 1149 | break; |
1150 | case Key_1: | 1150 | case Key_1: |
1151 | tabWidget->setCurrentPage(0); | 1151 | tabWidget->setCurrentPage(0); |
1152 | break; | 1152 | break; |
1153 | case Key_2: | 1153 | case Key_2: |
1154 | tabWidget->setCurrentPage(1); | 1154 | tabWidget->setCurrentPage(1); |
1155 | break; | 1155 | break; |
1156 | case Key_3: | 1156 | case Key_3: |
1157 | tabWidget->setCurrentPage(2); | 1157 | tabWidget->setCurrentPage(2); |
1158 | break; | 1158 | break; |
1159 | case Key_4: | 1159 | case Key_4: |
1160 | tabWidget->setCurrentPage(3); | 1160 | tabWidget->setCurrentPage(3); |
1161 | break; | 1161 | break; |
1162 | case Key_Down: | ||
1163 | if ( !d->selectedFiles->next() ) | ||
1164 | d->selectedFiles->first(); | ||
1165 | |||
1166 | break; | ||
1167 | case Key_Up: | ||
1168 | if ( !d->selectedFiles->prev() ) | ||
1169 | d->selectedFiles->last(); | ||
1170 | |||
1171 | break; | ||
1172 | |||
1162 | } | 1173 | } |
1163 | } | 1174 | } |
1164 | 1175 | ||
1165 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1176 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1166 | { | 1177 | { |
1167 | // qDebug("Key press"); | 1178 | // qDebug("Key press"); |
1168 | // switch ( e->key() ) { | 1179 | // switch ( e->key() ) { |
1169 | // ////////////////////////////// Zaurus keys | 1180 | // ////////////////////////////// Zaurus keys |
1170 | // case Key_A: //add to playlist | 1181 | // case Key_A: //add to playlist |
1171 | // qDebug("Add"); | 1182 | // qDebug("Add"); |
1172 | // addSelected(); | 1183 | // addSelected(); |
1173 | // break; | 1184 | // break; |
1174 | // case Key_R: //remove from playlist | 1185 | // case Key_R: //remove from playlist |
1175 | // removeSelected(); | 1186 | // removeSelected(); |
1176 | // break; | 1187 | // break; |
1177 | // case Key_P: //play | 1188 | // case Key_P: //play |
1178 | // qDebug("Play"); | 1189 | // qDebug("Play"); |
1179 | // playSelected(); | 1190 | // playSelected(); |
1180 | // break; | 1191 | // break; |
1181 | // case Key_Space: | 1192 | // case Key_Space: |
1182 | // qDebug("Play"); | 1193 | // qDebug("Play"); |
1183 | // playSelected(); | 1194 | // playSelected(); |
1184 | // break; | 1195 | // break; |
1185 | // } | 1196 | // } |
1186 | } | 1197 | } |
1187 | 1198 | ||
1188 | void PlayListWidget::doBlank() { | 1199 | void PlayListWidget::doBlank() { |
1189 | qDebug("do blanking"); | 1200 | qDebug("do blanking"); |
1190 | fd=open("/dev/fb0",O_RDWR); | 1201 | fd=open("/dev/fb0",O_RDWR); |
1191 | if (fd != -1) { | 1202 | if (fd != -1) { |
1192 | ioctl(fd,FBIOBLANK,1); | 1203 | ioctl(fd,FBIOBLANK,1); |
1193 | // close(fd); | 1204 | // close(fd); |
1194 | } | 1205 | } |
1195 | } | 1206 | } |
1196 | 1207 | ||
1197 | void PlayListWidget::doUnblank() { | 1208 | void PlayListWidget::doUnblank() { |
1198 | // this crashes opieplayer with a segfault | 1209 | // this crashes opieplayer with a segfault |
1199 | // int fd; | 1210 | // int fd; |
1200 | // fd=open("/dev/fb0",O_RDWR); | 1211 | // fd=open("/dev/fb0",O_RDWR); |
1201 | qDebug("do unblanking"); | 1212 | qDebug("do unblanking"); |
1202 | if (fd != -1) { | 1213 | if (fd != -1) { |
1203 | ioctl(fd,FBIOBLANK,0); | 1214 | ioctl(fd,FBIOBLANK,0); |
1204 | close(fd); | 1215 | close(fd); |
1205 | } | 1216 | } |
1206 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1217 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1207 | h <<-3;// v[1]; // -3 Force on | 1218 | h <<-3;// v[1]; // -3 Force on |
1208 | } | 1219 | } |
1209 | 1220 | ||
1210 | void PlayListWidget::readm3u(const QString &filename) { | 1221 | void PlayListWidget::readm3u(const QString &filename) { |
1211 | 1222 | ||
1212 | qDebug("m3u filename is "+filename); | 1223 | qDebug("m3u filename is "+filename); |
1213 | QFile f(filename); | 1224 | QFile f(filename); |
1214 | 1225 | ||
1215 | if(f.open(IO_ReadOnly)) { | 1226 | if(f.open(IO_ReadOnly)) { |
1216 | QTextStream t(&f); | 1227 | QTextStream t(&f); |
1217 | QString s;//, first, second; | 1228 | QString s;//, first, second; |
1218 | int i=0; | 1229 | int i=0; |
1219 | while ( !t.atEnd()) { | 1230 | while ( !t.atEnd()) { |
1220 | // Lview->insertLine(t.readLine(),-1); | 1231 | // Lview->insertLine(t.readLine(),-1); |
1221 | s=t.readLine(); | 1232 | s=t.readLine(); |
1222 | if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { | 1233 | if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { |
1223 | QMessageBox::message("Note","Spaces in urls are not allowed."); | 1234 | QMessageBox::message("Note","Spaces in urls are not allowed."); |
1224 | } | 1235 | } |
1225 | else if(s.find("#",0,TRUE) == -1) { | 1236 | else if(s.find("#",0,TRUE) == -1) { |
1226 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1237 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1227 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1238 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1228 | s=s.right(s.length()-2); | 1239 | s=s.right(s.length()-2); |
1229 | DocLnk lnk( s ); | 1240 | DocLnk lnk( s ); |
1230 | QFileInfo f(s); | 1241 | QFileInfo f(s); |
1231 | QString name = f.baseName(); | 1242 | QString name = f.baseName(); |
1232 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1243 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1233 | lnk.setName( name); | 1244 | lnk.setName( name); |
1234 | s=s.replace( QRegExp("\\"),"/"); | 1245 | s=s.replace( QRegExp("\\"),"/"); |
1235 | lnk.setFile( s); | 1246 | lnk.setFile( s); |
1236 | lnk.writeLink(); | 1247 | lnk.writeLink(); |
1237 | // lnk.setIcon(opieplayer/MPEGPlayer); | 1248 | // lnk.setIcon(opieplayer/MPEGPlayer); |
1238 | qDebug("add "+name); | 1249 | qDebug("add "+name); |
1239 | d->selectedFiles->addToSelection( lnk); | 1250 | d->selectedFiles->addToSelection( lnk); |
1240 | } else { // is url | 1251 | } else { // is url |
1241 | 1252 | ||
1242 | s.replace(QRegExp("%20")," "); | 1253 | s.replace(QRegExp("%20")," "); |
1243 | DocLnk lnk( s); | 1254 | DocLnk lnk( s); |
1244 | QString name; | 1255 | QString name; |
1245 | if(name.left(4)=="http") | 1256 | if(name.left(4)=="http") |
1246 | name = s.right( s.length() - 7); | 1257 | name = s.right( s.length() - 7); |
1247 | else | 1258 | else |
1248 | name=s; | 1259 | name=s; |
1249 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1260 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1250 | lnk.setName(name); | 1261 | lnk.setName(name); |
1251 | if(s.at(s.length()-4) == '.') | 1262 | if(s.at(s.length()-4) == '.') |
1252 | lnk.setFile( s); | 1263 | lnk.setFile( s); |
1253 | else | 1264 | else |
1254 | lnk.setFile( s+"/"); | 1265 | lnk.setFile( s+"/"); |
1255 | // lnk.setFile( filename); | 1266 | // lnk.setFile( filename); |
1256 | // lnk.setComment( s+"/"); | 1267 | // lnk.setComment( s+"/"); |
1257 | lnk.setType("audio/x-mpegurl"); | 1268 | lnk.setType("audio/x-mpegurl"); |
1258 | lnk.writeLink(); | 1269 | lnk.writeLink(); |
1259 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | 1270 | // lnk.setIcon( "opieplayer/MPEGPlayer"); |
1260 | // qDebug("add "+s); | 1271 | // qDebug("add "+s); |
1261 | d->selectedFiles->addToSelection( lnk); | 1272 | d->selectedFiles->addToSelection( lnk); |
1262 | } | 1273 | } |
1263 | i++; | 1274 | i++; |
1264 | } | 1275 | } |
1265 | } | 1276 | } |
1266 | } | 1277 | } |
1267 | } | 1278 | } |
1268 | f.close(); | 1279 | f.close(); |
1269 | } | 1280 | } |
1270 | 1281 | ||
1271 | void PlayListWidget::writem3u() { | 1282 | void PlayListWidget::writem3u() { |
1272 | 1283 | ||
1273 | InputDialog *fileDlg; | 1284 | InputDialog *fileDlg; |
1274 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1285 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1275 | fileDlg->exec(); | 1286 | fileDlg->exec(); |
1276 | QString filename,list; | 1287 | QString filename,list; |
1277 | if( fileDlg->result() == 1 ) { | 1288 | if( fileDlg->result() == 1 ) { |
1278 | filename = fileDlg->LineEdit1->text(); | 1289 | filename = fileDlg->LineEdit1->text(); |
1279 | qDebug(filename); | 1290 | qDebug(filename); |
1280 | int noOfFiles = 0; | 1291 | int noOfFiles = 0; |
1281 | d->selectedFiles->first(); | 1292 | d->selectedFiles->first(); |
1282 | do { | 1293 | do { |
1283 | // we dont check for existance because of url's | 1294 | // we dont check for existance because of url's |
1284 | // qDebug(d->selectedFiles->current()->file()); | 1295 | // qDebug(d->selectedFiles->current()->file()); |
1285 | list += d->selectedFiles->current()->file()+"\n"; | 1296 | list += d->selectedFiles->current()->file()+"\n"; |
1286 | noOfFiles++; | 1297 | noOfFiles++; |
1287 | } | 1298 | } |
1288 | while ( d->selectedFiles->next() ); | 1299 | while ( d->selectedFiles->next() ); |
1289 | qDebug(list); | 1300 | qDebug(list); |
1290 | if(filename.left(1) != "/") | 1301 | if(filename.left(1) != "/") |
1291 | filename=QPEApplication::documentDir()+"/"+filename; | 1302 | filename=QPEApplication::documentDir()+"/"+filename; |
1292 | if(filename.right(3) != "m3u") | 1303 | if(filename.right(3) != "m3u") |
1293 | filename=filename+".m3u"; | 1304 | filename=filename+".m3u"; |
1294 | 1305 | ||
1295 | QFile f(filename); | 1306 | QFile f(filename); |
1296 | f.open(IO_WriteOnly); | 1307 | f.open(IO_WriteOnly); |
1297 | f.writeBlock(list, list.length()); | 1308 | f.writeBlock(list, list.length()); |
1298 | f.close(); | 1309 | f.close(); |
1299 | } | 1310 | } |
1300 | if(fileDlg) delete fileDlg; | 1311 | if(fileDlg) delete fileDlg; |
1301 | } | 1312 | } |
1302 | 1313 | ||
1303 | void PlayListWidget::readPls(const QString &filename) { | 1314 | void PlayListWidget::readPls(const QString &filename) { |
1304 | 1315 | ||
1305 | qDebug("pls filename is "+filename); | 1316 | qDebug("pls filename is "+filename); |
1306 | QFile f(filename); | 1317 | QFile f(filename); |
1307 | 1318 | ||
1308 | if(f.open(IO_ReadOnly)) { | 1319 | if(f.open(IO_ReadOnly)) { |
1309 | QTextStream t(&f); | 1320 | QTextStream t(&f); |
1310 | QString s;//, first, second; | 1321 | QString s;//, first, second; |
1311 | int i=0; | 1322 | int i=0; |
1312 | while ( !t.atEnd()) { | 1323 | while ( !t.atEnd()) { |
1313 | s=t.readLine(); | 1324 | s=t.readLine(); |
1314 | if(s.left(4) == "File") { | 1325 | if(s.left(4) == "File") { |
1315 | s=s.right(s.length() - 6); | 1326 | s=s.right(s.length() - 6); |
1316 | s.replace(QRegExp("%20")," "); | 1327 | s.replace(QRegExp("%20")," "); |
1317 | qDebug("adding "+s+" to playlist"); | 1328 | qDebug("adding "+s+" to playlist"); |
1318 | // numberofentries=2 | 1329 | // numberofentries=2 |
1319 | // File1=http | 1330 | // File1=http |
1320 | // Title | 1331 | // Title |
1321 | // Length | 1332 | // Length |
1322 | // Version | 1333 | // Version |
1323 | // File2=http | 1334 | // File2=http |
1324 | 1335 | ||
1325 | s=s.replace( QRegExp("\\"),"/"); | 1336 | s=s.replace( QRegExp("\\"),"/"); |
1326 | DocLnk lnk( s ); | 1337 | DocLnk lnk( s ); |
1327 | QFileInfo f(s); | 1338 | QFileInfo f(s); |
1328 | QString name = f.baseName(); | 1339 | QString name = f.baseName(); |
1329 | if(name.left(4)=="http") | 1340 | if(name.left(4)=="http") |
1330 | name = s.right( s.length() - 7); | 1341 | name = s.right( s.length() - 7); |
1331 | else | 1342 | else |
1332 | name=s; | 1343 | name=s; |
1333 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1344 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1334 | // QFileInfo f(s); | 1345 | // QFileInfo f(s); |
1335 | // QString name = f.baseName(); | 1346 | // QString name = f.baseName(); |
1336 | // name = name.left(name.length()-4); | 1347 | // name = name.left(name.length()-4); |
1337 | // name = name.right(name.findRev("/",0,TRUE)); | 1348 | // name = name.right(name.findRev("/",0,TRUE)); |
1338 | lnk.setName( name); | 1349 | lnk.setName( name); |
1339 | if(s.at(s.length()-4) == '.') | 1350 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1340 | lnk.setFile( s); | 1351 | lnk.setFile( s); |
1341 | else { | 1352 | else { //if its a url |
1342 | if( name.right(1).find('/') == -1) | 1353 | if( name.right(1).find('/') == -1) |
1343 | s+="/"; | 1354 | s+="/"; |
1344 | // if(s.right(1) != '/') | 1355 | lnk.setFile( s); |
1345 | lnk.setFile( s); | ||
1346 | |||
1347 | } | 1356 | } |
1348 | lnk.setType("audio/x-mpegurl"); | 1357 | lnk.setType("audio/x-mpegurl"); |
1349 | 1358 | ||
1350 | qDebug("DocLnk add "+name); | 1359 | qDebug("DocLnk add "+name); |
1351 | d->selectedFiles->addToSelection( lnk); | 1360 | d->selectedFiles->addToSelection( lnk); |
1352 | } | 1361 | } |
1353 | } | 1362 | } |
1354 | i++; | 1363 | i++; |
1355 | } | 1364 | } |
1356 | } | 1365 | } |
1357 | 1366 | ||