-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 60eb0c8..86130d5 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -329,619 +329,619 @@ void PlayListWidget::useSelectedDocument() { | |||
329 | 329 | ||
330 | 330 | ||
331 | const DocLnk *PlayListWidget::current() { // this is fugly | 331 | const DocLnk *PlayListWidget::current() { // this is fugly |
332 | switch ( whichList() ) { | 332 | switch ( whichList() ) { |
333 | case 0: //playlist | 333 | case 0: //playlist |
334 | { | 334 | { |
335 | // qDebug("playlist"); | 335 | // qDebug("playlist"); |
336 | if ( mediaPlayerState->playlist() ) { | 336 | if ( mediaPlayerState->playlist() ) { |
337 | return d->selectedFiles->current(); | 337 | return d->selectedFiles->current(); |
338 | } else if ( d->setDocumentUsed && d->current ) { | 338 | } else if ( d->setDocumentUsed && d->current ) { |
339 | return d->current; | 339 | return d->current; |
340 | } else { | 340 | } else { |
341 | return &(d->files->selectedDocument()); | 341 | return &(d->files->selectedDocument()); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | break; | 344 | break; |
345 | }; | 345 | }; |
346 | return 0; | 346 | return 0; |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | bool PlayListWidget::prev() { | 350 | bool PlayListWidget::prev() { |
351 | if ( mediaPlayerState->playlist() ) { | 351 | if ( mediaPlayerState->playlist() ) { |
352 | if ( mediaPlayerState->shuffled() ) { | 352 | if ( mediaPlayerState->shuffled() ) { |
353 | const DocLnk *cur = current(); | 353 | const DocLnk *cur = current(); |
354 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 354 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
355 | for ( int i = 0; i < j; i++ ) { | 355 | for ( int i = 0; i < j; i++ ) { |
356 | if ( !d->selectedFiles->next() ) | 356 | if ( !d->selectedFiles->next() ) |
357 | d->selectedFiles->first(); | 357 | d->selectedFiles->first(); |
358 | } | 358 | } |
359 | if ( cur == current() ) | 359 | if ( cur == current() ) |
360 | if ( !d->selectedFiles->next() ) { | 360 | if ( !d->selectedFiles->next() ) { |
361 | d->selectedFiles->first(); | 361 | d->selectedFiles->first(); |
362 | } | 362 | } |
363 | return TRUE; | 363 | return TRUE; |
364 | } else { | 364 | } else { |
365 | if ( !d->selectedFiles->prev() ) { | 365 | if ( !d->selectedFiles->prev() ) { |
366 | if ( mediaPlayerState->looping() ) { | 366 | if ( mediaPlayerState->looping() ) { |
367 | return d->selectedFiles->last(); | 367 | return d->selectedFiles->last(); |
368 | } else { | 368 | } else { |
369 | return FALSE; | 369 | return FALSE; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | return TRUE; | 372 | return TRUE; |
373 | } | 373 | } |
374 | } else { | 374 | } else { |
375 | return mediaPlayerState->looping(); | 375 | return mediaPlayerState->looping(); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | bool PlayListWidget::next() { | 380 | bool PlayListWidget::next() { |
381 | //qDebug("<<<<<<<<<<<<next()"); | 381 | //qDebug("<<<<<<<<<<<<next()"); |
382 | if ( mediaPlayerState->playlist() ) { | 382 | if ( mediaPlayerState->playlist() ) { |
383 | if ( mediaPlayerState->shuffled() ) { | 383 | if ( mediaPlayerState->shuffled() ) { |
384 | return prev(); | 384 | return prev(); |
385 | } else { | 385 | } else { |
386 | if ( !d->selectedFiles->next() ) { | 386 | if ( !d->selectedFiles->next() ) { |
387 | if ( mediaPlayerState->looping() ) { | 387 | if ( mediaPlayerState->looping() ) { |
388 | return d->selectedFiles->first(); | 388 | return d->selectedFiles->first(); |
389 | } else { | 389 | } else { |
390 | return FALSE; | 390 | return FALSE; |
391 | } | 391 | } |
392 | } | 392 | } |
393 | return TRUE; | 393 | return TRUE; |
394 | } | 394 | } |
395 | } else { | 395 | } else { |
396 | return mediaPlayerState->looping(); | 396 | return mediaPlayerState->looping(); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | bool PlayListWidget::first() { | 401 | bool PlayListWidget::first() { |
402 | if ( mediaPlayerState->playlist() ) | 402 | if ( mediaPlayerState->playlist() ) |
403 | return d->selectedFiles->first(); | 403 | return d->selectedFiles->first(); |
404 | else | 404 | else |
405 | return mediaPlayerState->looping(); | 405 | return mediaPlayerState->looping(); |
406 | } | 406 | } |
407 | 407 | ||
408 | 408 | ||
409 | bool PlayListWidget::last() { | 409 | bool PlayListWidget::last() { |
410 | if ( mediaPlayerState->playlist() ) | 410 | if ( mediaPlayerState->playlist() ) |
411 | return d->selectedFiles->last(); | 411 | return d->selectedFiles->last(); |
412 | else | 412 | else |
413 | return mediaPlayerState->looping(); | 413 | return mediaPlayerState->looping(); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PlayListWidget::saveList() { | 417 | void PlayListWidget::saveList() { |
418 | writem3u(); | 418 | writem3u(); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void PlayListWidget::loadList( const DocLnk & lnk) { | 422 | void PlayListWidget::loadList( const DocLnk & lnk) { |
423 | QString name = lnk.name(); | 423 | QString name = lnk.name(); |
424 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 424 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
425 | 425 | ||
426 | if( name.length()>0) { | 426 | if( name.length()>0) { |
427 | setCaption("OpiePlayer: "+name); | 427 | setCaption("OpiePlayer: "+name); |
428 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 428 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
429 | clearList(); | 429 | clearList(); |
430 | readm3u(lnk.file()); | 430 | readm3u(lnk.file()); |
431 | tabWidget->setCurrentPage(0); | 431 | tabWidget->setCurrentPage(0); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void PlayListWidget::setPlaylist( bool shown ) { | 436 | void PlayListWidget::setPlaylist( bool shown ) { |
437 | if ( shown ) { | 437 | if ( shown ) { |
438 | d->playListFrame->show(); | 438 | d->playListFrame->show(); |
439 | } else { | 439 | } else { |
440 | d->playListFrame->hide(); | 440 | d->playListFrame->hide(); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
445 | void PlayListWidget::addSelected() { | 445 | void PlayListWidget::addSelected() { |
446 | qDebug("addSelected"); | 446 | qDebug("addSelected"); |
447 | switch (whichList()) { | 447 | switch (whichList()) { |
448 | case 0: //playlist | 448 | case 0: //playlist |
449 | break; | 449 | break; |
450 | case 1: { //audio | 450 | case 1: { //audio |
451 | QListViewItemIterator it( audioView ); | 451 | QListViewItemIterator it( audioView ); |
452 | // iterate through all items of the listview | 452 | // iterate through all items of the listview |
453 | for ( ; it.current(); ++it ) { | 453 | for ( ; it.current(); ++it ) { |
454 | if ( it.current()->isSelected() ) { | 454 | if ( it.current()->isSelected() ) { |
455 | QListIterator<DocLnk> dit( files.children() ); | 455 | QListIterator<DocLnk> dit( files.children() ); |
456 | for ( ; dit.current(); ++dit ) { | 456 | for ( ; dit.current(); ++dit ) { |
457 | if( dit.current()->name() == it.current()->text(0) ) { | 457 | if( dit.current()->name() == it.current()->text(0) ) { |
458 | if( QFileInfo( dit.current()->file()).exists()) { | 458 | if( QFileInfo( dit.current()->file()).exists()) { |
459 | d->selectedFiles->addToSelection( **dit ); | 459 | d->selectedFiles->addToSelection( **dit ); |
460 | audioView->setSelected( it.current(),FALSE); | 460 | audioView->setSelected( it.current(),FALSE); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | // tabWidget->setCurrentPage(0); | 466 | // tabWidget->setCurrentPage(0); |
467 | writeCurrentM3u(); | 467 | writeCurrentM3u(); |
468 | d->selectedFiles->next(); | 468 | d->selectedFiles->next(); |
469 | } | 469 | } |
470 | break; | 470 | break; |
471 | case 2: { // video | 471 | case 2: { // video |
472 | QListViewItemIterator it( videoView ); | 472 | QListViewItemIterator it( videoView ); |
473 | // iterate through all items of the listview | 473 | // iterate through all items of the listview |
474 | for ( ; it.current(); ++it ) { | 474 | for ( ; it.current(); ++it ) { |
475 | if ( it.current()->isSelected() ) { | 475 | if ( it.current()->isSelected() ) { |
476 | QListIterator<DocLnk> dit( vFiles.children() ); | 476 | QListIterator<DocLnk> dit( vFiles.children() ); |
477 | for ( ; dit.current(); ++dit ) { | 477 | for ( ; dit.current(); ++dit ) { |
478 | if( dit.current()->name() == it.current()->text(0) ) { | 478 | if( dit.current()->name() == it.current()->text(0) ) { |
479 | if(QFileInfo( dit.current()->file()).exists()) { | 479 | if(QFileInfo( dit.current()->file()).exists()) { |
480 | d->selectedFiles->addToSelection( **dit ); | 480 | d->selectedFiles->addToSelection( **dit ); |
481 | videoView->setSelected( it.current(),FALSE); | 481 | videoView->setSelected( it.current(),FALSE); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | // tabWidget->setCurrentPage(0); | 487 | // tabWidget->setCurrentPage(0); |
488 | writeCurrentM3u(); | 488 | writeCurrentM3u(); |
489 | 489 | ||
490 | } | 490 | } |
491 | break; | 491 | break; |
492 | }; | 492 | }; |
493 | } | 493 | } |
494 | 494 | ||
495 | 495 | ||
496 | void PlayListWidget::removeSelected() { | 496 | void PlayListWidget::removeSelected() { |
497 | d->selectedFiles->removeSelected( ); | 497 | d->selectedFiles->removeSelected( ); |
498 | writeCurrentM3u(); | 498 | writeCurrentM3u(); |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | void PlayListWidget::playIt( QListViewItem *it) { | 502 | void PlayListWidget::playIt( QListViewItem *it) { |
503 | if(!it) return; | 503 | if(!it) return; |
504 | mediaPlayerState->setPlaying(FALSE); | 504 | mediaPlayerState->setPlaying(FALSE); |
505 | mediaPlayerState->setPlaying(TRUE); | 505 | mediaPlayerState->setPlaying(TRUE); |
506 | d->selectedFiles->unSelect(); | 506 | d->selectedFiles->unSelect(); |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | void PlayListWidget::addToSelection( QListViewItem *it) { | 510 | void PlayListWidget::addToSelection( QListViewItem *it) { |
511 | d->setDocumentUsed = FALSE; | 511 | d->setDocumentUsed = FALSE; |
512 | 512 | ||
513 | if(it) { | 513 | if(it) { |
514 | switch ( whichList()) { | 514 | switch ( whichList()) { |
515 | case 1: { | 515 | case 1: { |
516 | QListIterator<DocLnk> dit( files.children() ); | 516 | QListIterator<DocLnk> dit( files.children() ); |
517 | for ( ; dit.current(); ++dit ) { | 517 | for ( ; dit.current(); ++dit ) { |
518 | if( dit.current()->name() == it->text(0)) { | 518 | if( dit.current()->name() == it->text(0)) { |
519 | if(QFileInfo( dit.current()->file()).exists()) { | 519 | if(QFileInfo( dit.current()->file()).exists()) { |
520 | d->selectedFiles->addToSelection( **dit ); | 520 | d->selectedFiles->addToSelection( **dit ); |
521 | qDebug("blah "+ dit.current()->name()); | 521 | // qDebug("blah "+ dit.current()->name()); |
522 | d->selectedFiles->setSelectedItem( dit.current()->name()); | 522 | // d->selectedFiles->setSelectedItem( dit.current()->name()); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | } | 525 | } |
526 | writeCurrentM3u(); | 526 | writeCurrentM3u(); |
527 | } | 527 | } |
528 | break; | 528 | break; |
529 | case 2: { | 529 | case 2: { |
530 | QListIterator<DocLnk> dit( vFiles.children() ); | 530 | QListIterator<DocLnk> dit( vFiles.children() ); |
531 | for ( ; dit.current(); ++dit ) { | 531 | for ( ; dit.current(); ++dit ) { |
532 | if( dit.current()->name() == it->text(0)) { | 532 | if( dit.current()->name() == it->text(0)) { |
533 | if( QFileInfo( dit.current()->file()).exists() ) { | 533 | if( QFileInfo( dit.current()->file()).exists() ) { |
534 | d->selectedFiles->addToSelection( **dit ); | 534 | d->selectedFiles->addToSelection( **dit ); |
535 | qDebug("blah "+ dit.current()->name()); | 535 | // qDebug("blah "+ dit.current()->name()); |
536 | d->selectedFiles->setSelectedItem( dit.current()->name()); | 536 | // d->selectedFiles->setSelectedItem( dit.current()->name()); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | writeCurrentM3u(); | 540 | writeCurrentM3u(); |
541 | 541 | ||
542 | } | 542 | } |
543 | break; | 543 | break; |
544 | case 0: | 544 | case 0: |
545 | break; | 545 | break; |
546 | }; | 546 | }; |
547 | tabWidget->setCurrentPage(0); | 547 | tabWidget->setCurrentPage(0); |
548 | 548 | ||
549 | } | 549 | } |
550 | } | 550 | } |
551 | 551 | ||
552 | 552 | ||
553 | void PlayListWidget::tabChanged(QWidget *) { | 553 | void PlayListWidget::tabChanged(QWidget *) { |
554 | 554 | ||
555 | switch ( whichList()) { | 555 | switch ( whichList()) { |
556 | case 0: | 556 | case 0: |
557 | { | 557 | { |
558 | if( !tbDeletePlaylist->isHidden() ) { | 558 | if( !tbDeletePlaylist->isHidden() ) { |
559 | tbDeletePlaylist->hide(); | 559 | tbDeletePlaylist->hide(); |
560 | } | 560 | } |
561 | d->tbRemoveFromList->setEnabled(TRUE); | 561 | d->tbRemoveFromList->setEnabled(TRUE); |
562 | d->tbAddToList->setEnabled(FALSE); | 562 | d->tbAddToList->setEnabled(FALSE); |
563 | } | 563 | } |
564 | break; | 564 | break; |
565 | case 1: | 565 | case 1: |
566 | { | 566 | { |
567 | audioView->clear(); | 567 | audioView->clear(); |
568 | populateAudioView(); | 568 | populateAudioView(); |
569 | 569 | ||
570 | if( !tbDeletePlaylist->isHidden() ) { | 570 | if( !tbDeletePlaylist->isHidden() ) { |
571 | tbDeletePlaylist->hide(); | 571 | tbDeletePlaylist->hide(); |
572 | } | 572 | } |
573 | d->tbRemoveFromList->setEnabled(FALSE); | 573 | d->tbRemoveFromList->setEnabled(FALSE); |
574 | d->tbAddToList->setEnabled(TRUE); | 574 | d->tbAddToList->setEnabled(TRUE); |
575 | } | 575 | } |
576 | break; | 576 | break; |
577 | case 2: | 577 | case 2: |
578 | { | 578 | { |
579 | videoView->clear(); | 579 | videoView->clear(); |
580 | populateVideoView(); | 580 | populateVideoView(); |
581 | if( !tbDeletePlaylist->isHidden() ) { | 581 | if( !tbDeletePlaylist->isHidden() ) { |
582 | tbDeletePlaylist->hide(); | 582 | tbDeletePlaylist->hide(); |
583 | } | 583 | } |
584 | d->tbRemoveFromList->setEnabled(FALSE); | 584 | d->tbRemoveFromList->setEnabled(FALSE); |
585 | d->tbAddToList->setEnabled(TRUE); | 585 | d->tbAddToList->setEnabled(TRUE); |
586 | } | 586 | } |
587 | break; | 587 | break; |
588 | case 3: | 588 | case 3: |
589 | { | 589 | { |
590 | if( tbDeletePlaylist->isHidden() ) { | 590 | if( tbDeletePlaylist->isHidden() ) { |
591 | tbDeletePlaylist->show(); | 591 | tbDeletePlaylist->show(); |
592 | } | 592 | } |
593 | playLists->reread(); | 593 | playLists->reread(); |
594 | } | 594 | } |
595 | break; | 595 | break; |
596 | }; | 596 | }; |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | void PlayListWidget::btnPlay(bool b) { | 600 | void PlayListWidget::btnPlay(bool b) { |
601 | // mediaPlayerState->setPlaying(false); | 601 | // mediaPlayerState->setPlaying(false); |
602 | mediaPlayerState->setPlaying(b); | 602 | mediaPlayerState->setPlaying(b); |
603 | insanityBool=FALSE; | 603 | insanityBool=FALSE; |
604 | } | 604 | } |
605 | 605 | ||
606 | void PlayListWidget::deletePlaylist() { | 606 | void PlayListWidget::deletePlaylist() { |
607 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 607 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
608 | (tr("You really want to delete\nthis playlist?")), | 608 | (tr("You really want to delete\nthis playlist?")), |
609 | (tr("Yes")), (tr("No")), 0 )){ | 609 | (tr("Yes")), (tr("No")), 0 )){ |
610 | case 0: // Yes clicked, | 610 | case 0: // Yes clicked, |
611 | QFile().remove(playLists->selectedDocument().file()); | 611 | QFile().remove(playLists->selectedDocument().file()); |
612 | QFile().remove(playLists->selectedDocument().linkFile()); | 612 | QFile().remove(playLists->selectedDocument().linkFile()); |
613 | playLists->reread(); | 613 | playLists->reread(); |
614 | break; | 614 | break; |
615 | case 1: // Cancel | 615 | case 1: // Cancel |
616 | break; | 616 | break; |
617 | }; | 617 | }; |
618 | } | 618 | } |
619 | 619 | ||
620 | 620 | ||
621 | void PlayListWidget::playSelected() { | 621 | void PlayListWidget::playSelected() { |
622 | btnPlay( TRUE); | 622 | btnPlay( TRUE); |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | void PlayListWidget::scanForAudio() { | 626 | void PlayListWidget::scanForAudio() { |
627 | // qDebug("scan for audio"); | 627 | // qDebug("scan for audio"); |
628 | files.detachChildren(); | 628 | files.detachChildren(); |
629 | QListIterator<DocLnk> sdit( files.children() ); | 629 | QListIterator<DocLnk> sdit( files.children() ); |
630 | for ( ; sdit.current(); ++sdit ) { | 630 | for ( ; sdit.current(); ++sdit ) { |
631 | delete sdit.current(); | 631 | delete sdit.current(); |
632 | } | 632 | } |
633 | // Global::findDocuments( &files, "audio/*"); | 633 | // Global::findDocuments( &files, "audio/*"); |
634 | Global::findDocuments( &files, audioMimes); | 634 | Global::findDocuments( &files, audioMimes); |
635 | audioScan = TRUE; | 635 | audioScan = TRUE; |
636 | } | 636 | } |
637 | 637 | ||
638 | void PlayListWidget::scanForVideo() { | 638 | void PlayListWidget::scanForVideo() { |
639 | // qDebug("scan for video"); | 639 | // qDebug("scan for video"); |
640 | vFiles.detachChildren(); | 640 | vFiles.detachChildren(); |
641 | QListIterator<DocLnk> sdit( vFiles.children() ); | 641 | QListIterator<DocLnk> sdit( vFiles.children() ); |
642 | for ( ; sdit.current(); ++sdit ) { | 642 | for ( ; sdit.current(); ++sdit ) { |
643 | delete sdit.current(); | 643 | delete sdit.current(); |
644 | } | 644 | } |
645 | Global::findDocuments(&vFiles, "video/*"); | 645 | Global::findDocuments(&vFiles, "video/*"); |
646 | videoScan = TRUE; | 646 | videoScan = TRUE; |
647 | } | 647 | } |
648 | 648 | ||
649 | void PlayListWidget::populateAudioView() { | 649 | void PlayListWidget::populateAudioView() { |
650 | audioView->clear(); | 650 | audioView->clear(); |
651 | StorageInfo storageInfo; | 651 | StorageInfo storageInfo; |
652 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 652 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
653 | if(!audioScan) { | 653 | if(!audioScan) { |
654 | scanForAudio(); | 654 | scanForAudio(); |
655 | } | 655 | } |
656 | 656 | ||
657 | QListIterator<DocLnk> dit( files.children() ); | 657 | QListIterator<DocLnk> dit( files.children() ); |
658 | QListIterator<FileSystem> it ( fs ); | 658 | QListIterator<FileSystem> it ( fs ); |
659 | 659 | ||
660 | QString storage; | 660 | QString storage; |
661 | for ( ; dit.current(); ++dit ) { | 661 | for ( ; dit.current(); ++dit ) { |
662 | for( ; it.current(); ++it ){ | 662 | for( ; it.current(); ++it ){ |
663 | const QString name = (*it)->name(); | 663 | const QString name = (*it)->name(); |
664 | const QString path = (*it)->path(); | 664 | const QString path = (*it)->path(); |
665 | if(dit.current()->file().find(path) != -1 ) { | 665 | if(dit.current()->file().find(path) != -1 ) { |
666 | storage = name; | 666 | storage = name; |
667 | } | 667 | } |
668 | } | 668 | } |
669 | 669 | ||
670 | QListViewItem * newItem; | 670 | QListViewItem * newItem; |
671 | if ( QFile( dit.current()->file()).exists() || | 671 | if ( QFile( dit.current()->file()).exists() || |
672 | dit.current()->file().left(4) == "http" ) { | 672 | dit.current()->file().left(4) == "http" ) { |
673 | long size; | 673 | long size; |
674 | if( dit.current()->file().left(4) == "http" ) | 674 | if( dit.current()->file().left(4) == "http" ) |
675 | size=0; | 675 | size=0; |
676 | else | 676 | else |
677 | size = QFile( dit.current()->file() ).size(); | 677 | size = QFile( dit.current()->file() ).size(); |
678 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 678 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
679 | QString::number(size ), storage, dit.current()->file()); | 679 | QString::number(size ), storage, dit.current()->file()); |
680 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 680 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | } | 683 | } |
684 | 684 | ||
685 | 685 | ||
686 | void PlayListWidget::populateVideoView() { | 686 | void PlayListWidget::populateVideoView() { |
687 | videoView->clear(); | 687 | videoView->clear(); |
688 | StorageInfo storageInfo; | 688 | StorageInfo storageInfo; |
689 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 689 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
690 | 690 | ||
691 | if(!videoScan ) { | 691 | if(!videoScan ) { |
692 | scanForVideo(); | 692 | scanForVideo(); |
693 | } | 693 | } |
694 | 694 | ||
695 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 695 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
696 | QListIterator<FileSystem> it ( fs ); | 696 | QListIterator<FileSystem> it ( fs ); |
697 | videoView->clear(); | 697 | videoView->clear(); |
698 | QString storage, pathName; | 698 | QString storage, pathName; |
699 | for ( ; Vdit.current(); ++Vdit ) { | 699 | for ( ; Vdit.current(); ++Vdit ) { |
700 | for( ; it.current(); ++it ) { | 700 | for( ; it.current(); ++it ) { |
701 | const QString name = (*it)->name(); | 701 | const QString name = (*it)->name(); |
702 | const QString path = (*it)->path(); | 702 | const QString path = (*it)->path(); |
703 | if( Vdit.current()->file().find(path) != -1 ) { | 703 | if( Vdit.current()->file().find(path) != -1 ) { |
704 | storage=name; | 704 | storage=name; |
705 | pathName=path; | 705 | pathName=path; |
706 | } | 706 | } |
707 | } | 707 | } |
708 | 708 | ||
709 | QListViewItem * newItem; | 709 | QListViewItem * newItem; |
710 | if ( QFile( Vdit.current()->file() ).exists() ) { | 710 | if ( QFile( Vdit.current()->file() ).exists() ) { |
711 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 711 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
712 | QString::number( QFile( Vdit.current()->file() ).size() ), | 712 | QString::number( QFile( Vdit.current()->file() ).size() ), |
713 | storage, Vdit.current()->file()); | 713 | storage, Vdit.current()->file()); |
714 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 714 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
715 | } | 715 | } |
716 | } | 716 | } |
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | void PlayListWidget::openFile() { | 720 | void PlayListWidget::openFile() { |
721 | // http://66.28.164.33:2080 | 721 | // http://66.28.164.33:2080 |
722 | // http://somafm.com/star0242.m3u | 722 | // http://somafm.com/star0242.m3u |
723 | QString filename, name; | 723 | QString filename, name; |
724 | InputDialog *fileDlg; | 724 | InputDialog *fileDlg; |
725 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 725 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
726 | fileDlg->exec(); | 726 | fileDlg->exec(); |
727 | if( fileDlg->result() == 1 ) { | 727 | if( fileDlg->result() == 1 ) { |
728 | filename = fileDlg->text(); | 728 | filename = fileDlg->text(); |
729 | qDebug( "Selected filename is " + filename ); | 729 | qDebug( "Selected filename is " + filename ); |
730 | Om3u *m3uList; | 730 | Om3u *m3uList; |
731 | DocLnk lnk; | 731 | DocLnk lnk; |
732 | Config cfg( "OpiePlayer" ); | 732 | Config cfg( "OpiePlayer" ); |
733 | cfg.setGroup("PlayList"); | 733 | cfg.setGroup("PlayList"); |
734 | 734 | ||
735 | if(filename.left(4) == "http") { | 735 | if(filename.left(4) == "http") { |
736 | QString m3uFile, m3uFilePath; | 736 | QString m3uFile, m3uFilePath; |
737 | if(filename.find(":",8,TRUE) != -1) { //found a port | 737 | if(filename.find(":",8,TRUE) != -1) { //found a port |
738 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 738 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
739 | m3uFile = m3uFile.right( 7); | 739 | m3uFile = m3uFile.right( 7); |
740 | } else if(filename.left(4) == "http"){ | 740 | } else if(filename.left(4) == "http"){ |
741 | m3uFile=filename; | 741 | m3uFile=filename; |
742 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 742 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
743 | } else{ | 743 | } else{ |
744 | m3uFile=filename; | 744 | m3uFile=filename; |
745 | } | 745 | } |
746 | 746 | ||
747 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 747 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
748 | lnk.setName( filename ); //sets name | 748 | lnk.setName( filename ); //sets name |
749 | lnk.setFile( filename ); //sets file name | 749 | lnk.setFile( filename ); //sets file name |
750 | 750 | ||
751 | // lnk.setIcon("opieplayer2/musicfile"); | 751 | // lnk.setIcon("opieplayer2/musicfile"); |
752 | 752 | ||
753 | d->selectedFiles->addToSelection( lnk ); | 753 | d->selectedFiles->addToSelection( lnk ); |
754 | writeCurrentM3u(); | 754 | writeCurrentM3u(); |
755 | d->selectedFiles->setSelectedItem( lnk->name()); | 755 | d->selectedFiles->setSelectedItem( lnk.name()); |
756 | } | 756 | } |
757 | else if( filename.right( 3) == "m3u" ) { | 757 | else if( filename.right( 3) == "m3u" ) { |
758 | readm3u( filename ); | 758 | readm3u( filename ); |
759 | 759 | ||
760 | } else if( filename.right(3) == "pls" ) { | 760 | } else if( filename.right(3) == "pls" ) { |
761 | readPls( filename ); | 761 | readPls( filename ); |
762 | } else { | 762 | } else { |
763 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 763 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
764 | lnk.setFile( filename ); //sets file name | 764 | lnk.setFile( filename ); //sets file name |
765 | d->selectedFiles->addToSelection( lnk); | 765 | d->selectedFiles->addToSelection( lnk); |
766 | writeCurrentM3u(); | 766 | writeCurrentM3u(); |
767 | d->selectedFiles->setSelectedItem( lnk.name()); | 767 | d->selectedFiles->setSelectedItem( lnk.name()); |
768 | } | 768 | } |
769 | } | 769 | } |
770 | 770 | ||
771 | if( fileDlg ) { | 771 | if( fileDlg ) { |
772 | delete fileDlg; | 772 | delete fileDlg; |
773 | } | 773 | } |
774 | } | 774 | } |
775 | 775 | ||
776 | /* | 776 | /* |
777 | reads m3u and shows files/urls to playlist widget */ | 777 | reads m3u and shows files/urls to playlist widget */ |
778 | void PlayListWidget::readm3u( const QString &filename ) { | 778 | void PlayListWidget::readm3u( const QString &filename ) { |
779 | qDebug( "read m3u filename " + filename ); | 779 | qDebug( "read m3u filename " + filename ); |
780 | 780 | ||
781 | Om3u *m3uList; | 781 | Om3u *m3uList; |
782 | QString s, name; | 782 | QString s, name; |
783 | m3uList = new Om3u( filename, IO_ReadOnly ); | 783 | m3uList = new Om3u( filename, IO_ReadOnly ); |
784 | m3uList->readM3u(); | 784 | m3uList->readM3u(); |
785 | DocLnk lnk; | 785 | DocLnk lnk; |
786 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 786 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
787 | s = *it; | 787 | s = *it; |
788 | // qDebug("reading "+ s); | 788 | // qDebug("reading "+ s); |
789 | if(s.left(4)=="http") { | 789 | if(s.left(4)=="http") { |
790 | lnk.setName( s ); //sets file name | 790 | lnk.setName( s ); //sets file name |
791 | lnk.setIcon("opieplayer2/musicfile"); | 791 | lnk.setIcon("opieplayer2/musicfile"); |
792 | // if(s.right(4) != '.' || s.right(5) != '.') | 792 | // if(s.right(4) != '.' || s.right(5) != '.') |
793 | // lnk.setFile( s+"/"); //if url with no extension | 793 | // lnk.setFile( s+"/"); //if url with no extension |
794 | // else | 794 | // else |
795 | lnk.setFile( s ); //sets file name | 795 | lnk.setFile( s ); //sets file name |
796 | 796 | ||
797 | } else { | 797 | } else { |
798 | // if( QFileInfo( s ).exists() ) { | 798 | // if( QFileInfo( s ).exists() ) { |
799 | lnk.setName( QFileInfo(s).baseName()); | 799 | lnk.setName( QFileInfo(s).baseName()); |
800 | // if(s.right(4) == '.') {//if regular file | 800 | // if(s.right(4) == '.') {//if regular file |
801 | if(s.left(1) != "/") { | 801 | if(s.left(1) != "/") { |
802 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 802 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
803 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 803 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
804 | // lnk.setIcon(MimeType(s).pixmap() ); | 804 | // lnk.setIcon(MimeType(s).pixmap() ); |
805 | // lnk.setIcon("SoundPlayer"); | 805 | // lnk.setIcon("SoundPlayer"); |
806 | } else { | 806 | } else { |
807 | // qDebug("set link2 "+s); | 807 | // qDebug("set link2 "+s); |
808 | lnk.setFile( s); | 808 | lnk.setFile( s); |
809 | // lnk.setIcon(MimeType(s).pixmap() ); | 809 | // lnk.setIcon(MimeType(s).pixmap() ); |
810 | // lnk.setIcon("SoundPlayer"); | 810 | // lnk.setIcon("SoundPlayer"); |
811 | } | 811 | } |
812 | } | 812 | } |
813 | d->selectedFiles->addToSelection( lnk ); | 813 | d->selectedFiles->addToSelection( lnk ); |
814 | } | 814 | } |
815 | Config config( "OpiePlayer" ); | 815 | Config config( "OpiePlayer" ); |
816 | config.setGroup( "PlayList" ); | 816 | config.setGroup( "PlayList" ); |
817 | 817 | ||
818 | config.writeEntry("CurrentPlaylist",filename); | 818 | config.writeEntry("CurrentPlaylist",filename); |
819 | config.write(); | 819 | config.write(); |
820 | currentPlayList=filename; | 820 | currentPlayList=filename; |
821 | 821 | ||
822 | // m3uList->write(); | 822 | // m3uList->write(); |
823 | m3uList->close(); | 823 | m3uList->close(); |
824 | if(m3uList) delete m3uList; | 824 | if(m3uList) delete m3uList; |
825 | 825 | ||
826 | d->selectedFiles->setSelectedItem( s); | 826 | d->selectedFiles->setSelectedItem( s); |
827 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 827 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
828 | 828 | ||
829 | } | 829 | } |
830 | 830 | ||
831 | /* | 831 | /* |
832 | reads pls and adds files/urls to playlist */ | 832 | reads pls and adds files/urls to playlist */ |
833 | void PlayListWidget::readPls( const QString &filename ) { | 833 | void PlayListWidget::readPls( const QString &filename ) { |
834 | 834 | ||
835 | qDebug( "pls filename is " + filename ); | 835 | qDebug( "pls filename is " + filename ); |
836 | Om3u *m3uList; | 836 | Om3u *m3uList; |
837 | QString s, name; | 837 | QString s, name; |
838 | m3uList = new Om3u( filename, IO_ReadOnly ); | 838 | m3uList = new Om3u( filename, IO_ReadOnly ); |
839 | m3uList->readPls(); | 839 | m3uList->readPls(); |
840 | 840 | ||
841 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 841 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
842 | s = *it; | 842 | s = *it; |
843 | // s.replace( QRegExp( "%20" )," " ); | 843 | // s.replace( QRegExp( "%20" )," " ); |
844 | DocLnk lnk( s ); | 844 | DocLnk lnk( s ); |
845 | QFileInfo f( s ); | 845 | QFileInfo f( s ); |
846 | QString name = f.baseName(); | 846 | QString name = f.baseName(); |
847 | 847 | ||
848 | if( name.left( 4 ) == "http" ) { | 848 | if( name.left( 4 ) == "http" ) { |
849 | name = s.right( s.length() - 7); | 849 | name = s.right( s.length() - 7); |
850 | } else { | 850 | } else { |
851 | name = s; | 851 | name = s; |
852 | } | 852 | } |
853 | 853 | ||
854 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 854 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
855 | 855 | ||
856 | lnk.setName( name ); | 856 | lnk.setName( name ); |
857 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 857 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
858 | lnk.setFile( s ); | 858 | lnk.setFile( s ); |
859 | } else { //if its a url | 859 | } else { //if its a url |
860 | // if( name.right( 1 ).find( '/' ) == -1) { | 860 | // if( name.right( 1 ).find( '/' ) == -1) { |
861 | // s += "/"; | 861 | // s += "/"; |
862 | // } | 862 | // } |
863 | lnk.setFile( s ); | 863 | lnk.setFile( s ); |
864 | } | 864 | } |
865 | lnk.setType( "audio/x-mpegurl" ); | 865 | lnk.setType( "audio/x-mpegurl" ); |
866 | 866 | ||
867 | lnk.writeLink(); | 867 | lnk.writeLink(); |
868 | d->selectedFiles->addToSelection( lnk ); | 868 | d->selectedFiles->addToSelection( lnk ); |
869 | } | 869 | } |
870 | 870 | ||
871 | m3uList->close(); | 871 | m3uList->close(); |
872 | if(m3uList) delete m3uList; | 872 | if(m3uList) delete m3uList; |
873 | } | 873 | } |
874 | 874 | ||
875 | /* | 875 | /* |
876 | writes current playlist to current m3u file */ | 876 | writes current playlist to current m3u file */ |
877 | void PlayListWidget::writeCurrentM3u() { | 877 | void PlayListWidget::writeCurrentM3u() { |
878 | qDebug("writing to current m3u"); | 878 | qDebug("writing to current m3u"); |
879 | Config cfg( "OpiePlayer" ); | 879 | Config cfg( "OpiePlayer" ); |
880 | cfg.setGroup("PlayList"); | 880 | cfg.setGroup("PlayList"); |
881 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 881 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
882 | 882 | ||
883 | Om3u *m3uList; | 883 | Om3u *m3uList; |
884 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 884 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
885 | if( d->selectedFiles->first()) { | 885 | if( d->selectedFiles->first()) { |
886 | 886 | ||
887 | do { | 887 | do { |
888 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 888 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
889 | m3uList->add( d->selectedFiles->current()->file() ); | 889 | m3uList->add( d->selectedFiles->current()->file() ); |
890 | } | 890 | } |
891 | while ( d->selectedFiles->next() ); | 891 | while ( d->selectedFiles->next() ); |
892 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 892 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
893 | m3uList->write(); | 893 | m3uList->write(); |
894 | m3uList->close(); | 894 | m3uList->close(); |
895 | 895 | ||
896 | if(m3uList) delete m3uList; | 896 | if(m3uList) delete m3uList; |
897 | } | 897 | } |
898 | 898 | ||
899 | } | 899 | } |
900 | 900 | ||
901 | /* | 901 | /* |
902 | writes current playlist to m3u file */ | 902 | writes current playlist to m3u file */ |
903 | void PlayListWidget::writem3u() { | 903 | void PlayListWidget::writem3u() { |
904 | InputDialog *fileDlg; | 904 | InputDialog *fileDlg; |
905 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 905 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
906 | fileDlg->exec(); | 906 | fileDlg->exec(); |
907 | QString name, filename, list; | 907 | QString name, filename, list; |
908 | Om3u *m3uList; | 908 | Om3u *m3uList; |
909 | 909 | ||
910 | if( fileDlg->result() == 1 ) { | 910 | if( fileDlg->result() == 1 ) { |
911 | name = fileDlg->text(); | 911 | name = fileDlg->text(); |
912 | // qDebug( filename ); | 912 | // qDebug( filename ); |
913 | 913 | ||
914 | if( name.left( 1) != "/" ) { | 914 | if( name.left( 1) != "/" ) { |
915 | filename = QPEApplication::documentDir() + "/" + name; | 915 | filename = QPEApplication::documentDir() + "/" + name; |
916 | } | 916 | } |
917 | 917 | ||
918 | if( name.right( 3 ) != "m3u" ) { | 918 | if( name.right( 3 ) != "m3u" ) { |
919 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 919 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
920 | } | 920 | } |
921 | 921 | ||
922 | if( d->selectedFiles->first()) { | 922 | if( d->selectedFiles->first()) { |
923 | m3uList = new Om3u(filename, IO_ReadWrite); | 923 | m3uList = new Om3u(filename, IO_ReadWrite); |
924 | 924 | ||
925 | do { | 925 | do { |
926 | m3uList->add( d->selectedFiles->current()->file()); | 926 | m3uList->add( d->selectedFiles->current()->file()); |
927 | } | 927 | } |
928 | while ( d->selectedFiles->next() ); | 928 | while ( d->selectedFiles->next() ); |
929 | // qDebug( list ); | 929 | // qDebug( list ); |
930 | m3uList->write(); | 930 | m3uList->write(); |
931 | m3uList->close(); | 931 | m3uList->close(); |
932 | if(m3uList) delete m3uList; | 932 | if(m3uList) delete m3uList; |
933 | 933 | ||
934 | if(fileDlg) delete fileDlg; | 934 | if(fileDlg) delete fileDlg; |
935 | 935 | ||
936 | DocLnk lnk; | 936 | DocLnk lnk; |
937 | lnk.setFile( filename); | 937 | lnk.setFile( filename); |
938 | // lnk.setIcon("opieplayer2/playlist2"); | 938 | // lnk.setIcon("opieplayer2/playlist2"); |
939 | lnk.setName( name); //sets file name | 939 | lnk.setName( name); //sets file name |
940 | 940 | ||
941 | // qDebug(filename); | 941 | // qDebug(filename); |
942 | Config config( "OpiePlayer" ); | 942 | Config config( "OpiePlayer" ); |
943 | config.setGroup( "PlayList" ); | 943 | config.setGroup( "PlayList" ); |
944 | 944 | ||
945 | config.writeEntry("CurrentPlaylist",filename); | 945 | config.writeEntry("CurrentPlaylist",filename); |
946 | currentPlayList=filename; | 946 | currentPlayList=filename; |
947 | 947 | ||