-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 133 |
1 files changed, 55 insertions, 78 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 15c70c3..2b58402 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -220,41 +220,41 @@ void PlayListWidget::clearList() { | |||
220 | d->selectedFiles->removeSelected(); | 220 | d->selectedFiles->removeSelected(); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
226 | switch (mouse) { | 226 | switch (mouse) { |
227 | case 1: | 227 | case 1: |
228 | break; | 228 | break; |
229 | case 2: | 229 | case 2: |
230 | { | 230 | { |
231 | QPopupMenu m; | 231 | QPopupMenu m; |
232 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
234 | m.exec( QCursor::pos() ); | 234 | m.exec( QCursor::pos() ); |
235 | } | 235 | } |
236 | break; | 236 | break; |
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 Selected" ), 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() ); |
@@ -313,60 +313,36 @@ void PlayListWidget::setDocument( const QString& fileref ) { | |||
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->selected(); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | break; | 336 | break; |
337 | case 1://audio | ||
338 | { | ||
339 | // qDebug("audioView"); | ||
340 | QListIterator<DocLnk> dit( files.children() ); | ||
341 | for ( ; dit.current(); ++dit ) { | ||
342 | if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) { | ||
343 | insanityBool = TRUE; | ||
344 | return dit; | ||
345 | } | ||
346 | } | ||
347 | } | ||
348 | break; | ||
349 | case 2: // video | ||
350 | { | ||
351 | // qDebug("videoView"); | ||
352 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
353 | for ( ; Vdit.current(); ++Vdit ) { | ||
354 | if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) { | ||
355 | insanityBool = TRUE; | ||
356 | return Vdit; | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | break; | ||
361 | }; | 337 | }; |
362 | return 0; | 338 | return 0; |
363 | } | 339 | } |
364 | 340 | ||
365 | 341 | ||
366 | bool PlayListWidget::prev() { | 342 | bool PlayListWidget::prev() { |
367 | if ( mediaPlayerState->playlist() ) { | 343 | if ( mediaPlayerState->playlist() ) { |
368 | if ( mediaPlayerState->shuffled() ) { | 344 | if ( mediaPlayerState->shuffled() ) { |
369 | const DocLnk *cur = current(); | 345 | const DocLnk *cur = current(); |
370 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 346 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
371 | for ( int i = 0; i < j; i++ ) { | 347 | for ( int i = 0; i < j; i++ ) { |
372 | if ( !d->selectedFiles->next() ) | 348 | if ( !d->selectedFiles->next() ) |
@@ -487,65 +463,65 @@ void PlayListWidget::setPlaylist( bool shown ) { | |||
487 | d->playListFrame->show(); | 463 | d->playListFrame->show(); |
488 | } else { | 464 | } else { |
489 | d->playListFrame->hide(); | 465 | d->playListFrame->hide(); |
490 | } | 466 | } |
491 | } | 467 | } |
492 | 468 | ||
493 | 469 | ||
494 | void PlayListWidget::addSelected() { | 470 | void PlayListWidget::addSelected() { |
495 | 471 | ||
496 | Config cfg( "OpiePlayer" ); | 472 | Config cfg( "OpiePlayer" ); |
497 | cfg.setGroup("PlayList"); | 473 | cfg.setGroup("PlayList"); |
498 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 474 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
499 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 475 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
500 | 476 | ||
501 | switch (whichList()) { | 477 | switch (whichList()) { |
502 | case 0: //playlist | 478 | case 0: //playlist |
503 | break; | 479 | break; |
504 | case 1: { //audio | 480 | case 1: { //audio |
505 | QListViewItemIterator it( audioView ); | 481 | QListViewItemIterator it( audioView ); |
506 | // iterate through all items of the listview | 482 | // iterate through all items of the listview |
507 | for ( ; it.current(); ++it ) { | 483 | for ( ; it.current(); ++it ) { |
508 | if ( it.current()->isSelected() ) { | 484 | if ( it.current()->isSelected() ) { |
509 | QListIterator<DocLnk> dit( files.children() ); | 485 | QListIterator<DocLnk> dit( files.children() ); |
510 | for ( ; dit.current(); ++dit ) { | 486 | for ( ; dit.current(); ++dit ) { |
511 | if( dit.current()->name() == it.current()->text(0) ) { | 487 | if( dit.current()->name() == it.current()->text(0) ) { |
512 | if(QFileInfo( dit.current()->file()).exists()) | 488 | if(QFileInfo( dit.current()->file()).exists()) |
513 | d->selectedFiles->addToSelection( **dit ); | 489 | d->selectedFiles->addToSelection( **dit ); |
514 | } | 490 | } |
515 | } | 491 | } |
516 | audioView->setSelected( it.current(),FALSE); | 492 | audioView->setSelected( it.current(),FALSE); |
517 | } | 493 | } |
518 | } | 494 | } |
519 | tabWidget->setCurrentPage(0); | 495 | tabWidget->setCurrentPage(0); |
520 | } | 496 | } |
521 | break; | 497 | break; |
522 | case 2: { // video | 498 | case 2: { // video |
523 | QListViewItemIterator it( videoView ); | 499 | QListViewItemIterator it( videoView ); |
524 | // iterate through all items of the listview | 500 | // iterate through all items of the listview |
525 | for ( ; it.current(); ++it ) { | 501 | for ( ; it.current(); ++it ) { |
526 | if ( it.current()->isSelected() ) { | 502 | if ( it.current()->isSelected() ) { |
527 | QListIterator<DocLnk> dit( vFiles.children() ); | 503 | QListIterator<DocLnk> dit( vFiles.children() ); |
528 | for ( ; dit.current(); ++dit ) { | 504 | for ( ; dit.current(); ++dit ) { |
529 | if( dit.current()->name() == it.current()->text(0) ) { | 505 | if( dit.current()->name() == it.current()->text(0) ) { |
530 | if(QFileInfo( dit.current()->file()).exists()) | 506 | if(QFileInfo( dit.current()->file()).exists()) |
531 | d->selectedFiles->addToSelection( **dit ); | 507 | d->selectedFiles->addToSelection( **dit ); |
532 | } | 508 | } |
533 | } | 509 | } |
534 | videoView->setSelected( it.current(),FALSE); | 510 | videoView->setSelected( it.current(),FALSE); |
535 | } | 511 | } |
536 | } | 512 | } |
537 | tabWidget->setCurrentPage(0); | 513 | tabWidget->setCurrentPage(0); |
538 | } | 514 | } |
539 | break; | 515 | break; |
540 | }; | 516 | }; |
541 | } | 517 | } |
542 | 518 | ||
543 | 519 | ||
544 | void PlayListWidget::removeSelected() { | 520 | void PlayListWidget::removeSelected() { |
545 | d->selectedFiles->removeSelected( ); | 521 | d->selectedFiles->removeSelected( ); |
546 | } | 522 | } |
547 | 523 | ||
548 | 524 | ||
549 | void PlayListWidget::playIt( QListViewItem *it) { | 525 | void PlayListWidget::playIt( QListViewItem *it) { |
550 | if(!it) return; | 526 | if(!it) return; |
551 | mediaPlayerState->setPlaying(FALSE); | 527 | mediaPlayerState->setPlaying(FALSE); |
@@ -626,24 +602,25 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
626 | { | 602 | { |
627 | if( tbDeletePlaylist->isHidden() ) { | 603 | if( tbDeletePlaylist->isHidden() ) { |
628 | tbDeletePlaylist->show(); | 604 | tbDeletePlaylist->show(); |
629 | } | 605 | } |
630 | playLists->reread(); | 606 | playLists->reread(); |
631 | } | 607 | } |
632 | break; | 608 | break; |
633 | }; | 609 | }; |
634 | } | 610 | } |
635 | 611 | ||
636 | 612 | ||
637 | void PlayListWidget::btnPlay(bool b) { | 613 | void PlayListWidget::btnPlay(bool b) { |
614 | // mediaPlayerState->setPlaying(false); | ||
638 | mediaPlayerState->setPlaying(b); | 615 | mediaPlayerState->setPlaying(b); |
639 | qApp->processEvents(); | 616 | qApp->processEvents(); |
640 | insanityBool=FALSE; | 617 | insanityBool=FALSE; |
641 | // switch ( whichList()) { | 618 | // switch ( whichList()) { |
642 | // case 0: | 619 | // case 0: |
643 | // { | 620 | // { |
644 | // mediaPlayerState->setPlaying(b); | 621 | // mediaPlayerState->setPlaying(b); |
645 | // } | 622 | // } |
646 | // break; | 623 | // break; |
647 | // case 1: | 624 | // case 1: |
648 | // { | 625 | // { |
649 | // mediaPlayerState->setPlaying(b); | 626 | // mediaPlayerState->setPlaying(b); |
@@ -1031,40 +1008,40 @@ void PlayListWidget::populateSkinsMenu() { | |||
1031 | Config cfg( "OpiePlayer" ); | 1008 | Config cfg( "OpiePlayer" ); |
1032 | cfg.setGroup("Options" ); | 1009 | cfg.setGroup("Options" ); |
1033 | QString skin = cfg.readEntry( "Skin", "default" ); | 1010 | QString skin = cfg.readEntry( "Skin", "default" ); |
1034 | 1011 | ||
1035 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1012 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1036 | skinsDir.setFilter( QDir::Dirs ); | 1013 | skinsDir.setFilter( QDir::Dirs ); |
1037 | skinsDir.setSorting(QDir::Name ); | 1014 | skinsDir.setSorting(QDir::Name ); |
1038 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1015 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1039 | QFileInfoListIterator it( *skinslist ); | 1016 | QFileInfoListIterator it( *skinslist ); |
1040 | QFileInfo *fi; | 1017 | QFileInfo *fi; |
1041 | while ( ( fi = it.current() ) ) { | 1018 | while ( ( fi = it.current() ) ) { |
1042 | skinName = fi->fileName(); | 1019 | skinName = fi->fileName(); |
1043 | qDebug( fi->fileName() ); | 1020 | // qDebug( fi->fileName() ); |
1044 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1021 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1045 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1022 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1046 | } | 1023 | } |
1047 | if( skinName == "default" ) { | 1024 | if( skinName == "default" ) { |
1048 | defaultSkinIndex = item; | 1025 | defaultSkinIndex = item; |
1049 | } | 1026 | } |
1050 | if( skinName == skin ) { | 1027 | if( skinName == skin ) { |
1051 | skinsMenu->setItemChecked( item, TRUE ); | 1028 | skinsMenu->setItemChecked( item, TRUE ); |
1052 | } | 1029 | } |
1053 | ++it; | 1030 | ++it; |
1054 | } | 1031 | } |
1055 | } | 1032 | } |
1056 | 1033 | ||
1057 | void PlayListWidget::skinsMenuActivated( int item ) { | 1034 | void PlayListWidget::skinsMenuActivated( int item ) { |
1058 | for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1035 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1059 | skinsMenu->setItemChecked( i, FALSE ); | 1036 | skinsMenu->setItemChecked( i, FALSE ); |
1060 | } | 1037 | } |
1061 | skinsMenu->setItemChecked( item, TRUE ); | 1038 | skinsMenu->setItemChecked( item, TRUE ); |
1062 | 1039 | ||
1063 | Config cfg( "OpiePlayer" ); | 1040 | Config cfg( "OpiePlayer" ); |
1064 | cfg.setGroup("Options"); | 1041 | cfg.setGroup("Options"); |
1065 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1042 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1066 | } | 1043 | } |
1067 | 1044 | ||
1068 | int PlayListWidget::whichList() { | 1045 | int PlayListWidget::whichList() { |
1069 | return tabWidget->currentPageIndex(); | 1046 | return tabWidget->currentPageIndex(); |
1070 | } | 1047 | } |