author | llornkcor <llornkcor> | 2002-04-10 21:06:18 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 21:06:18 (UTC) |
commit | 0c06c5acf099223f8b0b63849e7e4ed52bf365bb (patch) (unidiff) | |
tree | 9296f9c4ad38b84ecfdbfe8056b19a6ba2765dd0 | |
parent | 5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac (diff) | |
download | opie-0c06c5acf099223f8b0b63849e7e4ed52bf365bb.zip opie-0c06c5acf099223f8b0b63849e7e4ed52bf365bb.tar.gz opie-0c06c5acf099223f8b0b63849e7e4ed52bf365bb.tar.bz2 |
kickin out the bug fixes
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 0764c01..809d5ac 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -346,300 +346,301 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
346 | 346 | ||
347 | d->selectedFiles->writeCurrent( cfg); | 347 | d->selectedFiles->writeCurrent( cfg); |
348 | cfg.setGroup("PlayList"); | 348 | cfg.setGroup("PlayList"); |
349 | int noOfFiles = 0; | 349 | int noOfFiles = 0; |
350 | d->selectedFiles->first(); | 350 | d->selectedFiles->first(); |
351 | do { | 351 | do { |
352 | const DocLnk *lnk = d->selectedFiles->current(); | 352 | const DocLnk *lnk = d->selectedFiles->current(); |
353 | if ( lnk ) { | 353 | if ( lnk ) { |
354 | QString entryName; | 354 | QString entryName; |
355 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 355 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
356 | // qDebug(entryName); | 356 | // qDebug(entryName); |
357 | cfg.writeEntry( entryName, lnk->linkFile() ); | 357 | cfg.writeEntry( entryName, lnk->linkFile() ); |
358 | // if this link does exist, add it so we have the file | 358 | // if this link does exist, add it so we have the file |
359 | // next time... | 359 | // next time... |
360 | if ( !QFile::exists( lnk->linkFile() ) ) { | 360 | if ( !QFile::exists( lnk->linkFile() ) ) { |
361 | // the way writing lnks doesn't really check for out | 361 | // the way writing lnks doesn't really check for out |
362 | // of disk space, but check it anyway. | 362 | // of disk space, but check it anyway. |
363 | if ( !lnk->writeLink() ) { | 363 | if ( !lnk->writeLink() ) { |
364 | QMessageBox::critical( 0, tr("Out of space"), | 364 | QMessageBox::critical( 0, tr("Out of space"), |
365 | tr( "There was a problem saving " | 365 | tr( "There was a problem saving " |
366 | "the playlist.\n" | 366 | "the playlist.\n" |
367 | "Your playlist " | 367 | "Your playlist " |
368 | "may be missing some entries\n" | 368 | "may be missing some entries\n" |
369 | "the next time you start it." ) | 369 | "the next time you start it." ) |
370 | ); | 370 | ); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | noOfFiles++; | 373 | noOfFiles++; |
374 | } | 374 | } |
375 | } | 375 | } |
376 | while ( d->selectedFiles->next() ); | 376 | while ( d->selectedFiles->next() ); |
377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
382 | // qDebug("add"); | 382 | // qDebug("add"); |
383 | d->setDocumentUsed = FALSE; | 383 | d->setDocumentUsed = FALSE; |
384 | if ( mediaPlayerState->playlist() ) | 384 | if ( mediaPlayerState->playlist() ) |
385 | d->selectedFiles->addToSelection( lnk ); | 385 | d->selectedFiles->addToSelection( lnk ); |
386 | else | 386 | else |
387 | mediaPlayerState->setPlaying( TRUE ); | 387 | mediaPlayerState->setPlaying( TRUE ); |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | void PlayListWidget::clearList() { | 391 | void PlayListWidget::clearList() { |
392 | while ( first() ) | 392 | while ( first() ) |
393 | d->selectedFiles->removeSelected(); | 393 | d->selectedFiles->removeSelected(); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | void PlayListWidget::addAllToList() { | 397 | void PlayListWidget::addAllToList() { |
398 | DocLnkSet filesAll; | 398 | DocLnkSet filesAll; |
399 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 399 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
400 | QListIterator<DocLnk> Adit( filesAll.children() ); | 400 | QListIterator<DocLnk> Adit( filesAll.children() ); |
401 | for ( ; Adit.current(); ++Adit ) | 401 | for ( ; Adit.current(); ++Adit ) |
402 | d->selectedFiles->addToSelection( **Adit ); | 402 | d->selectedFiles->addToSelection( **Adit ); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | void PlayListWidget::addAllMusicToList() { | 406 | void PlayListWidget::addAllMusicToList() { |
407 | // DocLnkSet files; | 407 | // DocLnkSet files; |
408 | // Global::findDocuments(&files, "audio/*"); | 408 | // Global::findDocuments(&files, "audio/*"); |
409 | QListIterator<DocLnk> dit( files.children() ); | 409 | QListIterator<DocLnk> dit( files.children() ); |
410 | for ( ; dit.current(); ++dit ) | 410 | for ( ; dit.current(); ++dit ) |
411 | d->selectedFiles->addToSelection( **dit ); | 411 | d->selectedFiles->addToSelection( **dit ); |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | void PlayListWidget::addAllVideoToList() { | 415 | void PlayListWidget::addAllVideoToList() { |
416 | QListIterator<DocLnk> dit( vFiles.children() ); | 416 | QListIterator<DocLnk> dit( vFiles.children() ); |
417 | for ( ; dit.current(); ++dit ) | 417 | for ( ; dit.current(); ++dit ) |
418 | d->selectedFiles->addToSelection( **dit ); | 418 | d->selectedFiles->addToSelection( **dit ); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void PlayListWidget::setDocument(const QString& fileref) { | 422 | void PlayListWidget::setDocument(const QString& fileref) { |
423 | fromSetDocument = TRUE; | 423 | fromSetDocument = TRUE; |
424 | if ( fileref.isNull() ) { | 424 | if ( fileref.isNull() ) { |
425 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 425 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | // qDebug("setDocument "+fileref); | 428 | // qDebug("setDocument "+fileref); |
429 | if(fileref.find("playlist",0,TRUE) == -1) { | 429 | if(fileref.find("playlist",0,TRUE) == -1) { |
430 | clearList(); | 430 | clearList(); |
431 | addToSelection( DocLnk( fileref ) ); | 431 | addToSelection( DocLnk( fileref ) ); |
432 | d->setDocumentUsed = TRUE; | 432 | d->setDocumentUsed = TRUE; |
433 | mediaPlayerState->setPlaying( FALSE ); | 433 | mediaPlayerState->setPlaying( FALSE ); |
434 | qApp->processEvents(); | 434 | qApp->processEvents(); |
435 | mediaPlayerState->setPlaying( TRUE ); | 435 | mediaPlayerState->setPlaying( TRUE ); |
436 | qApp->processEvents(); | 436 | qApp->processEvents(); |
437 | setCaption(tr("OpiePlayer")); | 437 | setCaption(tr("OpiePlayer")); |
438 | 438 | ||
439 | } else { //is playlist | 439 | } else { //is playlist |
440 | clearList(); | 440 | clearList(); |
441 | loadList(DocLnk(fileref)); | 441 | loadList(DocLnk(fileref)); |
442 | d->selectedFiles->first(); | 442 | d->selectedFiles->first(); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void PlayListWidget::setActiveWindow() { | 447 | void PlayListWidget::setActiveWindow() { |
448 | // When we get raised we need to ensure that it switches views | 448 | // When we get raised we need to ensure that it switches views |
449 | char origView = mediaPlayerState->view(); | 449 | char origView = mediaPlayerState->view(); |
450 | mediaPlayerState->setView( 'l' ); // invalidate | 450 | mediaPlayerState->setView( 'l' ); // invalidate |
451 | mediaPlayerState->setView( origView ); // now switch back | 451 | mediaPlayerState->setView( origView ); // now switch back |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PlayListWidget::useSelectedDocument() { | 455 | void PlayListWidget::useSelectedDocument() { |
456 | d->setDocumentUsed = FALSE; | 456 | d->setDocumentUsed = FALSE; |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | const DocLnk *PlayListWidget::current() { // this is fugly | 460 | const DocLnk *PlayListWidget::current() { // this is fugly |
461 | 461 | ||
462 | // if( fromSetDocument) { | 462 | // if( fromSetDocument) { |
463 | // qDebug("from setDoc"); | 463 | // qDebug("from setDoc"); |
464 | // DocLnkSet files; | 464 | // DocLnkSet files; |
465 | // Global::findDocuments(&files, "video/*;audio/*"); | 465 | // Global::findDocuments(&files, "video/*;audio/*"); |
466 | // QListIterator<DocLnk> dit( files.children() ); | 466 | // QListIterator<DocLnk> dit( files.children() ); |
467 | // for ( ; dit.current(); ++dit ) { | 467 | // for ( ; dit.current(); ++dit ) { |
468 | // if(dit.current()->linkFile() == setDocFileRef) { | 468 | // if(dit.current()->linkFile() == setDocFileRef) { |
469 | // qDebug(setDocFileRef); | 469 | // qDebug(setDocFileRef); |
470 | // return dit; | 470 | // return dit; |
471 | // } | 471 | // } |
472 | // } | 472 | // } |
473 | // } else | 473 | // } else |
474 | // qDebug("current"); | 474 | |
475 | // switch (tabWidget->currentPageIndex()) { | 475 | |
476 | // case 0: //playlist | 476 | switch (tabWidget->currentPageIndex()) { |
477 | // { | 477 | case 0: //playlist |
478 | // qDebug("playlist"); | 478 | { |
479 | if ( mediaPlayerState->playlist() ) { | 479 | qDebug("playlist"); |
480 | return d->selectedFiles->current(); | 480 | if ( mediaPlayerState->playlist() ) { |
481 | } | 481 | return d->selectedFiles->current(); |
482 | else if ( d->setDocumentUsed && d->current ) { | 482 | } |
483 | return d->current; | 483 | else if ( d->setDocumentUsed && d->current ) { |
484 | } else { | 484 | return d->current; |
485 | return d->files->selected(); | 485 | } else { |
486 | } | 486 | return d->files->selected(); |
487 | // } | 487 | } |
488 | // break; | 488 | } |
489 | // case 1://audio | 489 | break; |
490 | // { | 490 | case 1://audio |
491 | // qDebug("audioView"); | 491 | { |
492 | // Global::findDocuments(&files, "audio/*"); | 492 | qDebug("audioView"); |
493 | // QListIterator<DocLnk> dit( files.children() ); | 493 | // Global::findDocuments(&files, "audio/*"); |
494 | // for ( ; dit.current(); ++dit ) { | 494 | QListIterator<DocLnk> dit( files.children() ); |
495 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 495 | for ( ; dit.current(); ++dit ) { |
496 | // qDebug("here"); | 496 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
497 | // insanityBool=TRUE; | 497 | qDebug("here"); |
498 | // return dit; | 498 | insanityBool=TRUE; |
499 | // } | 499 | return dit; |
500 | // } | 500 | } |
501 | // } | 501 | } |
502 | // break; | 502 | } |
503 | // case 2: // video | 503 | break; |
504 | // { | 504 | case 2: // video |
505 | // qDebug("videoView"); | 505 | { |
506 | // Global::findDocuments(&vFiles, "video/*"); | 506 | qDebug("videoView"); |
507 | // QListIterator<DocLnk> Vdit( vFiles.children() ); | 507 | // Global::findDocuments(&vFiles, "video/*"); |
508 | // for ( ; Vdit.current(); ++Vdit ) { | 508 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
509 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 509 | for ( ; Vdit.current(); ++Vdit ) { |
510 | // insanityBool=TRUE; | 510 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
511 | // return Vdit; | 511 | insanityBool=TRUE; |
512 | // } | 512 | return Vdit; |
513 | // } | 513 | } |
514 | // } | 514 | } |
515 | // break; | 515 | } |
516 | // }; | 516 | break; |
517 | // return 0; | 517 | }; |
518 | return 0; | ||
518 | } | 519 | } |
519 | 520 | ||
520 | bool PlayListWidget::prev() { | 521 | bool PlayListWidget::prev() { |
521 | if ( mediaPlayerState->playlist() ) { | 522 | if ( mediaPlayerState->playlist() ) { |
522 | if ( mediaPlayerState->shuffled() ) { | 523 | if ( mediaPlayerState->shuffled() ) { |
523 | const DocLnk *cur = current(); | 524 | const DocLnk *cur = current(); |
524 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 525 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
525 | for ( int i = 0; i < j; i++ ) { | 526 | for ( int i = 0; i < j; i++ ) { |
526 | if ( !d->selectedFiles->next() ) | 527 | if ( !d->selectedFiles->next() ) |
527 | d->selectedFiles->first(); | 528 | d->selectedFiles->first(); |
528 | } | 529 | } |
529 | if ( cur == current() ) | 530 | if ( cur == current() ) |
530 | if ( !d->selectedFiles->next() ) | 531 | if ( !d->selectedFiles->next() ) |
531 | d->selectedFiles->first(); | 532 | d->selectedFiles->first(); |
532 | return TRUE; | 533 | return TRUE; |
533 | } else { | 534 | } else { |
534 | if ( !d->selectedFiles->prev() ) { | 535 | if ( !d->selectedFiles->prev() ) { |
535 | if ( mediaPlayerState->looping() ) { | 536 | if ( mediaPlayerState->looping() ) { |
536 | return d->selectedFiles->last(); | 537 | return d->selectedFiles->last(); |
537 | } else { | 538 | } else { |
538 | return FALSE; | 539 | return FALSE; |
539 | } | 540 | } |
540 | } | 541 | } |
541 | return TRUE; | 542 | return TRUE; |
542 | } | 543 | } |
543 | } else { | 544 | } else { |
544 | return mediaPlayerState->looping(); | 545 | return mediaPlayerState->looping(); |
545 | } | 546 | } |
546 | } | 547 | } |
547 | 548 | ||
548 | 549 | ||
549 | bool PlayListWidget::next() { | 550 | bool PlayListWidget::next() { |
550 | if ( mediaPlayerState->playlist() ) { | 551 | if ( mediaPlayerState->playlist() ) { |
551 | if ( mediaPlayerState->shuffled() ) { | 552 | if ( mediaPlayerState->shuffled() ) { |
552 | return prev(); | 553 | return prev(); |
553 | } else { | 554 | } else { |
554 | if ( !d->selectedFiles->next() ) { | 555 | if ( !d->selectedFiles->next() ) { |
555 | if ( mediaPlayerState->looping() ) { | 556 | if ( mediaPlayerState->looping() ) { |
556 | return d->selectedFiles->first(); | 557 | return d->selectedFiles->first(); |
557 | } else { | 558 | } else { |
558 | return FALSE; | 559 | return FALSE; |
559 | } | 560 | } |
560 | } | 561 | } |
561 | return TRUE; | 562 | return TRUE; |
562 | } | 563 | } |
563 | } else { | 564 | } else { |
564 | return mediaPlayerState->looping(); | 565 | return mediaPlayerState->looping(); |
565 | } | 566 | } |
566 | } | 567 | } |
567 | 568 | ||
568 | 569 | ||
569 | bool PlayListWidget::first() { | 570 | bool PlayListWidget::first() { |
570 | if ( mediaPlayerState->playlist() ) | 571 | if ( mediaPlayerState->playlist() ) |
571 | return d->selectedFiles->first(); | 572 | return d->selectedFiles->first(); |
572 | else | 573 | else |
573 | return mediaPlayerState->looping(); | 574 | return mediaPlayerState->looping(); |
574 | } | 575 | } |
575 | 576 | ||
576 | 577 | ||
577 | bool PlayListWidget::last() { | 578 | bool PlayListWidget::last() { |
578 | if ( mediaPlayerState->playlist() ) | 579 | if ( mediaPlayerState->playlist() ) |
579 | return d->selectedFiles->last(); | 580 | return d->selectedFiles->last(); |
580 | else | 581 | else |
581 | return mediaPlayerState->looping(); | 582 | return mediaPlayerState->looping(); |
582 | } | 583 | } |
583 | 584 | ||
584 | 585 | ||
585 | void PlayListWidget::saveList() { | 586 | void PlayListWidget::saveList() { |
586 | 587 | ||
587 | QString filename; | 588 | QString filename; |
588 | InputDialog *fileDlg; | 589 | InputDialog *fileDlg; |
589 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 590 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
590 | fileDlg->exec(); | 591 | fileDlg->exec(); |
591 | if( fileDlg->result() == 1 ) { | 592 | if( fileDlg->result() == 1 ) { |
592 | if ( d->current ) | 593 | if ( d->current ) |
593 | delete d->current; | 594 | delete d->current; |
594 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 595 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
595 | // qDebug("saving playlist "+filename+".playlist"); | 596 | // qDebug("saving playlist "+filename+".playlist"); |
596 | Config cfg( filename +".playlist"); | 597 | Config cfg( filename +".playlist"); |
597 | writeConfig( cfg ); | 598 | writeConfig( cfg ); |
598 | 599 | ||
599 | // qDebug("same name so delete lnk??"); | 600 | // qDebug("same name so delete lnk??"); |
600 | // if( playLists->selected()->name() == filename) { | 601 | // if( playLists->selected()->name() == filename) { |
601 | 602 | ||
602 | // qDebug("same name so delete lnk"); | 603 | // qDebug("same name so delete lnk"); |
603 | // QFile().remove(playLists->selected()->file()); | 604 | // QFile().remove(playLists->selected()->file()); |
604 | // QFile().remove(playLists->selected()->linkFile()); | 605 | // QFile().remove(playLists->selected()->linkFile()); |
605 | // playLists->reread(); | 606 | // playLists->reread(); |
606 | // } | 607 | // } |
607 | // qDebug("new doclnk"); | 608 | // qDebug("new doclnk"); |
608 | DocLnk lnk; | 609 | DocLnk lnk; |
609 | // lnk.setComment( ""); | 610 | // lnk.setComment( ""); |
610 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 611 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
611 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 612 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
612 | lnk.setIcon("mpegplayer/playlist2"); | 613 | lnk.setIcon("mpegplayer/playlist2"); |
613 | lnk.setName( filename); //sets file name | 614 | lnk.setName( filename); //sets file name |
614 | // qDebug(filename); | 615 | // qDebug(filename); |
615 | if(!lnk.writeLink()) | 616 | if(!lnk.writeLink()) |
616 | qDebug("Writing doclink did not work"); | 617 | qDebug("Writing doclink did not work"); |
617 | } | 618 | } |
618 | Config config( "MediaPlayer" ); | 619 | Config config( "MediaPlayer" ); |
619 | config.writeEntry("CurrentPlaylist",filename); | 620 | config.writeEntry("CurrentPlaylist",filename); |
620 | setCaption(tr("OpiePlayer: ")+filename); | 621 | setCaption(tr("OpiePlayer: ")+filename); |
621 | d->selectedFiles->first(); | 622 | d->selectedFiles->first(); |
622 | if(fileDlg) | 623 | if(fileDlg) |
623 | delete fileDlg; | 624 | delete fileDlg; |
624 | } | 625 | } |
625 | 626 | ||
626 | void PlayListWidget::loadList( const DocLnk & lnk) { | 627 | void PlayListWidget::loadList( const DocLnk & lnk) { |
627 | QString name= lnk.name(); | 628 | QString name= lnk.name(); |
628 | // qDebug("currentList is "+name); | 629 | // qDebug("currentList is "+name); |
629 | if( name.length()>1) { | 630 | if( name.length()>1) { |
630 | setCaption("OpiePlayer: "+name); | 631 | setCaption("OpiePlayer: "+name); |
631 | // qDebug("load list "+ name+".playlist"); | 632 | // qDebug("load list "+ name+".playlist"); |
632 | clearList(); | 633 | clearList(); |
633 | Config cfg( name+".playlist"); | 634 | Config cfg( name+".playlist"); |
634 | readConfig(cfg); | 635 | readConfig(cfg); |
635 | 636 | ||
636 | tabWidget->setCurrentPage(0); | 637 | tabWidget->setCurrentPage(0); |
637 | 638 | ||
638 | Config config( "MediaPlayer" ); | 639 | Config config( "MediaPlayer" ); |
639 | config.writeEntry("CurrentPlaylist", name); | 640 | config.writeEntry("CurrentPlaylist", name); |
640 | // d->selectedFiles->first(); | 641 | // d->selectedFiles->first(); |
641 | } | 642 | } |
642 | 643 | ||
643 | } | 644 | } |
644 | 645 | ||
645 | void PlayListWidget::setPlaylist( bool shown ) { | 646 | void PlayListWidget::setPlaylist( bool shown ) { |
@@ -669,274 +670,271 @@ void PlayListWidget::addSelected() { | |||
669 | case 1: { //audio | 670 | case 1: { //audio |
670 | for ( int i = 0; i < noOfFiles; i++ ) { | 671 | for ( int i = 0; i < noOfFiles; i++ ) { |
671 | QString entryName; | 672 | QString entryName; |
672 | entryName.sprintf( "File%i", i + 1 ); | 673 | entryName.sprintf( "File%i", i + 1 ); |
673 | QString linkFile = cfg.readEntry( entryName ); | 674 | QString linkFile = cfg.readEntry( entryName ); |
674 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 675 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
675 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 676 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
676 | tr("This is all ready in your playlist.\nContinue?"), | 677 | tr("This is all ready in your playlist.\nContinue?"), |
677 | tr("Yes"),tr("No"),0,0,1); | 678 | tr("Yes"),tr("No"),0,0,1); |
678 | if (result !=0) | 679 | if (result !=0) |
679 | return; | 680 | return; |
680 | } | 681 | } |
681 | } | 682 | } |
682 | addToSelection( audioView->selectedItem() ); | 683 | addToSelection( audioView->selectedItem() ); |
683 | tabWidget->setCurrentPage(1); | 684 | tabWidget->setCurrentPage(1); |
684 | } | 685 | } |
685 | break; | 686 | break; |
686 | case 2: { // video | 687 | case 2: { // video |
687 | for ( int i = 0; i < noOfFiles; i++ ) { | 688 | for ( int i = 0; i < noOfFiles; i++ ) { |
688 | QString entryName; | 689 | QString entryName; |
689 | entryName.sprintf( "File%i", i + 1 ); | 690 | entryName.sprintf( "File%i", i + 1 ); |
690 | QString linkFile = cfg.readEntry( entryName ); | 691 | QString linkFile = cfg.readEntry( entryName ); |
691 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 692 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
692 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 693 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
693 | tr("This is all ready in your playlist.\nContinue?"), | 694 | tr("This is all ready in your playlist.\nContinue?"), |
694 | tr("Yes"),tr("No"),0,0,1); | 695 | tr("Yes"),tr("No"),0,0,1); |
695 | if (result !=0) | 696 | if (result !=0) |
696 | return; | 697 | return; |
697 | } | 698 | } |
698 | } | 699 | } |
699 | addToSelection( videoView->selectedItem() ); | 700 | addToSelection( videoView->selectedItem() ); |
700 | tabWidget->setCurrentPage(2); | 701 | tabWidget->setCurrentPage(2); |
701 | } | 702 | } |
702 | break; | 703 | break; |
703 | }; | 704 | }; |
704 | } | 705 | } |
705 | 706 | ||
706 | void PlayListWidget::removeSelected() { | 707 | void PlayListWidget::removeSelected() { |
707 | d->selectedFiles->removeSelected( ); | 708 | d->selectedFiles->removeSelected( ); |
708 | } | 709 | } |
709 | 710 | ||
710 | void PlayListWidget::playIt( QListViewItem *it) { | 711 | void PlayListWidget::playIt( QListViewItem *it) { |
711 | // d->setDocumentUsed = FALSE; | 712 | // d->setDocumentUsed = FALSE; |
712 | mediaPlayerState->setPlaying(TRUE); | 713 | mediaPlayerState->setPlaying(TRUE); |
713 | } | 714 | } |
714 | 715 | ||
715 | void PlayListWidget::addToSelection( QListViewItem *it) { | 716 | void PlayListWidget::addToSelection( QListViewItem *it) { |
716 | d->setDocumentUsed = FALSE; | 717 | d->setDocumentUsed = FALSE; |
717 | 718 | ||
718 | if(it) { | 719 | if(it) { |
719 | switch (tabWidget->currentPageIndex()) { | 720 | switch (tabWidget->currentPageIndex()) { |
720 | case 1: { | 721 | case 1: { |
721 | QListIterator<DocLnk> dit( files.children() ); | 722 | QListIterator<DocLnk> dit( files.children() ); |
722 | for ( ; dit.current(); ++dit ) { | 723 | for ( ; dit.current(); ++dit ) { |
723 | if( dit.current()->name() == it->text(0)) { | 724 | if( dit.current()->name() == it->text(0)) { |
724 | d->selectedFiles->addToSelection( **dit ); | 725 | d->selectedFiles->addToSelection( **dit ); |
725 | } | 726 | } |
726 | } | 727 | } |
727 | } | 728 | } |
728 | break; | 729 | break; |
729 | case 2: { | 730 | case 2: { |
730 | QListIterator<DocLnk> dit( vFiles.children() ); | 731 | QListIterator<DocLnk> dit( vFiles.children() ); |
731 | for ( ; dit.current(); ++dit ) { | 732 | for ( ; dit.current(); ++dit ) { |
732 | if( dit.current()->name() == it->text(0)) { | 733 | if( dit.current()->name() == it->text(0)) { |
733 | d->selectedFiles->addToSelection( **dit ); | 734 | d->selectedFiles->addToSelection( **dit ); |
734 | } | 735 | } |
735 | } | 736 | } |
736 | } | 737 | } |
737 | break; | 738 | break; |
738 | case 0: | 739 | case 0: |
739 | break; | 740 | break; |
740 | }; | 741 | }; |
741 | tabWidget->setCurrentPage(0); | 742 | tabWidget->setCurrentPage(0); |
742 | } | 743 | } |
743 | } | 744 | } |
744 | 745 | ||
745 | void PlayListWidget::tabChanged(QWidget *widg) { | 746 | void PlayListWidget::tabChanged(QWidget *widg) { |
746 | 747 | ||
747 | switch ( tabWidget->currentPageIndex()) { | 748 | switch ( tabWidget->currentPageIndex()) { |
748 | case 0: | 749 | case 0: |
749 | { | 750 | { |
750 | if( !tbDeletePlaylist->isHidden()) | 751 | if( !tbDeletePlaylist->isHidden()) |
751 | tbDeletePlaylist->hide(); | 752 | tbDeletePlaylist->hide(); |
752 | d->tbRemoveFromList->setEnabled(TRUE); | 753 | d->tbRemoveFromList->setEnabled(TRUE); |
753 | d->tbAddToList->setEnabled(FALSE); | 754 | d->tbAddToList->setEnabled(FALSE); |
754 | } | 755 | } |
755 | break; | 756 | break; |
756 | case 1: | 757 | case 1: |
757 | { | 758 | { |
758 | if( !tbDeletePlaylist->isHidden()) | 759 | if( !tbDeletePlaylist->isHidden()) |
759 | tbDeletePlaylist->hide(); | 760 | tbDeletePlaylist->hide(); |
760 | d->tbRemoveFromList->setEnabled(FALSE); | 761 | d->tbRemoveFromList->setEnabled(FALSE); |
761 | d->tbAddToList->setEnabled(TRUE); | 762 | d->tbAddToList->setEnabled(TRUE); |
762 | } | 763 | } |
763 | break; | 764 | break; |
764 | case 2: | 765 | case 2: |
765 | { | 766 | { |
766 | if( !tbDeletePlaylist->isHidden()) | 767 | if( !tbDeletePlaylist->isHidden()) |
767 | tbDeletePlaylist->hide(); | 768 | tbDeletePlaylist->hide(); |
768 | d->tbRemoveFromList->setEnabled(FALSE); | 769 | d->tbRemoveFromList->setEnabled(FALSE); |
769 | d->tbAddToList->setEnabled(TRUE); | 770 | d->tbAddToList->setEnabled(TRUE); |
770 | } | 771 | } |
771 | break; | 772 | break; |
772 | case 3: | 773 | case 3: |
773 | { | 774 | { |
774 | if( tbDeletePlaylist->isHidden()) | 775 | if( tbDeletePlaylist->isHidden()) |
775 | tbDeletePlaylist->show(); | 776 | tbDeletePlaylist->show(); |
776 | playLists->reread(); | 777 | playLists->reread(); |
777 | } | 778 | } |
778 | break; | 779 | break; |
779 | }; | 780 | }; |
780 | } | 781 | } |
781 | 782 | ||
782 | 783 | ||
783 | 784 | ||
784 | void PlayListWidget::btnPlay(bool b) { | 785 | void PlayListWidget::btnPlay(bool b) { |
785 | 786 | ||
786 | // mediaPlayerState->setPlaying(b); | 787 | // mediaPlayerState->setPlaying(b); |
787 | switch ( tabWidget->currentPageIndex()) { | 788 | switch ( tabWidget->currentPageIndex()) { |
788 | case 0: | 789 | case 0: |
789 | { | 790 | { |
790 | mediaPlayerState->setPlaying(b); | 791 | mediaPlayerState->setPlaying(b); |
791 | } | 792 | } |
792 | break; | 793 | break; |
793 | case 1: | 794 | case 1: |
794 | { | 795 | { |
795 | addToSelection( audioView->selectedItem() ); | 796 | addToSelection( audioView->selectedItem() ); |
796 | mediaPlayerState->setPlaying(b); | 797 | mediaPlayerState->setPlaying(b); |
797 | // qApp->processEvents(); | ||
798 | d->selectedFiles->removeSelected( ); | 798 | d->selectedFiles->removeSelected( ); |
799 | tabWidget->setCurrentPage(1); | 799 | tabWidget->setCurrentPage(1); |
800 | audioView->clearSelection(); | 800 | d->selectedFiles->unSelect(); |
801 | // d->selectedFiles->unSelect(); | 801 | // audioView->clearSelection(); |
802 | // mediaPlayerState->setPlaying(FALSE); | ||
803 | } | 802 | } |
804 | break; | 803 | break; |
805 | case 2: | 804 | case 2: |
806 | { | 805 | { |
807 | addToSelection( videoView->selectedItem() ); | 806 | addToSelection( videoView->selectedItem() ); |
808 | mediaPlayerState->setPlaying(b); | 807 | mediaPlayerState->setPlaying(b); |
809 | qApp->processEvents(); | 808 | qApp->processEvents(); |
810 | d->selectedFiles->removeSelected( ); | 809 | d->selectedFiles->removeSelected( ); |
811 | tabWidget->setCurrentPage(2); | 810 | tabWidget->setCurrentPage(2); |
812 | videoView->clearSelection(); | 811 | d->selectedFiles->unSelect(); |
813 | // d->selectedFiles->unSelect(); | 812 | // videoView->clearSelection(); |
814 | // mediaPlayerState->setPlaying(FALSE); | ||
815 | } | 813 | } |
816 | break; | 814 | break; |
817 | }; | 815 | }; |
818 | } | 816 | } |
819 | 817 | ||
820 | void PlayListWidget::deletePlaylist() { | 818 | void PlayListWidget::deletePlaylist() { |
821 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
822 | (tr("You really want to delete\nthis playlist?")), | 820 | (tr("You really want to delete\nthis playlist?")), |
823 | (tr("Yes")), (tr("No")), 0 )){ | 821 | (tr("Yes")), (tr("No")), 0 )){ |
824 | case 0: // Yes clicked, | 822 | case 0: // Yes clicked, |
825 | QFile().remove(playLists->selected()->file()); | 823 | QFile().remove(playLists->selected()->file()); |
826 | QFile().remove(playLists->selected()->linkFile()); | 824 | QFile().remove(playLists->selected()->linkFile()); |
827 | playLists->reread(); | 825 | playLists->reread(); |
828 | break; | 826 | break; |
829 | case 1: // Cancel | 827 | case 1: // Cancel |
830 | break; | 828 | break; |
831 | }; | 829 | }; |
832 | 830 | ||
833 | } | 831 | } |
834 | 832 | ||
835 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
836 | { | 834 | { |
837 | switch (mouse) { | 835 | switch (mouse) { |
838 | case 1: | 836 | case 1: |
839 | break; | 837 | break; |
840 | case 2:{ | 838 | case 2:{ |
841 | QPopupMenu m; | 839 | QPopupMenu m; |
842 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 840 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
843 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
844 | m.insertSeparator(); | 842 | m.insertSeparator(); |
845 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
846 | m.exec( QCursor::pos() ); | 844 | m.exec( QCursor::pos() ); |
847 | } | 845 | } |
848 | break; | 846 | break; |
849 | }; | 847 | }; |
850 | } | 848 | } |
851 | 849 | ||
852 | void PlayListWidget::playSelected() | 850 | void PlayListWidget::playSelected() |
853 | { | 851 | { |
854 | btnPlay( TRUE); | 852 | btnPlay( TRUE); |
855 | } | 853 | } |
856 | 854 | ||
857 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
858 | { | 856 | { |
859 | switch (mouse) { | 857 | switch (mouse) { |
860 | case 1: | 858 | case 1: |
861 | break; | 859 | break; |
862 | case 2:{ | 860 | case 2:{ |
863 | QPopupMenu m; | 861 | QPopupMenu m; |
864 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 862 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
865 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 863 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
866 | // m.insertSeparator(); | 864 | // m.insertSeparator(); |
867 | m.exec( QCursor::pos() ); | 865 | m.exec( QCursor::pos() ); |
868 | } | 866 | } |
869 | break; | 867 | break; |
870 | }; | 868 | }; |
871 | 869 | ||
872 | } | 870 | } |
873 | 871 | ||
874 | void PlayListWidget::listDelete() { | 872 | void PlayListWidget::listDelete() { |
875 | Config cfg( "MediaPlayer" ); | 873 | Config cfg( "MediaPlayer" ); |
876 | cfg.setGroup("PlayList"); | 874 | cfg.setGroup("PlayList"); |
877 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
878 | QString file; | 876 | QString file; |
879 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
880 | switch ( tabWidget->currentPageIndex()) { | 878 | switch ( tabWidget->currentPageIndex()) { |
881 | case 0: | 879 | case 0: |
882 | break; | 880 | break; |
883 | case 1: | 881 | case 1: |
884 | { | 882 | { |
885 | file = audioView->selectedItem()->text(0); | 883 | file = audioView->selectedItem()->text(0); |
886 | // Global::findDocuments(&files, "audio/*"); | 884 | // Global::findDocuments(&files, "audio/*"); |
887 | // AppLnkSet appFiles; | 885 | // AppLnkSet appFiles; |
888 | QListIterator<DocLnk> dit( files.children() ); | 886 | QListIterator<DocLnk> dit( files.children() ); |
889 | for ( ; dit.current(); ++dit ) { | 887 | for ( ; dit.current(); ++dit ) { |
890 | if( dit.current()->name() == file) { | 888 | if( dit.current()->name() == file) { |
891 | // qDebug(file); | 889 | // qDebug(file); |
892 | LnkProperties prop( dit.current() ); | 890 | LnkProperties prop( dit.current() ); |
893 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
894 | prop.showMaximized(); | 892 | prop.showMaximized(); |
895 | prop.exec(); | 893 | prop.exec(); |
896 | } | 894 | } |
897 | } | 895 | } |
898 | populateAudioView(); | 896 | populateAudioView(); |
899 | } | 897 | } |
900 | break; | 898 | break; |
901 | case 2: | 899 | case 2: |
902 | { | 900 | { |
903 | // file = videoView->selectedItem()->text(0); | 901 | // file = videoView->selectedItem()->text(0); |
904 | // for ( int i = 0; i < noOfFiles; i++ ) { | 902 | // for ( int i = 0; i < noOfFiles; i++ ) { |
905 | // QString entryName; | 903 | // QString entryName; |
906 | // entryName.sprintf( "File%i", i + 1 ); | 904 | // entryName.sprintf( "File%i", i + 1 ); |
907 | // QString linkFile = cfg.readEntry( entryName ); | 905 | // QString linkFile = cfg.readEntry( entryName ); |
908 | // AppLnk lnk( AppLnk(linkFile)); | 906 | // AppLnk lnk( AppLnk(linkFile)); |
909 | // if( lnk.name() == file ) { | 907 | // if( lnk.name() == file ) { |
910 | // LnkProperties prop( &lnk); | 908 | // LnkProperties prop( &lnk); |
911 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
912 | // prop.showMaximized(); | 910 | // prop.showMaximized(); |
913 | // prop.exec(); | 911 | // prop.exec(); |
914 | // } | 912 | // } |
915 | // } | 913 | // } |
916 | } | 914 | } |
917 | break; | 915 | break; |
918 | }; | 916 | }; |
919 | } | 917 | } |
920 | 918 | ||
921 | void PlayListWidget::populateAudioView() { | 919 | void PlayListWidget::populateAudioView() { |
922 | // if(files) | 920 | // if(files) |
923 | // files.~DocLnkSet(); | 921 | // files.~DocLnkSet(); |
924 | StorageInfo storageInfo; | 922 | StorageInfo storageInfo; |
925 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
926 | 924 | ||
927 | Global::findDocuments(&files, "audio/*"); | 925 | Global::findDocuments(&files, "audio/*"); |
928 | QListIterator<DocLnk> dit( files.children() ); | 926 | QListIterator<DocLnk> dit( files.children() ); |
929 | QListIterator<FileSystem> it ( fs ); | 927 | QListIterator<FileSystem> it ( fs ); |
930 | audioView->clear(); | 928 | audioView->clear(); |
931 | QString storage; | 929 | QString storage; |
932 | for ( ; dit.current(); ++dit ) { | 930 | for ( ; dit.current(); ++dit ) { |
933 | for( ; it.current(); ++it ){ | 931 | for( ; it.current(); ++it ){ |
934 | const QString name = (*it)->name(); | 932 | const QString name = (*it)->name(); |
935 | const QString path = (*it)->path(); | 933 | const QString path = (*it)->path(); |
936 | if(dit.current()->file().find(path) != -1 ) storage=name; | 934 | if(dit.current()->file().find(path) != -1 ) storage=name; |
937 | } | 935 | } |
938 | 936 | ||
939 | QListViewItem * newItem; | 937 | QListViewItem * newItem; |
940 | if ( QFile( dit.current()->file()).exists() ) { | 938 | if ( QFile( dit.current()->file()).exists() ) { |
941 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
942 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |