-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 707f4d2..e9615f1 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -238,133 +238,89 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi | |||
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | ||
251 | // t.start(); | ||
252 | 250 | ||
253 | audioView->populateView(); | 251 | audioView->populateView(); |
254 | 252 | ||
255 | QListViewItemIterator audioIt( audioView ); | 253 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 254 | DocLnk lnk; |
257 | QString filename; | 255 | QString filename; |
258 | // iterate through all items of the listview | 256 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 257 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 258 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 259 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 260 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 261 | d->selectedFiles->addToSelection( lnk); |
264 | } | 262 | } |
265 | 263 | ||
266 | videoView->populateView(); | 264 | videoView->populateView(); |
267 | 265 | ||
268 | QListViewItemIterator videoIt( videoView ); | 266 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 267 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 268 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 269 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 270 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 271 | d->selectedFiles->addToSelection( lnk); |
274 | } | 272 | } |
275 | 273 | ||
276 | // d->selectedFiles->addToSelection( ); | ||
277 | // if ( it.current()->isSelected() ) | ||
278 | // lst->append( audioIt.current() ); | ||
279 | // } | ||
280 | |||
281 | |||
282 | // if(!audioScan) | ||
283 | // scanForAudio(); | ||
284 | // if(!videoScan) | ||
285 | // scanForVideo(); | ||
286 | |||
287 | // DocLnkSet filesAll; | ||
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | ||
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | ||
290 | // for ( ; Adit.current(); ++Adit ) { | ||
291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | ||
292 | // d->selectedFiles->addToSelection( **Adit ); | ||
293 | // } | ||
294 | // } | ||
295 | |||
296 | // qDebug("elapsed time %d", t.elapsed() ); | ||
297 | |||
298 | tabWidget->setCurrentPage(0); | 274 | tabWidget->setCurrentPage(0); |
299 | 275 | ||
300 | writeCurrentM3u(); | 276 | writeCurrentM3u(); |
301 | d->selectedFiles->first(); | 277 | d->selectedFiles->first(); |
302 | } | 278 | } |
303 | 279 | ||
304 | 280 | ||
305 | void PlayListWidget::addAllMusicToList() { | 281 | void PlayListWidget::addAllMusicToList() { |
306 | 282 | ||
307 | audioView->populateView(); | 283 | audioView->populateView(); |
308 | 284 | ||
309 | QListViewItemIterator audioIt( audioView ); | 285 | QListViewItemIterator audioIt( audioView ); |
310 | DocLnk lnk; | 286 | DocLnk lnk; |
311 | QString filename; | 287 | QString filename; |
312 | // iterate through all items of the listview | 288 | // iterate through all items of the listview |
313 | for ( ; audioIt.current(); ++audioIt ) { | 289 | for ( ; audioIt.current(); ++audioIt ) { |
314 | filename = audioIt.current()->text(3); | 290 | filename = audioIt.current()->text(3); |
315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 291 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
316 | lnk.setFile( filename ); //sets file name | 292 | lnk.setFile( filename ); //sets file name |
317 | d->selectedFiles->addToSelection( lnk); | 293 | d->selectedFiles->addToSelection( lnk); |
318 | } | 294 | } |
319 | 295 | ||
320 | /* if(!audioScan) | ||
321 | scanForAudio(); | ||
322 | QListIterator<DocLnk> dit( files.children() ); | ||
323 | for ( ; dit.current(); ++dit ) { | ||
324 | if( QFileInfo(dit.current()->file() ).exists() ) { | ||
325 | d->selectedFiles->addToSelection( **dit ); | ||
326 | } | ||
327 | } | ||
328 | */ | ||
329 | tabWidget->setCurrentPage(0); | 296 | tabWidget->setCurrentPage(0); |
330 | writeCurrentM3u(); | 297 | writeCurrentM3u(); |
331 | d->selectedFiles->first(); | 298 | d->selectedFiles->first(); |
332 | } | 299 | } |
333 | 300 | ||
334 | 301 | ||
335 | void PlayListWidget::addAllVideoToList() { | 302 | void PlayListWidget::addAllVideoToList() { |
336 | 303 | ||
337 | videoView->populateView(); | 304 | videoView->populateView(); |
338 | 305 | ||
339 | QListViewItemIterator videoIt( videoView ); | 306 | QListViewItemIterator videoIt( videoView ); |
340 | DocLnk lnk; | 307 | DocLnk lnk; |
341 | QString filename; | 308 | QString filename; |
342 | for ( ; videoIt.current(); ++videoIt ) { | 309 | for ( ; videoIt.current(); ++videoIt ) { |
343 | filename = videoIt.current()->text(3); | 310 | filename = videoIt.current()->text(3); |
344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 311 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
345 | lnk.setFile( filename ); //sets file name | 312 | lnk.setFile( filename ); //sets file name |
346 | d->selectedFiles->addToSelection( lnk); | 313 | d->selectedFiles->addToSelection( lnk); |
347 | } | 314 | } |
348 | |||
349 | |||
350 | /* if(!videoScan) | ||
351 | scanForVideo(); | ||
352 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
353 | for ( ; dit.current(); ++dit ) { | ||
354 | if( QFileInfo( dit.current()->file() ).exists() ) { | ||
355 | d->selectedFiles->addToSelection( **dit ); | ||
356 | } | ||
357 | } | ||
358 | */ | ||
359 | tabWidget->setCurrentPage(0); | 315 | tabWidget->setCurrentPage(0); |
360 | writeCurrentM3u(); | 316 | writeCurrentM3u(); |
361 | d->selectedFiles->first(); | 317 | d->selectedFiles->first(); |
362 | } | 318 | } |
363 | 319 | ||
364 | 320 | ||
365 | void PlayListWidget::setDocument( const QString& fileref ) { | 321 | void PlayListWidget::setDocument( const QString& fileref ) { |
366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 322 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
367 | fromSetDocument = TRUE; | 323 | fromSetDocument = TRUE; |
368 | QFileInfo fileInfo(fileref); | 324 | QFileInfo fileInfo(fileref); |
369 | 325 | ||
370 | if ( !fileInfo.exists() ) { | 326 | if ( !fileInfo.exists() ) { |
@@ -463,79 +419,74 @@ bool PlayListWidget::first() { | |||
463 | bool PlayListWidget::last() { | 419 | bool PlayListWidget::last() { |
464 | return d->selectedFiles->last(); | 420 | return d->selectedFiles->last(); |
465 | } | 421 | } |
466 | 422 | ||
467 | 423 | ||
468 | void PlayListWidget::saveList() { | 424 | void PlayListWidget::saveList() { |
469 | writem3u(); | 425 | writem3u(); |
470 | } | 426 | } |
471 | 427 | ||
472 | 428 | ||
473 | void PlayListWidget::loadList( const DocLnk & lnk) { | 429 | void PlayListWidget::loadList( const DocLnk & lnk) { |
474 | QString name = lnk.name(); | 430 | QString name = lnk.name(); |
475 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | ||
476 | 431 | ||
477 | if( name.length()>0) { | 432 | if( name.length()>0) { |
478 | setCaption("OpiePlayer: "+name); | 433 | setCaption("OpiePlayer: "+name); |
479 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | ||
480 | clearList(); | 434 | clearList(); |
481 | // readm3u(lnk.file()); | ||
482 | readListFromFile(lnk.file()); | 435 | readListFromFile(lnk.file()); |
483 | tabWidget->setCurrentPage(0); | 436 | tabWidget->setCurrentPage(0); |
484 | } | 437 | } |
485 | } | 438 | } |
486 | 439 | ||
487 | void PlayListWidget::addSelected() { | 440 | void PlayListWidget::addSelected() { |
488 | assert( inFileListMode() ); | 441 | assert( inFileListMode() ); |
489 | 442 | ||
490 | QListViewItemIterator it( currentFileListView ); | 443 | QListViewItemIterator it( currentFileListView ); |
491 | for ( ; it.current(); ++it ) | 444 | for ( ; it.current(); ++it ) |
492 | if ( it.current()->isSelected() ) { | 445 | if ( it.current()->isSelected() ) { |
493 | QString filename = it.current()->text(3); | 446 | QString filename = it.current()->text(3); |
494 | 447 | ||
495 | DocLnk lnk; | 448 | DocLnk lnk; |
496 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 449 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
497 | lnk.setFile( filename ); //sets file name | 450 | lnk.setFile( filename ); //sets file name |
498 | 451 | ||
499 | d->selectedFiles->addToSelection( lnk ); | 452 | d->selectedFiles->addToSelection( lnk ); |
500 | } | 453 | } |
501 | 454 | ||
502 | currentFileListView->clearSelection(); | 455 | currentFileListView->clearSelection(); |
503 | 456 | ||
504 | // tabWidget->setCurrentPage( 0 ); | ||
505 | writeCurrentM3u(); | 457 | writeCurrentM3u(); |
506 | } | 458 | } |
507 | 459 | ||
508 | 460 | ||
509 | void PlayListWidget::removeSelected() { | 461 | void PlayListWidget::removeSelected() { |
510 | d->selectedFiles->removeSelected( ); | 462 | d->selectedFiles->removeSelected( ); |
511 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
512 | } | 464 | } |
513 | 465 | ||
514 | 466 | ||
515 | void PlayListWidget::playIt( QListViewItem *it) { | 467 | void PlayListWidget::playIt( QListViewItem *it) { |
516 | if(!it) return; | 468 | if(!it) return; |
517 | mediaPlayerState.setPlaying(FALSE); | 469 | mediaPlayerState.setPlaying(FALSE); |
518 | mediaPlayerState.setPlaying(TRUE); | 470 | mediaPlayerState.setPlaying(TRUE); |
519 | d->selectedFiles->unSelect(); | 471 | d->selectedFiles->unSelect(); |
520 | } | 472 | } |
521 | 473 | ||
522 | 474 | ||
523 | void PlayListWidget::addToSelection( QListViewItem *it) { | 475 | void PlayListWidget::addToSelection( QListViewItem *it) { |
524 | d->setDocumentUsed = FALSE; | 476 | d->setDocumentUsed = FALSE; |
525 | 477 | ||
526 | if(it) { | 478 | if(it) { |
527 | if ( currentTab() == CurrentPlayList ) | 479 | if ( currentTab() == CurrentPlayList ) |
528 | return; | 480 | return; |
529 | // case 1: { | ||
530 | DocLnk lnk; | 481 | DocLnk lnk; |
531 | QString filename; | 482 | QString filename; |
532 | 483 | ||
533 | filename=it->text(3); | 484 | filename=it->text(3); |
534 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 485 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
535 | lnk.setFile( filename ); //sets file name | 486 | lnk.setFile( filename ); //sets file name |
536 | d->selectedFiles->addToSelection( lnk); | 487 | d->selectedFiles->addToSelection( lnk); |
537 | 488 | ||
538 | writeCurrentM3u(); | 489 | writeCurrentM3u(); |
539 | // tabWidget->setCurrentPage(0); | 490 | // tabWidget->setCurrentPage(0); |
540 | 491 | ||
541 | } | 492 | } |
@@ -664,37 +615,35 @@ void PlayListWidget::openFile() { | |||
664 | if(filename.left(4) == "http") { | 615 | if(filename.left(4) == "http") { |
665 | QString m3uFile, m3uFilePath; | 616 | QString m3uFile, m3uFilePath; |
666 | if(filename.find(":",8,TRUE) != -1) { //found a port | 617 | if(filename.find(":",8,TRUE) != -1) { //found a port |
667 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 618 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
668 | m3uFile = m3uFile.right( 7); | 619 | m3uFile = m3uFile.right( 7); |
669 | } else if(filename.left(4) == "http"){ | 620 | } else if(filename.left(4) == "http"){ |
670 | m3uFile=filename; | 621 | m3uFile=filename; |
671 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 622 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
672 | } else{ | 623 | } else{ |
673 | m3uFile=filename; | 624 | m3uFile=filename; |
674 | } | 625 | } |
675 | 626 | ||
676 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | ||
677 | lnk.setName( filename ); //sets name | 627 | lnk.setName( filename ); //sets name |
678 | lnk.setFile( filename ); //sets file name | 628 | lnk.setFile( filename ); //sets file name |
679 | 629 | ||
680 | // lnk.setIcon("opieplayer2/musicfile"); | 630 | // lnk.setIcon("opieplayer2/musicfile"); |
681 | 631 | ||
682 | d->selectedFiles->addToSelection( lnk ); | 632 | d->selectedFiles->addToSelection( lnk ); |
683 | writeCurrentM3u(); | 633 | writeCurrentM3u(); |
684 | d->selectedFiles->setSelectedItem( lnk.name()); | 634 | d->selectedFiles->setSelectedItem( lnk.name()); |
685 | } | 635 | } |
686 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 636 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
687 | readListFromFile( filename ); | 637 | readListFromFile( filename ); |
688 | // readPls( filename ); | ||
689 | } else { | 638 | } else { |
690 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 639 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
691 | lnk.setFile( filename ); //sets file name | 640 | lnk.setFile( filename ); //sets file name |
692 | d->selectedFiles->addToSelection( lnk); | 641 | d->selectedFiles->addToSelection( lnk); |
693 | writeCurrentM3u(); | 642 | writeCurrentM3u(); |
694 | d->selectedFiles->setSelectedItem( lnk.name()); | 643 | d->selectedFiles->setSelectedItem( lnk.name()); |
695 | } | 644 | } |
696 | } | 645 | } |
697 | 646 | ||
698 | 647 | ||
699 | delete fileDlg; | 648 | delete fileDlg; |
700 | } | 649 | } |
@@ -728,78 +677,32 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
728 | lnk.setFile( s); | 677 | lnk.setFile( s); |
729 | } | 678 | } |
730 | } | 679 | } |
731 | d->selectedFiles->addToSelection( lnk ); | 680 | d->selectedFiles->addToSelection( lnk ); |
732 | } | 681 | } |
733 | Config config( "OpiePlayer" ); | 682 | Config config( "OpiePlayer" ); |
734 | config.setGroup( "PlayList" ); | 683 | config.setGroup( "PlayList" ); |
735 | 684 | ||
736 | config.writeEntry("CurrentPlaylist",filename); | 685 | config.writeEntry("CurrentPlaylist",filename); |
737 | config.write(); | 686 | config.write(); |
738 | currentPlayList=filename; | 687 | currentPlayList=filename; |
739 | 688 | ||
740 | // m3uList->write(); | ||
741 | m3uList->close(); | 689 | m3uList->close(); |
742 | delete m3uList; | 690 | delete m3uList; |
743 | 691 | ||
744 | d->selectedFiles->setSelectedItem( s); | 692 | d->selectedFiles->setSelectedItem( s); |
745 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 693 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
746 | 694 | ||
747 | } | 695 | } |
748 | 696 | ||
749 | // /* | ||
750 | // reads pls and adds files/urls to playlist */ | ||
751 | // void PlayListWidget::readPls( const QString &filename ) { | ||
752 | |||
753 | // qDebug( "pls filename is " + filename ); | ||
754 | // Om3u *m3uList; | ||
755 | // QString s, name; | ||
756 | // m3uList = new Om3u( filename, IO_ReadOnly ); | ||
757 | // m3uList->readPls(); | ||
758 | |||
759 | // for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
760 | // s = *it; | ||
761 | // // s.replace( QRegExp( "%20" )," " ); | ||
762 | // DocLnk lnk( s ); | ||
763 | // QFileInfo f( s ); | ||
764 | // QString name = f.baseName(); | ||
765 | |||
766 | // if( name.left( 4 ) == "http" ) { | ||
767 | // name = s.right( s.length() - 7); | ||
768 | // } else { | ||
769 | // name = s; | ||
770 | // } | ||
771 | |||
772 | // name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | ||
773 | |||
774 | // lnk.setName( name ); | ||
775 | // if( s.at( s.length() - 4) == '.') {// if this is probably a file | ||
776 | // lnk.setFile( s ); | ||
777 | // } else { //if its a url | ||
778 | // // if( name.right( 1 ).find( '/' ) == -1) { | ||
779 | // // s += "/"; | ||
780 | // // } | ||
781 | // lnk.setFile( s ); | ||
782 | // } | ||
783 | // lnk.setType( "audio/x-mpegurl" ); | ||
784 | |||
785 | // lnk.writeLink(); | ||
786 | // d->selectedFiles->addToSelection( lnk ); | ||
787 | // } | ||
788 | |||
789 | // m3uList->close(); | ||
790 | // delete m3uList; | ||
791 | // } | ||
792 | |||
793 | // /* | ||
794 | // writes current playlist to current m3u file */ | 697 | // writes current playlist to current m3u file */ |
795 | void PlayListWidget::writeCurrentM3u() { | 698 | void PlayListWidget::writeCurrentM3u() { |
796 | qDebug("writing to current m3u"); | 699 | qDebug("writing to current m3u"); |
797 | Config cfg( "OpiePlayer" ); | 700 | Config cfg( "OpiePlayer" ); |
798 | cfg.setGroup("PlayList"); | 701 | cfg.setGroup("PlayList"); |
799 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 702 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
800 | 703 | ||
801 | Om3u *m3uList; | 704 | Om3u *m3uList; |
802 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 705 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
803 | if( d->selectedFiles->first()) { | 706 | if( d->selectedFiles->first()) { |
804 | 707 | ||
805 | do { | 708 | do { |