-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 | |||
@@ -236,399 +236,394 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , in | |||
236 | { | 236 | { |
237 | QPopupMenu m; | 237 | QPopupMenu m; |
238 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 238 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
239 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 239 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
240 | m.exec( QCursor::pos() ); | 240 | m.exec( QCursor::pos() ); |
241 | } | 241 | } |
242 | break; | 242 | break; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 247 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
248 | switch (mouse) { | 248 | switch (mouse) { |
249 | case 1: | 249 | case 1: |
250 | break; | 250 | break; |
251 | case 2: | 251 | case 2: |
252 | { | 252 | { |
253 | QPopupMenu m; | 253 | QPopupMenu m; |
254 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 254 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
255 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 255 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
256 | m.exec( QCursor::pos() ); | 256 | m.exec( QCursor::pos() ); |
257 | } | 257 | } |
258 | break; | 258 | break; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | void PlayListWidget::addAllToList() { | 263 | void PlayListWidget::addAllToList() { |
264 | 264 | ||
265 | // QTime t; | 265 | // QTime t; |
266 | // t.start(); | 266 | // t.start(); |
267 | 267 | ||
268 | if(!audioScan) { | 268 | if(!audioScan) { |
269 | if(audioView->childCount() < 1) | 269 | if(audioView->childCount() < 1) |
270 | populateAudioView(); | 270 | populateAudioView(); |
271 | } | 271 | } |
272 | 272 | ||
273 | QListViewItemIterator audioIt( audioView ); | 273 | QListViewItemIterator audioIt( audioView ); |
274 | DocLnk lnk; | 274 | DocLnk lnk; |
275 | QString filename; | 275 | QString filename; |
276 | // iterate through all items of the listview | 276 | // iterate through all items of the listview |
277 | for ( ; audioIt.current(); ++audioIt ) { | 277 | for ( ; audioIt.current(); ++audioIt ) { |
278 | filename = audioIt.current()->text(3); | 278 | filename = audioIt.current()->text(3); |
279 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 279 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
280 | lnk.setFile( filename ); //sets file name | 280 | lnk.setFile( filename ); //sets file name |
281 | d->selectedFiles->addToSelection( lnk); | 281 | d->selectedFiles->addToSelection( lnk); |
282 | } | 282 | } |
283 | 283 | ||
284 | if(!videoScan) { | 284 | if(!videoScan) { |
285 | if(videoView->childCount() < 1) | 285 | if(videoView->childCount() < 1) |
286 | populateVideoView(); | 286 | populateVideoView(); |
287 | } | 287 | } |
288 | 288 | ||
289 | QListViewItemIterator videoIt( videoView ); | 289 | QListViewItemIterator videoIt( videoView ); |
290 | for ( ; videoIt.current(); ++videoIt ) { | 290 | for ( ; videoIt.current(); ++videoIt ) { |
291 | filename = videoIt.current()->text(3); | 291 | filename = videoIt.current()->text(3); |
292 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 292 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
293 | lnk.setFile( filename ); //sets file name | 293 | lnk.setFile( filename ); //sets file name |
294 | d->selectedFiles->addToSelection( lnk); | 294 | d->selectedFiles->addToSelection( lnk); |
295 | } | 295 | } |
296 | 296 | ||
297 | // d->selectedFiles->addToSelection( ); | 297 | // d->selectedFiles->addToSelection( ); |
298 | // if ( it.current()->isSelected() ) | 298 | // if ( it.current()->isSelected() ) |
299 | // lst->append( audioIt.current() ); | 299 | // lst->append( audioIt.current() ); |
300 | // } | 300 | // } |
301 | 301 | ||
302 | 302 | ||
303 | // if(!audioScan) | 303 | // if(!audioScan) |
304 | // scanForAudio(); | 304 | // scanForAudio(); |
305 | // if(!videoScan) | 305 | // if(!videoScan) |
306 | // scanForVideo(); | 306 | // scanForVideo(); |
307 | 307 | ||
308 | // DocLnkSet filesAll; | 308 | // DocLnkSet filesAll; |
309 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 309 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
310 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 310 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
311 | // for ( ; Adit.current(); ++Adit ) { | 311 | // for ( ; Adit.current(); ++Adit ) { |
312 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 312 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
313 | // d->selectedFiles->addToSelection( **Adit ); | 313 | // d->selectedFiles->addToSelection( **Adit ); |
314 | // } | 314 | // } |
315 | // } | 315 | // } |
316 | 316 | ||
317 | // qDebug("elapsed time %d", t.elapsed() ); | 317 | // qDebug("elapsed time %d", t.elapsed() ); |
318 | 318 | ||
319 | tabWidget->setCurrentPage(0); | 319 | tabWidget->setCurrentPage(0); |
320 | 320 | ||
321 | writeCurrentM3u(); | 321 | writeCurrentM3u(); |
322 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | void PlayListWidget::addAllMusicToList() { | 326 | void PlayListWidget::addAllMusicToList() { |
327 | 327 | ||
328 | if(!audioScan) { | 328 | if(!audioScan) { |
329 | if(audioView->childCount() < 1) | 329 | if(audioView->childCount() < 1) |
330 | populateAudioView(); | 330 | populateAudioView(); |
331 | } | 331 | } |
332 | 332 | ||
333 | QListViewItemIterator audioIt( audioView ); | 333 | QListViewItemIterator audioIt( audioView ); |
334 | DocLnk lnk; | 334 | DocLnk lnk; |
335 | QString filename; | 335 | QString filename; |
336 | // iterate through all items of the listview | 336 | // iterate through all items of the listview |
337 | for ( ; audioIt.current(); ++audioIt ) { | 337 | for ( ; audioIt.current(); ++audioIt ) { |
338 | filename = audioIt.current()->text(3); | 338 | filename = audioIt.current()->text(3); |
339 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 339 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
340 | lnk.setFile( filename ); //sets file name | 340 | lnk.setFile( filename ); //sets file name |
341 | d->selectedFiles->addToSelection( lnk); | 341 | d->selectedFiles->addToSelection( lnk); |
342 | } | 342 | } |
343 | 343 | ||
344 | /* if(!audioScan) | 344 | /* if(!audioScan) |
345 | scanForAudio(); | 345 | scanForAudio(); |
346 | QListIterator<DocLnk> dit( files.children() ); | 346 | QListIterator<DocLnk> dit( files.children() ); |
347 | for ( ; dit.current(); ++dit ) { | 347 | for ( ; dit.current(); ++dit ) { |
348 | if( QFileInfo(dit.current()->file() ).exists() ) { | 348 | if( QFileInfo(dit.current()->file() ).exists() ) { |
349 | d->selectedFiles->addToSelection( **dit ); | 349 | d->selectedFiles->addToSelection( **dit ); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | */ | 352 | */ |
353 | tabWidget->setCurrentPage(0); | 353 | tabWidget->setCurrentPage(0); |
354 | writeCurrentM3u(); | 354 | writeCurrentM3u(); |
355 | d->selectedFiles->first(); | 355 | d->selectedFiles->first(); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void PlayListWidget::addAllVideoToList() { | 359 | void PlayListWidget::addAllVideoToList() { |
360 | 360 | ||
361 | if(!videoScan) { | 361 | if(!videoScan) { |
362 | if(videoView->childCount() < 1) | 362 | if(videoView->childCount() < 1) |
363 | populateVideoView(); | 363 | populateVideoView(); |
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 | ||
392 | void PlayListWidget::setDocument( const QString& fileref ) { | 392 | void 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 | ||
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 | ||
475 | 470 | ||
476 | bool PlayListWidget::next() { | 471 | bool 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 | ||
497 | bool PlayListWidget::first() { | 492 | bool 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 | ||
505 | bool PlayListWidget::last() { | 500 | bool PlayListWidget::last() { |
506 | if ( mediaPlayerState->isUsingPlaylist() ) | 501 | if ( mediaPlayerState->isUsingPlaylist() ) |
507 | return d->selectedFiles->last(); | 502 | return d->selectedFiles->last(); |
508 | else | 503 | else |
509 | return mediaPlayerState->isLooping(); | 504 | return mediaPlayerState->isLooping(); |
510 | } | 505 | } |
511 | 506 | ||
512 | 507 | ||
513 | void PlayListWidget::saveList() { | 508 | void PlayListWidget::saveList() { |
514 | writem3u(); | 509 | writem3u(); |
515 | } | 510 | } |
516 | 511 | ||
517 | 512 | ||
518 | void PlayListWidget::loadList( const DocLnk & lnk) { | 513 | void PlayListWidget::loadList( const DocLnk & lnk) { |
519 | QString name = lnk.name(); | 514 | QString name = lnk.name(); |
520 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 515 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
521 | 516 | ||
522 | if( name.length()>0) { | 517 | if( name.length()>0) { |
523 | setCaption("OpiePlayer: "+name); | 518 | setCaption("OpiePlayer: "+name); |
524 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 519 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
525 | clearList(); | 520 | clearList(); |
526 | readm3u(lnk.file()); | 521 | readm3u(lnk.file()); |
527 | tabWidget->setCurrentPage(0); | 522 | tabWidget->setCurrentPage(0); |
528 | } | 523 | } |
529 | } | 524 | } |
530 | 525 | ||
531 | 526 | ||
532 | void PlayListWidget::setPlaylist( bool shown ) { | 527 | void PlayListWidget::setPlaylist( bool shown ) { |
533 | if ( shown ) { | 528 | if ( shown ) { |
534 | d->playListFrame->show(); | 529 | d->playListFrame->show(); |
535 | } else { | 530 | } else { |
536 | d->playListFrame->hide(); | 531 | d->playListFrame->hide(); |
537 | } | 532 | } |
538 | } | 533 | } |
539 | 534 | ||
540 | 535 | ||
541 | void PlayListWidget::addSelected() { | 536 | void PlayListWidget::addSelected() { |
542 | qDebug("addSelected"); | 537 | qDebug("addSelected"); |
543 | DocLnk lnk; | 538 | DocLnk lnk; |
544 | QString filename; | 539 | QString filename; |
545 | switch (whichList()) { | 540 | switch (whichList()) { |
546 | 541 | ||
547 | case 0: //playlist | 542 | case 0: //playlist |
548 | return; | 543 | return; |
549 | break; | 544 | break; |
550 | case 1: { //audio | 545 | case 1: { //audio |
551 | QListViewItemIterator it( audioView ); | 546 | QListViewItemIterator it( audioView ); |
552 | for ( ; it.current(); ++it ) { | 547 | for ( ; it.current(); ++it ) { |
553 | if ( it.current()->isSelected() ) { | 548 | if ( it.current()->isSelected() ) { |
554 | filename=it.current()->text(3); | 549 | filename=it.current()->text(3); |
555 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
556 | lnk.setFile( filename ); //sets file name | 551 | lnk.setFile( filename ); //sets file name |
557 | d->selectedFiles->addToSelection( lnk); | 552 | d->selectedFiles->addToSelection( lnk); |
558 | 553 | ||
559 | } | 554 | } |
560 | } | 555 | } |
561 | audioView->clearSelection(); | 556 | audioView->clearSelection(); |
562 | } | 557 | } |
563 | break; | 558 | break; |
564 | 559 | ||
565 | case 2: { // video | 560 | case 2: { // video |
566 | QListViewItemIterator it( videoView ); | 561 | QListViewItemIterator it( videoView ); |
567 | for ( ; it.current(); ++it ) { | 562 | for ( ; it.current(); ++it ) { |
568 | if ( it.current()->isSelected() ) { | 563 | if ( it.current()->isSelected() ) { |
569 | filename=it.current()->text(3); | 564 | filename=it.current()->text(3); |
570 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 565 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
571 | lnk.setFile( filename ); //sets file name | 566 | lnk.setFile( filename ); //sets file name |
572 | d->selectedFiles->addToSelection( lnk); | 567 | d->selectedFiles->addToSelection( lnk); |
573 | } | 568 | } |
574 | } | 569 | } |
575 | videoView->clearSelection(); | 570 | videoView->clearSelection(); |
576 | } | 571 | } |
577 | break; | 572 | break; |
578 | }; | 573 | }; |
579 | tabWidget->setCurrentPage(0); | 574 | tabWidget->setCurrentPage(0); |
580 | writeCurrentM3u(); | 575 | writeCurrentM3u(); |
581 | } | 576 | } |
582 | 577 | ||
583 | 578 | ||
584 | void PlayListWidget::removeSelected() { | 579 | void PlayListWidget::removeSelected() { |
585 | d->selectedFiles->removeSelected( ); | 580 | d->selectedFiles->removeSelected( ); |
586 | writeCurrentM3u(); | 581 | writeCurrentM3u(); |
587 | } | 582 | } |
588 | 583 | ||
589 | 584 | ||
590 | void PlayListWidget::playIt( QListViewItem *it) { | 585 | void PlayListWidget::playIt( QListViewItem *it) { |
591 | if(!it) return; | 586 | if(!it) return; |
592 | mediaPlayerState->setPlaying(FALSE); | 587 | mediaPlayerState->setPlaying(FALSE); |
593 | mediaPlayerState->setPlaying(TRUE); | 588 | mediaPlayerState->setPlaying(TRUE); |
594 | d->selectedFiles->unSelect(); | 589 | d->selectedFiles->unSelect(); |
595 | } | 590 | } |
596 | 591 | ||
597 | 592 | ||
598 | void PlayListWidget::addToSelection( QListViewItem *it) { | 593 | void PlayListWidget::addToSelection( QListViewItem *it) { |
599 | d->setDocumentUsed = FALSE; | 594 | d->setDocumentUsed = FALSE; |
600 | 595 | ||
601 | if(it) { | 596 | if(it) { |
602 | switch ( whichList()) { | 597 | switch ( whichList()) { |
603 | case 0: //playlist | 598 | case 0: //playlist |
604 | return; | 599 | return; |
605 | break; | 600 | break; |
606 | }; | 601 | }; |
607 | // case 1: { | 602 | // case 1: { |
608 | DocLnk lnk; | 603 | DocLnk lnk; |
609 | QString filename; | 604 | QString filename; |
610 | 605 | ||
611 | filename=it->text(3); | 606 | filename=it->text(3); |
612 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 607 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
613 | lnk.setFile( filename ); //sets file name | 608 | lnk.setFile( filename ); //sets file name |
614 | d->selectedFiles->addToSelection( lnk); | 609 | d->selectedFiles->addToSelection( lnk); |
615 | 610 | ||
616 | writeCurrentM3u(); | 611 | writeCurrentM3u(); |
617 | tabWidget->setCurrentPage(0); | 612 | tabWidget->setCurrentPage(0); |
618 | 613 | ||
619 | } | 614 | } |
620 | } | 615 | } |
621 | 616 | ||
622 | 617 | ||
623 | void PlayListWidget::tabChanged(QWidget *) { | 618 | void PlayListWidget::tabChanged(QWidget *) { |
624 | 619 | ||
625 | switch ( whichList()) { | 620 | switch ( whichList()) { |
626 | case 0: | 621 | case 0: |
627 | { | 622 | { |
628 | if( !tbDeletePlaylist->isHidden() ) { | 623 | if( !tbDeletePlaylist->isHidden() ) { |
629 | tbDeletePlaylist->hide(); | 624 | tbDeletePlaylist->hide(); |
630 | } | 625 | } |
631 | d->tbRemoveFromList->setEnabled(TRUE); | 626 | d->tbRemoveFromList->setEnabled(TRUE); |
632 | d->tbAddToList->setEnabled(FALSE); | 627 | d->tbAddToList->setEnabled(FALSE); |
633 | } | 628 | } |
634 | break; | 629 | break; |
@@ -969,202 +964,201 @@ void PlayListWidget::writeCurrentM3u() { | |||
969 | m3uList->close(); | 964 | m3uList->close(); |
970 | 965 | ||
971 | if(m3uList) delete m3uList; | 966 | if(m3uList) delete m3uList; |
972 | } | 967 | } |
973 | 968 | ||
974 | } | 969 | } |
975 | 970 | ||
976 | /* | 971 | /* |
977 | writes current playlist to m3u file */ | 972 | writes current playlist to m3u file */ |
978 | void PlayListWidget::writem3u() { | 973 | void PlayListWidget::writem3u() { |
979 | InputDialog *fileDlg; | 974 | InputDialog *fileDlg; |
980 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 975 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
981 | fileDlg->exec(); | 976 | fileDlg->exec(); |
982 | QString name, filename, list; | 977 | QString name, filename, list; |
983 | Om3u *m3uList; | 978 | Om3u *m3uList; |
984 | 979 | ||
985 | if( fileDlg->result() == 1 ) { | 980 | if( fileDlg->result() == 1 ) { |
986 | name = fileDlg->text(); | 981 | name = fileDlg->text(); |
987 | // qDebug( filename ); | 982 | // qDebug( filename ); |
988 | 983 | ||
989 | if( name.left( 1) != "/" ) { | 984 | if( name.left( 1) != "/" ) { |
990 | filename = QPEApplication::documentDir() + "/" + name; | 985 | filename = QPEApplication::documentDir() + "/" + name; |
991 | } | 986 | } |
992 | 987 | ||
993 | if( name.right( 3 ) != "m3u" ) { | 988 | if( name.right( 3 ) != "m3u" ) { |
994 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 989 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
995 | } | 990 | } |
996 | 991 | ||
997 | if( d->selectedFiles->first()) { | 992 | if( d->selectedFiles->first()) { |
998 | m3uList = new Om3u(filename, IO_ReadWrite); | 993 | m3uList = new Om3u(filename, IO_ReadWrite); |
999 | 994 | ||
1000 | do { | 995 | do { |
1001 | m3uList->add( d->selectedFiles->current()->file()); | 996 | m3uList->add( d->selectedFiles->current()->file()); |
1002 | } | 997 | } |
1003 | while ( d->selectedFiles->next() ); | 998 | while ( d->selectedFiles->next() ); |
1004 | // qDebug( list ); | 999 | // qDebug( list ); |
1005 | m3uList->write(); | 1000 | m3uList->write(); |
1006 | m3uList->close(); | 1001 | m3uList->close(); |
1007 | if(m3uList) delete m3uList; | 1002 | if(m3uList) delete m3uList; |
1008 | 1003 | ||
1009 | if(fileDlg) delete fileDlg; | 1004 | if(fileDlg) delete fileDlg; |
1010 | 1005 | ||
1011 | DocLnk lnk; | 1006 | DocLnk lnk; |
1012 | lnk.setFile( filename); | 1007 | lnk.setFile( filename); |
1013 | lnk.setIcon("opieplayer2/playlist2"); | 1008 | lnk.setIcon("opieplayer2/playlist2"); |
1014 | lnk.setName( name); //sets file name | 1009 | lnk.setName( name); //sets file name |
1015 | 1010 | ||
1016 | // qDebug(filename); | 1011 | // qDebug(filename); |
1017 | Config config( "OpiePlayer" ); | 1012 | Config config( "OpiePlayer" ); |
1018 | config.setGroup( "PlayList" ); | 1013 | config.setGroup( "PlayList" ); |
1019 | 1014 | ||
1020 | config.writeEntry("CurrentPlaylist",filename); | 1015 | config.writeEntry("CurrentPlaylist",filename); |
1021 | currentPlayList=filename; | 1016 | currentPlayList=filename; |
1022 | 1017 | ||
1023 | if(!lnk.writeLink()) { | 1018 | if(!lnk.writeLink()) { |
1024 | qDebug("Writing doclink did not work"); | 1019 | qDebug("Writing doclink did not work"); |
1025 | } | 1020 | } |
1026 | 1021 | ||
1027 | setCaption(tr("OpiePlayer: ") + name); | 1022 | setCaption(tr("OpiePlayer: ") + name); |
1028 | } | 1023 | } |
1029 | } | 1024 | } |
1030 | } | 1025 | } |
1031 | 1026 | ||
1032 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 1027 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
1033 | switch ( e->key() ) { | 1028 | switch ( e->key() ) { |
1034 | ////////////////////////////// Zaurus keys | 1029 | ////////////////////////////// Zaurus keys |
1035 | case Key_F9: //activity | 1030 | case Key_F9: //activity |
1036 | // if(audioUI->isHidden()) | 1031 | // if(audioUI->isHidden()) |
1037 | // audioUI->showMaximized(); | 1032 | // audioUI->showMaximized(); |
1038 | break; | 1033 | break; |
1039 | case Key_F10: //contacts | 1034 | case Key_F10: //contacts |
1040 | // if( videoUI->isHidden()) | 1035 | // if( videoUI->isHidden()) |
1041 | // videoUI->showMaximized(); | 1036 | // videoUI->showMaximized(); |
1042 | break; | 1037 | break; |
1043 | case Key_F11: //menu | 1038 | case Key_F11: //menu |
1044 | break; | 1039 | break; |
1045 | case Key_F12: //home | 1040 | case Key_F12: //home |
1046 | // doBlank(); | 1041 | // doBlank(); |
1047 | break; | 1042 | break; |
1048 | case Key_F13: //mail | 1043 | case Key_F13: //mail |
1049 | // doUnblank(); | 1044 | // doUnblank(); |
1050 | break; | 1045 | break; |
1051 | case Key_Q: //add to playlist | 1046 | case Key_Q: //add to playlist |
1052 | addSelected(); | 1047 | addSelected(); |
1053 | break; | 1048 | break; |
1054 | case Key_R: //remove from playlist | 1049 | case Key_R: //remove from playlist |
1055 | removeSelected(); | 1050 | removeSelected(); |
1056 | break; | 1051 | break; |
1057 | // case Key_P: //play | 1052 | // case Key_P: //play |
1058 | // qDebug("Play"); | 1053 | // qDebug("Play"); |
1059 | // playSelected(); | 1054 | // playSelected(); |
1060 | // break; | 1055 | // break; |
1061 | case Key_Space: | 1056 | case Key_Space: |
1062 | // playSelected(); puh | 1057 | // playSelected(); puh |
1063 | break; | 1058 | break; |
1064 | case Key_1: | 1059 | case Key_1: |
1065 | tabWidget->setCurrentPage( 0 ); | 1060 | tabWidget->setCurrentPage( 0 ); |
1066 | break; | 1061 | break; |
1067 | case Key_2: | 1062 | case Key_2: |
1068 | tabWidget->setCurrentPage( 1 ); | 1063 | tabWidget->setCurrentPage( 1 ); |
1069 | break; | 1064 | break; |
1070 | case Key_3: | 1065 | case Key_3: |
1071 | tabWidget->setCurrentPage( 2 ); | 1066 | tabWidget->setCurrentPage( 2 ); |
1072 | break; | 1067 | break; |
1073 | case Key_4: | 1068 | case Key_4: |
1074 | tabWidget->setCurrentPage( 3 ); | 1069 | tabWidget->setCurrentPage( 3 ); |
1075 | break; | 1070 | break; |
1076 | case Key_Down: | 1071 | case Key_Down: |
1077 | if ( !d->selectedFiles->next() ) | 1072 | if ( !d->selectedFiles->next() ) |
1078 | d->selectedFiles->first(); | 1073 | d->selectedFiles->first(); |
1079 | break; | 1074 | break; |
1080 | case Key_Up: | 1075 | case Key_Up: |
1081 | if ( !d->selectedFiles->prev() ) | 1076 | if ( !d->selectedFiles->prev() ) |
1082 | // d->selectedFiles->last(); | 1077 | // d->selectedFiles->last(); |
1083 | break; | 1078 | break; |
1084 | } | 1079 | } |
1085 | } | 1080 | } |
1086 | 1081 | ||
1087 | void PlayListWidget::pmViewActivated(int index) { | 1082 | void PlayListWidget::pmViewActivated(int index) { |
1088 | // qDebug("%d", index); | 1083 | // qDebug("%d", index); |
1089 | switch(index) { | 1084 | switch(index) { |
1090 | case -16: | 1085 | case -16: |
1091 | { | 1086 | { |
1092 | mediaPlayerState->toggleFullscreen(); | 1087 | mediaPlayerState->toggleFullscreen(); |
1093 | bool b=mediaPlayerState->isFullscreen(); | 1088 | bool b=mediaPlayerState->isFullscreen(); |
1094 | pmView->setItemChecked( index, b); | 1089 | pmView->setItemChecked( index, b); |
1095 | Config cfg( "OpiePlayer" ); | 1090 | Config cfg( "OpiePlayer" ); |
1096 | cfg.writeEntry( "FullScreen", b ); | 1091 | cfg.writeEntry( "FullScreen", b ); |
1097 | } | 1092 | } |
1098 | break; | 1093 | break; |
1099 | }; | 1094 | }; |
1100 | } | 1095 | } |
1101 | 1096 | ||
1102 | void PlayListWidget::populateSkinsMenu() { | 1097 | void 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 | ||
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 | } |