Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 63df715..0764c01 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -274,129 +274,131 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
275 | 275 | ||
276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
278 | 278 | ||
279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
284 | 284 | ||
285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
287 | 287 | ||
288 | setCentralWidget( vbox5 ); | 288 | setCentralWidget( vbox5 ); |
289 | 289 | ||
290 | Config cfg( "MediaPlayer" ); | 290 | Config cfg( "MediaPlayer" ); |
291 | readConfig( cfg ); | 291 | readConfig( cfg ); |
292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
293 | // qDebug("currentList is "+currentPlaylist); | 293 | // qDebug("currentList is "+currentPlaylist); |
294 | loadList(DocLnk( currentPlaylist)); | 294 | loadList(DocLnk( currentPlaylist)); |
295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
296 | 296 | ||
297 | initializeStates(); | 297 | initializeStates(); |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | PlayListWidget::~PlayListWidget() { | 301 | PlayListWidget::~PlayListWidget() { |
302 | Config cfg( "MediaPlayer" ); | 302 | Config cfg( "MediaPlayer" ); |
303 | writeConfig( cfg ); | 303 | writeConfig( cfg ); |
304 | 304 | ||
305 | 305 | ||
306 | if ( d->current ) | 306 | if ( d->current ) |
307 | delete d->current; | 307 | delete d->current; |
308 | delete d; | 308 | delete d; |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | void PlayListWidget::initializeStates() { | 312 | void PlayListWidget::initializeStates() { |
313 | 313 | ||
314 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 314 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
315 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 315 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
320 | // setPlaylist( mediaPlayerState->playlist() ); | 320 | // setPlaylist( mediaPlayerState->playlist() ); |
321 | setPlaylist( true); | 321 | setPlaylist( true); |
322 | d->selectedFiles->first(); | 322 | // d->selectedFiles->first(); |
323 | |||
323 | } | 324 | } |
324 | 325 | ||
325 | 326 | ||
326 | void PlayListWidget::readConfig( Config& cfg ) { | 327 | void PlayListWidget::readConfig( Config& cfg ) { |
327 | cfg.setGroup("PlayList"); | 328 | cfg.setGroup("PlayList"); |
328 | QString currentString = cfg.readEntry("current", "" ); | 329 | QString currentString = cfg.readEntry("current", "" ); |
329 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 330 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
330 | for ( int i = 0; i < noOfFiles; i++ ) { | 331 | for ( int i = 0; i < noOfFiles; i++ ) { |
331 | QString entryName; | 332 | QString entryName; |
332 | entryName.sprintf( "File%i", i + 1 ); | 333 | entryName.sprintf( "File%i", i + 1 ); |
333 | QString linkFile = cfg.readEntry( entryName ); | 334 | QString linkFile = cfg.readEntry( entryName ); |
334 | DocLnk lnk( linkFile ); | 335 | DocLnk lnk( linkFile ); |
335 | if ( lnk.isValid() ) { | 336 | if ( lnk.isValid() ) { |
336 | d->selectedFiles->addToSelection( lnk ); | 337 | d->selectedFiles->addToSelection( lnk ); |
337 | } | 338 | } |
338 | } | 339 | } |
340 | d->selectedFiles->setSelectedItem( currentString); | ||
339 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 341 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
340 | } | 342 | } |
341 | 343 | ||
342 | 344 | ||
343 | void PlayListWidget::writeConfig( Config& cfg ) const { | 345 | void PlayListWidget::writeConfig( Config& cfg ) const { |
344 | 346 | ||
345 | d->selectedFiles->writeCurrent( cfg); | 347 | d->selectedFiles->writeCurrent( cfg); |
346 | cfg.setGroup("PlayList"); | 348 | cfg.setGroup("PlayList"); |
347 | int noOfFiles = 0; | 349 | int noOfFiles = 0; |
348 | d->selectedFiles->first(); | 350 | d->selectedFiles->first(); |
349 | do { | 351 | do { |
350 | const DocLnk *lnk = d->selectedFiles->current(); | 352 | const DocLnk *lnk = d->selectedFiles->current(); |
351 | if ( lnk ) { | 353 | if ( lnk ) { |
352 | QString entryName; | 354 | QString entryName; |
353 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 355 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
354 | qDebug(entryName); | 356 | // qDebug(entryName); |
355 | cfg.writeEntry( entryName, lnk->linkFile() ); | 357 | cfg.writeEntry( entryName, lnk->linkFile() ); |
356 | // 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 |
357 | // next time... | 359 | // next time... |
358 | if ( !QFile::exists( lnk->linkFile() ) ) { | 360 | if ( !QFile::exists( lnk->linkFile() ) ) { |
359 | // the way writing lnks doesn't really check for out | 361 | // the way writing lnks doesn't really check for out |
360 | // of disk space, but check it anyway. | 362 | // of disk space, but check it anyway. |
361 | if ( !lnk->writeLink() ) { | 363 | if ( !lnk->writeLink() ) { |
362 | QMessageBox::critical( 0, tr("Out of space"), | 364 | QMessageBox::critical( 0, tr("Out of space"), |
363 | tr( "There was a problem saving " | 365 | tr( "There was a problem saving " |
364 | "the playlist.\n" | 366 | "the playlist.\n" |
365 | "Your playlist " | 367 | "Your playlist " |
366 | "may be missing some entries\n" | 368 | "may be missing some entries\n" |
367 | "the next time you start it." ) | 369 | "the next time you start it." ) |
368 | ); | 370 | ); |
369 | } | 371 | } |
370 | } | 372 | } |
371 | noOfFiles++; | 373 | noOfFiles++; |
372 | } | 374 | } |
373 | } | 375 | } |
374 | while ( d->selectedFiles->next() ); | 376 | while ( d->selectedFiles->next() ); |
375 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
376 | } | 378 | } |
377 | 379 | ||
378 | 380 | ||
379 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
380 | // qDebug("add"); | 382 | // qDebug("add"); |
381 | d->setDocumentUsed = FALSE; | 383 | d->setDocumentUsed = FALSE; |
382 | if ( mediaPlayerState->playlist() ) | 384 | if ( mediaPlayerState->playlist() ) |
383 | d->selectedFiles->addToSelection( lnk ); | 385 | d->selectedFiles->addToSelection( lnk ); |
384 | else | 386 | else |
385 | mediaPlayerState->setPlaying( TRUE ); | 387 | mediaPlayerState->setPlaying( TRUE ); |
386 | } | 388 | } |
387 | 389 | ||
388 | 390 | ||
389 | void PlayListWidget::clearList() { | 391 | void PlayListWidget::clearList() { |
390 | while ( first() ) | 392 | while ( first() ) |
391 | d->selectedFiles->removeSelected(); | 393 | d->selectedFiles->removeSelected(); |
392 | } | 394 | } |
393 | 395 | ||
394 | 396 | ||
395 | void PlayListWidget::addAllToList() { | 397 | void PlayListWidget::addAllToList() { |
396 | DocLnkSet filesAll; | 398 | DocLnkSet filesAll; |
397 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 399 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
398 | QListIterator<DocLnk> Adit( filesAll.children() ); | 400 | QListIterator<DocLnk> Adit( filesAll.children() ); |
399 | for ( ; Adit.current(); ++Adit ) | 401 | for ( ; Adit.current(); ++Adit ) |
400 | d->selectedFiles->addToSelection( **Adit ); | 402 | d->selectedFiles->addToSelection( **Adit ); |
401 | } | 403 | } |
402 | 404 | ||
@@ -428,97 +430,97 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
428 | clearList(); | 430 | clearList(); |
429 | addToSelection( DocLnk( fileref ) ); | 431 | addToSelection( DocLnk( fileref ) ); |
430 | d->setDocumentUsed = TRUE; | 432 | d->setDocumentUsed = TRUE; |
431 | mediaPlayerState->setPlaying( FALSE ); | 433 | mediaPlayerState->setPlaying( FALSE ); |
432 | qApp->processEvents(); | 434 | qApp->processEvents(); |
433 | mediaPlayerState->setPlaying( TRUE ); | 435 | mediaPlayerState->setPlaying( TRUE ); |
434 | qApp->processEvents(); | 436 | qApp->processEvents(); |
435 | setCaption(tr("OpiePlayer")); | 437 | setCaption(tr("OpiePlayer")); |
436 | 438 | ||
437 | } else { //is playlist | 439 | } else { //is playlist |
438 | clearList(); | 440 | clearList(); |
439 | loadList(DocLnk(fileref)); | 441 | loadList(DocLnk(fileref)); |
440 | d->selectedFiles->first(); | 442 | d->selectedFiles->first(); |
441 | } | 443 | } |
442 | } | 444 | } |
443 | 445 | ||
444 | 446 | ||
445 | void PlayListWidget::setActiveWindow() { | 447 | void PlayListWidget::setActiveWindow() { |
446 | // 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 |
447 | char origView = mediaPlayerState->view(); | 449 | char origView = mediaPlayerState->view(); |
448 | mediaPlayerState->setView( 'l' ); // invalidate | 450 | mediaPlayerState->setView( 'l' ); // invalidate |
449 | mediaPlayerState->setView( origView ); // now switch back | 451 | mediaPlayerState->setView( origView ); // now switch back |
450 | } | 452 | } |
451 | 453 | ||
452 | 454 | ||
453 | void PlayListWidget::useSelectedDocument() { | 455 | void PlayListWidget::useSelectedDocument() { |
454 | d->setDocumentUsed = FALSE; | 456 | d->setDocumentUsed = FALSE; |
455 | } | 457 | } |
456 | 458 | ||
457 | 459 | ||
458 | const DocLnk *PlayListWidget::current() { // this is fugly | 460 | const DocLnk *PlayListWidget::current() { // this is fugly |
459 | 461 | ||
460 | // if( fromSetDocument) { | 462 | // if( fromSetDocument) { |
461 | // qDebug("from setDoc"); | 463 | // qDebug("from setDoc"); |
462 | // DocLnkSet files; | 464 | // DocLnkSet files; |
463 | // Global::findDocuments(&files, "video/*;audio/*"); | 465 | // Global::findDocuments(&files, "video/*;audio/*"); |
464 | // QListIterator<DocLnk> dit( files.children() ); | 466 | // QListIterator<DocLnk> dit( files.children() ); |
465 | // for ( ; dit.current(); ++dit ) { | 467 | // for ( ; dit.current(); ++dit ) { |
466 | // if(dit.current()->linkFile() == setDocFileRef) { | 468 | // if(dit.current()->linkFile() == setDocFileRef) { |
467 | // qDebug(setDocFileRef); | 469 | // qDebug(setDocFileRef); |
468 | // return dit; | 470 | // return dit; |
469 | // } | 471 | // } |
470 | // } | 472 | // } |
471 | // } else | 473 | // } else |
472 | // qDebug("current"); | 474 | // qDebug("current"); |
473 | // switch (tabWidget->currentPageIndex()) { | 475 | // switch (tabWidget->currentPageIndex()) { |
474 | // case 0: //playlist | 476 | // case 0: //playlist |
475 | // { | 477 | // { |
476 | qDebug("playlist"); | 478 | // qDebug("playlist"); |
477 | if ( mediaPlayerState->playlist() ) { | 479 | if ( mediaPlayerState->playlist() ) { |
478 | return d->selectedFiles->current(); | 480 | return d->selectedFiles->current(); |
479 | } | 481 | } |
480 | else if ( d->setDocumentUsed && d->current ) { | 482 | else if ( d->setDocumentUsed && d->current ) { |
481 | return d->current; | 483 | return d->current; |
482 | } else { | 484 | } else { |
483 | return d->files->selected(); | 485 | return d->files->selected(); |
484 | } | 486 | } |
485 | // } | 487 | // } |
486 | // break; | 488 | // break; |
487 | // case 1://audio | 489 | // case 1://audio |
488 | // { | 490 | // { |
489 | // qDebug("audioView"); | 491 | // qDebug("audioView"); |
490 | // Global::findDocuments(&files, "audio/*"); | 492 | // Global::findDocuments(&files, "audio/*"); |
491 | // QListIterator<DocLnk> dit( files.children() ); | 493 | // QListIterator<DocLnk> dit( files.children() ); |
492 | // for ( ; dit.current(); ++dit ) { | 494 | // for ( ; dit.current(); ++dit ) { |
493 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 495 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
494 | // qDebug("here"); | 496 | // qDebug("here"); |
495 | // insanityBool=TRUE; | 497 | // insanityBool=TRUE; |
496 | // return dit; | 498 | // return dit; |
497 | // } | 499 | // } |
498 | // } | 500 | // } |
499 | // } | 501 | // } |
500 | // break; | 502 | // break; |
501 | // case 2: // video | 503 | // case 2: // video |
502 | // { | 504 | // { |
503 | // qDebug("videoView"); | 505 | // qDebug("videoView"); |
504 | // Global::findDocuments(&vFiles, "video/*"); | 506 | // Global::findDocuments(&vFiles, "video/*"); |
505 | // QListIterator<DocLnk> Vdit( vFiles.children() ); | 507 | // QListIterator<DocLnk> Vdit( vFiles.children() ); |
506 | // for ( ; Vdit.current(); ++Vdit ) { | 508 | // for ( ; Vdit.current(); ++Vdit ) { |
507 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 509 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
508 | // insanityBool=TRUE; | 510 | // insanityBool=TRUE; |
509 | // return Vdit; | 511 | // return Vdit; |
510 | // } | 512 | // } |
511 | // } | 513 | // } |
512 | // } | 514 | // } |
513 | // break; | 515 | // break; |
514 | // }; | 516 | // }; |
515 | // return 0; | 517 | // return 0; |
516 | } | 518 | } |
517 | 519 | ||
518 | bool PlayListWidget::prev() { | 520 | bool PlayListWidget::prev() { |
519 | if ( mediaPlayerState->playlist() ) { | 521 | if ( mediaPlayerState->playlist() ) { |
520 | if ( mediaPlayerState->shuffled() ) { | 522 | if ( mediaPlayerState->shuffled() ) { |
521 | const DocLnk *cur = current(); | 523 | const DocLnk *cur = current(); |
522 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 524 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
523 | for ( int i = 0; i < j; i++ ) { | 525 | for ( int i = 0; i < j; i++ ) { |
524 | if ( !d->selectedFiles->next() ) | 526 | if ( !d->selectedFiles->next() ) |
@@ -564,97 +566,97 @@ bool PlayListWidget::next() { | |||
564 | } | 566 | } |
565 | 567 | ||
566 | 568 | ||
567 | bool PlayListWidget::first() { | 569 | bool PlayListWidget::first() { |
568 | if ( mediaPlayerState->playlist() ) | 570 | if ( mediaPlayerState->playlist() ) |
569 | return d->selectedFiles->first(); | 571 | return d->selectedFiles->first(); |
570 | else | 572 | else |
571 | return mediaPlayerState->looping(); | 573 | return mediaPlayerState->looping(); |
572 | } | 574 | } |
573 | 575 | ||
574 | 576 | ||
575 | bool PlayListWidget::last() { | 577 | bool PlayListWidget::last() { |
576 | if ( mediaPlayerState->playlist() ) | 578 | if ( mediaPlayerState->playlist() ) |
577 | return d->selectedFiles->last(); | 579 | return d->selectedFiles->last(); |
578 | else | 580 | else |
579 | return mediaPlayerState->looping(); | 581 | return mediaPlayerState->looping(); |
580 | } | 582 | } |
581 | 583 | ||
582 | 584 | ||
583 | void PlayListWidget::saveList() { | 585 | void PlayListWidget::saveList() { |
584 | 586 | ||
585 | QString filename; | 587 | QString filename; |
586 | InputDialog *fileDlg; | 588 | InputDialog *fileDlg; |
587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 589 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
588 | fileDlg->exec(); | 590 | fileDlg->exec(); |
589 | if( fileDlg->result() == 1 ) { | 591 | if( fileDlg->result() == 1 ) { |
590 | if ( d->current ) | 592 | if ( d->current ) |
591 | delete d->current; | 593 | delete d->current; |
592 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 594 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
593 | // qDebug("saving playlist "+filename+".playlist"); | 595 | // qDebug("saving playlist "+filename+".playlist"); |
594 | Config cfg( filename +".playlist"); | 596 | Config cfg( filename +".playlist"); |
595 | writeConfig( cfg ); | 597 | writeConfig( cfg ); |
596 | 598 | ||
597 | // qDebug("same name so delete lnk??"); | 599 | // qDebug("same name so delete lnk??"); |
598 | // if( playLists->selected()->name() == filename) { | 600 | // if( playLists->selected()->name() == filename) { |
599 | 601 | ||
600 | // qDebug("same name so delete lnk"); | 602 | // qDebug("same name so delete lnk"); |
601 | // QFile().remove(playLists->selected()->file()); | 603 | // QFile().remove(playLists->selected()->file()); |
602 | // QFile().remove(playLists->selected()->linkFile()); | 604 | // QFile().remove(playLists->selected()->linkFile()); |
603 | // playLists->reread(); | 605 | // playLists->reread(); |
604 | // } | 606 | // } |
605 | // qDebug("new doclnk"); | 607 | // qDebug("new doclnk"); |
606 | DocLnk lnk; | 608 | DocLnk lnk; |
607 | // lnk.setComment( ""); | 609 | // lnk.setComment( ""); |
608 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 610 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
609 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 611 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
610 | lnk.setIcon("mpegplayer/playlist2"); | 612 | lnk.setIcon("mpegplayer/playlist2"); |
611 | lnk.setName( filename); //sets file name | 613 | lnk.setName( filename); //sets file name |
612 | qDebug(filename); | 614 | // qDebug(filename); |
613 | if(!lnk.writeLink()) | 615 | if(!lnk.writeLink()) |
614 | qDebug("Writing doclink did not work"); | 616 | qDebug("Writing doclink did not work"); |
615 | } | 617 | } |
616 | Config config( "MediaPlayer" ); | 618 | Config config( "MediaPlayer" ); |
617 | config.writeEntry("CurrentPlaylist",filename); | 619 | config.writeEntry("CurrentPlaylist",filename); |
618 | setCaption(tr("OpiePlayer: ")+filename); | 620 | setCaption(tr("OpiePlayer: ")+filename); |
619 | d->selectedFiles->first(); | 621 | d->selectedFiles->first(); |
620 | if(fileDlg) | 622 | if(fileDlg) |
621 | delete fileDlg; | 623 | delete fileDlg; |
622 | } | 624 | } |
623 | 625 | ||
624 | void PlayListWidget::loadList( const DocLnk & lnk) { | 626 | void PlayListWidget::loadList( const DocLnk & lnk) { |
625 | QString name= lnk.name(); | 627 | QString name= lnk.name(); |
626 | // qDebug("currentList is "+name); | 628 | // qDebug("currentList is "+name); |
627 | if( name.length()>1) { | 629 | if( name.length()>1) { |
628 | setCaption("OpiePlayer: "+name); | 630 | setCaption("OpiePlayer: "+name); |
629 | // qDebug("load list "+ name+".playlist"); | 631 | // qDebug("load list "+ name+".playlist"); |
630 | clearList(); | 632 | clearList(); |
631 | Config cfg( name+".playlist"); | 633 | Config cfg( name+".playlist"); |
632 | readConfig(cfg); | 634 | readConfig(cfg); |
633 | 635 | ||
634 | tabWidget->setCurrentPage(0); | 636 | tabWidget->setCurrentPage(0); |
635 | 637 | ||
636 | Config config( "MediaPlayer" ); | 638 | Config config( "MediaPlayer" ); |
637 | config.writeEntry("CurrentPlaylist", name); | 639 | config.writeEntry("CurrentPlaylist", name); |
638 | // d->selectedFiles->first(); | 640 | // d->selectedFiles->first(); |
639 | } | 641 | } |
640 | 642 | ||
641 | } | 643 | } |
642 | 644 | ||
643 | void PlayListWidget::setPlaylist( bool shown ) { | 645 | void PlayListWidget::setPlaylist( bool shown ) { |
644 | if ( shown ) | 646 | if ( shown ) |
645 | d->playListFrame->show(); | 647 | d->playListFrame->show(); |
646 | else | 648 | else |
647 | d->playListFrame->hide(); | 649 | d->playListFrame->hide(); |
648 | } | 650 | } |
649 | 651 | ||
650 | void PlayListWidget::setView( char view ) { | 652 | void PlayListWidget::setView( char view ) { |
651 | if ( view == 'l' ) | 653 | if ( view == 'l' ) |
652 | showMaximized(); | 654 | showMaximized(); |
653 | else | 655 | else |
654 | hide(); | 656 | hide(); |
655 | } | 657 | } |
656 | 658 | ||
657 | void PlayListWidget::addSelected() { | 659 | void PlayListWidget::addSelected() { |
658 | 660 | ||
659 | Config cfg( "MediaPlayer" ); | 661 | Config cfg( "MediaPlayer" ); |
660 | cfg.setGroup("PlayList"); | 662 | cfg.setGroup("PlayList"); |
@@ -841,97 +843,97 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& | |||
841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 843 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
842 | m.insertSeparator(); | 844 | m.insertSeparator(); |
843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 845 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
844 | m.exec( QCursor::pos() ); | 846 | m.exec( QCursor::pos() ); |
845 | } | 847 | } |
846 | break; | 848 | break; |
847 | }; | 849 | }; |
848 | } | 850 | } |
849 | 851 | ||
850 | void PlayListWidget::playSelected() | 852 | void PlayListWidget::playSelected() |
851 | { | 853 | { |
852 | btnPlay( TRUE); | 854 | btnPlay( TRUE); |
853 | } | 855 | } |
854 | 856 | ||
855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 857 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
856 | { | 858 | { |
857 | switch (mouse) { | 859 | switch (mouse) { |
858 | case 1: | 860 | case 1: |
859 | break; | 861 | break; |
860 | case 2:{ | 862 | case 2:{ |
861 | QPopupMenu m; | 863 | QPopupMenu m; |
862 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 864 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
863 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 865 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
864 | // m.insertSeparator(); | 866 | // m.insertSeparator(); |
865 | m.exec( QCursor::pos() ); | 867 | m.exec( QCursor::pos() ); |
866 | } | 868 | } |
867 | break; | 869 | break; |
868 | }; | 870 | }; |
869 | 871 | ||
870 | } | 872 | } |
871 | 873 | ||
872 | void PlayListWidget::listDelete() { | 874 | void PlayListWidget::listDelete() { |
873 | Config cfg( "MediaPlayer" ); | 875 | Config cfg( "MediaPlayer" ); |
874 | cfg.setGroup("PlayList"); | 876 | cfg.setGroup("PlayList"); |
875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 877 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
876 | QString file; | 878 | QString file; |
877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 879 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
878 | switch ( tabWidget->currentPageIndex()) { | 880 | switch ( tabWidget->currentPageIndex()) { |
879 | case 0: | 881 | case 0: |
880 | break; | 882 | break; |
881 | case 1: | 883 | case 1: |
882 | { | 884 | { |
883 | file = audioView->selectedItem()->text(0); | 885 | file = audioView->selectedItem()->text(0); |
884 | // Global::findDocuments(&files, "audio/*"); | 886 | // Global::findDocuments(&files, "audio/*"); |
885 | // AppLnkSet appFiles; | 887 | // AppLnkSet appFiles; |
886 | QListIterator<DocLnk> dit( files.children() ); | 888 | QListIterator<DocLnk> dit( files.children() ); |
887 | for ( ; dit.current(); ++dit ) { | 889 | for ( ; dit.current(); ++dit ) { |
888 | if( dit.current()->name() == file) { | 890 | if( dit.current()->name() == file) { |
889 | qDebug(file); | 891 | // qDebug(file); |
890 | LnkProperties prop( dit.current() ); | 892 | LnkProperties prop( dit.current() ); |
891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 893 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
892 | prop.showMaximized(); | 894 | prop.showMaximized(); |
893 | prop.exec(); | 895 | prop.exec(); |
894 | } | 896 | } |
895 | } | 897 | } |
896 | populateAudioView(); | 898 | populateAudioView(); |
897 | } | 899 | } |
898 | break; | 900 | break; |
899 | case 2: | 901 | case 2: |
900 | { | 902 | { |
901 | // file = videoView->selectedItem()->text(0); | 903 | // file = videoView->selectedItem()->text(0); |
902 | // for ( int i = 0; i < noOfFiles; i++ ) { | 904 | // for ( int i = 0; i < noOfFiles; i++ ) { |
903 | // QString entryName; | 905 | // QString entryName; |
904 | // entryName.sprintf( "File%i", i + 1 ); | 906 | // entryName.sprintf( "File%i", i + 1 ); |
905 | // QString linkFile = cfg.readEntry( entryName ); | 907 | // QString linkFile = cfg.readEntry( entryName ); |
906 | // AppLnk lnk( AppLnk(linkFile)); | 908 | // AppLnk lnk( AppLnk(linkFile)); |
907 | // if( lnk.name() == file ) { | 909 | // if( lnk.name() == file ) { |
908 | // LnkProperties prop( &lnk); | 910 | // LnkProperties prop( &lnk); |
909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 911 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
910 | // prop.showMaximized(); | 912 | // prop.showMaximized(); |
911 | // prop.exec(); | 913 | // prop.exec(); |
912 | // } | 914 | // } |
913 | // } | 915 | // } |
914 | } | 916 | } |
915 | break; | 917 | break; |
916 | }; | 918 | }; |
917 | } | 919 | } |
918 | 920 | ||
919 | void PlayListWidget::populateAudioView() { | 921 | void PlayListWidget::populateAudioView() { |
920 | // if(files) | 922 | // if(files) |
921 | // files.~DocLnkSet(); | 923 | // files.~DocLnkSet(); |
922 | StorageInfo storageInfo; | 924 | StorageInfo storageInfo; |
923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 925 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
924 | 926 | ||
925 | Global::findDocuments(&files, "audio/*"); | 927 | Global::findDocuments(&files, "audio/*"); |
926 | QListIterator<DocLnk> dit( files.children() ); | 928 | QListIterator<DocLnk> dit( files.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | 929 | QListIterator<FileSystem> it ( fs ); |
928 | audioView->clear(); | 930 | audioView->clear(); |
929 | QString storage; | 931 | QString storage; |
930 | for ( ; dit.current(); ++dit ) { | 932 | for ( ; dit.current(); ++dit ) { |
931 | for( ; it.current(); ++it ){ | 933 | for( ; it.current(); ++it ){ |
932 | const QString name = (*it)->name(); | 934 | const QString name = (*it)->name(); |
933 | const QString path = (*it)->path(); | 935 | const QString path = (*it)->path(); |
934 | if(dit.current()->file().find(path) != -1 ) storage=name; | 936 | if(dit.current()->file().find(path) != -1 ) storage=name; |
935 | } | 937 | } |
936 | 938 | ||
937 | QListViewItem * newItem; | 939 | QListViewItem * newItem; |