author | simon <simon> | 2002-12-02 14:47:45 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 14:47:45 (UTC) |
commit | 3644bde7c86013c699978446c29ec6502220e29c (patch) (unidiff) | |
tree | b3c1df324e8f3051d0b54fdb3e5e7e4904fbde4a | |
parent | 46d64cdfe9a3d949e91ea6a72828405d03337225 (diff) | |
download | opie-3644bde7c86013c699978446c29ec6502220e29c.zip opie-3644bde7c86013c699978446c29ec6502220e29c.tar.gz opie-3644bde7c86013c699978446c29ec6502220e29c.tar.bz2 |
- more whichList usage removed
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 34 |
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 | |||
@@ -396,79 +396,74 @@ void PlayListWidget::setDocument( const QString& fileref ) { | |||
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 | ||
422 | void PlayListWidget::useSelectedDocument() { | 422 | void PlayListWidget::useSelectedDocument() { |
423 | d->setDocumentUsed = FALSE; | 423 | d->setDocumentUsed = FALSE; |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | const DocLnk *PlayListWidget::current() { // this is fugly | 427 | const 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 | ||
446 | bool PlayListWidget::prev() { | 441 | bool 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 | ||
@@ -1129,42 +1124,41 @@ void PlayListWidget::populateSkinsMenu() { | |||
1129 | } | 1124 | } |
1130 | } | 1125 | } |
1131 | 1126 | ||
1132 | void PlayListWidget::skinsMenuActivated( int item ) { | 1127 | void 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 | ||
1145 | int PlayListWidget::whichList() const { | 1140 | int PlayListWidget::whichList() const { |
1146 | return tabWidget->currentPageIndex(); | 1141 | return tabWidget->currentPageIndex(); |
1147 | } | 1142 | } |
1148 | 1143 | ||
1149 | PlayListWidget::TabType PlayListWidget::currentTab() const | 1144 | PlayListWidget::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 | ||
1160 | QString PlayListWidget::currentFileListPathName() const { | 1155 | QString 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 | } |