summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp133
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
@@ -208,65 +208,65 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
208 d->setDocumentUsed = FALSE; 208 d->setDocumentUsed = FALSE;
209 if ( mediaPlayerState->playlist() ) { 209 if ( mediaPlayerState->playlist() ) {
210 if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) 210 if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" )
211 d->selectedFiles->addToSelection( lnk ); 211 d->selectedFiles->addToSelection( lnk );
212 } 212 }
213 else 213 else
214 mediaPlayerState->setPlaying( TRUE ); 214 mediaPlayerState->setPlaying( TRUE );
215} 215}
216 216
217 217
218void PlayListWidget::clearList() { 218void PlayListWidget::clearList() {
219 while ( first() ) { 219 while ( first() ) {
220 d->selectedFiles->removeSelected(); 220 d->selectedFiles->removeSelected();
221 } 221 }
222} 222}
223 223
224 224
225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 225void 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
241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 241void 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
257void PlayListWidget::addAllToList() { 257void 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
269void PlayListWidget::addAllMusicToList() { 269void 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() ) {
@@ -301,84 +301,60 @@ void PlayListWidget::setDocument( const QString& 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
318void PlayListWidget::useSelectedDocument() { 318void PlayListWidget::useSelectedDocument() {
319 d->setDocumentUsed = FALSE; 319 d->setDocumentUsed = FALSE;
320} 320}
321 321
322 322
323const DocLnk *PlayListWidget::current() { // this is fugly 323const 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
366bool PlayListWidget::prev() { 342bool 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() )
373 d->selectedFiles->first(); 349 d->selectedFiles->first();
374 } 350 }
375 if ( cur == current() ) 351 if ( cur == current() )
376 if ( !d->selectedFiles->next() ) { 352 if ( !d->selectedFiles->next() ) {
377 d->selectedFiles->first(); 353 d->selectedFiles->first();
378 } 354 }
379 return TRUE; 355 return TRUE;
380 } else { 356 } else {
381 if ( !d->selectedFiles->prev() ) { 357 if ( !d->selectedFiles->prev() ) {
382 if ( mediaPlayerState->looping() ) { 358 if ( mediaPlayerState->looping() ) {
383 return d->selectedFiles->last(); 359 return d->selectedFiles->last();
384 } else { 360 } else {
@@ -475,89 +451,89 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
475 451
476 tabWidget->setCurrentPage(0); 452 tabWidget->setCurrentPage(0);
477 453
478 Config config( "OpiePlayer" ); 454 Config config( "OpiePlayer" );
479 config.writeEntry("CurrentPlaylist", name); 455 config.writeEntry("CurrentPlaylist", name);
480 // d->selectedFiles->first(); 456 // d->selectedFiles->first();
481 } 457 }
482} 458}
483 459
484 460
485void PlayListWidget::setPlaylist( bool shown ) { 461void PlayListWidget::setPlaylist( bool shown ) {
486 if ( shown ) { 462 if ( 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
494void PlayListWidget::addSelected() { 470void 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
544void PlayListWidget::removeSelected() { 520void PlayListWidget::removeSelected() {
545 d->selectedFiles->removeSelected( ); 521 d->selectedFiles->removeSelected( );
546} 522}
547 523
548 524
549void PlayListWidget::playIt( QListViewItem *it) { 525void PlayListWidget::playIt( QListViewItem *it) {
550 if(!it) return; 526 if(!it) return;
551 mediaPlayerState->setPlaying(FALSE); 527 mediaPlayerState->setPlaying(FALSE);
552 mediaPlayerState->setPlaying(TRUE); 528 mediaPlayerState->setPlaying(TRUE);
553 d->selectedFiles->unSelect(); 529 d->selectedFiles->unSelect();
554} 530}
555 531
556 532
557void PlayListWidget::addToSelection( QListViewItem *it) { 533void PlayListWidget::addToSelection( QListViewItem *it) {
558 d->setDocumentUsed = FALSE; 534 d->setDocumentUsed = FALSE;
559 535
560 if(it) { 536 if(it) {
561 switch ( whichList()) { 537 switch ( whichList()) {
562 case 1: { 538 case 1: {
563 QListIterator<DocLnk> dit( files.children() ); 539 QListIterator<DocLnk> dit( files.children() );
@@ -614,48 +590,49 @@ void PlayListWidget::tabChanged(QWidget *) {
614 case 2: 590 case 2:
615 { 591 {
616 videoView->clear(); 592 videoView->clear();
617 populateVideoView(); 593 populateVideoView();
618 if( !tbDeletePlaylist->isHidden() ) { 594 if( !tbDeletePlaylist->isHidden() ) {
619 tbDeletePlaylist->hide(); 595 tbDeletePlaylist->hide();
620 } 596 }
621 d->tbRemoveFromList->setEnabled(FALSE); 597 d->tbRemoveFromList->setEnabled(FALSE);
622 d->tbAddToList->setEnabled(TRUE); 598 d->tbAddToList->setEnabled(TRUE);
623 } 599 }
624 break; 600 break;
625 case 3: 601 case 3:
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
637void PlayListWidget::btnPlay(bool b) { 613void 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);
650// qApp->processEvents(); 627// qApp->processEvents();
651// insanityBool=FALSE; 628// insanityBool=FALSE;
652// }// audioView->clearSelection(); 629// }// audioView->clearSelection();
653// break; 630// break;
654// case 2: 631// case 2:
655// { 632// {
656// // addToSelection( videoView->currentItem() ); 633// // addToSelection( videoView->currentItem() );
657// mediaPlayerState->setPlaying(b); 634// mediaPlayerState->setPlaying(b);
658// qApp->processEvents(); 635// qApp->processEvents();
659// // d->selectedFiles->removeSelected( ); 636// // d->selectedFiles->removeSelected( );
660// // tabWidget->setCurrentPage(2); 637// // tabWidget->setCurrentPage(2);
661// // d->selectedFiles->unSelect(); 638// // d->selectedFiles->unSelect();
@@ -1019,64 +996,64 @@ void PlayListWidget::pmViewActivated(int index) {
1019 pmView->setItemChecked( index, b); 996 pmView->setItemChecked( index, b);
1020 Config cfg( "OpiePlayer" ); 997 Config cfg( "OpiePlayer" );
1021 cfg.writeEntry( "FullScreen", b ); 998 cfg.writeEntry( "FullScreen", b );
1022 } 999 }
1023 break; 1000 break;
1024 }; 1001 };
1025} 1002}
1026 1003
1027void PlayListWidget::populateSkinsMenu() { 1004void PlayListWidget::populateSkinsMenu() {
1028 int item = 0; 1005 int item = 0;
1029 defaultSkinIndex = 0; 1006 defaultSkinIndex = 0;
1030 QString skinName; 1007 QString skinName;
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
1057void PlayListWidget::skinsMenuActivated( int item ) { 1034void 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
1068int PlayListWidget::whichList() { 1045int PlayListWidget::whichList() {
1069 return tabWidget->currentPageIndex(); 1046 return tabWidget->currentPageIndex();
1070} 1047}
1071 1048
1072QString PlayListWidget::currentFileListPathName() { 1049QString PlayListWidget::currentFileListPathName() {
1073 switch (whichList()) { 1050 switch (whichList()) {
1074 case 1: 1051 case 1:
1075 return audioView->currentItem()->text(3); 1052 return audioView->currentItem()->text(3);
1076 break; 1053 break;
1077 case 2: 1054 case 2:
1078 return videoView->currentItem()->text(3); 1055 return videoView->currentItem()->text(3);
1079 break; 1056 break;
1080 }; 1057 };
1081 return ""; 1058 return "";
1082} 1059}