summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-10 15:09:42 (UTC)
committer llornkcor <llornkcor>2002-11-10 15:09:42 (UTC)
commit1486b6f940adde3cd80592e436e8e025045d7f8e (patch) (unidiff)
treec7e0add7b96a10cbd5095bdfd2845c4e063ebccb
parent521b993fb4175e699e9ac832c50558af0354ca25 (diff)
downloadopie-1486b6f940adde3cd80592e436e8e025045d7f8e.zip
opie-1486b6f940adde3cd80592e436e8e025045d7f8e.tar.gz
opie-1486b6f940adde3cd80592e436e8e025045d7f8e.tar.bz2
need a default m3u to write too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 7ada5ee..75c7332 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -200,863 +200,865 @@ void PlayListWidget::writeDefaultPlaylist() {
200 if(m3uList) delete m3uList; 200 if(m3uList) delete m3uList;
201 201
202 } 202 }
203 } 203 }
204} 204}
205 205
206void PlayListWidget::addToSelection( const DocLnk& lnk ) { 206void PlayListWidget::addToSelection( const DocLnk& lnk ) {
207 d->setDocumentUsed = FALSE; 207 d->setDocumentUsed = FALSE;
208 if ( mediaPlayerState->playlist() ) { 208 if ( mediaPlayerState->playlist() ) {
209 if( QFileInfo( lnk.file() ).exists() || 209 if( QFileInfo( lnk.file() ).exists() ||
210 lnk.file().left(4) == "http" ) 210 lnk.file().left(4) == "http" )
211 d->selectedFiles->addToSelection( lnk ); 211 d->selectedFiles->addToSelection( lnk );
212// writeCurrentM3u(); 212// writeCurrentM3u();
213 } 213 }
214 else 214 else
215 mediaPlayerState->setPlaying( TRUE ); 215 mediaPlayerState->setPlaying( TRUE );
216} 216}
217 217
218 218
219void PlayListWidget::clearList() { 219void PlayListWidget::clearList() {
220 while ( first() ) { 220 while ( first() ) {
221 d->selectedFiles->removeSelected(); 221 d->selectedFiles->removeSelected();
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 Selected" ), 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" ), 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/*;"+audioMimes); 259 Global::findDocuments(&filesAll, "video/*;"+audioMimes);
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 writeCurrentM3u(); 266 writeCurrentM3u();
267} 267}
268 268
269 269
270void PlayListWidget::addAllMusicToList() { 270void PlayListWidget::addAllMusicToList() {
271 if(!audioScan) 271 if(!audioScan)
272 scanForAudio(); 272 scanForAudio();
273 QListIterator<DocLnk> dit( files.children() ); 273 QListIterator<DocLnk> dit( files.children() );
274 for ( ; dit.current(); ++dit ) { 274 for ( ; dit.current(); ++dit ) {
275 if( QFileInfo(dit.current()->file() ).exists() ) { 275 if( QFileInfo(dit.current()->file() ).exists() ) {
276 d->selectedFiles->addToSelection( **dit ); 276 d->selectedFiles->addToSelection( **dit );
277 } 277 }
278 } 278 }
279 writeCurrentM3u(); 279 writeCurrentM3u();
280} 280}
281 281
282 282
283void PlayListWidget::addAllVideoToList() { 283void PlayListWidget::addAllVideoToList() {
284 if(!videoScan) 284 if(!videoScan)
285 scanForVideo(); 285 scanForVideo();
286 QListIterator<DocLnk> dit( vFiles.children() ); 286 QListIterator<DocLnk> dit( vFiles.children() );
287 for ( ; dit.current(); ++dit ) { 287 for ( ; dit.current(); ++dit ) {
288 if( QFileInfo( dit.current()->file() ).exists() ) { 288 if( QFileInfo( dit.current()->file() ).exists() ) {
289 d->selectedFiles->addToSelection( **dit ); 289 d->selectedFiles->addToSelection( **dit );
290 } 290 }
291 } 291 }
292 writeCurrentM3u(); 292 writeCurrentM3u();
293} 293}
294 294
295 295
296void PlayListWidget::setDocument( const QString& fileref ) { 296void PlayListWidget::setDocument( const QString& fileref ) {
297 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 297 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
298 fromSetDocument = TRUE; 298 fromSetDocument = TRUE;
299 if ( fileref.isNull() ) { 299 if ( fileref.isNull() ) {
300 QMessageBox::critical( 0, tr( "Invalid File" ), 300 QMessageBox::critical( 0, tr( "Invalid File" ),
301 tr( "There was a problem in getting the file." ) ); 301 tr( "There was a problem in getting the file." ) );
302 return; 302 return;
303 } 303 }
304 304
305 clearList(); 305 clearList();
306 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 306 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
307 readm3u( fileref ); 307 readm3u( fileref );
308 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 308 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
309 readm3u( DocLnk( fileref).file() ); 309 readm3u( DocLnk( fileref).file() );
310 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 310 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
311 readPls( fileref ); 311 readPls( fileref );
312 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 312 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
313 readPls( DocLnk( fileref).file() ); 313 readPls( DocLnk( fileref).file() );
314 } else { 314 } else {
315 clearList(); 315 clearList();
316 addToSelection( DocLnk( fileref ) ); 316 addToSelection( DocLnk( fileref ) );
317 writeCurrentM3u(); 317 writeCurrentM3u();
318 318
319 d->setDocumentUsed = TRUE; 319 d->setDocumentUsed = TRUE;
320 mediaPlayerState->setPlaying( FALSE ); 320 mediaPlayerState->setPlaying( FALSE );
321 mediaPlayerState->setPlaying( TRUE ); 321 mediaPlayerState->setPlaying( TRUE );
322 } 322 }
323} 323}
324 324
325 325
326void PlayListWidget::useSelectedDocument() { 326void PlayListWidget::useSelectedDocument() {
327 d->setDocumentUsed = FALSE; 327 d->setDocumentUsed = FALSE;
328} 328}
329 329
330 330
331const DocLnk *PlayListWidget::current() { // this is fugly 331const DocLnk *PlayListWidget::current() { // this is fugly
332 switch ( whichList() ) { 332 switch ( whichList() ) {
333 case 0: //playlist 333 case 0: //playlist
334 { 334 {
335// qDebug("playlist"); 335// qDebug("playlist");
336 if ( mediaPlayerState->playlist() ) { 336 if ( mediaPlayerState->playlist() ) {
337 return d->selectedFiles->current(); 337 return d->selectedFiles->current();
338 } else if ( d->setDocumentUsed && d->current ) { 338 } else if ( d->setDocumentUsed && d->current ) {
339 return d->current; 339 return d->current;
340 } else { 340 } else {
341 return &(d->files->selectedDocument()); 341 return &(d->files->selectedDocument());
342 } 342 }
343 } 343 }
344 break; 344 break;
345 }; 345 };
346 return 0; 346 return 0;
347} 347}
348 348
349 349
350bool PlayListWidget::prev() { 350bool PlayListWidget::prev() {
351 if ( mediaPlayerState->playlist() ) { 351 if ( mediaPlayerState->playlist() ) {
352 if ( mediaPlayerState->shuffled() ) { 352 if ( mediaPlayerState->shuffled() ) {
353 const DocLnk *cur = current(); 353 const DocLnk *cur = current();
354 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 354 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
355 for ( int i = 0; i < j; i++ ) { 355 for ( int i = 0; i < j; i++ ) {
356 if ( !d->selectedFiles->next() ) 356 if ( !d->selectedFiles->next() )
357 d->selectedFiles->first(); 357 d->selectedFiles->first();
358 } 358 }
359 if ( cur == current() ) 359 if ( cur == current() )
360 if ( !d->selectedFiles->next() ) { 360 if ( !d->selectedFiles->next() ) {
361 d->selectedFiles->first(); 361 d->selectedFiles->first();
362 } 362 }
363 return TRUE; 363 return TRUE;
364 } else { 364 } else {
365 if ( !d->selectedFiles->prev() ) { 365 if ( !d->selectedFiles->prev() ) {
366 if ( mediaPlayerState->looping() ) { 366 if ( mediaPlayerState->looping() ) {
367 return d->selectedFiles->last(); 367 return d->selectedFiles->last();
368 } else { 368 } else {
369 return FALSE; 369 return FALSE;
370 } 370 }
371 } 371 }
372 return TRUE; 372 return TRUE;
373 } 373 }
374 } else { 374 } else {
375 return mediaPlayerState->looping(); 375 return mediaPlayerState->looping();
376 } 376 }
377} 377}
378 378
379 379
380bool PlayListWidget::next() { 380bool PlayListWidget::next() {
381//qDebug("<<<<<<<<<<<<next()"); 381//qDebug("<<<<<<<<<<<<next()");
382 if ( mediaPlayerState->playlist() ) { 382 if ( mediaPlayerState->playlist() ) {
383 if ( mediaPlayerState->shuffled() ) { 383 if ( mediaPlayerState->shuffled() ) {
384 return prev(); 384 return prev();
385 } else { 385 } else {
386 if ( !d->selectedFiles->next() ) { 386 if ( !d->selectedFiles->next() ) {
387 if ( mediaPlayerState->looping() ) { 387 if ( mediaPlayerState->looping() ) {
388 return d->selectedFiles->first(); 388 return d->selectedFiles->first();
389 } else { 389 } else {
390 return FALSE; 390 return FALSE;
391 } 391 }
392 } 392 }
393 return TRUE; 393 return TRUE;
394 } 394 }
395 } else { 395 } else {
396 return mediaPlayerState->looping(); 396 return mediaPlayerState->looping();
397 } 397 }
398} 398}
399 399
400 400
401bool PlayListWidget::first() { 401bool PlayListWidget::first() {
402 if ( mediaPlayerState->playlist() ) 402 if ( mediaPlayerState->playlist() )
403 return d->selectedFiles->first(); 403 return d->selectedFiles->first();
404 else 404 else
405 return mediaPlayerState->looping(); 405 return mediaPlayerState->looping();
406} 406}
407 407
408 408
409bool PlayListWidget::last() { 409bool PlayListWidget::last() {
410 if ( mediaPlayerState->playlist() ) 410 if ( mediaPlayerState->playlist() )
411 return d->selectedFiles->last(); 411 return d->selectedFiles->last();
412 else 412 else
413 return mediaPlayerState->looping(); 413 return mediaPlayerState->looping();
414} 414}
415 415
416 416
417 void PlayListWidget::saveList() { 417 void PlayListWidget::saveList() {
418 writem3u(); 418 writem3u();
419 } 419 }
420 420
421 421
422void PlayListWidget::loadList( const DocLnk & lnk) { 422void PlayListWidget::loadList( const DocLnk & lnk) {
423 QString name = lnk.name(); 423 QString name = lnk.name();
424 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 424 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
425 425
426 if( name.length()>0) { 426 if( name.length()>0) {
427 setCaption("OpiePlayer: "+name); 427 setCaption("OpiePlayer: "+name);
428 qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 428 qDebug("<<<<<<<<<<<<load list "+ lnk.file());
429 clearList(); 429 clearList();
430 readm3u(lnk.file()); 430 readm3u(lnk.file());
431 tabWidget->setCurrentPage(0); 431 tabWidget->setCurrentPage(0);
432 } 432 }
433} 433}
434 434
435 435
436void PlayListWidget::setPlaylist( bool shown ) { 436void PlayListWidget::setPlaylist( bool shown ) {
437 if ( shown ) { 437 if ( shown ) {
438 d->playListFrame->show(); 438 d->playListFrame->show();
439 } else { 439 } else {
440 d->playListFrame->hide(); 440 d->playListFrame->hide();
441 } 441 }
442} 442}
443 443
444 444
445void PlayListWidget::addSelected() { 445void PlayListWidget::addSelected() {
446 qDebug("addSelected"); 446 qDebug("addSelected");
447 switch (whichList()) { 447 switch (whichList()) {
448 case 0: //playlist 448 case 0: //playlist
449 break; 449 break;
450 case 1: { //audio 450 case 1: { //audio
451 QListViewItemIterator it( audioView ); 451 QListViewItemIterator it( audioView );
452 // iterate through all items of the listview 452 // iterate through all items of the listview
453 for ( ; it.current(); ++it ) { 453 for ( ; it.current(); ++it ) {
454 if ( it.current()->isSelected() ) { 454 if ( it.current()->isSelected() ) {
455 QListIterator<DocLnk> dit( files.children() ); 455 QListIterator<DocLnk> dit( files.children() );
456 for ( ; dit.current(); ++dit ) { 456 for ( ; dit.current(); ++dit ) {
457 if( dit.current()->name() == it.current()->text(0) ) { 457 if( dit.current()->name() == it.current()->text(0) ) {
458 if( QFileInfo( dit.current()->file()).exists()) { 458 if( QFileInfo( dit.current()->file()).exists()) {
459 d->selectedFiles->addToSelection( **dit ); 459 d->selectedFiles->addToSelection( **dit );
460 audioView->setSelected( it.current(),FALSE); 460 audioView->setSelected( it.current(),FALSE);
461 } 461 }
462 } 462 }
463 } 463 }
464 } 464 }
465 } 465 }
466// tabWidget->setCurrentPage(0); 466// tabWidget->setCurrentPage(0);
467 writeCurrentM3u(); 467 writeCurrentM3u();
468 } 468 }
469 break; 469 break;
470 case 2: { // video 470 case 2: { // video
471 QListViewItemIterator it( videoView ); 471 QListViewItemIterator it( videoView );
472 // iterate through all items of the listview 472 // iterate through all items of the listview
473 for ( ; it.current(); ++it ) { 473 for ( ; it.current(); ++it ) {
474 if ( it.current()->isSelected() ) { 474 if ( it.current()->isSelected() ) {
475 QListIterator<DocLnk> dit( vFiles.children() ); 475 QListIterator<DocLnk> dit( vFiles.children() );
476 for ( ; dit.current(); ++dit ) { 476 for ( ; dit.current(); ++dit ) {
477 if( dit.current()->name() == it.current()->text(0) ) { 477 if( dit.current()->name() == it.current()->text(0) ) {
478 if(QFileInfo( dit.current()->file()).exists()) { 478 if(QFileInfo( dit.current()->file()).exists()) {
479 d->selectedFiles->addToSelection( **dit ); 479 d->selectedFiles->addToSelection( **dit );
480 videoView->setSelected( it.current(),FALSE); 480 videoView->setSelected( it.current(),FALSE);
481 } 481 }
482 } 482 }
483 } 483 }
484 } 484 }
485 } 485 }
486// tabWidget->setCurrentPage(0); 486// tabWidget->setCurrentPage(0);
487 writeCurrentM3u(); 487 writeCurrentM3u();
488 } 488 }
489 break; 489 break;
490 }; 490 };
491} 491}
492 492
493 493
494void PlayListWidget::removeSelected() { 494void PlayListWidget::removeSelected() {
495 d->selectedFiles->removeSelected( ); 495 d->selectedFiles->removeSelected( );
496 writeCurrentM3u(); 496 writeCurrentM3u();
497} 497}
498 498
499 499
500void PlayListWidget::playIt( QListViewItem *it) { 500void PlayListWidget::playIt( QListViewItem *it) {
501 if(!it) return; 501 if(!it) return;
502 mediaPlayerState->setPlaying(FALSE); 502 mediaPlayerState->setPlaying(FALSE);
503 mediaPlayerState->setPlaying(TRUE); 503 mediaPlayerState->setPlaying(TRUE);
504 d->selectedFiles->unSelect(); 504 d->selectedFiles->unSelect();
505} 505}
506 506
507 507
508void PlayListWidget::addToSelection( QListViewItem *it) { 508void PlayListWidget::addToSelection( QListViewItem *it) {
509 d->setDocumentUsed = FALSE; 509 d->setDocumentUsed = FALSE;
510 510
511 if(it) { 511 if(it) {
512 switch ( whichList()) { 512 switch ( whichList()) {
513 case 1: { 513 case 1: {
514 QListIterator<DocLnk> dit( files.children() ); 514 QListIterator<DocLnk> dit( files.children() );
515 for ( ; dit.current(); ++dit ) { 515 for ( ; dit.current(); ++dit ) {
516 if( dit.current()->name() == it->text(0)) { 516 if( dit.current()->name() == it->text(0)) {
517 if(QFileInfo( dit.current()->file()).exists()) 517 if(QFileInfo( dit.current()->file()).exists())
518 d->selectedFiles->addToSelection( **dit ); 518 d->selectedFiles->addToSelection( **dit );
519 } 519 }
520 } 520 }
521 writeCurrentM3u(); 521 writeCurrentM3u();
522 } 522 }
523 break; 523 break;
524 case 2: { 524 case 2: {
525 QListIterator<DocLnk> dit( vFiles.children() ); 525 QListIterator<DocLnk> dit( vFiles.children() );
526 for ( ; dit.current(); ++dit ) { 526 for ( ; dit.current(); ++dit ) {
527 if( dit.current()->name() == it->text(0)) { 527 if( dit.current()->name() == it->text(0)) {
528 if( QFileInfo( dit.current()->file()).exists() ) 528 if( QFileInfo( dit.current()->file()).exists() )
529 d->selectedFiles->addToSelection( **dit ); 529 d->selectedFiles->addToSelection( **dit );
530 } 530 }
531 } 531 }
532 writeCurrentM3u(); 532 writeCurrentM3u();
533 533
534 } 534 }
535 break; 535 break;
536 case 0: 536 case 0:
537 break; 537 break;
538 }; 538 };
539 tabWidget->setCurrentPage(0); 539 tabWidget->setCurrentPage(0);
540 } 540 }
541} 541}
542 542
543 543
544void PlayListWidget::tabChanged(QWidget *) { 544void PlayListWidget::tabChanged(QWidget *) {
545 545
546 switch ( whichList()) { 546 switch ( whichList()) {
547 case 0: 547 case 0:
548 { 548 {
549 if( !tbDeletePlaylist->isHidden() ) { 549 if( !tbDeletePlaylist->isHidden() ) {
550 tbDeletePlaylist->hide(); 550 tbDeletePlaylist->hide();
551 } 551 }
552 d->tbRemoveFromList->setEnabled(TRUE); 552 d->tbRemoveFromList->setEnabled(TRUE);
553 d->tbAddToList->setEnabled(FALSE); 553 d->tbAddToList->setEnabled(FALSE);
554 } 554 }
555 break; 555 break;
556 case 1: 556 case 1:
557 { 557 {
558 audioView->clear(); 558 audioView->clear();
559 populateAudioView(); 559 populateAudioView();
560 560
561 if( !tbDeletePlaylist->isHidden() ) { 561 if( !tbDeletePlaylist->isHidden() ) {
562 tbDeletePlaylist->hide(); 562 tbDeletePlaylist->hide();
563 } 563 }
564 d->tbRemoveFromList->setEnabled(FALSE); 564 d->tbRemoveFromList->setEnabled(FALSE);
565 d->tbAddToList->setEnabled(TRUE); 565 d->tbAddToList->setEnabled(TRUE);
566 } 566 }
567 break; 567 break;
568 case 2: 568 case 2:
569 { 569 {
570 videoView->clear(); 570 videoView->clear();
571 populateVideoView(); 571 populateVideoView();
572 if( !tbDeletePlaylist->isHidden() ) { 572 if( !tbDeletePlaylist->isHidden() ) {
573 tbDeletePlaylist->hide(); 573 tbDeletePlaylist->hide();
574 } 574 }
575 d->tbRemoveFromList->setEnabled(FALSE); 575 d->tbRemoveFromList->setEnabled(FALSE);
576 d->tbAddToList->setEnabled(TRUE); 576 d->tbAddToList->setEnabled(TRUE);
577 } 577 }
578 break; 578 break;
579 case 3: 579 case 3:
580 { 580 {
581 if( tbDeletePlaylist->isHidden() ) { 581 if( tbDeletePlaylist->isHidden() ) {
582 tbDeletePlaylist->show(); 582 tbDeletePlaylist->show();
583 } 583 }
584 playLists->reread(); 584 playLists->reread();
585 } 585 }
586 break; 586 break;
587 }; 587 };
588} 588}
589 589
590 590
591void PlayListWidget::btnPlay(bool b) { 591void PlayListWidget::btnPlay(bool b) {
592// mediaPlayerState->setPlaying(false); 592// mediaPlayerState->setPlaying(false);
593 mediaPlayerState->setPlaying(b); 593 mediaPlayerState->setPlaying(b);
594 insanityBool=FALSE; 594 insanityBool=FALSE;
595} 595}
596 596
597void PlayListWidget::deletePlaylist() { 597void PlayListWidget::deletePlaylist() {
598 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 598 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
599 (tr("You really want to delete\nthis playlist?")), 599 (tr("You really want to delete\nthis playlist?")),
600 (tr("Yes")), (tr("No")), 0 )){ 600 (tr("Yes")), (tr("No")), 0 )){
601 case 0: // Yes clicked, 601 case 0: // Yes clicked,
602 QFile().remove(playLists->selectedDocument().file()); 602 QFile().remove(playLists->selectedDocument().file());
603 QFile().remove(playLists->selectedDocument().linkFile()); 603 QFile().remove(playLists->selectedDocument().linkFile());
604 playLists->reread(); 604 playLists->reread();
605 break; 605 break;
606 case 1: // Cancel 606 case 1: // Cancel
607 break; 607 break;
608 }; 608 };
609} 609}
610 610
611 611
612void PlayListWidget::playSelected() { 612void PlayListWidget::playSelected() {
613 btnPlay( TRUE); 613 btnPlay( TRUE);
614} 614}
615 615
616 616
617void PlayListWidget::scanForAudio() { 617void PlayListWidget::scanForAudio() {
618// qDebug("scan for audio"); 618// qDebug("scan for audio");
619 files.detachChildren(); 619 files.detachChildren();
620 QListIterator<DocLnk> sdit( files.children() ); 620 QListIterator<DocLnk> sdit( files.children() );
621 for ( ; sdit.current(); ++sdit ) { 621 for ( ; sdit.current(); ++sdit ) {
622 delete sdit.current(); 622 delete sdit.current();
623 } 623 }
624// Global::findDocuments( &files, "audio/*"); 624// Global::findDocuments( &files, "audio/*");
625 Global::findDocuments( &files, audioMimes); 625 Global::findDocuments( &files, audioMimes);
626 audioScan = TRUE; 626 audioScan = TRUE;
627} 627}
628 628
629void PlayListWidget::scanForVideo() { 629void PlayListWidget::scanForVideo() {
630// qDebug("scan for video"); 630// qDebug("scan for video");
631 vFiles.detachChildren(); 631 vFiles.detachChildren();
632 QListIterator<DocLnk> sdit( vFiles.children() ); 632 QListIterator<DocLnk> sdit( vFiles.children() );
633 for ( ; sdit.current(); ++sdit ) { 633 for ( ; sdit.current(); ++sdit ) {
634 delete sdit.current(); 634 delete sdit.current();
635 } 635 }
636 Global::findDocuments(&vFiles, "video/*"); 636 Global::findDocuments(&vFiles, "video/*");
637 videoScan = TRUE; 637 videoScan = TRUE;
638} 638}
639 639
640void PlayListWidget::populateAudioView() { 640void PlayListWidget::populateAudioView() {
641 audioView->clear(); 641 audioView->clear();
642 StorageInfo storageInfo; 642 StorageInfo storageInfo;
643 const QList<FileSystem> &fs = storageInfo.fileSystems(); 643 const QList<FileSystem> &fs = storageInfo.fileSystems();
644 if(!audioScan) { 644 if(!audioScan) {
645 scanForAudio(); 645 scanForAudio();
646 } 646 }
647 647
648 QListIterator<DocLnk> dit( files.children() ); 648 QListIterator<DocLnk> dit( files.children() );
649 QListIterator<FileSystem> it ( fs ); 649 QListIterator<FileSystem> it ( fs );
650 650
651 QString storage; 651 QString storage;
652 for ( ; dit.current(); ++dit ) { 652 for ( ; dit.current(); ++dit ) {
653 for( ; it.current(); ++it ){ 653 for( ; it.current(); ++it ){
654 const QString name = (*it)->name(); 654 const QString name = (*it)->name();
655 const QString path = (*it)->path(); 655 const QString path = (*it)->path();
656 if(dit.current()->file().find(path) != -1 ) { 656 if(dit.current()->file().find(path) != -1 ) {
657 storage = name; 657 storage = name;
658 } 658 }
659 } 659 }
660 660
661 QListViewItem * newItem; 661 QListViewItem * newItem;
662 if ( QFile( dit.current()->file()).exists() || 662 if ( QFile( dit.current()->file()).exists() ||
663 dit.current()->file().left(4) == "http" ) { 663 dit.current()->file().left(4) == "http" ) {
664 long size; 664 long size;
665 if( dit.current()->file().left(4) == "http" ) 665 if( dit.current()->file().left(4) == "http" )
666 size=0; 666 size=0;
667 else 667 else
668 size = QFile( dit.current()->file() ).size(); 668 size = QFile( dit.current()->file() ).size();
669 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 669 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
670 QString::number(size ), storage, dit.current()->file()); 670 QString::number(size ), storage, dit.current()->file());
671 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 671 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
672 } 672 }
673 } 673 }
674} 674}
675 675
676 676
677void PlayListWidget::populateVideoView() { 677void PlayListWidget::populateVideoView() {
678 videoView->clear(); 678 videoView->clear();
679 StorageInfo storageInfo; 679 StorageInfo storageInfo;
680 const QList<FileSystem> &fs = storageInfo.fileSystems(); 680 const QList<FileSystem> &fs = storageInfo.fileSystems();
681 681
682 if(!videoScan ) { 682 if(!videoScan ) {
683 scanForVideo(); 683 scanForVideo();
684 } 684 }
685 685
686 QListIterator<DocLnk> Vdit( vFiles.children() ); 686 QListIterator<DocLnk> Vdit( vFiles.children() );
687 QListIterator<FileSystem> it ( fs ); 687 QListIterator<FileSystem> it ( fs );
688 videoView->clear(); 688 videoView->clear();
689 QString storage, pathName; 689 QString storage, pathName;
690 for ( ; Vdit.current(); ++Vdit ) { 690 for ( ; Vdit.current(); ++Vdit ) {
691 for( ; it.current(); ++it ) { 691 for( ; it.current(); ++it ) {
692 const QString name = (*it)->name(); 692 const QString name = (*it)->name();
693 const QString path = (*it)->path(); 693 const QString path = (*it)->path();
694 if( Vdit.current()->file().find(path) != -1 ) { 694 if( Vdit.current()->file().find(path) != -1 ) {
695 storage=name; 695 storage=name;
696 pathName=path; 696 pathName=path;
697 } 697 }
698 } 698 }
699 699
700 QListViewItem * newItem; 700 QListViewItem * newItem;
701 if ( QFile( Vdit.current()->file() ).exists() ) { 701 if ( QFile( Vdit.current()->file() ).exists() ) {
702 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 702 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
703 QString::number( QFile( Vdit.current()->file() ).size() ), 703 QString::number( QFile( Vdit.current()->file() ).size() ),
704 storage, Vdit.current()->file()); 704 storage, Vdit.current()->file());
705 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 705 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
706 } 706 }
707 } 707 }
708} 708}
709 709
710 710
711void PlayListWidget::openFile() { 711void PlayListWidget::openFile() {
712 // http://66.28.164.33:2080
713 // http://somafm.com/star0242.m3u
712 QString filename, name; 714 QString filename, name;
713 InputDialog *fileDlg; 715 InputDialog *fileDlg;
714 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 716 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
715 fileDlg->exec(); 717 fileDlg->exec();
716 if( fileDlg->result() == 1 ) { 718 if( fileDlg->result() == 1 ) {
717 filename = fileDlg->text(); 719 filename = fileDlg->text();
718 qDebug( "Selected filename is " + filename ); 720 qDebug( "Selected filename is " + filename );
719 Om3u *m3uList; 721 Om3u *m3uList;
720 DocLnk lnk; 722 DocLnk lnk;
721 Config cfg( "OpiePlayer" ); 723 Config cfg( "OpiePlayer" );
722 cfg.setGroup("PlayList"); 724 cfg.setGroup("PlayList");
723 725
724 if(filename.left(4) == "http") { 726 if(filename.left(4) == "http") {
725 QString m3uFile, m3uFilePath; 727 QString m3uFile, m3uFilePath;
726 if(filename.find(":",8,TRUE) != -1) { //found a port 728 if(filename.find(":",8,TRUE) != -1) { //found a port
727 m3uFile = filename.left( filename.find( ":",8,TRUE)); 729 m3uFile = filename.left( filename.find( ":",8,TRUE));
728 m3uFile = m3uFile.right( 7); 730 m3uFile = m3uFile.right( 7);
729 } else if(filename.left(4) == "http"){ 731 } else if(filename.left(4) == "http"){
730 m3uFile=filename; 732 m3uFile=filename;
731 m3uFile = m3uFile.right( m3uFile.length() - 7); 733 m3uFile = m3uFile.right( m3uFile.length() - 7);
732 } else{ 734 } else{
733 m3uFile=filename; 735 m3uFile=filename;
734 } 736 }
735 737
736// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 738// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
737 lnk.setName( filename ); //sets name 739 lnk.setName( filename ); //sets name
738 lnk.setFile( filename ); //sets file name 740 lnk.setFile( filename ); //sets file name
739 lnk.setIcon("opieplayer2/musicfile"); 741 lnk.setIcon("opieplayer2/musicfile");
740 d->selectedFiles->addToSelection( lnk ); 742 d->selectedFiles->addToSelection( lnk );
741 writeCurrentM3u(); 743 writeCurrentM3u();
742 } 744 }
743 else if( filename.right( 3) == "m3u" ) { 745 else if( filename.right( 3) == "m3u" ) {
744 readm3u( filename ); 746 readm3u( filename );
745 747
746 } else if( filename.right(3) == "pls" ) { 748 } else if( filename.right(3) == "pls" ) {
747 readPls( filename ); 749 readPls( filename );
748 } else { 750 } else {
749 d->selectedFiles->addToSelection( DocLnk(filename) ); 751 d->selectedFiles->addToSelection( DocLnk(filename) );
750 writeCurrentM3u(); 752 writeCurrentM3u();
751 } 753 }
752 } 754 }
753 755
754 if( fileDlg ) { 756 if( fileDlg ) {
755 delete fileDlg; 757 delete fileDlg;
756 } 758 }
757} 759}
758 760
759/* 761/*
760reads m3u and shows files/urls to playlist widget */ 762reads m3u and shows files/urls to playlist widget */
761void PlayListWidget::readm3u( const QString &filename ) { 763void PlayListWidget::readm3u( const QString &filename ) {
762 qDebug( "read m3u filename " + filename ); 764 qDebug( "read m3u filename " + filename );
763 765
764 Om3u *m3uList; 766 Om3u *m3uList;
765 QString s, name; 767 QString s, name;
766 m3uList = new Om3u( filename, IO_ReadOnly ); 768 m3uList = new Om3u( filename, IO_ReadOnly );
767 m3uList->readM3u(); 769 m3uList->readM3u();
768 DocLnk lnk; 770 DocLnk lnk;
769 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 771 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
770 s = *it; 772 s = *it;
771// qDebug("reading "+ s); 773// qDebug("reading "+ s);
772 if(s.left(4)=="http") { 774 if(s.left(4)=="http") {
773 lnk.setName( s ); //sets file name 775 lnk.setName( s ); //sets file name
774 lnk.setIcon("opieplayer2/musicfile"); 776 lnk.setIcon("opieplayer2/musicfile");
775 if(s.right(4) != '.' || s.right(5) != '.') 777 if(s.right(4) != '.' || s.right(5) != '.')
776 lnk.setFile( s+"/"); //if url with no extension 778 lnk.setFile( s+"/"); //if url with no extension
777 else 779 else
778 lnk.setFile( s ); //sets file name 780 lnk.setFile( s ); //sets file name
779 781
780 } else { 782 } else {
781 // if( QFileInfo( s ).exists() ) { 783 // if( QFileInfo( s ).exists() ) {
782 lnk.setName( QFileInfo(s).baseName()); 784 lnk.setName( QFileInfo(s).baseName());
783 // if(s.right(4) == '.') {//if regular file 785 // if(s.right(4) == '.') {//if regular file
784 if(s.left(1) != "/") { 786 if(s.left(1) != "/") {
785 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 787 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
786 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 788 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
787 lnk.setIcon("SoundPlayer"); 789 lnk.setIcon("SoundPlayer");
788 } else { 790 } else {
789 // qDebug("set link2 "+s); 791 // qDebug("set link2 "+s);
790 lnk.setFile( s); 792 lnk.setFile( s);
791 lnk.setIcon("SoundPlayer"); 793 lnk.setIcon("SoundPlayer");
792 } 794 }
793 } 795 }
794 d->selectedFiles->addToSelection( lnk ); 796 d->selectedFiles->addToSelection( lnk );
795 } 797 }
796 Config config( "OpiePlayer" ); 798 Config config( "OpiePlayer" );
797 config.setGroup( "PlayList" ); 799 config.setGroup( "PlayList" );
798 800
799 config.writeEntry("CurrentPlaylist",filename); 801 config.writeEntry("CurrentPlaylist",filename);
800 config.write(); 802 config.write();
801 currentPlayList=filename; 803 currentPlayList=filename;
802 804
803// m3uList->write(); 805// m3uList->write();
804 m3uList->close(); 806 m3uList->close();
805 if(m3uList) delete m3uList; 807 if(m3uList) delete m3uList;
806 808
807 d->selectedFiles->setSelectedItem( s); 809 d->selectedFiles->setSelectedItem( s);
808 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 810 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
809 811
810} 812}
811 813
812/* 814/*
813reads pls and adds files/urls to playlist */ 815reads pls and adds files/urls to playlist */
814void PlayListWidget::readPls( const QString &filename ) { 816void PlayListWidget::readPls( const QString &filename ) {
815 817
816 qDebug( "pls filename is " + filename ); 818 qDebug( "pls filename is " + filename );
817 Om3u *m3uList; 819 Om3u *m3uList;
818 QString s, name; 820 QString s, name;
819 m3uList = new Om3u( filename, IO_ReadOnly ); 821 m3uList = new Om3u( filename, IO_ReadOnly );
820 m3uList->readPls(); 822 m3uList->readPls();
821 823
822 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 824 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
823 s = *it; 825 s = *it;
824 // s.replace( QRegExp( "%20" )," " ); 826 // s.replace( QRegExp( "%20" )," " );
825 DocLnk lnk( s ); 827 DocLnk lnk( s );
826 QFileInfo f( s ); 828 QFileInfo f( s );
827 QString name = f.baseName(); 829 QString name = f.baseName();
828 830
829 if( name.left( 4 ) == "http" ) { 831 if( name.left( 4 ) == "http" ) {
830 name = s.right( s.length() - 7); 832 name = s.right( s.length() - 7);
831 } else { 833 } else {
832 name = s; 834 name = s;
833 } 835 }
834 836
835 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 837 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
836 838
837 lnk.setName( name ); 839 lnk.setName( name );
838 if( s.at( s.length() - 4) == '.') {// if this is probably a file 840 if( s.at( s.length() - 4) == '.') {// if this is probably a file
839 lnk.setFile( s ); 841 lnk.setFile( s );
840 } else { //if its a url 842 } else { //if its a url
841 if( name.right( 1 ).find( '/' ) == -1) { 843 if( name.right( 1 ).find( '/' ) == -1) {
842 s += "/"; 844 s += "/";
843 } 845 }
844 lnk.setFile( s ); 846 lnk.setFile( s );
845 } 847 }
846 lnk.setType( "audio/x-mpegurl" ); 848 lnk.setType( "audio/x-mpegurl" );
847 849
848 lnk.writeLink(); 850 lnk.writeLink();
849 d->selectedFiles->addToSelection( lnk ); 851 d->selectedFiles->addToSelection( lnk );
850 } 852 }
851 853
852 m3uList->close(); 854 m3uList->close();
853 if(m3uList) delete m3uList; 855 if(m3uList) delete m3uList;
854} 856}
855 857
856/* 858/*
857 writes current playlist to current m3u file */ 859 writes current playlist to current m3u file */
858void PlayListWidget::writeCurrentM3u() { 860void PlayListWidget::writeCurrentM3u() {
859 qDebug("writing to current m3u"); 861 qDebug("writing to current m3u");
860 Config cfg( "OpiePlayer" ); 862 Config cfg( "OpiePlayer" );
861 cfg.setGroup("PlayList"); 863 cfg.setGroup("PlayList");
862 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 864 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
863 865
864 if( d->selectedFiles->first()) { 866 if( d->selectedFiles->first()) {
865 Om3u *m3uList; 867 Om3u *m3uList;
866 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 868 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
867 869
868 do { 870 do {
869 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 871 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
870 m3uList->add( d->selectedFiles->current()->file() ); 872 m3uList->add( d->selectedFiles->current()->file() );
871 } 873 }
872 while ( d->selectedFiles->next() ); 874 while ( d->selectedFiles->next() );
873 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 875 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
874 m3uList->write(); 876 m3uList->write();
875 m3uList->close(); 877 m3uList->close();
876 878
877 if(m3uList) delete m3uList; 879 if(m3uList) delete m3uList;
878 } 880 }
879} 881}
880 882
881 /* 883 /*
882 writes current playlist to m3u file */ 884 writes current playlist to m3u file */
883void PlayListWidget::writem3u() { 885void PlayListWidget::writem3u() {
884 InputDialog *fileDlg; 886 InputDialog *fileDlg;
885 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 887 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
886 fileDlg->exec(); 888 fileDlg->exec();
887 QString name, filename, list; 889 QString name, filename, list;
888 Om3u *m3uList; 890 Om3u *m3uList;
889 891
890 if( fileDlg->result() == 1 ) { 892 if( fileDlg->result() == 1 ) {
891 name = fileDlg->text(); 893 name = fileDlg->text();
892// qDebug( filename ); 894// qDebug( filename );
893 895
894 if( name.left( 1) != "/" ) { 896 if( name.left( 1) != "/" ) {
895 filename = QPEApplication::documentDir() + "/" + name; 897 filename = QPEApplication::documentDir() + "/" + name;
896 } 898 }
897 899
898 if( name.right( 3 ) != "m3u" ) { 900 if( name.right( 3 ) != "m3u" ) {
899 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 901 filename = QPEApplication::documentDir() + "/" +name+".m3u";
900 } 902 }
901 903
902 if( d->selectedFiles->first()) { 904 if( d->selectedFiles->first()) {
903 m3uList = new Om3u(filename, IO_ReadWrite); 905 m3uList = new Om3u(filename, IO_ReadWrite);
904 906
905 do { 907 do {
906 m3uList->add( d->selectedFiles->current()->file()); 908 m3uList->add( d->selectedFiles->current()->file());
907 } 909 }
908 while ( d->selectedFiles->next() ); 910 while ( d->selectedFiles->next() );
909 // qDebug( list ); 911 // qDebug( list );
910 m3uList->write(); 912 m3uList->write();
911 m3uList->close(); 913 m3uList->close();
912 if(m3uList) delete m3uList; 914 if(m3uList) delete m3uList;
913 915
914 if(fileDlg) delete fileDlg; 916 if(fileDlg) delete fileDlg;
915 917
916 DocLnk lnk; 918 DocLnk lnk;
917 lnk.setFile( filename); 919 lnk.setFile( filename);
918 lnk.setIcon("opieplayer2/playlist2"); 920 lnk.setIcon("opieplayer2/playlist2");
919 lnk.setName( name); //sets file name 921 lnk.setName( name); //sets file name
920 922
921 // qDebug(filename); 923 // qDebug(filename);
922 Config config( "OpiePlayer" ); 924 Config config( "OpiePlayer" );
923 config.setGroup( "PlayList" ); 925 config.setGroup( "PlayList" );
924 926
925 config.writeEntry("CurrentPlaylist",filename); 927 config.writeEntry("CurrentPlaylist",filename);
926 currentPlayList=filename; 928 currentPlayList=filename;
927 929
928 if(!lnk.writeLink()) { 930 if(!lnk.writeLink()) {
929 qDebug("Writing doclink did not work"); 931 qDebug("Writing doclink did not work");
930 } 932 }
931 933
932 setCaption(tr("OpiePlayer: ") + name); 934 setCaption(tr("OpiePlayer: ") + name);
933 } 935 }
934 } 936 }
935} 937}
936 938
937void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 939void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
938 switch ( e->key() ) { 940 switch ( e->key() ) {
939 ////////////////////////////// Zaurus keys 941 ////////////////////////////// Zaurus keys
940 case Key_F9: //activity 942 case Key_F9: //activity
941 // if(audioUI->isHidden()) 943 // if(audioUI->isHidden())
942 // audioUI->showMaximized(); 944 // audioUI->showMaximized();
943 break; 945 break;
944 case Key_F10: //contacts 946 case Key_F10: //contacts
945 // if( videoUI->isHidden()) 947 // if( videoUI->isHidden())
946 // videoUI->showMaximized(); 948 // videoUI->showMaximized();
947 break; 949 break;
948 case Key_F11: //menu 950 case Key_F11: //menu
949 break; 951 break;
950 case Key_F12: //home 952 case Key_F12: //home
951 // doBlank(); 953 // doBlank();
952 break; 954 break;
953 case Key_F13: //mail 955 case Key_F13: //mail
954 // doUnblank(); 956 // doUnblank();
955 break; 957 break;
956 case Key_Q: //add to playlist 958 case Key_Q: //add to playlist
957 addSelected(); 959 addSelected();
958 break; 960 break;
959 case Key_R: //remove from playlist 961 case Key_R: //remove from playlist
960 removeSelected(); 962 removeSelected();
961 break; 963 break;
962 // case Key_P: //play 964 // case Key_P: //play
963 // qDebug("Play"); 965 // qDebug("Play");
964 // playSelected(); 966 // playSelected();
965 // break; 967 // break;
966 case Key_Space: 968 case Key_Space:
967 // playSelected(); puh 969 // playSelected(); puh
968 break; 970 break;
969 case Key_1: 971 case Key_1:
970 tabWidget->setCurrentPage( 0 ); 972 tabWidget->setCurrentPage( 0 );
971 break; 973 break;
972 case Key_2: 974 case Key_2:
973 tabWidget->setCurrentPage( 1 ); 975 tabWidget->setCurrentPage( 1 );
974 break; 976 break;
975 case Key_3: 977 case Key_3:
976 tabWidget->setCurrentPage( 2 ); 978 tabWidget->setCurrentPage( 2 );
977 break; 979 break;
978 case Key_4: 980 case Key_4:
979 tabWidget->setCurrentPage( 3 ); 981 tabWidget->setCurrentPage( 3 );
980 break; 982 break;
981 case Key_Down: 983 case Key_Down:
982 if ( !d->selectedFiles->next() ) 984 if ( !d->selectedFiles->next() )
983 d->selectedFiles->first(); 985 d->selectedFiles->first();
984 break; 986 break;
985 case Key_Up: 987 case Key_Up:
986 if ( !d->selectedFiles->prev() ) 988 if ( !d->selectedFiles->prev() )
987 // d->selectedFiles->last(); 989 // d->selectedFiles->last();
988 break; 990 break;
989 } 991 }
990} 992}
991 993
992void PlayListWidget::pmViewActivated(int index) { 994void PlayListWidget::pmViewActivated(int index) {
993// qDebug("%d", index); 995// qDebug("%d", index);
994 switch(index) { 996 switch(index) {
995 case -16: 997 case -16:
996 { 998 {
997 mediaPlayerState->toggleFullscreen(); 999 mediaPlayerState->toggleFullscreen();
998 bool b=mediaPlayerState->fullscreen(); 1000 bool b=mediaPlayerState->fullscreen();
999 pmView->setItemChecked( index, b); 1001 pmView->setItemChecked( index, b);
1000 Config cfg( "OpiePlayer" ); 1002 Config cfg( "OpiePlayer" );
1001 cfg.writeEntry( "FullScreen", b ); 1003 cfg.writeEntry( "FullScreen", b );
1002 } 1004 }
1003 break; 1005 break;
1004 }; 1006 };
1005} 1007}
1006 1008
1007void PlayListWidget::populateSkinsMenu() { 1009void PlayListWidget::populateSkinsMenu() {
1008 int item = 0; 1010 int item = 0;
1009 defaultSkinIndex = 0; 1011 defaultSkinIndex = 0;
1010 QString skinName; 1012 QString skinName;
1011 Config cfg( "OpiePlayer" ); 1013 Config cfg( "OpiePlayer" );
1012 cfg.setGroup("Options" ); 1014 cfg.setGroup("Options" );
1013 QString skin = cfg.readEntry( "Skin", "default" ); 1015 QString skin = cfg.readEntry( "Skin", "default" );
1014 1016
1015 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1017 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1016 skinsDir.setFilter( QDir::Dirs ); 1018 skinsDir.setFilter( QDir::Dirs );
1017 skinsDir.setSorting(QDir::Name ); 1019 skinsDir.setSorting(QDir::Name );
1018 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1020 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1019 QFileInfoListIterator it( *skinslist ); 1021 QFileInfoListIterator it( *skinslist );
1020 QFileInfo *fi; 1022 QFileInfo *fi;
1021 while ( ( fi = it.current() ) ) { 1023 while ( ( fi = it.current() ) ) {
1022 skinName = fi->fileName(); 1024 skinName = fi->fileName();
1023// qDebug( fi->fileName() ); 1025// qDebug( fi->fileName() );
1024 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1026 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1025 item = skinsMenu->insertItem( fi->fileName() ) ; 1027 item = skinsMenu->insertItem( fi->fileName() ) ;
1026 } 1028 }
1027 if( skinName == "default" ) { 1029 if( skinName == "default" ) {
1028 defaultSkinIndex = item; 1030 defaultSkinIndex = item;
1029 } 1031 }
1030 if( skinName == skin ) { 1032 if( skinName == skin ) {
1031 skinsMenu->setItemChecked( item, TRUE ); 1033 skinsMenu->setItemChecked( item, TRUE );
1032 } 1034 }
1033 ++it; 1035 ++it;
1034 } 1036 }
1035} 1037}
1036 1038
1037void PlayListWidget::skinsMenuActivated( int item ) { 1039void PlayListWidget::skinsMenuActivated( int item ) {
1038 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1040 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1039 skinsMenu->setItemChecked( i, FALSE ); 1041 skinsMenu->setItemChecked( i, FALSE );
1040 } 1042 }
1041 skinsMenu->setItemChecked( item, TRUE ); 1043 skinsMenu->setItemChecked( item, TRUE );
1042 1044
1043 Config cfg( "OpiePlayer" ); 1045 Config cfg( "OpiePlayer" );
1044 cfg.setGroup("Options"); 1046 cfg.setGroup("Options");
1045 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1047 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1046} 1048}
1047 1049
1048int PlayListWidget::whichList() { 1050int PlayListWidget::whichList() {
1049 return tabWidget->currentPageIndex(); 1051 return tabWidget->currentPageIndex();
1050} 1052}
1051 1053
1052QString PlayListWidget::currentFileListPathName() { 1054QString PlayListWidget::currentFileListPathName() {
1053 switch (whichList()) { 1055 switch (whichList()) {
1054 case 1: 1056 case 1:
1055 return audioView->currentItem()->text(3); 1057 return audioView->currentItem()->text(3);
1056 break; 1058 break;
1057 case 2: 1059 case 2:
1058 return videoView->currentItem()->text(3); 1060 return videoView->currentItem()->text(3);
1059 break; 1061 break;
1060 }; 1062 };
1061 return ""; 1063 return "";
1062} 1064}