summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 20adf17..4c4a921 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -252,386 +252,386 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
252 break; 252 break;
253 } 253 }
254} 254}
255 255
256 256
257void PlayListWidget::addAllToList() { 257void PlayListWidget::addAllToList() {
258 DocLnkSet filesAll; 258 DocLnkSet filesAll;
259 Global::findDocuments(&filesAll, "video/*;audio/*"); 259 Global::findDocuments(&filesAll, "video/*;audio/*");
260 QListIterator<DocLnk> Adit( filesAll.children() ); 260 QListIterator<DocLnk> Adit( filesAll.children() );
261 for ( ; Adit.current(); ++Adit ) { 261 for ( ; Adit.current(); ++Adit ) {
262 if( QFileInfo( Adit.current()->file() ).exists() ) { 262 if( QFileInfo( Adit.current()->file() ).exists() ) {
263 d->selectedFiles->addToSelection( **Adit ); 263 d->selectedFiles->addToSelection( **Adit );
264 } 264 }
265 } 265 }
266} 266}
267 267
268 268
269void PlayListWidget::addAllMusicToList() { 269void PlayListWidget::addAllMusicToList() {
270 QListIterator<DocLnk> dit( files.children() ); 270 QListIterator<DocLnk> dit( files.children() );
271 for ( ; dit.current(); ++dit ) { 271 for ( ; dit.current(); ++dit ) {
272 if( QFileInfo(dit.current()->file() ).exists() ) { 272 if( QFileInfo(dit.current()->file() ).exists() ) {
273 d->selectedFiles->addToSelection( **dit ); 273 d->selectedFiles->addToSelection( **dit );
274 } 274 }
275 } 275 }
276} 276}
277 277
278 278
279void PlayListWidget::addAllVideoToList() { 279void PlayListWidget::addAllVideoToList() {
280 QListIterator<DocLnk> dit( vFiles.children() ); 280 QListIterator<DocLnk> dit( vFiles.children() );
281 for ( ; dit.current(); ++dit ) { 281 for ( ; dit.current(); ++dit ) {
282 if( QFileInfo( dit.current()->file() ).exists() ) { 282 if( QFileInfo( dit.current()->file() ).exists() ) {
283 d->selectedFiles->addToSelection( **dit ); 283 d->selectedFiles->addToSelection( **dit );
284 } 284 }
285 } 285 }
286} 286}
287 287
288 288
289void PlayListWidget::setDocument( const QString& fileref ) { 289void PlayListWidget::setDocument( const QString& fileref ) {
290 //qDebug( fileref ); 290 //qDebug( fileref );
291 fromSetDocument = TRUE; 291 fromSetDocument = TRUE;
292 if ( fileref.isNull() ) { 292 if ( fileref.isNull() ) {
293 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 293 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
294 return; 294 return;
295 } 295 }
296 296
297 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 297 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
298 readm3u( fileref ); 298 readm3u( fileref );
299 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 299 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
300 readPls( fileref ); 300 readPls( fileref );
301 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist 301 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
302 clearList(); 302 clearList();
303 loadList( DocLnk( fileref ) ); 303 loadList( DocLnk( fileref ) );
304 d->selectedFiles->first(); 304 d->selectedFiles->first();
305 } else { 305 } else {
306 clearList(); 306 clearList();
307 addToSelection( DocLnk( fileref ) ); 307 addToSelection( DocLnk( fileref ) );
308 d->setDocumentUsed = TRUE; 308 d->setDocumentUsed = TRUE;
309 mediaPlayerState->setPlaying( FALSE ); 309 mediaPlayerState->setPlaying( FALSE );
310 qApp->processEvents(); 310 qApp->processEvents();
311 mediaPlayerState->setPlaying( TRUE ); 311 mediaPlayerState->setPlaying( TRUE );
312 qApp->processEvents(); 312 qApp->processEvents();
313 setCaption( tr("OpiePlayer") ); 313 setCaption( tr("OpiePlayer") );
314 } 314 }
315} 315}
316 316
317 317
318void PlayListWidget::useSelectedDocument() { 318void PlayListWidget::useSelectedDocument() {
319 d->setDocumentUsed = FALSE; 319 d->setDocumentUsed = FALSE;
320} 320}
321 321
322 322
323const DocLnk *PlayListWidget::current() { // this is fugly 323const DocLnk *PlayListWidget::current() { // this is fugly
324 switch ( whichList() ) { 324 switch ( whichList() ) {
325 case 0: //playlist 325 case 0: //playlist
326 { 326 {
327// qDebug("playlist"); 327// qDebug("playlist");
328 if ( mediaPlayerState->playlist() ) { 328 if ( mediaPlayerState->playlist() ) {
329 return d->selectedFiles->current(); 329 return d->selectedFiles->current();
330 } else if ( d->setDocumentUsed && d->current ) { 330 } else if ( d->setDocumentUsed && d->current ) {
331 return d->current; 331 return d->current;
332 } else { 332 } else {
333 return &(d->files->selectedDocument()); 333 return &(d->files->selectedDocument());
334 } 334 }
335 } 335 }
336 break; 336 break;
337 }; 337 };
338 return 0; 338 return 0;
339} 339}
340 340
341 341
342bool PlayListWidget::prev() { 342bool PlayListWidget::prev() {
343 if ( mediaPlayerState->playlist() ) { 343 if ( mediaPlayerState->playlist() ) {
344 if ( mediaPlayerState->shuffled() ) { 344 if ( mediaPlayerState->shuffled() ) {
345 const DocLnk *cur = current(); 345 const DocLnk *cur = current();
346 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 346 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
347 for ( int i = 0; i < j; i++ ) { 347 for ( int i = 0; i < j; i++ ) {
348 if ( !d->selectedFiles->next() ) 348 if ( !d->selectedFiles->next() )
349 d->selectedFiles->first(); 349 d->selectedFiles->first();
350 } 350 }
351 if ( cur == current() ) 351 if ( cur == current() )
352 if ( !d->selectedFiles->next() ) { 352 if ( !d->selectedFiles->next() ) {
353 d->selectedFiles->first(); 353 d->selectedFiles->first();
354 } 354 }
355 return TRUE; 355 return TRUE;
356 } else { 356 } else {
357 if ( !d->selectedFiles->prev() ) { 357 if ( !d->selectedFiles->prev() ) {
358 if ( mediaPlayerState->looping() ) { 358 if ( mediaPlayerState->looping() ) {
359 return d->selectedFiles->last(); 359 return d->selectedFiles->last();
360 } else { 360 } else {
361 return FALSE; 361 return FALSE;
362 } 362 }
363 } 363 }
364 return TRUE; 364 return TRUE;
365 } 365 }
366 } else { 366 } else {
367 return mediaPlayerState->looping(); 367 return mediaPlayerState->looping();
368 } 368 }
369} 369}
370 370
371 371
372bool PlayListWidget::next() { 372bool PlayListWidget::next() {
373qDebug("<<<<<<<<<<<<next()"); 373qDebug("<<<<<<<<<<<<next()");
374 if ( mediaPlayerState->playlist() ) { 374 if ( mediaPlayerState->playlist() ) {
375 if ( mediaPlayerState->shuffled() ) { 375 if ( mediaPlayerState->shuffled() ) {
376 return prev(); 376 return prev();
377 } else { 377 } else {
378 if ( !d->selectedFiles->next() ) { 378 if ( !d->selectedFiles->next() ) {
379 if ( mediaPlayerState->looping() ) { 379 if ( mediaPlayerState->looping() ) {
380 return d->selectedFiles->first(); 380 return d->selectedFiles->first();
381 } else { 381 } else {
382 return FALSE; 382 return FALSE;
383 } 383 }
384 } 384 }
385 return TRUE; 385 return TRUE;
386 } 386 }
387 } else { 387 } else {
388 return mediaPlayerState->looping(); 388 return mediaPlayerState->looping();
389 } 389 }
390} 390}
391 391
392 392
393bool PlayListWidget::first() { 393bool PlayListWidget::first() {
394 if ( mediaPlayerState->playlist() ) 394 if ( mediaPlayerState->playlist() )
395 return d->selectedFiles->first(); 395 return d->selectedFiles->first();
396 else 396 else
397 return mediaPlayerState->looping(); 397 return mediaPlayerState->looping();
398} 398}
399 399
400 400
401bool PlayListWidget::last() { 401bool PlayListWidget::last() {
402 if ( mediaPlayerState->playlist() ) 402 if ( mediaPlayerState->playlist() )
403 return d->selectedFiles->last(); 403 return d->selectedFiles->last();
404 else 404 else
405 return mediaPlayerState->looping(); 405 return mediaPlayerState->looping();
406} 406}
407 407
408 408
409void PlayListWidget::saveList() { 409void PlayListWidget::saveList() {
410 410
411 QString filename; 411 QString filename;
412 InputDialog *fileDlg = 0l; 412 InputDialog *fileDlg = 0l;
413 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 413 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
414 fileDlg->exec(); 414 fileDlg->exec();
415 if( fileDlg->result() == 1 ) { 415 if( fileDlg->result() == 1 ) {
416 if ( d->current ) 416 if ( d->current )
417 delete d->current; 417 delete d->current;
418 filename = fileDlg->text();//+".playlist"; 418 filename = fileDlg->text();//+".playlist";
419 // qDebug("saving playlist "+filename+".playlist"); 419 // qDebug("saving playlist "+filename+".playlist");
420 Config cfg( filename +".playlist"); 420 Config cfg( filename +".playlist");
421 writeConfig( cfg ); 421 writeConfig( cfg );
422 422
423 DocLnk lnk; 423 DocLnk lnk;
424 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 424 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
425 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 425 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
426 lnk.setIcon("opieplayer2/playlist2"); 426 lnk.setIcon("opieplayer2/playlist2");
427 lnk.setName( filename); //sets file name 427 lnk.setName( filename); //sets file name
428 // qDebug(filename); 428 // qDebug(filename);
429 if(!lnk.writeLink()) { 429 if(!lnk.writeLink()) {
430 qDebug("Writing doclink did not work"); 430 qDebug("Writing doclink did not work");
431 } 431 }
432 } 432 }
433 Config config( "OpiePlayer" ); 433 Config config( "OpiePlayer" );
434 config.writeEntry("CurrentPlaylist",filename); 434 config.writeEntry("CurrentPlaylist",filename);
435 setCaption(tr("OpiePlayer: ")+filename); 435 setCaption(tr("OpiePlayer: ")+filename);
436 d->selectedFiles->first(); 436 d->selectedFiles->first();
437 if(fileDlg) { 437 if(fileDlg) {
438 delete fileDlg; 438 delete fileDlg;
439 } 439 }
440} 440}
441 441
442void PlayListWidget::loadList( const DocLnk & lnk) { 442void PlayListWidget::loadList( const DocLnk & lnk) {
443 QString name= lnk.name(); 443 QString name= lnk.name();
444 // qDebug("currentList is "+name); 444// qDebug("currentList is "+name);
445 if( name.length()>1) { 445 if( name.length()>0) {
446 setCaption("OpiePlayer: "+name); 446 setCaption("OpiePlayer: "+name);
447 // qDebug("load list "+ name+".playlist"); 447 // qDebug("load list "+ name+".playlist");
448 clearList(); 448 clearList();
449 Config cfg( name+".playlist"); 449 Config cfg( name+".playlist");
450 readConfig(cfg); 450 readConfig(cfg);
451 451
452 tabWidget->setCurrentPage(0); 452 tabWidget->setCurrentPage(0);
453 453
454 Config config( "OpiePlayer" ); 454 Config config( "OpiePlayer" );
455 config.writeEntry("CurrentPlaylist", name); 455 config.writeEntry("CurrentPlaylist", name);
456 // d->selectedFiles->first(); 456 // d->selectedFiles->first();
457 } 457 }
458} 458}
459 459
460 460
461void PlayListWidget::setPlaylist( bool shown ) { 461void PlayListWidget::setPlaylist( bool shown ) {
462 if ( shown ) { 462 if ( shown ) {
463 d->playListFrame->show(); 463 d->playListFrame->show();
464 } else { 464 } else {
465 d->playListFrame->hide(); 465 d->playListFrame->hide();
466 } 466 }
467} 467}
468 468
469 469
470void PlayListWidget::addSelected() { 470void PlayListWidget::addSelected() {
471 471
472 Config cfg( "OpiePlayer" ); 472 Config cfg( "OpiePlayer" );
473 cfg.setGroup("PlayList"); 473 cfg.setGroup("PlayList");
474 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 474 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
475 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 475 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
476 476
477 switch (whichList()) { 477 switch (whichList()) {
478 case 0: //playlist 478 case 0: //playlist
479 break; 479 break;
480 case 1: { //audio 480 case 1: { //audio
481 QListViewItemIterator it( audioView ); 481 QListViewItemIterator it( audioView );
482 // iterate through all items of the listview 482 // iterate through all items of the listview
483 for ( ; it.current(); ++it ) { 483 for ( ; it.current(); ++it ) {
484 if ( it.current()->isSelected() ) { 484 if ( it.current()->isSelected() ) {
485 QListIterator<DocLnk> dit( files.children() ); 485 QListIterator<DocLnk> dit( files.children() );
486 for ( ; dit.current(); ++dit ) { 486 for ( ; dit.current(); ++dit ) {
487 if( dit.current()->name() == it.current()->text(0) ) { 487 if( dit.current()->name() == it.current()->text(0) ) {
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 } 490 }
491 } 491 }
492 audioView->setSelected( it.current(),FALSE); 492 audioView->setSelected( it.current(),FALSE);
493 } 493 }
494 } 494 }
495 tabWidget->setCurrentPage(0); 495 tabWidget->setCurrentPage(0);
496 } 496 }
497 break; 497 break;
498 case 2: { // video 498 case 2: { // video
499 QListViewItemIterator it( videoView ); 499 QListViewItemIterator it( videoView );
500 // iterate through all items of the listview 500 // iterate through all items of the listview
501 for ( ; it.current(); ++it ) { 501 for ( ; it.current(); ++it ) {
502 if ( it.current()->isSelected() ) { 502 if ( it.current()->isSelected() ) {
503 QListIterator<DocLnk> dit( vFiles.children() ); 503 QListIterator<DocLnk> dit( vFiles.children() );
504 for ( ; dit.current(); ++dit ) { 504 for ( ; dit.current(); ++dit ) {
505 if( dit.current()->name() == it.current()->text(0) ) { 505 if( dit.current()->name() == it.current()->text(0) ) {
506 if(QFileInfo( dit.current()->file()).exists()) 506 if(QFileInfo( dit.current()->file()).exists())
507 d->selectedFiles->addToSelection( **dit ); 507 d->selectedFiles->addToSelection( **dit );
508 } 508 }
509 } 509 }
510 videoView->setSelected( it.current(),FALSE); 510 videoView->setSelected( it.current(),FALSE);
511 } 511 }
512 } 512 }
513 tabWidget->setCurrentPage(0); 513 tabWidget->setCurrentPage(0);
514 } 514 }
515 break; 515 break;
516 }; 516 };
517} 517}
518 518
519 519
520void PlayListWidget::removeSelected() { 520void PlayListWidget::removeSelected() {
521 d->selectedFiles->removeSelected( ); 521 d->selectedFiles->removeSelected( );
522} 522}
523 523
524 524
525void PlayListWidget::playIt( QListViewItem *it) { 525void PlayListWidget::playIt( QListViewItem *it) {
526 if(!it) return; 526 if(!it) return;
527 mediaPlayerState->setPlaying(FALSE); 527 mediaPlayerState->setPlaying(FALSE);
528 mediaPlayerState->setPlaying(TRUE); 528 mediaPlayerState->setPlaying(TRUE);
529 d->selectedFiles->unSelect(); 529 d->selectedFiles->unSelect();
530} 530}
531 531
532 532
533void PlayListWidget::addToSelection( QListViewItem *it) { 533void PlayListWidget::addToSelection( QListViewItem *it) {
534 d->setDocumentUsed = FALSE; 534 d->setDocumentUsed = FALSE;
535 535
536 if(it) { 536 if(it) {
537 switch ( whichList()) { 537 switch ( whichList()) {
538 case 1: { 538 case 1: {
539 QListIterator<DocLnk> dit( files.children() ); 539 QListIterator<DocLnk> dit( files.children() );
540 for ( ; dit.current(); ++dit ) { 540 for ( ; dit.current(); ++dit ) {
541 if( dit.current()->name() == it->text(0)) { 541 if( dit.current()->name() == it->text(0)) {
542 if(QFileInfo( dit.current()->file()).exists()) 542 if(QFileInfo( dit.current()->file()).exists())
543 d->selectedFiles->addToSelection( **dit ); 543 d->selectedFiles->addToSelection( **dit );
544 } 544 }
545 } 545 }
546 } 546 }
547 break; 547 break;
548 case 2: { 548 case 2: {
549 QListIterator<DocLnk> dit( vFiles.children() ); 549 QListIterator<DocLnk> dit( vFiles.children() );
550 for ( ; dit.current(); ++dit ) { 550 for ( ; dit.current(); ++dit ) {
551 if( dit.current()->name() == it->text(0)) { 551 if( dit.current()->name() == it->text(0)) {
552 if(QFileInfo( dit.current()->file()).exists()) 552 if(QFileInfo( dit.current()->file()).exists())
553 d->selectedFiles->addToSelection( **dit ); 553 d->selectedFiles->addToSelection( **dit );
554 } 554 }
555 } 555 }
556 } 556 }
557 break; 557 break;
558 case 0: 558 case 0:
559 break; 559 break;
560 }; 560 };
561 tabWidget->setCurrentPage(0); 561 tabWidget->setCurrentPage(0);
562 } 562 }
563} 563}
564 564
565 565
566void PlayListWidget::tabChanged(QWidget *) { 566void PlayListWidget::tabChanged(QWidget *) {
567 567
568 switch ( whichList()) { 568 switch ( whichList()) {
569 case 0: 569 case 0:
570 { 570 {
571 if( !tbDeletePlaylist->isHidden() ) { 571 if( !tbDeletePlaylist->isHidden() ) {
572 tbDeletePlaylist->hide(); 572 tbDeletePlaylist->hide();
573 } 573 }
574 d->tbRemoveFromList->setEnabled(TRUE); 574 d->tbRemoveFromList->setEnabled(TRUE);
575 d->tbAddToList->setEnabled(FALSE); 575 d->tbAddToList->setEnabled(FALSE);
576 } 576 }
577 break; 577 break;
578 case 1: 578 case 1:
579 { 579 {
580 audioView->clear(); 580 audioView->clear();
581 populateAudioView(); 581 populateAudioView();
582 582
583 if( !tbDeletePlaylist->isHidden() ) { 583 if( !tbDeletePlaylist->isHidden() ) {
584 tbDeletePlaylist->hide(); 584 tbDeletePlaylist->hide();
585 } 585 }
586 d->tbRemoveFromList->setEnabled(FALSE); 586 d->tbRemoveFromList->setEnabled(FALSE);
587 d->tbAddToList->setEnabled(TRUE); 587 d->tbAddToList->setEnabled(TRUE);
588 } 588 }
589 break; 589 break;
590 case 2: 590 case 2:
591 { 591 {
592 videoView->clear(); 592 videoView->clear();
593 populateVideoView(); 593 populateVideoView();
594 if( !tbDeletePlaylist->isHidden() ) { 594 if( !tbDeletePlaylist->isHidden() ) {
595 tbDeletePlaylist->hide(); 595 tbDeletePlaylist->hide();
596 } 596 }
597 d->tbRemoveFromList->setEnabled(FALSE); 597 d->tbRemoveFromList->setEnabled(FALSE);
598 d->tbAddToList->setEnabled(TRUE); 598 d->tbAddToList->setEnabled(TRUE);
599 } 599 }
600 break; 600 break;
601 case 3: 601 case 3:
602 { 602 {
603 if( tbDeletePlaylist->isHidden() ) { 603 if( tbDeletePlaylist->isHidden() ) {
604 tbDeletePlaylist->show(); 604 tbDeletePlaylist->show();
605 } 605 }
606 playLists->reread(); 606 playLists->reread();
607 } 607 }
608 break; 608 break;
609 }; 609 };
610} 610}
611 611
612 612
613void PlayListWidget::btnPlay(bool b) { 613void PlayListWidget::btnPlay(bool b) {
614// mediaPlayerState->setPlaying(false); 614// mediaPlayerState->setPlaying(false);
615 mediaPlayerState->setPlaying(b); 615 mediaPlayerState->setPlaying(b);
616 qApp->processEvents(); 616 qApp->processEvents();
617 insanityBool=FALSE; 617 insanityBool=FALSE;
618// switch ( whichList()) { 618// switch ( whichList()) {
619// case 0: 619// case 0:
620// { 620// {
621// mediaPlayerState->setPlaying(b); 621// mediaPlayerState->setPlaying(b);
622// } 622// }
623// break; 623// break;
624// case 1: 624// case 1:
625// { 625// {
626// mediaPlayerState->setPlaying(b); 626// mediaPlayerState->setPlaying(b);
627// qApp->processEvents(); 627// qApp->processEvents();
628// insanityBool=FALSE; 628// insanityBool=FALSE;
629// }// audioView->clearSelection(); 629// }// audioView->clearSelection();
630// break; 630// break;
631// case 2: 631// case 2:
632// { 632// {
633// // addToSelection( videoView->currentItem() ); 633// // addToSelection( videoView->currentItem() );
634// mediaPlayerState->setPlaying(b); 634// mediaPlayerState->setPlaying(b);
635// qApp->processEvents(); 635// qApp->processEvents();
636// // d->selectedFiles->removeSelected( ); 636// // d->selectedFiles->removeSelected( );
637// // tabWidget->setCurrentPage(2); 637// // tabWidget->setCurrentPage(2);