-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 2b58402..20adf17 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -237,193 +237,193 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , in | |||
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
242 | switch (mouse) { | 242 | switch (mouse) { |
243 | case 1: | 243 | case 1: |
244 | break; | 244 | break; |
245 | case 2: | 245 | case 2: |
246 | { | 246 | { |
247 | QPopupMenu m; | 247 | QPopupMenu m; |
248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
250 | m.exec( QCursor::pos() ); | 250 | m.exec( QCursor::pos() ); |
251 | } | 251 | } |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | void PlayListWidget::addAllToList() { | 257 | void 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 | ||
269 | void PlayListWidget::addAllMusicToList() { | 269 | void 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 | ||
279 | void PlayListWidget::addAllVideoToList() { | 279 | void 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 | ||
289 | void PlayListWidget::setDocument( const QString& fileref ) { | 289 | void 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 | ||
318 | void PlayListWidget::useSelectedDocument() { | 318 | void PlayListWidget::useSelectedDocument() { |
319 | d->setDocumentUsed = FALSE; | 319 | d->setDocumentUsed = FALSE; |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | const DocLnk *PlayListWidget::current() { // this is fugly | 323 | const 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->selected(); | 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 | ||
342 | bool PlayListWidget::prev() { | 342 | bool 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 | ||
372 | bool PlayListWidget::next() { | 372 | bool PlayListWidget::next() { |
373 | qDebug("<<<<<<<<<<<<next()"); | 373 | qDebug("<<<<<<<<<<<<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 | ||
393 | bool PlayListWidget::first() { | 393 | bool 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 | ||
401 | bool PlayListWidget::last() { | 401 | bool 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 | ||
409 | void PlayListWidget::saveList() { | 409 | void 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()) { |
@@ -555,194 +555,194 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
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 | ||
566 | void PlayListWidget::tabChanged(QWidget *) { | 566 | void 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 | ||
613 | void PlayListWidget::btnPlay(bool b) { | 613 | void 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); |
638 | // // d->selectedFiles->unSelect(); | 638 | // // d->selectedFiles->unSelect(); |
639 | // insanityBool=FALSE; | 639 | // insanityBool=FALSE; |
640 | // }// videoView->clearSelection(); | 640 | // }// videoView->clearSelection(); |
641 | // break; | 641 | // break; |
642 | // }; | 642 | // }; |
643 | 643 | ||
644 | } | 644 | } |
645 | 645 | ||
646 | void PlayListWidget::deletePlaylist() { | 646 | void PlayListWidget::deletePlaylist() { |
647 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 647 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
648 | (tr("You really want to delete\nthis playlist?")), | 648 | (tr("You really want to delete\nthis playlist?")), |
649 | (tr("Yes")), (tr("No")), 0 )){ | 649 | (tr("Yes")), (tr("No")), 0 )){ |
650 | case 0: // Yes clicked, | 650 | case 0: // Yes clicked, |
651 | QFile().remove(playLists->selected()->file()); | 651 | QFile().remove(playLists->selectedDocument().file()); |
652 | QFile().remove(playLists->selected()->linkFile()); | 652 | QFile().remove(playLists->selectedDocument().linkFile()); |
653 | playLists->reread(); | 653 | playLists->reread(); |
654 | break; | 654 | break; |
655 | case 1: // Cancel | 655 | case 1: // Cancel |
656 | break; | 656 | break; |
657 | }; | 657 | }; |
658 | } | 658 | } |
659 | 659 | ||
660 | 660 | ||
661 | void PlayListWidget::playSelected() { | 661 | void PlayListWidget::playSelected() { |
662 | btnPlay( TRUE); | 662 | btnPlay( TRUE); |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | void PlayListWidget::scanForAudio() { | 666 | void PlayListWidget::scanForAudio() { |
667 | // qDebug("scan for audio"); | 667 | // qDebug("scan for audio"); |
668 | files.detachChildren(); | 668 | files.detachChildren(); |
669 | QListIterator<DocLnk> sdit( files.children() ); | 669 | QListIterator<DocLnk> sdit( files.children() ); |
670 | for ( ; sdit.current(); ++sdit ) { | 670 | for ( ; sdit.current(); ++sdit ) { |
671 | delete sdit.current(); | 671 | delete sdit.current(); |
672 | } | 672 | } |
673 | Global::findDocuments(&files, "audio/*"); | 673 | Global::findDocuments(&files, "audio/*"); |
674 | audioScan = TRUE; | 674 | audioScan = TRUE; |
675 | } | 675 | } |
676 | 676 | ||
677 | void PlayListWidget::scanForVideo() { | 677 | void PlayListWidget::scanForVideo() { |
678 | // qDebug("scan for video"); | 678 | // qDebug("scan for video"); |
679 | vFiles.detachChildren(); | 679 | vFiles.detachChildren(); |
680 | QListIterator<DocLnk> sdit( vFiles.children() ); | 680 | QListIterator<DocLnk> sdit( vFiles.children() ); |
681 | for ( ; sdit.current(); ++sdit ) { | 681 | for ( ; sdit.current(); ++sdit ) { |
682 | delete sdit.current(); | 682 | delete sdit.current(); |
683 | } | 683 | } |
684 | Global::findDocuments(&vFiles, "video/*"); | 684 | Global::findDocuments(&vFiles, "video/*"); |
685 | videoScan = TRUE; | 685 | videoScan = TRUE; |
686 | } | 686 | } |
687 | 687 | ||
688 | void PlayListWidget::populateAudioView() { | 688 | void PlayListWidget::populateAudioView() { |
689 | audioView->clear(); | 689 | audioView->clear(); |
690 | StorageInfo storageInfo; | 690 | StorageInfo storageInfo; |
691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
692 | if(!audioScan) { | 692 | if(!audioScan) { |
693 | scanForAudio(); | 693 | scanForAudio(); |
694 | } | 694 | } |
695 | 695 | ||
696 | QListIterator<DocLnk> dit( files.children() ); | 696 | QListIterator<DocLnk> dit( files.children() ); |
697 | QListIterator<FileSystem> it ( fs ); | 697 | QListIterator<FileSystem> it ( fs ); |
698 | 698 | ||
699 | QString storage; | 699 | QString storage; |
700 | for ( ; dit.current(); ++dit ) { | 700 | for ( ; dit.current(); ++dit ) { |
701 | for( ; it.current(); ++it ){ | 701 | for( ; it.current(); ++it ){ |
702 | const QString name = (*it)->name(); | 702 | const QString name = (*it)->name(); |
703 | const QString path = (*it)->path(); | 703 | const QString path = (*it)->path(); |
704 | if(dit.current()->file().find(path) != -1 ) { | 704 | if(dit.current()->file().find(path) != -1 ) { |
705 | storage = name; | 705 | storage = name; |
706 | } | 706 | } |
707 | } | 707 | } |
708 | 708 | ||
709 | QListViewItem * newItem; | 709 | QListViewItem * newItem; |
710 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 710 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
711 | long size; | 711 | long size; |
712 | if( dit.current()->file().left(4) == "http" ) | 712 | if( dit.current()->file().left(4) == "http" ) |
713 | size=0; | 713 | size=0; |
714 | else | 714 | else |
715 | size = QFile( dit.current()->file() ).size(); | 715 | size = QFile( dit.current()->file() ).size(); |
716 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 716 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
717 | QString::number(size ), storage, dit.current()->file()); | 717 | QString::number(size ), storage, dit.current()->file()); |
718 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 718 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
719 | } | 719 | } |
720 | } | 720 | } |
721 | } | 721 | } |
722 | 722 | ||
723 | 723 | ||
724 | void PlayListWidget::populateVideoView() { | 724 | void PlayListWidget::populateVideoView() { |
725 | videoView->clear(); | 725 | videoView->clear(); |
726 | StorageInfo storageInfo; | 726 | StorageInfo storageInfo; |
727 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 727 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
728 | 728 | ||
729 | if(!videoScan ) { | 729 | if(!videoScan ) { |
730 | scanForVideo(); | 730 | scanForVideo(); |
731 | } | 731 | } |
732 | 732 | ||
733 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 733 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
734 | QListIterator<FileSystem> it ( fs ); | 734 | QListIterator<FileSystem> it ( fs ); |
735 | videoView->clear(); | 735 | videoView->clear(); |
736 | QString storage, pathName; | 736 | QString storage, pathName; |
737 | for ( ; Vdit.current(); ++Vdit ) { | 737 | for ( ; Vdit.current(); ++Vdit ) { |
738 | for( ; it.current(); ++it ) { | 738 | for( ; it.current(); ++it ) { |
739 | const QString name = (*it)->name(); | 739 | const QString name = (*it)->name(); |
740 | const QString path = (*it)->path(); | 740 | const QString path = (*it)->path(); |
741 | if( Vdit.current()->file().find(path) != -1 ) { | 741 | if( Vdit.current()->file().find(path) != -1 ) { |
742 | storage=name; | 742 | storage=name; |
743 | pathName=path; | 743 | pathName=path; |
744 | } | 744 | } |
745 | } | 745 | } |
746 | 746 | ||
747 | QListViewItem * newItem; | 747 | QListViewItem * newItem; |
748 | if ( QFile( Vdit.current()->file() ).exists() ) { | 748 | if ( QFile( Vdit.current()->file() ).exists() ) { |
@@ -955,105 +955,105 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
955 | // File1=http | 955 | // File1=http |
956 | // Title | 956 | // Title |
957 | // Length | 957 | // Length |
958 | // Version | 958 | // Version |
959 | // File2=http | 959 | // File2=http |
960 | s = s.replace( QRegExp( "\\" ), "/" ); | 960 | s = s.replace( QRegExp( "\\" ), "/" ); |
961 | DocLnk lnk( s ); | 961 | DocLnk lnk( s ); |
962 | QFileInfo f( s ); | 962 | QFileInfo f( s ); |
963 | QString name = f.baseName(); | 963 | QString name = f.baseName(); |
964 | if( name.left( 4 ) == "http" ) { | 964 | if( name.left( 4 ) == "http" ) { |
965 | name = s.right( s.length() - 7); | 965 | name = s.right( s.length() - 7); |
966 | } else { | 966 | } else { |
967 | name = s; | 967 | name = s; |
968 | } | 968 | } |
969 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 969 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
970 | lnk.setName( name ); | 970 | lnk.setName( name ); |
971 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 971 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
972 | lnk.setFile( s ); | 972 | lnk.setFile( s ); |
973 | else { //if its a url | 973 | else { //if its a url |
974 | if( name.right( 1 ).find( '/' ) == -1) { | 974 | if( name.right( 1 ).find( '/' ) == -1) { |
975 | s += "/"; | 975 | s += "/"; |
976 | } | 976 | } |
977 | lnk.setFile( s ); | 977 | lnk.setFile( s ); |
978 | } | 978 | } |
979 | lnk.setType( "audio/x-mpegurl" ); | 979 | lnk.setType( "audio/x-mpegurl" ); |
980 | 980 | ||
981 | //qDebug("DocLnk add "+name); | 981 | //qDebug("DocLnk add "+name); |
982 | d->selectedFiles->addToSelection( lnk ); | 982 | d->selectedFiles->addToSelection( lnk ); |
983 | } | 983 | } |
984 | } | 984 | } |
985 | i++; | 985 | i++; |
986 | } | 986 | } |
987 | } | 987 | } |
988 | 988 | ||
989 | void PlayListWidget::pmViewActivated(int index) { | 989 | void PlayListWidget::pmViewActivated(int index) { |
990 | // qDebug("%d", index); | 990 | // qDebug("%d", index); |
991 | switch(index) { | 991 | switch(index) { |
992 | case -16: | 992 | case -16: |
993 | { | 993 | { |
994 | mediaPlayerState->toggleFullscreen(); | 994 | mediaPlayerState->toggleFullscreen(); |
995 | bool b=mediaPlayerState->fullscreen(); | 995 | bool b=mediaPlayerState->fullscreen(); |
996 | pmView->setItemChecked( index, b); | 996 | pmView->setItemChecked( index, b); |
997 | Config cfg( "OpiePlayer" ); | 997 | Config cfg( "OpiePlayer" ); |
998 | cfg.writeEntry( "FullScreen", b ); | 998 | cfg.writeEntry( "FullScreen", b ); |
999 | } | 999 | } |
1000 | break; | 1000 | break; |
1001 | }; | 1001 | }; |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void PlayListWidget::populateSkinsMenu() { | 1004 | void PlayListWidget::populateSkinsMenu() { |
1005 | int item = 0; | 1005 | int item = 0; |
1006 | defaultSkinIndex = 0; | 1006 | defaultSkinIndex = 0; |
1007 | QString skinName; | 1007 | QString skinName; |
1008 | Config cfg( "OpiePlayer" ); | 1008 | Config cfg( "OpiePlayer" ); |
1009 | cfg.setGroup("Options" ); | 1009 | cfg.setGroup("Options" ); |
1010 | QString skin = cfg.readEntry( "Skin", "default" ); | 1010 | QString skin = cfg.readEntry( "Skin", "default" ); |
1011 | 1011 | ||
1012 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1012 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1013 | skinsDir.setFilter( QDir::Dirs ); | 1013 | skinsDir.setFilter( QDir::Dirs ); |
1014 | skinsDir.setSorting(QDir::Name ); | 1014 | skinsDir.setSorting(QDir::Name ); |
1015 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1015 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1016 | QFileInfoListIterator it( *skinslist ); | 1016 | QFileInfoListIterator it( *skinslist ); |
1017 | QFileInfo *fi; | 1017 | QFileInfo *fi; |
1018 | while ( ( fi = it.current() ) ) { | 1018 | while ( ( fi = it.current() ) ) { |
1019 | skinName = fi->fileName(); | 1019 | skinName = fi->fileName(); |
1020 | // qDebug( fi->fileName() ); | 1020 | // qDebug( fi->fileName() ); |
1021 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1021 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1022 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1022 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1023 | } | 1023 | } |
1024 | if( skinName == "default" ) { | 1024 | if( skinName == "default" ) { |
1025 | defaultSkinIndex = item; | 1025 | defaultSkinIndex = item; |
1026 | } | 1026 | } |
1027 | if( skinName == skin ) { | 1027 | if( skinName == skin ) { |
1028 | skinsMenu->setItemChecked( item, TRUE ); | 1028 | skinsMenu->setItemChecked( item, TRUE ); |
1029 | } | 1029 | } |
1030 | ++it; | 1030 | ++it; |
1031 | } | 1031 | } |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void PlayListWidget::skinsMenuActivated( int item ) { | 1034 | void PlayListWidget::skinsMenuActivated( int item ) { |
1035 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1035 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1036 | skinsMenu->setItemChecked( i, FALSE ); | 1036 | skinsMenu->setItemChecked( i, FALSE ); |
1037 | } | 1037 | } |
1038 | skinsMenu->setItemChecked( item, TRUE ); | 1038 | skinsMenu->setItemChecked( item, TRUE ); |
1039 | 1039 | ||
1040 | Config cfg( "OpiePlayer" ); | 1040 | Config cfg( "OpiePlayer" ); |
1041 | cfg.setGroup("Options"); | 1041 | cfg.setGroup("Options"); |
1042 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1042 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | int PlayListWidget::whichList() { | 1045 | int PlayListWidget::whichList() { |
1046 | return tabWidget->currentPageIndex(); | 1046 | return tabWidget->currentPageIndex(); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | QString PlayListWidget::currentFileListPathName() { | 1049 | QString PlayListWidget::currentFileListPathName() { |
1050 | switch (whichList()) { | 1050 | switch (whichList()) { |
1051 | case 1: | 1051 | case 1: |
1052 | return audioView->currentItem()->text(3); | 1052 | return audioView->currentItem()->text(3); |
1053 | break; | 1053 | break; |
1054 | case 2: | 1054 | case 2: |
1055 | return videoView->currentItem()->text(3); | 1055 | return videoView->currentItem()->text(3); |
1056 | break; | 1056 | break; |
1057 | }; | 1057 | }; |
1058 | return ""; | 1058 | return ""; |
1059 | } | 1059 | } |