Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 5d0f6de..7ea95ab 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -404,192 +404,193 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
404 | 404 | ||
405 | 405 | ||
406 | void PlayListWidget::writeConfig( Config& cfg ) const { | 406 | void PlayListWidget::writeConfig( Config& cfg ) const { |
407 | 407 | ||
408 | d->selectedFiles->writeCurrent( cfg); | 408 | d->selectedFiles->writeCurrent( cfg); |
409 | cfg.setGroup("PlayList"); | 409 | cfg.setGroup("PlayList"); |
410 | int noOfFiles = 0; | 410 | int noOfFiles = 0; |
411 | d->selectedFiles->first(); | 411 | d->selectedFiles->first(); |
412 | do { | 412 | do { |
413 | const DocLnk *lnk = d->selectedFiles->current(); | 413 | const DocLnk *lnk = d->selectedFiles->current(); |
414 | if ( lnk ) { | 414 | if ( lnk ) { |
415 | QString entryName; | 415 | QString entryName; |
416 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 416 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
417 | // qDebug(entryName); | 417 | // qDebug(entryName); |
418 | cfg.writeEntry( entryName, lnk->linkFile() ); | 418 | cfg.writeEntry( entryName, lnk->linkFile() ); |
419 | // if this link does exist, add it so we have the file | 419 | // if this link does exist, add it so we have the file |
420 | // next time... | 420 | // next time... |
421 | if ( !QFile::exists( lnk->linkFile() ) ) { | 421 | if ( !QFile::exists( lnk->linkFile() ) ) { |
422 | // the way writing lnks doesn't really check for out | 422 | // the way writing lnks doesn't really check for out |
423 | // of disk space, but check it anyway. | 423 | // of disk space, but check it anyway. |
424 | if ( !lnk->writeLink() ) { | 424 | if ( !lnk->writeLink() ) { |
425 | QMessageBox::critical( 0, tr("Out of space"), | 425 | QMessageBox::critical( 0, tr("Out of space"), |
426 | tr( "There was a problem saving " | 426 | tr( "There was a problem saving " |
427 | "the playlist.\n" | 427 | "the playlist.\n" |
428 | "Your playlist " | 428 | "Your playlist " |
429 | "may be missing some entries\n" | 429 | "may be missing some entries\n" |
430 | "the next time you start it." ) | 430 | "the next time you start it." ) |
431 | ); | 431 | ); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | noOfFiles++; | 434 | noOfFiles++; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | while ( d->selectedFiles->next() ); | 437 | while ( d->selectedFiles->next() ); |
438 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 438 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 442 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
443 | d->setDocumentUsed = false; | 443 | d->setDocumentUsed = false; |
444 | if ( mediaPlayerState->playlist() ) { | 444 | if ( mediaPlayerState->playlist() ) { |
445 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 445 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
446 | d->selectedFiles->addToSelection( lnk ); | 446 | d->selectedFiles->addToSelection( lnk ); |
447 | } | 447 | } |
448 | else | 448 | else |
449 | mediaPlayerState->setPlaying( true); | 449 | mediaPlayerState->setPlaying( true); |
450 | } | 450 | } |
451 | 451 | ||
452 | 452 | ||
453 | void PlayListWidget::clearList() { | 453 | void PlayListWidget::clearList() { |
454 | while ( first() ) | 454 | while ( first() ) |
455 | d->selectedFiles->removeSelected(); | 455 | d->selectedFiles->removeSelected(); |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void PlayListWidget::addAllToList() { | 459 | void PlayListWidget::addAllToList() { |
460 | DocLnkSet filesAll; | 460 | DocLnkSet filesAll; |
461 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 461 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
462 | QListIterator<DocLnk> Adit( filesAll.children() ); | 462 | QListIterator<DocLnk> Adit( filesAll.children() ); |
463 | for ( ; Adit.current(); ++Adit ) | 463 | for ( ; Adit.current(); ++Adit ) |
464 | if(QFileInfo(Adit.current()->file()).exists()) | 464 | if(QFileInfo(Adit.current()->file()).exists()) |
465 | d->selectedFiles->addToSelection( **Adit ); | 465 | d->selectedFiles->addToSelection( **Adit ); |
466 | tabWidget->setCurrentPage(0); | 466 | tabWidget->setCurrentPage(0); |
467 | 467 | ||
468 | writeCurrentM3u(); | 468 | writeCurrentM3u(); |
469 | d->selectedFiles->first(); | 469 | d->selectedFiles->first(); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void PlayListWidget::addAllMusicToList() { | 473 | void PlayListWidget::addAllMusicToList() { |
474 | QListIterator<DocLnk> dit( files.children() ); | 474 | QListIterator<DocLnk> dit( files.children() ); |
475 | for ( ; dit.current(); ++dit ) | 475 | for ( ; dit.current(); ++dit ) |
476 | if(QFileInfo(dit.current()->file()).exists()) | 476 | if(QFileInfo(dit.current()->file()).exists()) |
477 | d->selectedFiles->addToSelection( **dit ); | 477 | d->selectedFiles->addToSelection( **dit ); |
478 | tabWidget->setCurrentPage(0); | 478 | tabWidget->setCurrentPage(0); |
479 | 479 | ||
480 | writeCurrentM3u(); | 480 | writeCurrentM3u(); |
481 | d->selectedFiles->first(); | 481 | d->selectedFiles->first(); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | void PlayListWidget::addAllVideoToList() { | 485 | void PlayListWidget::addAllVideoToList() { |
486 | QListIterator<DocLnk> dit( vFiles.children() ); | 486 | QListIterator<DocLnk> dit( vFiles.children() ); |
487 | for ( ; dit.current(); ++dit ) | 487 | for ( ; dit.current(); ++dit ) |
488 | if(QFileInfo( dit.current()->file()).exists()) | 488 | if(QFileInfo( dit.current()->file()).exists()) |
489 | d->selectedFiles->addToSelection( **dit ); | 489 | d->selectedFiles->addToSelection( **dit ); |
490 | tabWidget->setCurrentPage(0); | 490 | tabWidget->setCurrentPage(0); |
491 | 491 | ||
492 | writeCurrentM3u(); | 492 | writeCurrentM3u(); |
493 | d->selectedFiles->first(); | 493 | d->selectedFiles->first(); |
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
497 | void PlayListWidget::setDocument(const QString& fileref) { | 497 | void PlayListWidget::setDocument(const QString& fileref) { |
498 | fromSetDocument = true; | 498 | fromSetDocument = true; |
499 | d->setDocumentUsed = TRUE; | 499 | d->setDocumentUsed = TRUE; |
500 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); | ||
500 | mediaPlayerState->setPlaying( FALSE ); | 501 | mediaPlayerState->setPlaying( FALSE ); |
501 | qApp->processEvents(); | 502 | qApp->processEvents(); |
502 | mediaPlayerState->setPlaying( TRUE ); | 503 | mediaPlayerState->setPlaying( TRUE ); |
503 | } | 504 | } |
504 | 505 | ||
505 | void PlayListWidget::setDocumentEx(const QString& fileref) { | 506 | void PlayListWidget::setDocumentEx(const QString& fileref) { |
506 | 507 | ||
507 | QFileInfo fileInfo(fileref); | 508 | QFileInfo fileInfo(fileref); |
508 | if ( !fileInfo.exists() ) { | 509 | if ( !fileInfo.exists() ) { |
509 | QMessageBox::critical( 0, tr( "Invalid File" ), | 510 | QMessageBox::critical( 0, tr( "Invalid File" ), |
510 | tr( "There was a problem in getting the file." ) ); | 511 | tr( "There was a problem in getting the file." ) ); |
511 | return; | 512 | return; |
512 | } | 513 | } |
513 | qDebug("setDocument "+fileref); | 514 | qDebug("setDocument "+fileref); |
514 | QString extension = fileInfo.extension(false); | 515 | QString extension = fileInfo.extension(false); |
515 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 516 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
516 | readm3u( fileref); | 517 | readm3u( fileref); |
517 | } | 518 | } |
518 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 519 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
519 | readPls( fileref); | 520 | readPls( fileref); |
520 | } | 521 | } |
521 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 522 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
522 | clearList(); | 523 | clearList(); |
523 | DocLnk lnk; | 524 | DocLnk lnk; |
524 | lnk.setName( fileInfo.baseName() ); //sets name | 525 | lnk.setName( fileInfo.baseName() ); //sets name |
525 | lnk.setFile( fileref ); //sets file name | 526 | lnk.setFile( fileref ); //sets file name |
526 | //addToSelection( lnk ); | 527 | //addToSelection( lnk ); |
527 | 528 | ||
528 | loadList( lnk); | 529 | loadList( lnk); |
529 | d->selectedFiles->first(); | 530 | d->selectedFiles->first(); |
530 | } else { | 531 | } else { |
531 | clearList(); | 532 | clearList(); |
532 | DocLnk lnk; | 533 | DocLnk lnk; |
533 | lnk.setName( fileInfo.baseName() ); //sets name | 534 | lnk.setName( fileInfo.baseName() ); //sets name |
534 | lnk.setFile( fileref ); //sets file name | 535 | lnk.setFile( fileref ); //sets file name |
535 | addToSelection( lnk ); | 536 | addToSelection( lnk ); |
536 | // addToSelection( DocLnk( fileref ) ); | 537 | // addToSelection( DocLnk( fileref ) ); |
537 | d->setDocumentUsed = TRUE; | 538 | d->setDocumentUsed = TRUE; |
538 | mediaPlayerState->setPlaying( FALSE ); | 539 | mediaPlayerState->setPlaying( FALSE ); |
539 | qApp->processEvents(); | 540 | qApp->processEvents(); |
540 | mediaPlayerState->setPlaying( TRUE ); | 541 | mediaPlayerState->setPlaying( TRUE ); |
541 | // qApp->processEvents(); | 542 | // qApp->processEvents(); |
542 | setCaption(tr("OpiePlayer")); | 543 | setCaption(tr("OpiePlayer")); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | 546 | ||
546 | 547 | ||
547 | void PlayListWidget::setActiveWindow() { | 548 | void PlayListWidget::setActiveWindow() { |
548 | qDebug("SETTING active window"); | 549 | qDebug("SETTING active window"); |
549 | 550 | ||
550 | // When we get raised we need to ensure that it switches views | 551 | // When we get raised we need to ensure that it switches views |
551 | char origView = mediaPlayerState->view(); | 552 | char origView = mediaPlayerState->view(); |
552 | mediaPlayerState->setView( 'l' ); // invalidate | 553 | mediaPlayerState->setView( 'l' ); // invalidate |
553 | mediaPlayerState->setView( origView ); // now switch back | 554 | mediaPlayerState->setView( origView ); // now switch back |
554 | } | 555 | } |
555 | 556 | ||
556 | 557 | ||
557 | void PlayListWidget::useSelectedDocument() { | 558 | void PlayListWidget::useSelectedDocument() { |
558 | d->setDocumentUsed = FALSE; | 559 | d->setDocumentUsed = FALSE; |
559 | } | 560 | } |
560 | 561 | ||
561 | 562 | ||
562 | const DocLnk *PlayListWidget::current() { // this is fugly | 563 | const DocLnk *PlayListWidget::current() { // this is fugly |
563 | 564 | ||
564 | // if( fromSetDocument) { | 565 | // if( fromSetDocument) { |
565 | // qDebug("from setDoc"); | 566 | // qDebug("from setDoc"); |
566 | // DocLnkSet files; | 567 | // DocLnkSet files; |
567 | // Global::findDocuments(&files, "video/*;audio/*"); | 568 | // Global::findDocuments(&files, "video/*;audio/*"); |
568 | // QListIterator<DocLnk> dit( files.children() ); | 569 | // QListIterator<DocLnk> dit( files.children() ); |
569 | // for ( ; dit.current(); ++dit ) { | 570 | // for ( ; dit.current(); ++dit ) { |
570 | // if(dit.current()->linkFile() == setDocFileRef) { | 571 | // if(dit.current()->linkFile() == setDocFileRef) { |
571 | // qDebug(setDocFileRef); | 572 | // qDebug(setDocFileRef); |
572 | // return dit; | 573 | // return dit; |
573 | // } | 574 | // } |
574 | // } | 575 | // } |
575 | // } else | 576 | // } else |
576 | 577 | ||
577 | qDebug("current"); | 578 | qDebug("current"); |
578 | 579 | ||
579 | switch (tabWidget->currentPageIndex()) { | 580 | switch (tabWidget->currentPageIndex()) { |
580 | case 0: //playlist | 581 | case 0: //playlist |
581 | { | 582 | { |
582 | qDebug("playlist"); | 583 | qDebug("playlist"); |
583 | if ( mediaPlayerState->playlist() ) { | 584 | if ( mediaPlayerState->playlist() ) { |
584 | return d->selectedFiles->current(); | 585 | return d->selectedFiles->current(); |
585 | } | 586 | } |
586 | else if ( d->setDocumentUsed && d->current ) { | 587 | else if ( d->setDocumentUsed && d->current ) { |
587 | return d->current; | 588 | return d->current; |
588 | } else { | 589 | } else { |
589 | return &(d->files->selectedDocument()); | 590 | return &(d->files->selectedDocument()); |
590 | } | 591 | } |
591 | } | 592 | } |
592 | break; | 593 | break; |
593 | case 1://audio | 594 | case 1://audio |
594 | { | 595 | { |
595 | qDebug("audioView"); | 596 | qDebug("audioView"); |