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