summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 11a7b5c..a708cf6 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -364,143 +364,138 @@ void PlayListWidget::addAllVideoToList() {
364 } 364 }
365 365
366 QListViewItemIterator videoIt( videoView ); 366 QListViewItemIterator videoIt( videoView );
367 DocLnk lnk; 367 DocLnk lnk;
368 QString filename; 368 QString filename;
369 for ( ; videoIt.current(); ++videoIt ) { 369 for ( ; videoIt.current(); ++videoIt ) {
370 filename = videoIt.current()->text(3); 370 filename = videoIt.current()->text(3);
371 lnk.setName( QFileInfo(filename).baseName() ); //sets name 371 lnk.setName( QFileInfo(filename).baseName() ); //sets name
372 lnk.setFile( filename ); //sets file name 372 lnk.setFile( filename ); //sets file name
373 d->selectedFiles->addToSelection( lnk); 373 d->selectedFiles->addToSelection( lnk);
374 } 374 }
375 375
376 376
377 /* if(!videoScan) 377 /* if(!videoScan)
378 scanForVideo(); 378 scanForVideo();
379 QListIterator<DocLnk> dit( vFiles.children() ); 379 QListIterator<DocLnk> dit( vFiles.children() );
380 for ( ; dit.current(); ++dit ) { 380 for ( ; dit.current(); ++dit ) {
381 if( QFileInfo( dit.current()->file() ).exists() ) { 381 if( QFileInfo( dit.current()->file() ).exists() ) {
382 d->selectedFiles->addToSelection( **dit ); 382 d->selectedFiles->addToSelection( **dit );
383 } 383 }
384 } 384 }
385*/ 385*/
386 tabWidget->setCurrentPage(0); 386 tabWidget->setCurrentPage(0);
387 writeCurrentM3u(); 387 writeCurrentM3u();
388 d->selectedFiles->first(); 388 d->selectedFiles->first();
389} 389}
390 390
391 391
392void PlayListWidget::setDocument( const QString& fileref ) { 392void PlayListWidget::setDocument( const QString& fileref ) {
393 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 393 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
394 fromSetDocument = TRUE; 394 fromSetDocument = TRUE;
395 if ( fileref.isNull() ) { 395 if ( fileref.isNull() ) {
396 QMessageBox::warning( this, tr( "Invalid File" ), 396 QMessageBox::warning( this, tr( "Invalid File" ),
397 tr( "There was a problem in getting the file." ) ); 397 tr( "There was a problem in getting the file." ) );
398 return; 398 return;
399 } 399 }
400 400
401 clearList(); 401 clearList();
402 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 402 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
403 readm3u( fileref ); 403 readm3u( fileref );
404 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 404 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
405 readm3u( DocLnk( fileref).file() ); 405 readm3u( DocLnk( fileref).file() );
406 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 406 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
407 readPls( fileref ); 407 readPls( fileref );
408 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 408 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
409 readPls( DocLnk( fileref).file() ); 409 readPls( DocLnk( fileref).file() );
410 } else { 410 } else {
411 clearList(); 411 clearList();
412 addToSelection( DocLnk( fileref ) ); 412 addToSelection( DocLnk( fileref ) );
413 writeCurrentM3u(); 413 writeCurrentM3u();
414 414
415 d->setDocumentUsed = TRUE; 415 d->setDocumentUsed = TRUE;
416 mediaPlayerState->setPlaying( FALSE ); 416 mediaPlayerState->setPlaying( FALSE );
417 mediaPlayerState->setPlaying( TRUE ); 417 mediaPlayerState->setPlaying( TRUE );
418 } 418 }
419} 419}
420 420
421 421
422void PlayListWidget::useSelectedDocument() { 422void PlayListWidget::useSelectedDocument() {
423 d->setDocumentUsed = FALSE; 423 d->setDocumentUsed = FALSE;
424} 424}
425 425
426 426
427const DocLnk *PlayListWidget::current() { // this is fugly 427const DocLnk *PlayListWidget::current() { // this is fugly
428 switch ( whichList() ) { 428 assert( currentTab() == CurrentPlayList );
429 case 0: //playlist 429
430 {
431// qDebug("playlist"); 430// qDebug("playlist");
432 if ( mediaPlayerState->isUsingPlaylist() ) { 431 if ( mediaPlayerState->isUsingPlaylist() ) {
433 return d->selectedFiles->current(); 432 return d->selectedFiles->current();
434 } else if ( d->setDocumentUsed && d->current ) { 433 } else if ( d->setDocumentUsed && d->current ) {
435 return d->current; 434 return d->current;
436 } else { 435 } else {
437 return &(d->files->selectedDocument()); 436 return &(d->files->selectedDocument());
438 } 437 }
439 }
440 break;
441 };
442 return 0;
443} 438}
444 439
445 440
446bool PlayListWidget::prev() { 441bool PlayListWidget::prev() {
447 if ( mediaPlayerState->isUsingPlaylist() ) { 442 if ( mediaPlayerState->isUsingPlaylist() ) {
448 if ( mediaPlayerState->isShuffled() ) { 443 if ( mediaPlayerState->isShuffled() ) {
449 const DocLnk *cur = current(); 444 const DocLnk *cur = current();
450 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 445 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
451 for ( int i = 0; i < j; i++ ) { 446 for ( int i = 0; i < j; i++ ) {
452 if ( !d->selectedFiles->next() ) 447 if ( !d->selectedFiles->next() )
453 d->selectedFiles->first(); 448 d->selectedFiles->first();
454 } 449 }
455 if ( cur == current() ) 450 if ( cur == current() )
456 if ( !d->selectedFiles->next() ) { 451 if ( !d->selectedFiles->next() ) {
457 d->selectedFiles->first(); 452 d->selectedFiles->first();
458 } 453 }
459 return TRUE; 454 return TRUE;
460 } else { 455 } else {
461 if ( !d->selectedFiles->prev() ) { 456 if ( !d->selectedFiles->prev() ) {
462 if ( mediaPlayerState->isLooping() ) { 457 if ( mediaPlayerState->isLooping() ) {
463 return d->selectedFiles->last(); 458 return d->selectedFiles->last();
464 } else { 459 } else {
465 return FALSE; 460 return FALSE;
466 } 461 }
467 } 462 }
468 return TRUE; 463 return TRUE;
469 } 464 }
470 } else { 465 } else {
471 return mediaPlayerState->isLooping(); 466 return mediaPlayerState->isLooping();
472 } 467 }
473} 468}
474 469
475 470
476bool PlayListWidget::next() { 471bool PlayListWidget::next() {
477//qDebug("<<<<<<<<<<<<next()"); 472//qDebug("<<<<<<<<<<<<next()");
478 if ( mediaPlayerState->isUsingPlaylist() ) { 473 if ( mediaPlayerState->isUsingPlaylist() ) {
479 if ( mediaPlayerState->isShuffled() ) { 474 if ( mediaPlayerState->isShuffled() ) {
480 return prev(); 475 return prev();
481 } else { 476 } else {
482 if ( !d->selectedFiles->next() ) { 477 if ( !d->selectedFiles->next() ) {
483 if ( mediaPlayerState->isLooping() ) { 478 if ( mediaPlayerState->isLooping() ) {
484 return d->selectedFiles->first(); 479 return d->selectedFiles->first();
485 } else { 480 } else {
486 return FALSE; 481 return FALSE;
487 } 482 }
488 } 483 }
489 return TRUE; 484 return TRUE;
490 } 485 }
491 } else { 486 } else {
492 return mediaPlayerState->isLooping(); 487 return mediaPlayerState->isLooping();
493 } 488 }
494} 489}
495 490
496 491
497bool PlayListWidget::first() { 492bool PlayListWidget::first() {
498 if ( mediaPlayerState->isUsingPlaylist() ) 493 if ( mediaPlayerState->isUsingPlaylist() )
499 return d->selectedFiles->first(); 494 return d->selectedFiles->first();
500 else 495 else
501 return mediaPlayerState->isLooping(); 496 return mediaPlayerState->isLooping();
502} 497}
503 498
504 499
505bool PlayListWidget::last() { 500bool PlayListWidget::last() {
506 if ( mediaPlayerState->isUsingPlaylist() ) 501 if ( mediaPlayerState->isUsingPlaylist() )
@@ -1097,74 +1092,73 @@ void PlayListWidget::pmViewActivated(int index) {
1097 } 1092 }
1098 break; 1093 break;
1099 }; 1094 };
1100} 1095}
1101 1096
1102void PlayListWidget::populateSkinsMenu() { 1097void PlayListWidget::populateSkinsMenu() {
1103 int item = 0; 1098 int item = 0;
1104 defaultSkinIndex = 0; 1099 defaultSkinIndex = 0;
1105 QString skinName; 1100 QString skinName;
1106 Config cfg( "OpiePlayer" ); 1101 Config cfg( "OpiePlayer" );
1107 cfg.setGroup("Options" ); 1102 cfg.setGroup("Options" );
1108 QString skin = cfg.readEntry( "Skin", "default" ); 1103 QString skin = cfg.readEntry( "Skin", "default" );
1109 1104
1110 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1105 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1111 skinsDir.setFilter( QDir::Dirs ); 1106 skinsDir.setFilter( QDir::Dirs );
1112 skinsDir.setSorting(QDir::Name ); 1107 skinsDir.setSorting(QDir::Name );
1113 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1108 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1114 QFileInfoListIterator it( *skinslist ); 1109 QFileInfoListIterator it( *skinslist );
1115 QFileInfo *fi; 1110 QFileInfo *fi;
1116 while ( ( fi = it.current() ) ) { 1111 while ( ( fi = it.current() ) ) {
1117 skinName = fi->fileName(); 1112 skinName = fi->fileName();
1118// qDebug( fi->fileName() ); 1113// qDebug( fi->fileName() );
1119 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1114 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1120 item = skinsMenu->insertItem( fi->fileName() ) ; 1115 item = skinsMenu->insertItem( fi->fileName() ) ;
1121 } 1116 }
1122 if( skinName == "default" ) { 1117 if( skinName == "default" ) {
1123 defaultSkinIndex = item; 1118 defaultSkinIndex = item;
1124 } 1119 }
1125 if( skinName == skin ) { 1120 if( skinName == skin ) {
1126 skinsMenu->setItemChecked( item, TRUE ); 1121 skinsMenu->setItemChecked( item, TRUE );
1127 } 1122 }
1128 ++it; 1123 ++it;
1129 } 1124 }
1130} 1125}
1131 1126
1132void PlayListWidget::skinsMenuActivated( int item ) { 1127void PlayListWidget::skinsMenuActivated( int item ) {
1133 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1128 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1134 skinsMenu->setItemChecked( i, FALSE ); 1129 skinsMenu->setItemChecked( i, FALSE );
1135 } 1130 }
1136 skinsMenu->setItemChecked( item, TRUE ); 1131 skinsMenu->setItemChecked( item, TRUE );
1137 1132
1138 Config cfg( "OpiePlayer" ); 1133 Config cfg( "OpiePlayer" );
1139 cfg.setGroup("Options"); 1134 cfg.setGroup("Options");
1140 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1135 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1141 QMessageBox::warning( this, tr( "OpiePlayer" ), 1136 QMessageBox::warning( this, tr( "OpiePlayer" ),
1142 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); 1137 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
1143} 1138}
1144 1139
1145int PlayListWidget::whichList() const { 1140int PlayListWidget::whichList() const {
1146 return tabWidget->currentPageIndex(); 1141 return tabWidget->currentPageIndex();
1147} 1142}
1148 1143
1149PlayListWidget::TabType PlayListWidget::currentTab() const 1144PlayListWidget::TabType PlayListWidget::currentTab() const
1150{ 1145{
1151 static const TabType indexToTabType[ NumTabTypes ] = 1146 static const TabType indexToTabType[ NumTabTypes ] =
1152 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 1147 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
1153 1148
1154 int index = tabWidget->currentPageIndex(); 1149 int index = tabWidget->currentPageIndex();
1155 assert( index < NumTabTypes && index >= 0 ); 1150 assert( index < NumTabTypes && index >= 0 );
1156 1151
1157 return indexToTabType[ index ]; 1152 return indexToTabType[ index ];
1158} 1153}
1159 1154
1160QString PlayListWidget::currentFileListPathName() const { 1155QString PlayListWidget::currentFileListPathName() const {
1161 switch (whichList()) { 1156 switch (currentTab()) {
1162 case 1: 1157 case AudioFiles:
1163 return audioView->currentItem()->text(3); 1158 return audioView->currentItem()->text(3);
1164 break; 1159 case VideoFiles:
1165 case 2:
1166 return videoView->currentItem()->text(3); 1160 return videoView->currentItem()->text(3);
1167 break; 1161 default: assert( false );
1168 }; 1162 };
1169 return ""; 1163 return QString::null;
1170} 1164}