author | llornkcor <llornkcor> | 2002-06-17 23:21:17 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-17 23:21:17 (UTC) |
commit | 8b089ad594fad0eed4303bc83db4910784e17dd5 (patch) (unidiff) | |
tree | 77a84d7b564db72f4c04b6efc2e4fa2d8c9eef11 | |
parent | 554f88d0e8839bd6112fa42139a967712552e519 (diff) | |
download | opie-8b089ad594fad0eed4303bc83db4910784e17dd5.zip opie-8b089ad594fad0eed4303bc83db4910784e17dd5.tar.gz opie-8b089ad594fad0eed4303bc83db4910784e17dd5.tar.bz2 |
check for file existing before adding to playlist
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 35208e4..b0d4958 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -372,129 +372,134 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
372 | if ( lnk.isValid() ) { | 372 | if ( lnk.isValid() ) { |
373 | d->selectedFiles->addToSelection( lnk ); | 373 | d->selectedFiles->addToSelection( lnk ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | d->selectedFiles->setSelectedItem( currentString); | 376 | d->selectedFiles->setSelectedItem( currentString); |
377 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 377 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::writeConfig( Config& cfg ) const { | 381 | void PlayListWidget::writeConfig( Config& cfg ) const { |
382 | 382 | ||
383 | d->selectedFiles->writeCurrent( cfg); | 383 | d->selectedFiles->writeCurrent( cfg); |
384 | cfg.setGroup("PlayList"); | 384 | cfg.setGroup("PlayList"); |
385 | int noOfFiles = 0; | 385 | int noOfFiles = 0; |
386 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
387 | do { | 387 | do { |
388 | const DocLnk *lnk = d->selectedFiles->current(); | 388 | const DocLnk *lnk = d->selectedFiles->current(); |
389 | if ( lnk ) { | 389 | if ( lnk ) { |
390 | QString entryName; | 390 | QString entryName; |
391 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 391 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
392 | // qDebug(entryName); | 392 | // qDebug(entryName); |
393 | cfg.writeEntry( entryName, lnk->linkFile() ); | 393 | cfg.writeEntry( entryName, lnk->linkFile() ); |
394 | // if this link does exist, add it so we have the file | 394 | // if this link does exist, add it so we have the file |
395 | // next time... | 395 | // next time... |
396 | if ( !QFile::exists( lnk->linkFile() ) ) { | 396 | if ( !QFile::exists( lnk->linkFile() ) ) { |
397 | // the way writing lnks doesn't really check for out | 397 | // the way writing lnks doesn't really check for out |
398 | // of disk space, but check it anyway. | 398 | // of disk space, but check it anyway. |
399 | if ( !lnk->writeLink() ) { | 399 | if ( !lnk->writeLink() ) { |
400 | QMessageBox::critical( 0, tr("Out of space"), | 400 | QMessageBox::critical( 0, tr("Out of space"), |
401 | tr( "There was a problem saving " | 401 | tr( "There was a problem saving " |
402 | "the playlist.\n" | 402 | "the playlist.\n" |
403 | "Your playlist " | 403 | "Your playlist " |
404 | "may be missing some entries\n" | 404 | "may be missing some entries\n" |
405 | "the next time you start it." ) | 405 | "the next time you start it." ) |
406 | ); | 406 | ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | noOfFiles++; | 409 | noOfFiles++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | while ( d->selectedFiles->next() ); | 412 | while ( d->selectedFiles->next() ); |
413 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 413 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 417 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
418 | // qDebug("add"); | 418 | // qDebug("add"); |
419 | d->setDocumentUsed = FALSE; | 419 | d->setDocumentUsed = FALSE; |
420 | if ( mediaPlayerState->playlist() ) | 420 | if ( mediaPlayerState->playlist() ) { |
421 | d->selectedFiles->addToSelection( lnk ); | 421 | if(QFileInfo(lnk.file()).exists()) |
422 | d->selectedFiles->addToSelection( lnk ); | ||
423 | } | ||
422 | else | 424 | else |
423 | mediaPlayerState->setPlaying( TRUE ); | 425 | mediaPlayerState->setPlaying( TRUE ); |
424 | } | 426 | } |
425 | 427 | ||
426 | 428 | ||
427 | void PlayListWidget::clearList() { | 429 | void PlayListWidget::clearList() { |
428 | while ( first() ) | 430 | while ( first() ) |
429 | d->selectedFiles->removeSelected(); | 431 | d->selectedFiles->removeSelected(); |
430 | } | 432 | } |
431 | 433 | ||
432 | 434 | ||
433 | void PlayListWidget::addAllToList() { | 435 | void PlayListWidget::addAllToList() { |
434 | DocLnkSet filesAll; | 436 | DocLnkSet filesAll; |
435 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 437 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
436 | QListIterator<DocLnk> Adit( filesAll.children() ); | 438 | QListIterator<DocLnk> Adit( filesAll.children() ); |
437 | for ( ; Adit.current(); ++Adit ) | 439 | for ( ; Adit.current(); ++Adit ) |
438 | d->selectedFiles->addToSelection( **Adit ); | 440 | if(QFileInfo(Adit.current()->file()).exists()) |
441 | d->selectedFiles->addToSelection( **Adit ); | ||
439 | } | 442 | } |
440 | 443 | ||
441 | 444 | ||
442 | void PlayListWidget::addAllMusicToList() { | 445 | void PlayListWidget::addAllMusicToList() { |
443 | QListIterator<DocLnk> dit( files.children() ); | 446 | QListIterator<DocLnk> dit( files.children() ); |
444 | for ( ; dit.current(); ++dit ) | 447 | for ( ; dit.current(); ++dit ) |
448 | if(QFileInfo(dit.current()->file()).exists()) | ||
445 | d->selectedFiles->addToSelection( **dit ); | 449 | d->selectedFiles->addToSelection( **dit ); |
446 | } | 450 | } |
447 | 451 | ||
448 | 452 | ||
449 | void PlayListWidget::addAllVideoToList() { | 453 | void PlayListWidget::addAllVideoToList() { |
450 | QListIterator<DocLnk> dit( vFiles.children() ); | 454 | QListIterator<DocLnk> dit( vFiles.children() ); |
451 | for ( ; dit.current(); ++dit ) | 455 | for ( ; dit.current(); ++dit ) |
452 | d->selectedFiles->addToSelection( **dit ); | 456 | if(QFileInfo( dit.current()->file()).exists()) |
457 | d->selectedFiles->addToSelection( **dit ); | ||
453 | } | 458 | } |
454 | 459 | ||
455 | 460 | ||
456 | void PlayListWidget::setDocument(const QString& fileref) { | 461 | void PlayListWidget::setDocument(const QString& fileref) { |
457 | qDebug(fileref); | 462 | qDebug(fileref); |
458 | fromSetDocument = TRUE; | 463 | fromSetDocument = TRUE; |
459 | if ( fileref.isNull() ) { | 464 | if ( fileref.isNull() ) { |
460 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 465 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
461 | return; | 466 | return; |
462 | } | 467 | } |
463 | // qDebug("setDocument "+fileref); | 468 | // qDebug("setDocument "+fileref); |
464 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 469 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
465 | readm3u( fileref); | 470 | readm3u( fileref); |
466 | } | 471 | } |
467 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 472 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
468 | readPls( fileref); | 473 | readPls( fileref); |
469 | } | 474 | } |
470 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 475 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
471 | clearList(); | 476 | clearList(); |
472 | loadList(DocLnk(fileref)); | 477 | loadList(DocLnk(fileref)); |
473 | d->selectedFiles->first(); | 478 | d->selectedFiles->first(); |
474 | } else { | 479 | } else { |
475 | clearList(); | 480 | clearList(); |
476 | addToSelection( DocLnk( fileref ) ); | 481 | addToSelection( DocLnk( fileref ) ); |
477 | d->setDocumentUsed = TRUE; | 482 | d->setDocumentUsed = TRUE; |
478 | mediaPlayerState->setPlaying( FALSE ); | 483 | mediaPlayerState->setPlaying( FALSE ); |
479 | qApp->processEvents(); | 484 | qApp->processEvents(); |
480 | mediaPlayerState->setPlaying( TRUE ); | 485 | mediaPlayerState->setPlaying( TRUE ); |
481 | qApp->processEvents(); | 486 | qApp->processEvents(); |
482 | setCaption(tr("OpiePlayer")); | 487 | setCaption(tr("OpiePlayer")); |
483 | } | 488 | } |
484 | } | 489 | } |
485 | 490 | ||
486 | 491 | ||
487 | void PlayListWidget::setActiveWindow() { | 492 | void PlayListWidget::setActiveWindow() { |
488 | // When we get raised we need to ensure that it switches views | 493 | // When we get raised we need to ensure that it switches views |
489 | char origView = mediaPlayerState->view(); | 494 | char origView = mediaPlayerState->view(); |
490 | mediaPlayerState->setView( 'l' ); // invalidate | 495 | mediaPlayerState->setView( 'l' ); // invalidate |
491 | mediaPlayerState->setView( origView ); // now switch back | 496 | mediaPlayerState->setView( origView ); // now switch back |
492 | } | 497 | } |
493 | 498 | ||
494 | 499 | ||
495 | void PlayListWidget::useSelectedDocument() { | 500 | void PlayListWidget::useSelectedDocument() { |
496 | d->setDocumentUsed = FALSE; | 501 | d->setDocumentUsed = FALSE; |
497 | } | 502 | } |
498 | 503 | ||
499 | 504 | ||
500 | const DocLnk *PlayListWidget::current() { // this is fugly | 505 | const DocLnk *PlayListWidget::current() { // this is fugly |