author | llornkcor <llornkcor> | 2002-11-12 02:36:55 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-12 02:36:55 (UTC) |
commit | c829e55b85c20034f0ae07336fd3f5b9a03d9a48 (patch) (unidiff) | |
tree | 4bf1909c70c90a9fb1a70ad0d129f38e06d5ee80 | |
parent | 03932444a6873eae016b934e540fd76a1197a0c1 (diff) | |
download | opie-c829e55b85c20034f0ae07336fd3f5b9a03d9a48.zip opie-c829e55b85c20034f0ae07336fd3f5b9a03d9a48.tar.gz opie-c829e55b85c20034f0ae07336fd3f5b9a03d9a48.tar.bz2 |
fix playlist adding when two file share the same basename but different paths. made it faster adding files to playlist
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 147 |
1 files changed, 58 insertions, 89 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 8e88e9b..a6a9eca 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -206,14 +206,15 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
206 | } | 206 | } |
207 | 207 | ||
208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
209 | d->setDocumentUsed = FALSE; | 209 | d->setDocumentUsed = FALSE; |
210 | if ( mediaPlayerState->playlist() ) { | 210 | if ( mediaPlayerState->playlist() ) { |
211 | if( QFileInfo( lnk.file() ).exists() || | 211 | if( QFileInfo( lnk.file() ).exists() || |
212 | lnk.file().left(4) == "http" ) | 212 | lnk.file().left(4) == "http" ) { |
213 | d->selectedFiles->addToSelection( lnk ); | 213 | d->selectedFiles->addToSelection( lnk ); |
214 | } | ||
214 | // writeCurrentM3u(); | 215 | // writeCurrentM3u(); |
215 | } | 216 | } |
216 | else | 217 | else |
217 | mediaPlayerState->setPlaying( TRUE ); | 218 | mediaPlayerState->setPlaying( TRUE ); |
218 | } | 219 | } |
219 | 220 | ||
@@ -262,39 +263,46 @@ void PlayListWidget::addAllToList() { | |||
262 | QListIterator<DocLnk> Adit( filesAll.children() ); | 263 | QListIterator<DocLnk> Adit( filesAll.children() ); |
263 | for ( ; Adit.current(); ++Adit ) { | 264 | for ( ; Adit.current(); ++Adit ) { |
264 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 265 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
265 | d->selectedFiles->addToSelection( **Adit ); | 266 | d->selectedFiles->addToSelection( **Adit ); |
266 | } | 267 | } |
267 | } | 268 | } |
268 | writeCurrentM3u(); | 269 | tabWidget->setCurrentPage(0); |
270 | |||
271 | writeCurrentM3u(); | ||
272 | d->selectedFiles->first(); | ||
269 | } | 273 | } |
270 | 274 | ||
271 | 275 | ||
272 | void PlayListWidget::addAllMusicToList() { | 276 | void PlayListWidget::addAllMusicToList() { |
273 | if(!audioScan) | 277 | if(!audioScan) |
274 | scanForAudio(); | 278 | scanForAudio(); |
275 | QListIterator<DocLnk> dit( files.children() ); | 279 | QListIterator<DocLnk> dit( files.children() ); |
276 | for ( ; dit.current(); ++dit ) { | 280 | for ( ; dit.current(); ++dit ) { |
277 | if( QFileInfo(dit.current()->file() ).exists() ) { | 281 | if( QFileInfo(dit.current()->file() ).exists() ) { |
278 | d->selectedFiles->addToSelection( **dit ); | 282 | d->selectedFiles->addToSelection( **dit ); |
279 | } | 283 | } |
280 | } | 284 | } |
281 | writeCurrentM3u(); | 285 | tabWidget->setCurrentPage(0); |
286 | writeCurrentM3u(); | ||
287 | d->selectedFiles->first(); | ||
282 | } | 288 | } |
283 | 289 | ||
284 | 290 | ||
285 | void PlayListWidget::addAllVideoToList() { | 291 | void PlayListWidget::addAllVideoToList() { |
286 | if(!videoScan) | 292 | if(!videoScan) |
287 | scanForVideo(); | 293 | scanForVideo(); |
288 | QListIterator<DocLnk> dit( vFiles.children() ); | 294 | QListIterator<DocLnk> dit( vFiles.children() ); |
289 | for ( ; dit.current(); ++dit ) { | 295 | for ( ; dit.current(); ++dit ) { |
290 | if( QFileInfo( dit.current()->file() ).exists() ) { | 296 | if( QFileInfo( dit.current()->file() ).exists() ) { |
291 | d->selectedFiles->addToSelection( **dit ); | 297 | d->selectedFiles->addToSelection( **dit ); |
292 | } | 298 | } |
293 | } | 299 | } |
300 | tabWidget->setCurrentPage(0); | ||
294 | writeCurrentM3u(); | 301 | writeCurrentM3u(); |
302 | d->selectedFiles->first(); | ||
295 | } | 303 | } |
296 | 304 | ||
297 | 305 | ||
298 | void PlayListWidget::setDocument( const QString& fileref ) { | 306 | void PlayListWidget::setDocument( const QString& fileref ) { |
299 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 307 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
300 | fromSetDocument = TRUE; | 308 | fromSetDocument = TRUE; |
@@ -420,17 +428,17 @@ bool PlayListWidget::last() { | |||
420 | writem3u(); | 428 | writem3u(); |
421 | } | 429 | } |
422 | 430 | ||
423 | 431 | ||
424 | void PlayListWidget::loadList( const DocLnk & lnk) { | 432 | void PlayListWidget::loadList( const DocLnk & lnk) { |
425 | QString name = lnk.name(); | 433 | QString name = lnk.name(); |
426 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 434 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
427 | 435 | ||
428 | if( name.length()>0) { | 436 | if( name.length()>0) { |
429 | setCaption("OpiePlayer: "+name); | 437 | setCaption("OpiePlayer: "+name); |
430 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 438 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
431 | clearList(); | 439 | clearList(); |
432 | readm3u(lnk.file()); | 440 | readm3u(lnk.file()); |
433 | tabWidget->setCurrentPage(0); | 441 | tabWidget->setCurrentPage(0); |
434 | } | 442 | } |
435 | } | 443 | } |
436 | 444 | ||
@@ -442,59 +450,38 @@ void PlayListWidget::setPlaylist( bool shown ) { | |||
442 | d->playListFrame->hide(); | 450 | d->playListFrame->hide(); |
443 | } | 451 | } |
444 | } | 452 | } |
445 | 453 | ||
446 | 454 | ||
447 | void PlayListWidget::addSelected() { | 455 | void PlayListWidget::addSelected() { |
448 | qDebug("addSelected"); | 456 | qDebug("addSelected"); |
449 | switch (whichList()) { | 457 | DocLnk lnk; |
450 | case 0: //playlist | 458 | QString filename; |
451 | break; | 459 | switch (whichList()) { |
452 | case 1: { //audio | 460 | |
453 | QListViewItemIterator it( audioView ); | 461 | case 0: //playlist |
454 | // iterate through all items of the listview | 462 | return; |
455 | for ( ; it.current(); ++it ) { | 463 | break; |
456 | if ( it.current()->isSelected() ) { | 464 | case 1: { //audio |
457 | QListIterator<DocLnk> dit( files.children() ); | 465 | filename=audioView->currentItem()->text(3); |
458 | for ( ; dit.current(); ++dit ) { | 466 | // d->selectedFiles->next(); |
459 | if( dit.current()->name() == it.current()->text(0) ) { | 467 | } |
460 | if( QFileInfo( dit.current()->file()).exists()) { | 468 | break; |
461 | d->selectedFiles->addToSelection( **dit ); | ||
462 | audioView->setSelected( it.current(),FALSE); | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | } | ||
467 | } | ||
468 | // tabWidget->setCurrentPage(0); | ||
469 | writeCurrentM3u(); | ||
470 | d->selectedFiles->next(); | ||
471 | } | ||
472 | break; | ||
473 | case 2: { // video | ||
474 | QListViewItemIterator it( videoView ); | ||
475 | // iterate through all items of the listview | ||
476 | for ( ; it.current(); ++it ) { | ||
477 | if ( it.current()->isSelected() ) { | ||
478 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
479 | for ( ; dit.current(); ++dit ) { | ||
480 | if( dit.current()->name() == it.current()->text(0) ) { | ||
481 | if(QFileInfo( dit.current()->file()).exists()) { | ||
482 | d->selectedFiles->addToSelection( **dit ); | ||
483 | videoView->setSelected( it.current(),FALSE); | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | // tabWidget->setCurrentPage(0); | ||
490 | writeCurrentM3u(); | ||
491 | 469 | ||
492 | } | 470 | case 2: { // video |
493 | break; | 471 | filename=videoView->currentItem()->text(3); |
494 | }; | 472 | // tabWidget->setCurrentPage(0); |
473 | |||
474 | } | ||
475 | break; | ||
476 | }; | ||
477 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
478 | lnk.setFile( filename ); //sets file name | ||
479 | d->selectedFiles->addToSelection( lnk); | ||
480 | tabWidget->setCurrentPage(0); | ||
481 | writeCurrentM3u(); | ||
495 | } | 482 | } |
496 | 483 | ||
497 | 484 | ||
498 | void PlayListWidget::removeSelected() { | 485 | void PlayListWidget::removeSelected() { |
499 | d->selectedFiles->removeSelected( ); | 486 | d->selectedFiles->removeSelected( ); |
500 | writeCurrentM3u(); | 487 | writeCurrentM3u(); |
@@ -507,51 +494,33 @@ void PlayListWidget::playIt( QListViewItem *it) { | |||
507 | mediaPlayerState->setPlaying(TRUE); | 494 | mediaPlayerState->setPlaying(TRUE); |
508 | d->selectedFiles->unSelect(); | 495 | d->selectedFiles->unSelect(); |
509 | } | 496 | } |
510 | 497 | ||
511 | 498 | ||
512 | void PlayListWidget::addToSelection( QListViewItem *it) { | 499 | void PlayListWidget::addToSelection( QListViewItem *it) { |
513 | d->setDocumentUsed = FALSE; | 500 | d->setDocumentUsed = FALSE; |
514 | 501 | ||
515 | if(it) { | 502 | if(it) { |
516 | switch ( whichList()) { | 503 | switch ( whichList()) { |
517 | case 1: { | 504 | case 0: //playlist |
518 | QListIterator<DocLnk> dit( files.children() ); | 505 | return; |
519 | for ( ; dit.current(); ++dit ) { | 506 | break; |
520 | if( dit.current()->name() == it->text(0)) { | 507 | }; |
521 | if(QFileInfo( dit.current()->file()).exists()) { | 508 | // case 1: { |
522 | d->selectedFiles->addToSelection( **dit ); | 509 | DocLnk lnk; |
523 | // qDebug("blah "+ dit.current()->name()); | 510 | QString filename; |
524 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | 511 | |
525 | } | 512 | filename=it->text(3); |
526 | } | 513 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
527 | } | 514 | lnk.setFile( filename ); //sets file name |
528 | writeCurrentM3u(); | 515 | d->selectedFiles->addToSelection( lnk); |
529 | } | 516 | |
530 | break; | 517 | writeCurrentM3u(); |
531 | case 2: { | 518 | tabWidget->setCurrentPage(0); |
532 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
533 | for ( ; dit.current(); ++dit ) { | ||
534 | if( dit.current()->name() == it->text(0)) { | ||
535 | if( QFileInfo( dit.current()->file()).exists() ) { | ||
536 | d->selectedFiles->addToSelection( **dit ); | ||
537 | // qDebug("blah "+ dit.current()->name()); | ||
538 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | ||
539 | } | ||
540 | } | ||
541 | } | ||
542 | writeCurrentM3u(); | ||
543 | |||
544 | } | ||
545 | break; | ||
546 | case 0: | ||
547 | break; | ||
548 | }; | ||
549 | tabWidget->setCurrentPage(0); | ||
550 | 519 | ||
551 | } | 520 | } |
552 | } | 521 | } |
553 | 522 | ||
554 | 523 | ||
555 | void PlayListWidget::tabChanged(QWidget *) { | 524 | void PlayListWidget::tabChanged(QWidget *) { |
556 | 525 | ||
557 | switch ( whichList()) { | 526 | switch ( whichList()) { |
@@ -916,13 +885,13 @@ void PlayListWidget::writem3u() { | |||
916 | 885 | ||
917 | if( name.right( 3 ) != "m3u" ) { | 886 | if( name.right( 3 ) != "m3u" ) { |
918 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 887 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
919 | } | 888 | } |
920 | 889 | ||
921 | if( d->selectedFiles->first()) { | 890 | if( d->selectedFiles->first()) { |
922 | m3uList = new Om3u(filename, IO_ReadWrite); | 891 | m3uList = new Om3u(filename, IO_ReadWrite); |
923 | 892 | ||
924 | do { | 893 | do { |
925 | m3uList->add( d->selectedFiles->current()->file()); | 894 | m3uList->add( d->selectedFiles->current()->file()); |
926 | } | 895 | } |
927 | while ( d->selectedFiles->next() ); | 896 | while ( d->selectedFiles->next() ); |
928 | // qDebug( list ); | 897 | // qDebug( list ); |