author | llornkcor <llornkcor> | 2002-04-21 15:49:37 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-21 15:49:37 (UTC) |
commit | d7ff40e1530a1aab578a3d3c3126c4367cf3e898 (patch) (unidiff) | |
tree | c581ad533a4cbb7a0fbbcaa9f624ae8f9475adde | |
parent | a588c90b0191e837b472dcaa76a5dedc289a5b10 (diff) | |
download | opie-d7ff40e1530a1aab578a3d3c3126c4367cf3e898.zip opie-d7ff40e1530a1aab578a3d3c3126c4367cf3e898.tar.gz opie-d7ff40e1530a1aab578a3d3c3126c4367cf3e898.tar.bz2 |
added multiselect to playlist
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 14 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 78 |
2 files changed, 55 insertions, 37 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 6793773..7de4282 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -281,548 +281,548 @@ int LibMadPlugin::tcp_open(char *address, int port) { | |||
281 | int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) { | 281 | int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) { |
282 | int offset = 0; | 282 | int offset = 0; |
283 | 283 | ||
284 | do | 284 | do |
285 | { | 285 | { |
286 | if (std::read(tcp_sock, buf + offset, 1) < 0) | 286 | if (std::read(tcp_sock, buf + offset, 1) < 0) |
287 | return -1; | 287 | return -1; |
288 | if (buf[offset] != '\r') /* Strip \r from answer */ | 288 | if (buf[offset] != '\r') /* Strip \r from answer */ |
289 | offset++; | 289 | offset++; |
290 | } | 290 | } |
291 | while (offset < size - 1 && buf[offset - 1] != '\n'); | 291 | while (offset < size - 1 && buf[offset - 1] != '\n'); |
292 | 292 | ||
293 | buf[offset] = 0; | 293 | buf[offset] = 0; |
294 | return offset; | 294 | return offset; |
295 | } | 295 | } |
296 | 296 | ||
297 | int LibMadPlugin::http_open(const QString& path ) { | 297 | int LibMadPlugin::http_open(const QString& path ) { |
298 | char *host; | 298 | char *host; |
299 | int port; | 299 | int port; |
300 | char *request; | 300 | char *request; |
301 | int tcp_sock; | 301 | int tcp_sock; |
302 | char http_request[PATH_MAX]; | 302 | char http_request[PATH_MAX]; |
303 | char filename[PATH_MAX]; | 303 | char filename[PATH_MAX]; |
304 | char c; | 304 | char c; |
305 | char *arg =strdup(path.latin1()); | 305 | char *arg =strdup(path.latin1()); |
306 | 306 | ||
307 | /* Check for URL syntax */ | 307 | /* Check for URL syntax */ |
308 | if (strncmp(arg, "http://", strlen("http://"))) | 308 | if (strncmp(arg, "http://", strlen("http://"))) |
309 | return (0); | 309 | return (0); |
310 | 310 | ||
311 | /* Parse URL */ | 311 | /* Parse URL */ |
312 | port = 80; | 312 | port = 80; |
313 | host = arg + strlen("http://"); | 313 | host = arg + strlen("http://"); |
314 | if ((request = strchr(host, '/')) == NULL) | 314 | if ((request = strchr(host, '/')) == NULL) |
315 | return (0); | 315 | return (0); |
316 | *request++ = 0; | 316 | *request++ = 0; |
317 | 317 | ||
318 | if (strchr(host, ':') != NULL) /* port is specified */ | 318 | if (strchr(host, ':') != NULL) /* port is specified */ |
319 | { | 319 | { |
320 | port = atoi(strchr(host, ':') + 1); | 320 | port = atoi(strchr(host, ':') + 1); |
321 | *strchr(host, ':') = 0; | 321 | *strchr(host, ':') = 0; |
322 | } | 322 | } |
323 | 323 | ||
324 | /* Open a TCP socket */ | 324 | /* Open a TCP socket */ |
325 | if (!(tcp_sock = tcp_open(host, port))) | 325 | if (!(tcp_sock = tcp_open(host, port))) |
326 | { | 326 | { |
327 | perror("http_open"); | 327 | perror("http_open"); |
328 | return (0); | 328 | return (0); |
329 | } | 329 | } |
330 | 330 | ||
331 | snprintf(filename, sizeof(filename) - strlen(host) - 75, "%s", request); | 331 | snprintf(filename, sizeof(filename) - strlen(host) - 75, "%s", request); |
332 | 332 | ||
333 | /* Send HTTP GET request */ | 333 | /* Send HTTP GET request */ |
334 | /* Please don't use a Agent know by shoutcast (Lynx, Mozilla) seems to be reconized and print | 334 | /* Please don't use a Agent know by shoutcast (Lynx, Mozilla) seems to be reconized and print |
335 | * a html page and not the stream */ | 335 | * a html page and not the stream */ |
336 | snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n" | 336 | snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n" |
337 | /* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */ | 337 | /* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */ |
338 | "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host); | 338 | "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host); |
339 | 339 | ||
340 | send(tcp_sock, http_request, strlen(http_request), 0); | 340 | send(tcp_sock, http_request, strlen(http_request), 0); |
341 | 341 | ||
342 | /* Parse server reply */ | 342 | /* Parse server reply */ |
343 | #if 0 | 343 | #if 0 |
344 | do | 344 | do |
345 | read(tcp_sock, &c, sizeof(char)); | 345 | read(tcp_sock, &c, sizeof(char)); |
346 | while (c != ' '); | 346 | while (c != ' '); |
347 | read(tcp_sock, http_request, 4 * sizeof(char)); | 347 | read(tcp_sock, http_request, 4 * sizeof(char)); |
348 | http_request[4] = 0; | 348 | http_request[4] = 0; |
349 | if (strcmp(http_request, "200 ")) | 349 | if (strcmp(http_request, "200 ")) |
350 | { | 350 | { |
351 | fprintf(stderr, "http_open: "); | 351 | fprintf(stderr, "http_open: "); |
352 | do | 352 | do |
353 | { | 353 | { |
354 | read(tcp_sock, &c, sizeof(char)); | 354 | read(tcp_sock, &c, sizeof(char)); |
355 | fprintf(stderr, "%c", c); | 355 | fprintf(stderr, "%c", c); |
356 | } | 356 | } |
357 | while (c != '\r'); | 357 | while (c != '\r'); |
358 | fprintf(stderr, "\n"); | 358 | fprintf(stderr, "\n"); |
359 | return (0); | 359 | return (0); |
360 | } | 360 | } |
361 | #endif | 361 | #endif |
362 | 362 | ||
363 | do | 363 | do |
364 | { | 364 | { |
365 | int len; | 365 | int len; |
366 | 366 | ||
367 | len = http_read_line(tcp_sock, http_request, sizeof(http_request)); | 367 | len = http_read_line(tcp_sock, http_request, sizeof(http_request)); |
368 | 368 | ||
369 | if (len == -1) | 369 | if (len == -1) |
370 | { | 370 | { |
371 | fprintf(stderr, "http_open: %s\n", strerror(errno)); | 371 | fprintf(stderr, "http_open: %s\n", strerror(errno)); |
372 | return 0; | 372 | return 0; |
373 | } | 373 | } |
374 | 374 | ||
375 | if (strncmp(http_request, "Location:", 9) == 0) | 375 | if (strncmp(http_request, "Location:", 9) == 0) |
376 | { | 376 | { |
377 | /* redirect */ | 377 | /* redirect */ |
378 | std::close(tcp_sock); | 378 | std::close(tcp_sock); |
379 | 379 | ||
380 | http_request[strlen(http_request) - 1] = '\0'; | 380 | http_request[strlen(http_request) - 1] = '\0'; |
381 | 381 | ||
382 | return http_open(&http_request[10]); | 382 | return http_open(&http_request[10]); |
383 | } | 383 | } |
384 | 384 | ||
385 | if (strncmp(http_request, "ICY ", 4) == 0) | 385 | if (strncmp(http_request, "ICY ", 4) == 0) |
386 | { | 386 | { |
387 | /* This is icecast streaming */ | 387 | /* This is icecast streaming */ |
388 | if (strncmp(http_request + 4, "200 ", 4)) | 388 | if (strncmp(http_request + 4, "200 ", 4)) |
389 | { | 389 | { |
390 | fprintf(stderr, "http_open: %s\n", http_request); | 390 | fprintf(stderr, "http_open: %s\n", http_request); |
391 | return 0; | 391 | return 0; |
392 | } | 392 | } |
393 | } | 393 | } |
394 | else if (strncmp(http_request, "icy-", 4) == 0) | 394 | else if (strncmp(http_request, "icy-", 4) == 0) |
395 | { | 395 | { |
396 | /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ | 396 | /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ |
397 | /* Don't print these - mpg123 doesn't */ | 397 | /* Don't print these - mpg123 doesn't */ |
398 | /* fprintf(stderr,"%s\n",http_request); */ | 398 | /* fprintf(stderr,"%s\n",http_request); */ |
399 | } | 399 | } |
400 | } | 400 | } |
401 | while (strcmp(http_request, "\n") != 0); | 401 | while (strcmp(http_request, "\n") != 0); |
402 | 402 | ||
403 | return (tcp_sock); | 403 | return (tcp_sock); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | bool LibMadPlugin::open( const QString& path ) { | 407 | bool LibMadPlugin::open( const QString& path ) { |
408 | debugMsg( "LibMadPlugin::open" ); | 408 | debugMsg( "LibMadPlugin::open" ); |
409 | Config cfg("MediaPlayer"); | 409 | Config cfg("MediaPlayer"); |
410 | cfg.setGroup("Options"); | 410 | cfg.setGroup("Options"); |
411 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); | 411 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); |
412 | qDebug("buffer size is %d", bufferSize); | 412 | qDebug("buffer size is %d", bufferSize); |
413 | d->bad_last_frame = 0; | 413 | d->bad_last_frame = 0; |
414 | d->flush = TRUE; | 414 | d->flush = TRUE; |
415 | info = QString( "" ); | 415 | info = QString( "" ); |
416 | 416 | ||
417 | //qDebug( "Opening %s", path.latin1() ); | 417 | //qDebug( "Opening %s", path.latin1() ); |
418 | 418 | ||
419 | 419 | ||
420 | if (path.left( 4 ) == "http" ) { | 420 | if (path.left( 4 ) == "http" ) { |
421 | d->input.fd = http_open(path); | 421 | d->input.fd = http_open(path); |
422 | 422 | ||
423 | } else { | 423 | } else { |
424 | d->input.path = path.latin1(); | 424 | d->input.path = path.latin1(); |
425 | d->input.fd = ::open( d->input.path, O_RDONLY ); | 425 | d->input.fd = ::open( d->input.path, O_RDONLY ); |
426 | } | 426 | } |
427 | if (d->input.fd == -1) { | 427 | if (d->input.fd == -1) { |
428 | qDebug("error opening %s", d->input.path ); | 428 | qDebug("error opening %s", d->input.path ); |
429 | return FALSE; | 429 | return FALSE; |
430 | } | 430 | } |
431 | 431 | ||
432 | printID3Tags(); | 432 | printID3Tags(); |
433 | 433 | ||
434 | #if defined(HAVE_MMAP) | 434 | #if defined(HAVE_MMAP) |
435 | struct stat stat; | 435 | struct stat stat; |
436 | if (fstat(d->input.fd, &stat) == -1) { | 436 | if (fstat(d->input.fd, &stat) == -1) { |
437 | qDebug("error calling fstat"); return FALSE; | 437 | qDebug("error calling fstat"); return FALSE; |
438 | } | 438 | } |
439 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { | 439 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { |
440 | d->input.length = stat.st_size; | 440 | d->input.length = stat.st_size; |
441 | d->input.fdm = map_file(d->input.fd, &d->input.length); | 441 | d->input.fdm = map_file(d->input.fd, &d->input.length); |
442 | if (d->input.fdm == 0) { | 442 | if (d->input.fdm == 0) { |
443 | qDebug("error mmapping file"); return FALSE; | 443 | qDebug("error mmapping file"); return FALSE; |
444 | } | 444 | } |
445 | d->input.data = (unsigned char *)d->input.fdm; | 445 | d->input.data = (unsigned char *)d->input.fdm; |
446 | } | 446 | } |
447 | #endif | 447 | #endif |
448 | 448 | ||
449 | if (d->input.data == 0) { | 449 | if (d->input.data == 0) { |
450 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); | 450 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); |
451 | if (d->input.data == 0) { | 451 | if (d->input.data == 0) { |
452 | qDebug("error allocating input buffer"); | 452 | qDebug("error allocating input buffer"); |
453 | return FALSE; | 453 | return FALSE; |
454 | } | 454 | } |
455 | d->input.length = 0; | 455 | d->input.length = 0; |
456 | } | 456 | } |
457 | 457 | ||
458 | d->input.eof = 0; | 458 | d->input.eof = 0; |
459 | 459 | ||
460 | mad_stream_init(&d->stream); | 460 | mad_stream_init(&d->stream); |
461 | mad_frame_init(&d->frame); | 461 | mad_frame_init(&d->frame); |
462 | mad_synth_init(&d->synth); | 462 | mad_synth_init(&d->synth); |
463 | 463 | ||
464 | return TRUE; | 464 | return TRUE; |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | bool LibMadPlugin::close() { | 468 | bool LibMadPlugin::close() { |
469 | debugMsg( "LibMadPlugin::close" ); | 469 | debugMsg( "LibMadPlugin::close" ); |
470 | 470 | ||
471 | int result = TRUE; | 471 | int result = TRUE; |
472 | 472 | ||
473 | mad_synth_finish(&d->synth); | 473 | mad_synth_finish(&d->synth); |
474 | mad_frame_finish(&d->frame); | 474 | mad_frame_finish(&d->frame); |
475 | mad_stream_finish(&d->stream); | 475 | mad_stream_finish(&d->stream); |
476 | 476 | ||
477 | #if defined(HAVE_MMAP) | 477 | #if defined(HAVE_MMAP) |
478 | if (d->input.fdm) { | 478 | if (d->input.fdm) { |
479 | if (unmap_file(d->input.fdm, d->input.length) == -1) { | 479 | if (unmap_file(d->input.fdm, d->input.length) == -1) { |
480 | qDebug("error munmapping file"); | 480 | qDebug("error munmapping file"); |
481 | result = FALSE; | 481 | result = FALSE; |
482 | } | 482 | } |
483 | d->input.fdm = 0; | 483 | d->input.fdm = 0; |
484 | d->input.data = 0; | 484 | d->input.data = 0; |
485 | } | 485 | } |
486 | #endif | 486 | #endif |
487 | 487 | ||
488 | if (d->input.data) { | 488 | if (d->input.data) { |
489 | free(d->input.data); | 489 | free(d->input.data); |
490 | d->input.data = 0; | 490 | d->input.data = 0; |
491 | } | 491 | } |
492 | 492 | ||
493 | if (::close(d->input.fd) == -1) { | 493 | if (::close(d->input.fd) == -1) { |
494 | qDebug("error closing file %s", d->input.path); | 494 | qDebug("error closing file %s", d->input.path); |
495 | result = FALSE; | 495 | result = FALSE; |
496 | } | 496 | } |
497 | 497 | ||
498 | d->input.fd = 0; | 498 | d->input.fd = 0; |
499 | 499 | ||
500 | return result; | 500 | return result; |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | bool LibMadPlugin::isOpen() { | 504 | bool LibMadPlugin::isOpen() { |
505 | debugMsg( "LibMadPlugin::isOpen" ); | 505 | debugMsg( "LibMadPlugin::isOpen" ); |
506 | return ( d->input.fd != 0 ); | 506 | return ( d->input.fd != 0 ); |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | int LibMadPlugin::audioStreams() { | 510 | int LibMadPlugin::audioStreams() { |
511 | debugMsg( "LibMadPlugin::audioStreams" ); | 511 | debugMsg( "LibMadPlugin::audioStreams" ); |
512 | return 1; | 512 | return 1; |
513 | } | 513 | } |
514 | 514 | ||
515 | 515 | ||
516 | int LibMadPlugin::audioChannels( int ) { | 516 | int LibMadPlugin::audioChannels( int ) { |
517 | debugMsg( "LibMadPlugin::audioChannels" ); | 517 | debugMsg( "LibMadPlugin::audioChannels" ); |
518 | /* | 518 | /* |
519 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 519 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
520 | qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); | 520 | qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); |
521 | return d->frame.header.mode > 0 ? 2 : 1; | 521 | return d->frame.header.mode > 0 ? 2 : 1; |
522 | */ | 522 | */ |
523 | return 2; | 523 | return 2; |
524 | } | 524 | } |
525 | 525 | ||
526 | 526 | ||
527 | int LibMadPlugin::audioFrequency( int ) { | 527 | int LibMadPlugin::audioFrequency( int ) { |
528 | debugMsg( "LibMadPlugin::audioFrequency" ); | 528 | debugMsg( "LibMadPlugin::audioFrequency" ); |
529 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 529 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
530 | qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); | 530 | qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); |
531 | return d->frame.header.samplerate; | 531 | return d->frame.header.samplerate; |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | int LibMadPlugin::audioSamples( int ) { | 535 | int LibMadPlugin::audioSamples( int ) { |
536 | debugMsg( "LibMadPlugin::audioSamples" ); | 536 | debugMsg( "LibMadPlugin::audioSamples" ); |
537 | /* | 537 | |
538 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 538 | // long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
539 | mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); | 539 | // mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); |
540 | qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate ); | 540 | // qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate ); |
541 | return d->frame.header.duration.seconds * d->frame.header.samplerate; | 541 | // return d->frame.header.duration.seconds * d->frame.header.samplerate; |
542 | */ | 542 | |
543 | return 10000000; | 543 | return 10000000; |
544 | } | 544 | } |
545 | 545 | ||
546 | 546 | ||
547 | bool LibMadPlugin::audioSetSample( long, int ) { | 547 | bool LibMadPlugin::audioSetSample( long, int ) { |
548 | debugMsg( "LibMadPlugin::audioSetSample" ); | 548 | debugMsg( "LibMadPlugin::audioSetSample" ); |
549 | return FALSE; | 549 | return FALSE; |
550 | } | 550 | } |
551 | 551 | ||
552 | 552 | ||
553 | long LibMadPlugin::audioGetSample( int ) { | 553 | long LibMadPlugin::audioGetSample( int ) { |
554 | debugMsg( "LibMadPlugin::audioGetSample" ); | 554 | debugMsg( "LibMadPlugin::audioGetSample" ); |
555 | return 0; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | /* | 558 | /* |
559 | bool LibMadPlugin::audioReadSamples( short *, int, long, int ) { | 559 | bool LibMadPlugin::audioReadSamples( short *, int, long, int ) { |
560 | debugMsg( "LibMadPlugin::audioReadSamples" ); | 560 | debugMsg( "LibMadPlugin::audioReadSamples" ); |
561 | return FALSE; | 561 | return FALSE; |
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
565 | bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) { | 565 | bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) { |
566 | debugMsg( "LibMadPlugin::audioReReadSamples" ); | 566 | debugMsg( "LibMadPlugin::audioReReadSamples" ); |
567 | return FALSE; | 567 | return FALSE; |
568 | } | 568 | } |
569 | */ | 569 | */ |
570 | 570 | ||
571 | bool LibMadPlugin::read() { | 571 | bool LibMadPlugin::read() { |
572 | debugMsg( "LibMadPlugin::read" ); | 572 | debugMsg( "LibMadPlugin::read" ); |
573 | int len; | 573 | int len; |
574 | 574 | ||
575 | if (d->input.eof) | 575 | if (d->input.eof) |
576 | return FALSE; | 576 | return FALSE; |
577 | 577 | ||
578 | #if defined(HAVE_MMAP) | 578 | #if defined(HAVE_MMAP) |
579 | if (d->input.fdm) { | 579 | if (d->input.fdm) { |
580 | unsigned long skip = 0; | 580 | unsigned long skip = 0; |
581 | 581 | ||
582 | if (d->stream.next_frame) { | 582 | if (d->stream.next_frame) { |
583 | struct stat stat; | 583 | struct stat stat; |
584 | 584 | ||
585 | if (fstat(d->input.fd, &stat) == -1) | 585 | if (fstat(d->input.fd, &stat) == -1) |
586 | return FALSE; | 586 | return FALSE; |
587 | 587 | ||
588 | if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length) | 588 | if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length) |
589 | return FALSE; | 589 | return FALSE; |
590 | 590 | ||
591 | // file size changed; update memory map | 591 | // file size changed; update memory map |
592 | skip = d->stream.next_frame - d->input.data; | 592 | skip = d->stream.next_frame - d->input.data; |
593 | 593 | ||
594 | if (unmap_file(d->input.fdm, d->input.length) == -1) { | 594 | if (unmap_file(d->input.fdm, d->input.length) == -1) { |
595 | d->input.fdm = 0; | 595 | d->input.fdm = 0; |
596 | d->input.data = 0; | 596 | d->input.data = 0; |
597 | return FALSE; | 597 | return FALSE; |
598 | } | 598 | } |
599 | 599 | ||
600 | d->input.length = stat.st_size; | 600 | d->input.length = stat.st_size; |
601 | 601 | ||
602 | d->input.fdm = map_file(d->input.fd, &d->input.length); | 602 | d->input.fdm = map_file(d->input.fd, &d->input.length); |
603 | if (d->input.fdm == 0) { | 603 | if (d->input.fdm == 0) { |
604 | d->input.data = 0; | 604 | d->input.data = 0; |
605 | return FALSE; | 605 | return FALSE; |
606 | } | 606 | } |
607 | 607 | ||
608 | d->input.data = (unsigned char *)d->input.fdm; | 608 | d->input.data = (unsigned char *)d->input.fdm; |
609 | } | 609 | } |
610 | 610 | ||
611 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); | 611 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); |
612 | 612 | ||
613 | } else | 613 | } else |
614 | #endif | 614 | #endif |
615 | { | 615 | { |
616 | if (d->stream.next_frame) { | 616 | if (d->stream.next_frame) { |
617 | memmove(d->input.data, d->stream.next_frame, | 617 | memmove(d->input.data, d->stream.next_frame, |
618 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); | 618 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); |
619 | } | 619 | } |
620 | 620 | ||
621 | do { | 621 | do { |
622 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); | 622 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); |
623 | } | 623 | } |
624 | while (len == -1 && errno == EINTR); | 624 | while (len == -1 && errno == EINTR); |
625 | 625 | ||
626 | if (len == -1) { | 626 | if (len == -1) { |
627 | qDebug("error reading audio"); | 627 | qDebug("error reading audio"); |
628 | return FALSE; | 628 | return FALSE; |
629 | } | 629 | } |
630 | else if (len == 0) { | 630 | else if (len == 0) { |
631 | d->input.eof = 1; | 631 | d->input.eof = 1; |
632 | 632 | ||
633 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); | 633 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); |
634 | 634 | ||
635 | while (len < MAD_BUFFER_GUARD) | 635 | while (len < MAD_BUFFER_GUARD) |
636 | d->input.data[d->input.length + len++] = 0; | 636 | d->input.data[d->input.length + len++] = 0; |
637 | } | 637 | } |
638 | 638 | ||
639 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); | 639 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); |
640 | } | 640 | } |
641 | 641 | ||
642 | return TRUE; | 642 | return TRUE; |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | static mad_fixed_t left_err, right_err; | 646 | static mad_fixed_t left_err, right_err; |
647 | static const int bits = 16; | 647 | static const int bits = 16; |
648 | static const int shift = MAD_F_FRACBITS + 1 - bits; | 648 | static const int shift = MAD_F_FRACBITS + 1 - bits; |
649 | 649 | ||
650 | 650 | ||
651 | inline long audio_linear_dither( mad_fixed_t sample, mad_fixed_t& error ) | 651 | inline long audio_linear_dither( mad_fixed_t sample, mad_fixed_t& error ) |
652 | { | 652 | { |
653 | sample += error; | 653 | sample += error; |
654 | mad_fixed_t quantized = (sample >= MAD_F_ONE) ? MAD_F_ONE - 1 : ( (sample < -MAD_F_ONE) ? -MAD_F_ONE : sample ); | 654 | mad_fixed_t quantized = (sample >= MAD_F_ONE) ? MAD_F_ONE - 1 : ( (sample < -MAD_F_ONE) ? -MAD_F_ONE : sample ); |
655 | quantized &= ~((1L << shift) - 1); | 655 | quantized &= ~((1L << shift) - 1); |
656 | error = sample - quantized; | 656 | error = sample - quantized; |
657 | return quantized >> shift; | 657 | return quantized >> shift; |
658 | } | 658 | } |
659 | 659 | ||
660 | 660 | ||
661 | inline void audio_pcm( short *data, unsigned int nsamples, mad_fixed_t *left, mad_fixed_t *right ) | 661 | inline void audio_pcm( short *data, unsigned int nsamples, mad_fixed_t *left, mad_fixed_t *right ) |
662 | { | 662 | { |
663 | if ( right ) { | 663 | if ( right ) { |
664 | while (nsamples--) { | 664 | while (nsamples--) { |
665 | data[0] = audio_linear_dither( *left++, left_err ); | 665 | data[0] = audio_linear_dither( *left++, left_err ); |
666 | data[1] = audio_linear_dither( *right++, right_err ); | 666 | data[1] = audio_linear_dither( *right++, right_err ); |
667 | data += 2; | 667 | data += 2; |
668 | } | 668 | } |
669 | } else { | 669 | } else { |
670 | while (nsamples--) { | 670 | while (nsamples--) { |
671 | data[0] = data[1] = audio_linear_dither( *left++, left_err ); | 671 | data[0] = data[1] = audio_linear_dither( *left++, left_err ); |
672 | data += 2; | 672 | data += 2; |
673 | } | 673 | } |
674 | } | 674 | } |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { | 678 | bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { |
679 | debugMsg( "LibMadPlugin::decode" ); | 679 | debugMsg( "LibMadPlugin::decode" ); |
680 | 680 | ||
681 | static int buffered = 0; | 681 | static int buffered = 0; |
682 | static mad_fixed_t buffer[2][65536 * 2]; | 682 | static mad_fixed_t buffer[2][65536 * 2]; |
683 | int offset = buffered; | 683 | int offset = buffered; |
684 | samplesMade = 0; | 684 | samplesMade = 0; |
685 | 685 | ||
686 | static int maxBuffered = 8000; // 65536; | 686 | static int maxBuffered = 8000; // 65536; |
687 | 687 | ||
688 | if ( samples > maxBuffered ) | 688 | if ( samples > maxBuffered ) |
689 | samples = maxBuffered; | 689 | samples = maxBuffered; |
690 | 690 | ||
691 | if ( d->flush ) { | 691 | if ( d->flush ) { |
692 | buffered = 0; | 692 | buffered = 0; |
693 | offset = 0; | 693 | offset = 0; |
694 | d->flush = FALSE; | 694 | d->flush = FALSE; |
695 | } | 695 | } |
696 | 696 | ||
697 | while ( buffered < maxBuffered ) { | 697 | while ( buffered < maxBuffered ) { |
698 | 698 | ||
699 | while (mad_frame_decode(&d->frame, &d->stream) == -1) { | 699 | while (mad_frame_decode(&d->frame, &d->stream) == -1) { |
700 | if (!MAD_RECOVERABLE(d->stream.error)) { | 700 | if (!MAD_RECOVERABLE(d->stream.error)) { |
701 | debugMsg( "feed me" ); | 701 | debugMsg( "feed me" ); |
702 | return FALSE; // Feed me | 702 | return FALSE; // Feed me |
703 | } | 703 | } |
704 | if ( d->stream.error == MAD_ERROR_BADCRC ) { | 704 | if ( d->stream.error == MAD_ERROR_BADCRC ) { |
705 | mad_frame_mute(&d->frame); | 705 | mad_frame_mute(&d->frame); |
706 | qDebug( "error decoding, bad crc" ); | 706 | qDebug( "error decoding, bad crc" ); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | 709 | ||
710 | mad_synth_frame(&d->synth, &d->frame); | 710 | mad_synth_frame(&d->synth, &d->frame); |
711 | int decodedSamples = d->synth.pcm.length; | 711 | int decodedSamples = d->synth.pcm.length; |
712 | memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); | 712 | memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); |
713 | if ( d->synth.pcm.channels == 2 ) | 713 | if ( d->synth.pcm.channels == 2 ) |
714 | memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); | 714 | memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); |
715 | offset += decodedSamples; | 715 | offset += decodedSamples; |
716 | buffered += decodedSamples; | 716 | buffered += decodedSamples; |
717 | } | 717 | } |
718 | //qApp->processEvents(); | 718 | //qApp->processEvents(); |
719 | audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); | 719 | audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); |
720 | // audio_pcm( output, samples, buffer[1], buffer[0] ); | 720 | // audio_pcm( output, samples, buffer[1], buffer[0] ); |
721 | // audio_pcm( output, samples, buffer[0], buffer[1] ); | 721 | // audio_pcm( output, samples, buffer[0], buffer[1] ); |
722 | samplesMade = samples; | 722 | samplesMade = samples; |
723 | memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); | 723 | memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); |
724 | if ( d->synth.pcm.channels == 2 ) | 724 | if ( d->synth.pcm.channels == 2 ) |
725 | memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); | 725 | memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); |
726 | buffered -= samples; | 726 | buffered -= samples; |
727 | 727 | ||
728 | return TRUE; | 728 | return TRUE; |
729 | } | 729 | } |
730 | 730 | ||
731 | /* | 731 | /* |
732 | bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) { | 732 | bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) { |
733 | debugMsg( "LibMadPlugin::audioReadMonoSamples" ); | 733 | debugMsg( "LibMadPlugin::audioReadMonoSamples" ); |
734 | return FALSE; | 734 | return FALSE; |
735 | } | 735 | } |
736 | 736 | ||
737 | 737 | ||
738 | bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 738 | bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
739 | */ | 739 | */ |
740 | bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) { | 740 | bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) { |
741 | debugMsg( "LibMadPlugin::audioReadStereoSamples" ); | 741 | debugMsg( "LibMadPlugin::audioReadStereoSamples" ); |
742 | 742 | ||
743 | static bool needInput = TRUE; | 743 | static bool needInput = TRUE; |
744 | 744 | ||
745 | if ( samples == 0 ) | 745 | if ( samples == 0 ) |
746 | return FALSE; | 746 | return FALSE; |
747 | 747 | ||
748 | do { | 748 | do { |
749 | if ( needInput ) | 749 | if ( needInput ) |
750 | if ( !read() ) { | 750 | if ( !read() ) { |
751 | // if ( d->input.eof ) | 751 | // if ( d->input.eof ) |
752 | // needInput = FALSE; | 752 | // needInput = FALSE; |
753 | // else | 753 | // else |
754 | return FALSE; | 754 | return FALSE; |
755 | } | 755 | } |
756 | 756 | ||
757 | needInput = FALSE; | 757 | needInput = FALSE; |
758 | 758 | ||
759 | if ( decode( output, samples, samplesMade ) ) | 759 | if ( decode( output, samples, samplesMade ) ) |
760 | return TRUE; | 760 | return TRUE; |
761 | else | 761 | else |
762 | needInput = TRUE; | 762 | needInput = TRUE; |
763 | } | 763 | } |
764 | while ( ( samplesMade < samples ) && ( !d->input.eof ) ); | 764 | while ( ( samplesMade < samples ) && ( !d->input.eof ) ); |
765 | /* | 765 | /* |
766 | static bool firstTimeThru = TRUE; | 766 | static bool firstTimeThru = TRUE; |
767 | 767 | ||
768 | if ( firstTimeThru ) { | 768 | if ( firstTimeThru ) { |
769 | firstTimeThru = FALSE; | 769 | firstTimeThru = FALSE; |
770 | decode( output, samples, samplesMade ); | 770 | decode( output, samples, samplesMade ); |
771 | return FALSE; | 771 | return FALSE; |
772 | } else | 772 | } else |
773 | */ | 773 | */ |
774 | return FALSE; | 774 | return FALSE; |
775 | } | 775 | } |
776 | 776 | ||
777 | 777 | ||
778 | double LibMadPlugin::getTime() { | 778 | double LibMadPlugin::getTime() { |
779 | debugMsg( "LibMadPlugin::getTime" ); | 779 | debugMsg( "LibMadPlugin::getTime" ); |
780 | return 0.0; | 780 | return 0.0; |
781 | } | 781 | } |
782 | 782 | ||
783 | 783 | ||
784 | void LibMadPlugin::printID3Tags() { | 784 | void LibMadPlugin::printID3Tags() { |
785 | debugMsg( "LibMadPlugin::printID3Tags" ); | 785 | qDebug( "LibMadPlugin::printID3Tags" ); |
786 | 786 | ||
787 | char id3v1[128 + 1]; | 787 | char id3v1[128 + 1]; |
788 | 788 | ||
789 | if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { | 789 | if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { |
790 | qDebug( "error seeking to id3 tags" ); | 790 | qDebug( "error seeking to id3 tags" ); |
791 | return; | 791 | return; |
792 | } | 792 | } |
793 | 793 | ||
794 | if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { | 794 | if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { |
795 | qDebug( "error reading in id3 tags" ); | 795 | qDebug( "error reading in id3 tags" ); |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | 798 | ||
799 | if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { | 799 | if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { |
800 | debugMsg( "sorry, no id3 tags" ); | 800 | debugMsg( "sorry, no id3 tags" ); |
801 | } else { | 801 | } else { |
802 | int len[5] = { 30, 30, 30, 4, 30 }; | 802 | int len[5] = { 30, 30, 30, 4, 30 }; |
803 | QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; | 803 | QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; |
804 | char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; | 804 | char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; |
805 | qDebug( "ID3 tags in file:" ); | 805 | qDebug( "ID3 tags in file:" ); |
806 | info = ""; | 806 | info = ""; |
807 | for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { | 807 | for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { |
808 | char push = *ptr2; | 808 | char push = *ptr2; |
809 | *ptr2 = '\0'; | 809 | *ptr2 = '\0'; |
810 | char *ptr3 = ptr2; | 810 | char *ptr3 = ptr2; |
811 | while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; | 811 | while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; |
812 | char push2 = *ptr3; *ptr3 = '\0'; | 812 | char push2 = *ptr3; *ptr3 = '\0'; |
813 | if ( strcmp( ptr, "" ) ) | 813 | if ( strcmp( ptr, "" ) ) |
814 | info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; | 814 | info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; |
815 | //qDebug( info.latin1() ); | 815 | //qDebug( info.latin1() ); |
816 | *ptr3 = push2; | 816 | *ptr3 = push2; |
817 | *ptr2 = push; | 817 | *ptr2 = push; |
818 | } | 818 | } |
819 | if (id3v1[126] == 0 && id3v1[127] != 0) | 819 | if (id3v1[126] == 0 && id3v1[127] != 0) |
820 | info += tr( ", Track: " ) + id3v1[127]; | 820 | info += tr( ", Track: " ) + id3v1[127]; |
821 | } | 821 | } |
822 | 822 | ||
823 | if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { | 823 | if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { |
824 | qDebug( "error seeking back to beginning" ); | 824 | qDebug( "error seeking back to beginning" ); |
825 | return; | 825 | return; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index ff156f8..7c76400 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,969 +1,987 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | 27 | #include <qpe/lnkproperties.h> |
28 | #include <qpe/storage.h> | 28 | #include <qpe/storage.h> |
29 | 29 | ||
30 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | 34 | ||
35 | #include <qaction.h> | 35 | #include <qaction.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlist.h> | 41 | #include <qlist.h> |
42 | #include <qlistbox.h> | 42 | #include <qlistbox.h> |
43 | #include <qmainwindow.h> | 43 | #include <qmainwindow.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qtoolbutton.h> | 45 | #include <qtoolbutton.h> |
46 | #include <qtabwidget.h> | 46 | #include <qtabwidget.h> |
47 | #include <qlistview.h> | 47 | #include <qlistview.h> |
48 | #include <qpoint.h> | 48 | #include <qpoint.h> |
49 | #include <qlineedit.h> | 49 | #include <qlineedit.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | #include <qregexp.h> | 51 | #include <qregexp.h> |
52 | 52 | ||
53 | //#include <qtimer.h> | 53 | //#include <qtimer.h> |
54 | 54 | ||
55 | #include "playlistselection.h" | 55 | #include "playlistselection.h" |
56 | #include "playlistwidget.h" | 56 | #include "playlistwidget.h" |
57 | #include "mediaplayerstate.h" | 57 | #include "mediaplayerstate.h" |
58 | 58 | ||
59 | #include "inputDialog.h" | 59 | #include "inputDialog.h" |
60 | 60 | ||
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | 62 | ||
63 | #define BUTTONS_ON_TOOLBAR | 63 | #define BUTTONS_ON_TOOLBAR |
64 | #define SIDE_BUTTONS | 64 | #define SIDE_BUTTONS |
65 | #define CAN_SAVE_LOAD_PLAYLISTS | 65 | #define CAN_SAVE_LOAD_PLAYLISTS |
66 | 66 | ||
67 | extern MediaPlayerState *mediaPlayerState; | 67 | extern MediaPlayerState *mediaPlayerState; |
68 | 68 | ||
69 | // class myFileSelector { | 69 | // class myFileSelector { |
70 | 70 | ||
71 | // }; | 71 | // }; |
72 | class PlayListWidgetPrivate { | 72 | class PlayListWidgetPrivate { |
73 | public: | 73 | public: |
74 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 74 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
75 | QFrame *playListFrame; | 75 | QFrame *playListFrame; |
76 | FileSelector *files; | 76 | FileSelector *files; |
77 | PlayListSelection *selectedFiles; | 77 | PlayListSelection *selectedFiles; |
78 | bool setDocumentUsed; | 78 | bool setDocumentUsed; |
79 | DocLnk *current; | 79 | DocLnk *current; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | class ToolButton : public QToolButton { | 83 | class ToolButton : public QToolButton { |
84 | public: | 84 | public: |
85 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 85 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
86 | : QToolButton( parent, name ) { | 86 | : QToolButton( parent, name ) { |
87 | setTextLabel( name ); | 87 | setTextLabel( name ); |
88 | setPixmap( Resource::loadPixmap( icon ) ); | 88 | setPixmap( Resource::loadPixmap( icon ) ); |
89 | setAutoRaise( TRUE ); | 89 | setAutoRaise( TRUE ); |
90 | setFocusPolicy( QWidget::NoFocus ); | 90 | setFocusPolicy( QWidget::NoFocus ); |
91 | setToggleButton( t ); | 91 | setToggleButton( t ); |
92 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 92 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
93 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 93 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
94 | } | 94 | } |
95 | }; | 95 | }; |
96 | 96 | ||
97 | 97 | ||
98 | class MenuItem : public QAction { | 98 | class MenuItem : public QAction { |
99 | public: | 99 | public: |
100 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 100 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
101 | : QAction( text, QString::null, 0, 0 ) { | 101 | : QAction( text, QString::null, 0, 0 ) { |
102 | connect( this, SIGNAL( activated() ), handler, slot ); | 102 | connect( this, SIGNAL( activated() ), handler, slot ); |
103 | addTo( parent ); | 103 | addTo( parent ); |
104 | } | 104 | } |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 108 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
109 | : QMainWindow( parent, name, fl ) { | 109 | : QMainWindow( parent, name, fl ) { |
110 | 110 | ||
111 | d = new PlayListWidgetPrivate; | 111 | d = new PlayListWidgetPrivate; |
112 | d->setDocumentUsed = FALSE; | 112 | d->setDocumentUsed = FALSE; |
113 | d->current = NULL; | 113 | d->current = NULL; |
114 | fromSetDocument = FALSE; | 114 | fromSetDocument = FALSE; |
115 | insanityBool=FALSE; | 115 | insanityBool=FALSE; |
116 | // menuTimer = new QTimer( this ,"menu timer"), | 116 | // menuTimer = new QTimer( this ,"menu timer"), |
117 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 117 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
118 | 118 | ||
119 | setBackgroundMode( PaletteButton ); | 119 | setBackgroundMode( PaletteButton ); |
120 | 120 | ||
121 | setCaption( tr("OpiePlayer") ); | 121 | setCaption( tr("OpiePlayer") ); |
122 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 122 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
123 | 123 | ||
124 | setToolBarsMovable( FALSE ); | 124 | setToolBarsMovable( FALSE ); |
125 | 125 | ||
126 | // Create Toolbar | 126 | // Create Toolbar |
127 | QPEToolBar *toolbar = new QPEToolBar( this ); | 127 | QPEToolBar *toolbar = new QPEToolBar( this ); |
128 | toolbar->setHorizontalStretchable( TRUE ); | 128 | toolbar->setHorizontalStretchable( TRUE ); |
129 | 129 | ||
130 | // Create Menubar | 130 | // Create Menubar |
131 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 131 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
132 | menu->setMargin( 0 ); | 132 | menu->setMargin( 0 ); |
133 | 133 | ||
134 | QPEToolBar *bar = new QPEToolBar( this ); | 134 | QPEToolBar *bar = new QPEToolBar( this ); |
135 | bar->setLabel( tr( "Play Operations" ) ); | 135 | bar->setLabel( tr( "Play Operations" ) ); |
136 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 136 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
137 | // this , SLOT( addSelected()) ); | 137 | // this , SLOT( addSelected()) ); |
138 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 138 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
139 | tbDeletePlaylist->setFlat(TRUE); | 139 | tbDeletePlaylist->setFlat(TRUE); |
140 | tbDeletePlaylist->setFixedSize(20,20); | 140 | tbDeletePlaylist->setFixedSize(20,20); |
141 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 141 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
142 | 142 | ||
143 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 143 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
144 | this , SLOT(addSelected()) ); | 144 | this , SLOT(addSelected()) ); |
145 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 145 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
146 | this , SLOT(removeSelected()) ); | 146 | this , SLOT(removeSelected()) ); |
147 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 147 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
148 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 148 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
149 | this , SLOT( btnPlay(bool) ), TRUE ); | 149 | this , SLOT( btnPlay(bool) ), TRUE ); |
150 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 150 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
151 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 151 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
152 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 152 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
153 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 153 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
154 | tbDeletePlaylist->hide(); | 154 | tbDeletePlaylist->hide(); |
155 | 155 | ||
156 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 156 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
157 | menu->insertItem( tr( "File" ), pmPlayList ); | 157 | menu->insertItem( tr( "File" ), pmPlayList ); |
158 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 158 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
159 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 159 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
160 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 160 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
161 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 161 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
162 | // pmPlayList->insertSeparator(-1); | 162 | // pmPlayList->insertSeparator(-1); |
163 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 163 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
164 | pmPlayList->insertSeparator(-1); | 164 | pmPlayList->insertSeparator(-1); |
165 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 165 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
166 | 166 | ||
167 | QPopupMenu *pmView = new QPopupMenu( this ); | 167 | QPopupMenu *pmView = new QPopupMenu( this ); |
168 | menu->insertItem( tr( "View" ), pmView ); | 168 | menu->insertItem( tr( "View" ), pmView ); |
169 | 169 | ||
170 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 170 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
171 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 171 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
172 | fullScreenButton->addTo(pmView); | 172 | fullScreenButton->addTo(pmView); |
173 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 173 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
174 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 174 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
175 | scaleButton->addTo(pmView); | 175 | scaleButton->addTo(pmView); |
176 | 176 | ||
177 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 177 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
178 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 178 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
179 | 179 | ||
180 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 180 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
181 | 181 | ||
182 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 182 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
183 | tabWidget->setTabShape(QTabWidget::Triangular); | 183 | tabWidget->setTabShape(QTabWidget::Triangular); |
184 | 184 | ||
185 | QWidget *pTab; | 185 | QWidget *pTab; |
186 | pTab = new QWidget( tabWidget, "pTab" ); | 186 | pTab = new QWidget( tabWidget, "pTab" ); |
187 | // playlistView = new QListView( pTab, "playlistview" ); | 187 | // playlistView = new QListView( pTab, "playlistview" ); |
188 | // playlistView->setMinimumSize(236,260); | 188 | // playlistView->setMinimumSize(236,260); |
189 | tabWidget->insertTab( pTab,"Playlist"); | 189 | tabWidget->insertTab( pTab,"Playlist"); |
190 | 190 | ||
191 | 191 | ||
192 | // Add the playlist area | 192 | // Add the playlist area |
193 | 193 | ||
194 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 194 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
195 | d->playListFrame = vbox3; | 195 | d->playListFrame = vbox3; |
196 | d->playListFrame ->setMinimumSize(235,260); | 196 | d->playListFrame ->setMinimumSize(235,260); |
197 | 197 | ||
198 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 198 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
199 | 199 | ||
200 | d->selectedFiles = new PlayListSelection( hbox2); | 200 | d->selectedFiles = new PlayListSelection( hbox2); |
201 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 201 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
202 | 202 | ||
203 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 203 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
204 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 204 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
205 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 205 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
206 | 206 | ||
207 | 207 | ||
208 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 208 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
209 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 209 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
210 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 210 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
211 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 211 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
212 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 212 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
213 | 213 | ||
214 | QWidget *aTab; | 214 | QWidget *aTab; |
215 | aTab = new QWidget( tabWidget, "aTab" ); | 215 | aTab = new QWidget( tabWidget, "aTab" ); |
216 | audioView = new QListView( aTab, "Audioview" ); | 216 | audioView = new QListView( aTab, "Audioview" ); |
217 | audioView->setMinimumSize(233,260); | 217 | audioView->setMinimumSize(233,260); |
218 | audioView->addColumn( tr("Title"),140); | 218 | audioView->addColumn( tr("Title"),140); |
219 | audioView->addColumn(tr("Size"), -1); | 219 | audioView->addColumn(tr("Size"), -1); |
220 | audioView->addColumn(tr("Media"),-1); | 220 | audioView->addColumn(tr("Media"),-1); |
221 | audioView->setColumnAlignment(1, Qt::AlignRight); | 221 | audioView->setColumnAlignment(1, Qt::AlignRight); |
222 | audioView->setColumnAlignment(2, Qt::AlignRight); | 222 | audioView->setColumnAlignment(2, Qt::AlignRight); |
223 | audioView->setAllColumnsShowFocus(TRUE); | 223 | audioView->setAllColumnsShowFocus(TRUE); |
224 | // audioView->setMultiSelection( TRUE ); | 224 | |
225 | // audioView->setSelectionMode( QListView::Extended); | 225 | audioView->setMultiSelection( TRUE ); |
226 | audioView->setSelectionMode( QListView::Extended); | ||
226 | 227 | ||
227 | tabWidget->insertTab(aTab,tr("Audio")); | 228 | tabWidget->insertTab(aTab,tr("Audio")); |
228 | 229 | ||
229 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 230 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
230 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 231 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
231 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 232 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
232 | 233 | ||
233 | 234 | ||
234 | // audioView | 235 | // audioView |
235 | populateAudioView(); | 236 | populateAudioView(); |
236 | // videowidget | 237 | // videowidget |
237 | 238 | ||
238 | QWidget *vTab; | 239 | QWidget *vTab; |
239 | vTab = new QWidget( tabWidget, "vTab" ); | 240 | vTab = new QWidget( tabWidget, "vTab" ); |
240 | videoView = new QListView( vTab, "Videoview" ); | 241 | videoView = new QListView( vTab, "Videoview" ); |
241 | videoView->setMinimumSize(233,260); | 242 | videoView->setMinimumSize(233,260); |
242 | 243 | ||
243 | videoView->addColumn(tr("Title"),140); | 244 | videoView->addColumn(tr("Title"),140); |
244 | videoView->addColumn(tr("Size"),-1); | 245 | videoView->addColumn(tr("Size"),-1); |
245 | videoView->addColumn(tr("Media"),-1); | 246 | videoView->addColumn(tr("Media"),-1); |
246 | videoView->setColumnAlignment(1, Qt::AlignRight); | 247 | videoView->setColumnAlignment(1, Qt::AlignRight); |
247 | videoView->setColumnAlignment(2, Qt::AlignRight); | 248 | videoView->setColumnAlignment(2, Qt::AlignRight); |
248 | videoView->setAllColumnsShowFocus(TRUE); | 249 | videoView->setAllColumnsShowFocus(TRUE); |
249 | // videoView->setMultiSelection( TRUE ); | 250 | videoView->setMultiSelection( TRUE ); |
250 | // videoView->setSelectionMode( QListView::Extended); | 251 | videoView->setSelectionMode( QListView::Extended); |
251 | 252 | ||
252 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 253 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
253 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
254 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
255 | 256 | ||
256 | tabWidget->insertTab( vTab,tr("Video")); | 257 | tabWidget->insertTab( vTab,tr("Video")); |
257 | populateVideoView(); | 258 | populateVideoView(); |
258 | 259 | ||
259 | //playlists list | 260 | //playlists list |
260 | QWidget *LTab; | 261 | QWidget *LTab; |
261 | LTab = new QWidget( tabWidget, "LTab" ); | 262 | LTab = new QWidget( tabWidget, "LTab" ); |
262 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 263 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
263 | playLists->setMinimumSize(233,260);; | 264 | playLists->setMinimumSize(233,260);; |
264 | tabWidget->insertTab(LTab,tr("Lists")); | 265 | tabWidget->insertTab(LTab,tr("Lists")); |
265 | 266 | ||
266 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 267 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
267 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 268 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
268 | 269 | ||
269 | 270 | ||
270 | // add the library area | 271 | // add the library area |
271 | 272 | ||
272 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 273 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
273 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 274 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
274 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 275 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
275 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 276 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
276 | 277 | ||
277 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 278 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
278 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 279 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
279 | 280 | ||
280 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 281 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
281 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 282 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
282 | 283 | ||
283 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 284 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
284 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 285 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
285 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 286 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
286 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 287 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
287 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 288 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
288 | 289 | ||
289 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 290 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
290 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 291 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
291 | 292 | ||
292 | setCentralWidget( vbox5 ); | 293 | setCentralWidget( vbox5 ); |
293 | 294 | ||
294 | Config cfg( "OpiePlayer" ); | 295 | Config cfg( "OpiePlayer" ); |
295 | readConfig( cfg ); | 296 | readConfig( cfg ); |
296 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 297 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
297 | // qDebug("currentList is "+currentPlaylist); | 298 | // qDebug("currentList is "+currentPlaylist); |
298 | loadList(DocLnk( currentPlaylist)); | 299 | loadList(DocLnk( currentPlaylist)); |
299 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 300 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
300 | 301 | ||
301 | initializeStates(); | 302 | initializeStates(); |
302 | } | 303 | } |
303 | 304 | ||
304 | 305 | ||
305 | PlayListWidget::~PlayListWidget() { | 306 | PlayListWidget::~PlayListWidget() { |
306 | Config cfg( "OpiePlayer" ); | 307 | Config cfg( "OpiePlayer" ); |
307 | writeConfig( cfg ); | 308 | writeConfig( cfg ); |
308 | 309 | ||
309 | 310 | ||
310 | if ( d->current ) | 311 | if ( d->current ) |
311 | delete d->current; | 312 | delete d->current; |
312 | delete d; | 313 | delete d; |
313 | } | 314 | } |
314 | 315 | ||
315 | 316 | ||
316 | void PlayListWidget::initializeStates() { | 317 | void PlayListWidget::initializeStates() { |
317 | 318 | ||
318 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 319 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
319 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 320 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
320 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 321 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
321 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 322 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
322 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 323 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
323 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 324 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
324 | // setPlaylist( mediaPlayerState->playlist() ); | 325 | // setPlaylist( mediaPlayerState->playlist() ); |
325 | setPlaylist( true); | 326 | setPlaylist( true); |
326 | // d->selectedFiles->first(); | 327 | // d->selectedFiles->first(); |
327 | 328 | ||
328 | } | 329 | } |
329 | 330 | ||
330 | 331 | ||
331 | void PlayListWidget::readConfig( Config& cfg ) { | 332 | void PlayListWidget::readConfig( Config& cfg ) { |
332 | cfg.setGroup("PlayList"); | 333 | cfg.setGroup("PlayList"); |
333 | QString currentString = cfg.readEntry("current", "" ); | 334 | QString currentString = cfg.readEntry("current", "" ); |
334 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 335 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
335 | for ( int i = 0; i < noOfFiles; i++ ) { | 336 | for ( int i = 0; i < noOfFiles; i++ ) { |
336 | QString entryName; | 337 | QString entryName; |
337 | entryName.sprintf( "File%i", i + 1 ); | 338 | entryName.sprintf( "File%i", i + 1 ); |
338 | QString linkFile = cfg.readEntry( entryName ); | 339 | QString linkFile = cfg.readEntry( entryName ); |
339 | DocLnk lnk( linkFile ); | 340 | DocLnk lnk( linkFile ); |
340 | if ( lnk.isValid() ) { | 341 | if ( lnk.isValid() ) { |
341 | d->selectedFiles->addToSelection( lnk ); | 342 | d->selectedFiles->addToSelection( lnk ); |
342 | } | 343 | } |
343 | } | 344 | } |
344 | d->selectedFiles->setSelectedItem( currentString); | 345 | d->selectedFiles->setSelectedItem( currentString); |
345 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 346 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
346 | } | 347 | } |
347 | 348 | ||
348 | 349 | ||
349 | void PlayListWidget::writeConfig( Config& cfg ) const { | 350 | void PlayListWidget::writeConfig( Config& cfg ) const { |
350 | 351 | ||
351 | d->selectedFiles->writeCurrent( cfg); | 352 | d->selectedFiles->writeCurrent( cfg); |
352 | cfg.setGroup("PlayList"); | 353 | cfg.setGroup("PlayList"); |
353 | int noOfFiles = 0; | 354 | int noOfFiles = 0; |
354 | d->selectedFiles->first(); | 355 | d->selectedFiles->first(); |
355 | do { | 356 | do { |
356 | const DocLnk *lnk = d->selectedFiles->current(); | 357 | const DocLnk *lnk = d->selectedFiles->current(); |
357 | if ( lnk ) { | 358 | if ( lnk ) { |
358 | QString entryName; | 359 | QString entryName; |
359 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 360 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
360 | // qDebug(entryName); | 361 | // qDebug(entryName); |
361 | cfg.writeEntry( entryName, lnk->linkFile() ); | 362 | cfg.writeEntry( entryName, lnk->linkFile() ); |
362 | // if this link does exist, add it so we have the file | 363 | // if this link does exist, add it so we have the file |
363 | // next time... | 364 | // next time... |
364 | if ( !QFile::exists( lnk->linkFile() ) ) { | 365 | if ( !QFile::exists( lnk->linkFile() ) ) { |
365 | // the way writing lnks doesn't really check for out | 366 | // the way writing lnks doesn't really check for out |
366 | // of disk space, but check it anyway. | 367 | // of disk space, but check it anyway. |
367 | if ( !lnk->writeLink() ) { | 368 | if ( !lnk->writeLink() ) { |
368 | QMessageBox::critical( 0, tr("Out of space"), | 369 | QMessageBox::critical( 0, tr("Out of space"), |
369 | tr( "There was a problem saving " | 370 | tr( "There was a problem saving " |
370 | "the playlist.\n" | 371 | "the playlist.\n" |
371 | "Your playlist " | 372 | "Your playlist " |
372 | "may be missing some entries\n" | 373 | "may be missing some entries\n" |
373 | "the next time you start it." ) | 374 | "the next time you start it." ) |
374 | ); | 375 | ); |
375 | } | 376 | } |
376 | } | 377 | } |
377 | noOfFiles++; | 378 | noOfFiles++; |
378 | } | 379 | } |
379 | } | 380 | } |
380 | while ( d->selectedFiles->next() ); | 381 | while ( d->selectedFiles->next() ); |
381 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 382 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
382 | } | 383 | } |
383 | 384 | ||
384 | 385 | ||
385 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 386 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
386 | // qDebug("add"); | 387 | // qDebug("add"); |
387 | d->setDocumentUsed = FALSE; | 388 | d->setDocumentUsed = FALSE; |
388 | if ( mediaPlayerState->playlist() ) | 389 | if ( mediaPlayerState->playlist() ) |
389 | d->selectedFiles->addToSelection( lnk ); | 390 | d->selectedFiles->addToSelection( lnk ); |
390 | else | 391 | else |
391 | mediaPlayerState->setPlaying( TRUE ); | 392 | mediaPlayerState->setPlaying( TRUE ); |
392 | } | 393 | } |
393 | 394 | ||
394 | 395 | ||
395 | void PlayListWidget::clearList() { | 396 | void PlayListWidget::clearList() { |
396 | while ( first() ) | 397 | while ( first() ) |
397 | d->selectedFiles->removeSelected(); | 398 | d->selectedFiles->removeSelected(); |
398 | } | 399 | } |
399 | 400 | ||
400 | 401 | ||
401 | void PlayListWidget::addAllToList() { | 402 | void PlayListWidget::addAllToList() { |
402 | DocLnkSet filesAll; | 403 | DocLnkSet filesAll; |
403 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 404 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
404 | QListIterator<DocLnk> Adit( filesAll.children() ); | 405 | QListIterator<DocLnk> Adit( filesAll.children() ); |
405 | for ( ; Adit.current(); ++Adit ) | 406 | for ( ; Adit.current(); ++Adit ) |
406 | d->selectedFiles->addToSelection( **Adit ); | 407 | d->selectedFiles->addToSelection( **Adit ); |
407 | } | 408 | } |
408 | 409 | ||
409 | 410 | ||
410 | void PlayListWidget::addAllMusicToList() { | 411 | void PlayListWidget::addAllMusicToList() { |
411 | // DocLnkSet files; | 412 | // DocLnkSet files; |
412 | // Global::findDocuments(&files, "audio/*"); | 413 | // Global::findDocuments(&files, "audio/*"); |
413 | QListIterator<DocLnk> dit( files.children() ); | 414 | QListIterator<DocLnk> dit( files.children() ); |
414 | for ( ; dit.current(); ++dit ) | 415 | for ( ; dit.current(); ++dit ) |
415 | d->selectedFiles->addToSelection( **dit ); | 416 | d->selectedFiles->addToSelection( **dit ); |
416 | } | 417 | } |
417 | 418 | ||
418 | 419 | ||
419 | void PlayListWidget::addAllVideoToList() { | 420 | void PlayListWidget::addAllVideoToList() { |
420 | QListIterator<DocLnk> dit( vFiles.children() ); | 421 | QListIterator<DocLnk> dit( vFiles.children() ); |
421 | for ( ; dit.current(); ++dit ) | 422 | for ( ; dit.current(); ++dit ) |
422 | d->selectedFiles->addToSelection( **dit ); | 423 | d->selectedFiles->addToSelection( **dit ); |
423 | } | 424 | } |
424 | 425 | ||
425 | 426 | ||
426 | void PlayListWidget::setDocument(const QString& fileref) { | 427 | void PlayListWidget::setDocument(const QString& fileref) { |
427 | qDebug(fileref); | 428 | qDebug(fileref); |
428 | fromSetDocument = TRUE; | 429 | fromSetDocument = TRUE; |
429 | if ( fileref.isNull() ) { | 430 | if ( fileref.isNull() ) { |
430 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 431 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
431 | return; | 432 | return; |
432 | } | 433 | } |
433 | // qDebug("setDocument "+fileref); | 434 | // qDebug("setDocument "+fileref); |
434 | // if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 435 | // if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
435 | // clearList(); | 436 | // clearList(); |
436 | // addToSelection( DocLnk( fileref ) ); | 437 | // addToSelection( DocLnk( fileref ) ); |
437 | // d->setDocumentUsed = TRUE; | 438 | // d->setDocumentUsed = TRUE; |
438 | // d->selectedFiles->first(); | 439 | // d->selectedFiles->first(); |
439 | // qApp->processEvents(); | 440 | // qApp->processEvents(); |
440 | // } | 441 | // } |
441 | // else | 442 | // else |
442 | if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 443 | if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
443 | clearList(); | 444 | clearList(); |
444 | loadList(DocLnk(fileref)); | 445 | loadList(DocLnk(fileref)); |
445 | d->selectedFiles->first(); | 446 | d->selectedFiles->first(); |
446 | } else { | 447 | } else { |
447 | clearList(); | 448 | clearList(); |
448 | addToSelection( DocLnk( fileref ) ); | 449 | addToSelection( DocLnk( fileref ) ); |
449 | d->setDocumentUsed = TRUE; | 450 | d->setDocumentUsed = TRUE; |
450 | mediaPlayerState->setPlaying( FALSE ); | 451 | mediaPlayerState->setPlaying( FALSE ); |
451 | qApp->processEvents(); | 452 | qApp->processEvents(); |
452 | mediaPlayerState->setPlaying( TRUE ); | 453 | mediaPlayerState->setPlaying( TRUE ); |
453 | qApp->processEvents(); | 454 | qApp->processEvents(); |
454 | setCaption(tr("OpiePlayer")); | 455 | setCaption(tr("OpiePlayer")); |
455 | } | 456 | } |
456 | } | 457 | } |
457 | 458 | ||
458 | 459 | ||
459 | void PlayListWidget::setActiveWindow() { | 460 | void PlayListWidget::setActiveWindow() { |
460 | // When we get raised we need to ensure that it switches views | 461 | // When we get raised we need to ensure that it switches views |
461 | char origView = mediaPlayerState->view(); | 462 | char origView = mediaPlayerState->view(); |
462 | mediaPlayerState->setView( 'l' ); // invalidate | 463 | mediaPlayerState->setView( 'l' ); // invalidate |
463 | mediaPlayerState->setView( origView ); // now switch back | 464 | mediaPlayerState->setView( origView ); // now switch back |
464 | } | 465 | } |
465 | 466 | ||
466 | 467 | ||
467 | void PlayListWidget::useSelectedDocument() { | 468 | void PlayListWidget::useSelectedDocument() { |
468 | d->setDocumentUsed = FALSE; | 469 | d->setDocumentUsed = FALSE; |
469 | } | 470 | } |
470 | 471 | ||
471 | 472 | ||
472 | const DocLnk *PlayListWidget::current() { // this is fugly | 473 | const DocLnk *PlayListWidget::current() { // this is fugly |
473 | 474 | ||
474 | // if( fromSetDocument) { | 475 | // if( fromSetDocument) { |
475 | // qDebug("from setDoc"); | 476 | // qDebug("from setDoc"); |
476 | // DocLnkSet files; | 477 | // DocLnkSet files; |
477 | // Global::findDocuments(&files, "video/*;audio/*"); | 478 | // Global::findDocuments(&files, "video/*;audio/*"); |
478 | // QListIterator<DocLnk> dit( files.children() ); | 479 | // QListIterator<DocLnk> dit( files.children() ); |
479 | // for ( ; dit.current(); ++dit ) { | 480 | // for ( ; dit.current(); ++dit ) { |
480 | // if(dit.current()->linkFile() == setDocFileRef) { | 481 | // if(dit.current()->linkFile() == setDocFileRef) { |
481 | // qDebug(setDocFileRef); | 482 | // qDebug(setDocFileRef); |
482 | // return dit; | 483 | // return dit; |
483 | // } | 484 | // } |
484 | // } | 485 | // } |
485 | // } else | 486 | // } else |
486 | 487 | ||
487 | 488 | ||
488 | switch (tabWidget->currentPageIndex()) { | 489 | switch (tabWidget->currentPageIndex()) { |
489 | case 0: //playlist | 490 | case 0: //playlist |
490 | { | 491 | { |
491 | qDebug("playlist"); | 492 | qDebug("playlist"); |
492 | if ( mediaPlayerState->playlist() ) { | 493 | if ( mediaPlayerState->playlist() ) { |
493 | return d->selectedFiles->current(); | 494 | return d->selectedFiles->current(); |
494 | } | 495 | } |
495 | else if ( d->setDocumentUsed && d->current ) { | 496 | else if ( d->setDocumentUsed && d->current ) { |
496 | return d->current; | 497 | return d->current; |
497 | } else { | 498 | } else { |
498 | return d->files->selected(); | 499 | return d->files->selected(); |
499 | } | 500 | } |
500 | } | 501 | } |
501 | break; | 502 | break; |
502 | case 1://audio | 503 | case 1://audio |
503 | { | 504 | { |
504 | qDebug("audioView"); | 505 | qDebug("audioView"); |
505 | // Global::findDocuments(&files, "audio/*"); | 506 | // Global::findDocuments(&files, "audio/*"); |
506 | QListIterator<DocLnk> dit( files.children() ); | 507 | QListIterator<DocLnk> dit( files.children() ); |
507 | for ( ; dit.current(); ++dit ) { | 508 | for ( ; dit.current(); ++dit ) { |
508 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 509 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
509 | qDebug("here"); | 510 | qDebug("here"); |
510 | insanityBool=TRUE; | 511 | insanityBool=TRUE; |
511 | return dit; | 512 | return dit; |
512 | } | 513 | } |
513 | } | 514 | } |
514 | } | 515 | } |
515 | break; | 516 | break; |
516 | case 2: // video | 517 | case 2: // video |
517 | { | 518 | { |
518 | qDebug("videoView"); | 519 | qDebug("videoView"); |
519 | // Global::findDocuments(&vFiles, "video/*"); | 520 | // Global::findDocuments(&vFiles, "video/*"); |
520 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 521 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
521 | for ( ; Vdit.current(); ++Vdit ) { | 522 | for ( ; Vdit.current(); ++Vdit ) { |
522 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 523 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
523 | insanityBool=TRUE; | 524 | insanityBool=TRUE; |
524 | return Vdit; | 525 | return Vdit; |
525 | } | 526 | } |
526 | } | 527 | } |
527 | } | 528 | } |
528 | break; | 529 | break; |
529 | }; | 530 | }; |
530 | return 0; | 531 | return 0; |
531 | } | 532 | } |
532 | 533 | ||
533 | bool PlayListWidget::prev() { | 534 | bool PlayListWidget::prev() { |
534 | if ( mediaPlayerState->playlist() ) { | 535 | if ( mediaPlayerState->playlist() ) { |
535 | if ( mediaPlayerState->shuffled() ) { | 536 | if ( mediaPlayerState->shuffled() ) { |
536 | const DocLnk *cur = current(); | 537 | const DocLnk *cur = current(); |
537 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 538 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
538 | for ( int i = 0; i < j; i++ ) { | 539 | for ( int i = 0; i < j; i++ ) { |
539 | if ( !d->selectedFiles->next() ) | 540 | if ( !d->selectedFiles->next() ) |
540 | d->selectedFiles->first(); | 541 | d->selectedFiles->first(); |
541 | } | 542 | } |
542 | if ( cur == current() ) | 543 | if ( cur == current() ) |
543 | if ( !d->selectedFiles->next() ) | 544 | if ( !d->selectedFiles->next() ) |
544 | d->selectedFiles->first(); | 545 | d->selectedFiles->first(); |
545 | return TRUE; | 546 | return TRUE; |
546 | } else { | 547 | } else { |
547 | if ( !d->selectedFiles->prev() ) { | 548 | if ( !d->selectedFiles->prev() ) { |
548 | if ( mediaPlayerState->looping() ) { | 549 | if ( mediaPlayerState->looping() ) { |
549 | return d->selectedFiles->last(); | 550 | return d->selectedFiles->last(); |
550 | } else { | 551 | } else { |
551 | return FALSE; | 552 | return FALSE; |
552 | } | 553 | } |
553 | } | 554 | } |
554 | return TRUE; | 555 | return TRUE; |
555 | } | 556 | } |
556 | } else { | 557 | } else { |
557 | return mediaPlayerState->looping(); | 558 | return mediaPlayerState->looping(); |
558 | } | 559 | } |
559 | } | 560 | } |
560 | 561 | ||
561 | 562 | ||
562 | bool PlayListWidget::next() { | 563 | bool PlayListWidget::next() { |
563 | if ( mediaPlayerState->playlist() ) { | 564 | if ( mediaPlayerState->playlist() ) { |
564 | if ( mediaPlayerState->shuffled() ) { | 565 | if ( mediaPlayerState->shuffled() ) { |
565 | return prev(); | 566 | return prev(); |
566 | } else { | 567 | } else { |
567 | if ( !d->selectedFiles->next() ) { | 568 | if ( !d->selectedFiles->next() ) { |
568 | if ( mediaPlayerState->looping() ) { | 569 | if ( mediaPlayerState->looping() ) { |
569 | return d->selectedFiles->first(); | 570 | return d->selectedFiles->first(); |
570 | } else { | 571 | } else { |
571 | return FALSE; | 572 | return FALSE; |
572 | } | 573 | } |
573 | } | 574 | } |
574 | return TRUE; | 575 | return TRUE; |
575 | } | 576 | } |
576 | } else { | 577 | } else { |
577 | return mediaPlayerState->looping(); | 578 | return mediaPlayerState->looping(); |
578 | } | 579 | } |
579 | } | 580 | } |
580 | 581 | ||
581 | 582 | ||
582 | bool PlayListWidget::first() { | 583 | bool PlayListWidget::first() { |
583 | if ( mediaPlayerState->playlist() ) | 584 | if ( mediaPlayerState->playlist() ) |
584 | return d->selectedFiles->first(); | 585 | return d->selectedFiles->first(); |
585 | else | 586 | else |
586 | return mediaPlayerState->looping(); | 587 | return mediaPlayerState->looping(); |
587 | } | 588 | } |
588 | 589 | ||
589 | 590 | ||
590 | bool PlayListWidget::last() { | 591 | bool PlayListWidget::last() { |
591 | if ( mediaPlayerState->playlist() ) | 592 | if ( mediaPlayerState->playlist() ) |
592 | return d->selectedFiles->last(); | 593 | return d->selectedFiles->last(); |
593 | else | 594 | else |
594 | return mediaPlayerState->looping(); | 595 | return mediaPlayerState->looping(); |
595 | } | 596 | } |
596 | 597 | ||
597 | 598 | ||
598 | void PlayListWidget::saveList() { | 599 | void PlayListWidget::saveList() { |
599 | 600 | ||
600 | QString filename; | 601 | QString filename; |
601 | InputDialog *fileDlg; | 602 | InputDialog *fileDlg; |
602 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 603 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
603 | fileDlg->exec(); | 604 | fileDlg->exec(); |
604 | if( fileDlg->result() == 1 ) { | 605 | if( fileDlg->result() == 1 ) { |
605 | if ( d->current ) | 606 | if ( d->current ) |
606 | delete d->current; | 607 | delete d->current; |
607 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 608 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
608 | // qDebug("saving playlist "+filename+".playlist"); | 609 | // qDebug("saving playlist "+filename+".playlist"); |
609 | Config cfg( filename +".playlist"); | 610 | Config cfg( filename +".playlist"); |
610 | writeConfig( cfg ); | 611 | writeConfig( cfg ); |
611 | 612 | ||
612 | // qDebug("same name so delete lnk??"); | 613 | // qDebug("same name so delete lnk??"); |
613 | // if( playLists->selected()->name() == filename) { | 614 | // if( playLists->selected()->name() == filename) { |
614 | 615 | ||
615 | // qDebug("same name so delete lnk"); | 616 | // qDebug("same name so delete lnk"); |
616 | // QFile().remove(playLists->selected()->file()); | 617 | // QFile().remove(playLists->selected()->file()); |
617 | // QFile().remove(playLists->selected()->linkFile()); | 618 | // QFile().remove(playLists->selected()->linkFile()); |
618 | // playLists->reread(); | 619 | // playLists->reread(); |
619 | // } | 620 | // } |
620 | // qDebug("new doclnk"); | 621 | // qDebug("new doclnk"); |
621 | DocLnk lnk; | 622 | DocLnk lnk; |
622 | // lnk.setComment( ""); | 623 | // lnk.setComment( ""); |
623 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 624 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
624 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 625 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
625 | lnk.setIcon("opieplayer/playlist2"); | 626 | lnk.setIcon("opieplayer/playlist2"); |
626 | lnk.setName( filename); //sets file name | 627 | lnk.setName( filename); //sets file name |
627 | // qDebug(filename); | 628 | // qDebug(filename); |
628 | if(!lnk.writeLink()) | 629 | if(!lnk.writeLink()) |
629 | qDebug("Writing doclink did not work"); | 630 | qDebug("Writing doclink did not work"); |
630 | } | 631 | } |
631 | Config config( "OpiePlayer" ); | 632 | Config config( "OpiePlayer" ); |
632 | config.writeEntry("CurrentPlaylist",filename); | 633 | config.writeEntry("CurrentPlaylist",filename); |
633 | setCaption(tr("OpiePlayer: ")+filename); | 634 | setCaption(tr("OpiePlayer: ")+filename); |
634 | d->selectedFiles->first(); | 635 | d->selectedFiles->first(); |
635 | if(fileDlg) | 636 | if(fileDlg) |
636 | delete fileDlg; | 637 | delete fileDlg; |
637 | } | 638 | } |
638 | 639 | ||
639 | void PlayListWidget::loadList( const DocLnk & lnk) { | 640 | void PlayListWidget::loadList( const DocLnk & lnk) { |
640 | QString name= lnk.name(); | 641 | QString name= lnk.name(); |
641 | // qDebug("currentList is "+name); | 642 | // qDebug("currentList is "+name); |
642 | if( name.length()>1) { | 643 | if( name.length()>1) { |
643 | setCaption("OpiePlayer: "+name); | 644 | setCaption("OpiePlayer: "+name); |
644 | // qDebug("load list "+ name+".playlist"); | 645 | // qDebug("load list "+ name+".playlist"); |
645 | clearList(); | 646 | clearList(); |
646 | Config cfg( name+".playlist"); | 647 | Config cfg( name+".playlist"); |
647 | readConfig(cfg); | 648 | readConfig(cfg); |
648 | 649 | ||
649 | tabWidget->setCurrentPage(0); | 650 | tabWidget->setCurrentPage(0); |
650 | 651 | ||
651 | Config config( "OpiePlayer" ); | 652 | Config config( "OpiePlayer" ); |
652 | config.writeEntry("CurrentPlaylist", name); | 653 | config.writeEntry("CurrentPlaylist", name); |
653 | // d->selectedFiles->first(); | 654 | // d->selectedFiles->first(); |
654 | } | 655 | } |
655 | 656 | ||
656 | } | 657 | } |
657 | 658 | ||
658 | void PlayListWidget::setPlaylist( bool shown ) { | 659 | void PlayListWidget::setPlaylist( bool shown ) { |
659 | if ( shown ) | 660 | if ( shown ) |
660 | d->playListFrame->show(); | 661 | d->playListFrame->show(); |
661 | else | 662 | else |
662 | d->playListFrame->hide(); | 663 | d->playListFrame->hide(); |
663 | } | 664 | } |
664 | 665 | ||
665 | void PlayListWidget::setView( char view ) { | 666 | void PlayListWidget::setView( char view ) { |
666 | if ( view == 'l' ) | 667 | if ( view == 'l' ) |
667 | showMaximized(); | 668 | showMaximized(); |
668 | else | 669 | else |
669 | hide(); | 670 | hide(); |
670 | } | 671 | } |
671 | 672 | ||
672 | void PlayListWidget::addSelected() { | 673 | void PlayListWidget::addSelected() { |
673 | 674 | ||
674 | Config cfg( "OpiePlayer" ); | 675 | Config cfg( "OpiePlayer" ); |
675 | cfg.setGroup("PlayList"); | 676 | cfg.setGroup("PlayList"); |
676 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 677 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
677 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 678 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
678 | 679 | ||
679 | switch (tabWidget->currentPageIndex()) { | 680 | switch (tabWidget->currentPageIndex()) { |
680 | case 0: //playlist | 681 | case 0: //playlist |
681 | break; | 682 | break; |
682 | case 1: { //audio | 683 | case 1: { //audio |
683 | for ( int i = 0; i < noOfFiles; i++ ) { | 684 | // QString entryName; |
684 | QString entryName; | 685 | // entryName.sprintf( "File%i", i + 1 ); |
685 | entryName.sprintf( "File%i", i + 1 ); | 686 | // QString linkFile = cfg.readEntry( entryName ); |
686 | QString linkFile = cfg.readEntry( entryName ); | 687 | QListViewItemIterator it( audioView ); |
687 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 688 | // iterate through all items of the listview |
688 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 689 | for ( ; it.current(); ++it ) { |
689 | tr("This is all ready in your playlist.\nContinue?"), | 690 | if ( it.current()->isSelected() ) { |
690 | tr("Yes"),tr("No"),0,0,1); | 691 | QListIterator<DocLnk> dit( files.children() ); |
691 | if (result !=0) | 692 | for ( ; dit.current(); ++dit ) { |
692 | return; | 693 | if( dit.current()->name() == it.current()->text(0) ) { |
693 | } | 694 | d->selectedFiles->addToSelection( **dit ); |
695 | } | ||
696 | } | ||
697 | audioView->setSelected( it.current(),FALSE); | ||
698 | } | ||
694 | } | 699 | } |
695 | addToSelection( audioView->selectedItem() ); | 700 | tabWidget->setCurrentPage(0); |
696 | tabWidget->setCurrentPage(1); | ||
697 | } | 701 | } |
698 | break; | 702 | break; |
699 | case 2: { // video | 703 | case 2: { // video |
700 | for ( int i = 0; i < noOfFiles; i++ ) { | 704 | QListViewItemIterator it( videoView ); |
701 | QString entryName; | 705 | // iterate through all items of the listview |
702 | entryName.sprintf( "File%i", i + 1 ); | 706 | for ( ; it.current(); ++it ) { |
703 | QString linkFile = cfg.readEntry( entryName ); | 707 | if ( it.current()->isSelected() ) { |
704 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 708 | QListIterator<DocLnk> dit( vFiles.children() ); |
705 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 709 | for ( ; dit.current(); ++dit ) { |
706 | tr("This is all ready in your playlist.\nContinue?"), | 710 | if( dit.current()->name() == it.current()->text(0) ) { |
707 | tr("Yes"),tr("No"),0,0,1); | 711 | d->selectedFiles->addToSelection( **dit ); |
708 | if (result !=0) | 712 | } |
709 | return; | 713 | } |
710 | } | 714 | |
715 | videoView->setSelected( it.current(),FALSE); | ||
716 | } | ||
711 | } | 717 | } |
712 | addToSelection( videoView->selectedItem() ); | 718 | // for ( int i = 0; i < noOfFiles; i++ ) { |
713 | tabWidget->setCurrentPage(2); | 719 | // QString entryName; |
720 | // entryName.sprintf( "File%i", i + 1 ); | ||
721 | // QString linkFile = cfg.readEntry( entryName ); | ||
722 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | ||
723 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | ||
724 | // tr("This is all ready in your playlist.\nContinue?"), | ||
725 | // tr("Yes"),tr("No"),0,0,1); | ||
726 | // if (result !=0) | ||
727 | // return; | ||
728 | // } | ||
729 | // } | ||
730 | // addToSelection( videoView->selectedItem() ); | ||
731 | tabWidget->setCurrentPage(0); | ||
714 | } | 732 | } |
715 | break; | 733 | break; |
716 | }; | 734 | }; |
717 | } | 735 | } |
718 | 736 | ||
719 | void PlayListWidget::removeSelected() { | 737 | void PlayListWidget::removeSelected() { |
720 | d->selectedFiles->removeSelected( ); | 738 | d->selectedFiles->removeSelected( ); |
721 | } | 739 | } |
722 | 740 | ||
723 | void PlayListWidget::playIt( QListViewItem *it) { | 741 | void PlayListWidget::playIt( QListViewItem *it) { |
724 | // d->setDocumentUsed = FALSE; | 742 | // d->setDocumentUsed = FALSE; |
725 | mediaPlayerState->setPlaying(TRUE); | 743 | mediaPlayerState->setPlaying(TRUE); |
726 | } | 744 | } |
727 | 745 | ||
728 | void PlayListWidget::addToSelection( QListViewItem *it) { | 746 | void PlayListWidget::addToSelection( QListViewItem *it) { |
729 | d->setDocumentUsed = FALSE; | 747 | d->setDocumentUsed = FALSE; |
730 | 748 | ||
731 | if(it) { | 749 | if(it) { |
732 | switch (tabWidget->currentPageIndex()) { | 750 | switch (tabWidget->currentPageIndex()) { |
733 | case 1: { | 751 | case 1: { |
734 | QListIterator<DocLnk> dit( files.children() ); | 752 | QListIterator<DocLnk> dit( files.children() ); |
735 | for ( ; dit.current(); ++dit ) { | 753 | for ( ; dit.current(); ++dit ) { |
736 | if( dit.current()->name() == it->text(0)) { | 754 | if( dit.current()->name() == it->text(0)) { |
737 | d->selectedFiles->addToSelection( **dit ); | 755 | d->selectedFiles->addToSelection( **dit ); |
738 | } | 756 | } |
739 | } | 757 | } |
740 | } | 758 | } |
741 | break; | 759 | break; |
742 | case 2: { | 760 | case 2: { |
743 | QListIterator<DocLnk> dit( vFiles.children() ); | 761 | QListIterator<DocLnk> dit( vFiles.children() ); |
744 | for ( ; dit.current(); ++dit ) { | 762 | for ( ; dit.current(); ++dit ) { |
745 | if( dit.current()->name() == it->text(0)) { | 763 | if( dit.current()->name() == it->text(0)) { |
746 | d->selectedFiles->addToSelection( **dit ); | 764 | d->selectedFiles->addToSelection( **dit ); |
747 | } | 765 | } |
748 | } | 766 | } |
749 | } | 767 | } |
750 | break; | 768 | break; |
751 | case 0: | 769 | case 0: |
752 | break; | 770 | break; |
753 | }; | 771 | }; |
754 | tabWidget->setCurrentPage(0); | 772 | tabWidget->setCurrentPage(0); |
755 | } | 773 | } |
756 | } | 774 | } |
757 | 775 | ||
758 | void PlayListWidget::tabChanged(QWidget *widg) { | 776 | void PlayListWidget::tabChanged(QWidget *widg) { |
759 | 777 | ||
760 | switch ( tabWidget->currentPageIndex()) { | 778 | switch ( tabWidget->currentPageIndex()) { |
761 | case 0: | 779 | case 0: |
762 | { | 780 | { |
763 | if( !tbDeletePlaylist->isHidden()) | 781 | if( !tbDeletePlaylist->isHidden()) |
764 | tbDeletePlaylist->hide(); | 782 | tbDeletePlaylist->hide(); |
765 | d->tbRemoveFromList->setEnabled(TRUE); | 783 | d->tbRemoveFromList->setEnabled(TRUE); |
766 | d->tbAddToList->setEnabled(FALSE); | 784 | d->tbAddToList->setEnabled(FALSE); |
767 | } | 785 | } |
768 | break; | 786 | break; |
769 | case 1: | 787 | case 1: |
770 | { | 788 | { |
771 | if( !tbDeletePlaylist->isHidden()) | 789 | if( !tbDeletePlaylist->isHidden()) |
772 | tbDeletePlaylist->hide(); | 790 | tbDeletePlaylist->hide(); |
773 | d->tbRemoveFromList->setEnabled(FALSE); | 791 | d->tbRemoveFromList->setEnabled(FALSE); |
774 | d->tbAddToList->setEnabled(TRUE); | 792 | d->tbAddToList->setEnabled(TRUE); |
775 | } | 793 | } |
776 | break; | 794 | break; |
777 | case 2: | 795 | case 2: |
778 | { | 796 | { |
779 | if( !tbDeletePlaylist->isHidden()) | 797 | if( !tbDeletePlaylist->isHidden()) |
780 | tbDeletePlaylist->hide(); | 798 | tbDeletePlaylist->hide(); |
781 | d->tbRemoveFromList->setEnabled(FALSE); | 799 | d->tbRemoveFromList->setEnabled(FALSE); |
782 | d->tbAddToList->setEnabled(TRUE); | 800 | d->tbAddToList->setEnabled(TRUE); |
783 | } | 801 | } |
784 | break; | 802 | break; |
785 | case 3: | 803 | case 3: |
786 | { | 804 | { |
787 | if( tbDeletePlaylist->isHidden()) | 805 | if( tbDeletePlaylist->isHidden()) |
788 | tbDeletePlaylist->show(); | 806 | tbDeletePlaylist->show(); |
789 | playLists->reread(); | 807 | playLists->reread(); |
790 | } | 808 | } |
791 | break; | 809 | break; |
792 | }; | 810 | }; |
793 | } | 811 | } |
794 | 812 | ||
795 | 813 | ||
796 | 814 | ||
797 | void PlayListWidget::btnPlay(bool b) { | 815 | void PlayListWidget::btnPlay(bool b) { |
798 | 816 | ||
799 | // mediaPlayerState->setPlaying(b); | 817 | // mediaPlayerState->setPlaying(b); |
800 | switch ( tabWidget->currentPageIndex()) { | 818 | switch ( tabWidget->currentPageIndex()) { |
801 | case 0: | 819 | case 0: |
802 | { | 820 | { |
803 | mediaPlayerState->setPlaying(b); | 821 | mediaPlayerState->setPlaying(b); |
804 | } | 822 | } |
805 | break; | 823 | break; |
806 | case 1: | 824 | case 1: |
807 | { | 825 | { |
808 | addToSelection( audioView->selectedItem() ); | 826 | addToSelection( audioView->selectedItem() ); |
809 | mediaPlayerState->setPlaying(b); | 827 | mediaPlayerState->setPlaying(b); |
810 | d->selectedFiles->removeSelected( ); | 828 | d->selectedFiles->removeSelected( ); |
811 | tabWidget->setCurrentPage(1); | 829 | tabWidget->setCurrentPage(1); |
812 | d->selectedFiles->unSelect(); | 830 | d->selectedFiles->unSelect(); |
813 | // audioView->clearSelection(); | 831 | // audioView->clearSelection(); |
814 | } | 832 | } |
815 | break; | 833 | break; |
816 | case 2: | 834 | case 2: |
817 | { | 835 | { |
818 | addToSelection( videoView->selectedItem() ); | 836 | addToSelection( videoView->selectedItem() ); |
819 | mediaPlayerState->setPlaying(b); | 837 | mediaPlayerState->setPlaying(b); |
820 | qApp->processEvents(); | 838 | qApp->processEvents(); |
821 | d->selectedFiles->removeSelected( ); | 839 | d->selectedFiles->removeSelected( ); |
822 | tabWidget->setCurrentPage(2); | 840 | tabWidget->setCurrentPage(2); |
823 | d->selectedFiles->unSelect(); | 841 | d->selectedFiles->unSelect(); |
824 | // videoView->clearSelection(); | 842 | // videoView->clearSelection(); |
825 | } | 843 | } |
826 | break; | 844 | break; |
827 | }; | 845 | }; |
828 | } | 846 | } |
829 | 847 | ||
830 | void PlayListWidget::deletePlaylist() { | 848 | void PlayListWidget::deletePlaylist() { |
831 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 849 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
832 | (tr("You really want to delete\nthis playlist?")), | 850 | (tr("You really want to delete\nthis playlist?")), |
833 | (tr("Yes")), (tr("No")), 0 )){ | 851 | (tr("Yes")), (tr("No")), 0 )){ |
834 | case 0: // Yes clicked, | 852 | case 0: // Yes clicked, |
835 | QFile().remove(playLists->selected()->file()); | 853 | QFile().remove(playLists->selected()->file()); |
836 | QFile().remove(playLists->selected()->linkFile()); | 854 | QFile().remove(playLists->selected()->linkFile()); |
837 | playLists->reread(); | 855 | playLists->reread(); |
838 | break; | 856 | break; |
839 | case 1: // Cancel | 857 | case 1: // Cancel |
840 | break; | 858 | break; |
841 | }; | 859 | }; |
842 | 860 | ||
843 | } | 861 | } |
844 | 862 | ||
845 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 863 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
846 | { | 864 | { |
847 | switch (mouse) { | 865 | switch (mouse) { |
848 | case 1: | 866 | case 1: |
849 | break; | 867 | break; |
850 | case 2:{ | 868 | case 2:{ |
851 | QPopupMenu m; | 869 | QPopupMenu m; |
852 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 870 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
853 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 871 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
854 | m.insertSeparator(); | 872 | m.insertSeparator(); |
855 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 873 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
856 | m.exec( QCursor::pos() ); | 874 | m.exec( QCursor::pos() ); |
857 | } | 875 | } |
858 | break; | 876 | break; |
859 | }; | 877 | }; |
860 | } | 878 | } |
861 | 879 | ||
862 | void PlayListWidget::playSelected() | 880 | void PlayListWidget::playSelected() |
863 | { | 881 | { |
864 | btnPlay( TRUE); | 882 | btnPlay( TRUE); |
865 | } | 883 | } |
866 | 884 | ||
867 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 885 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
868 | { | 886 | { |
869 | switch (mouse) { | 887 | switch (mouse) { |
870 | case 1: | 888 | case 1: |
871 | break; | 889 | break; |
872 | case 2:{ | 890 | case 2:{ |
873 | QPopupMenu m; | 891 | QPopupMenu m; |
874 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 892 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
875 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 893 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
876 | // m.insertSeparator(); | 894 | // m.insertSeparator(); |
877 | m.exec( QCursor::pos() ); | 895 | m.exec( QCursor::pos() ); |
878 | } | 896 | } |
879 | break; | 897 | break; |
880 | }; | 898 | }; |
881 | 899 | ||
882 | } | 900 | } |
883 | 901 | ||
884 | void PlayListWidget::listDelete() { | 902 | void PlayListWidget::listDelete() { |
885 | Config cfg( "OpiePlayer" ); | 903 | Config cfg( "OpiePlayer" ); |
886 | cfg.setGroup("PlayList"); | 904 | cfg.setGroup("PlayList"); |
887 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 905 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
888 | QString file; | 906 | QString file; |
889 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 907 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
890 | switch ( tabWidget->currentPageIndex()) { | 908 | switch ( tabWidget->currentPageIndex()) { |
891 | case 0: | 909 | case 0: |
892 | break; | 910 | break; |
893 | case 1: | 911 | case 1: |
894 | { | 912 | { |
895 | file = audioView->selectedItem()->text(0); | 913 | file = audioView->selectedItem()->text(0); |
896 | // Global::findDocuments(&files, "audio/*"); | 914 | // Global::findDocuments(&files, "audio/*"); |
897 | // AppLnkSet appFiles; | 915 | // AppLnkSet appFiles; |
898 | QListIterator<DocLnk> dit( files.children() ); | 916 | QListIterator<DocLnk> dit( files.children() ); |
899 | for ( ; dit.current(); ++dit ) { | 917 | for ( ; dit.current(); ++dit ) { |
900 | if( dit.current()->name() == file) { | 918 | if( dit.current()->name() == file) { |
901 | // qDebug(file); | 919 | // qDebug(file); |
902 | LnkProperties prop( dit.current() ); | 920 | LnkProperties prop( dit.current() ); |
903 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 921 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
904 | prop.showMaximized(); | 922 | prop.showMaximized(); |
905 | prop.exec(); | 923 | prop.exec(); |
906 | } | 924 | } |
907 | } | 925 | } |
908 | populateAudioView(); | 926 | populateAudioView(); |
909 | } | 927 | } |
910 | break; | 928 | break; |
911 | case 2: | 929 | case 2: |
912 | { | 930 | { |
913 | // file = videoView->selectedItem()->text(0); | 931 | // file = videoView->selectedItem()->text(0); |
914 | // for ( int i = 0; i < noOfFiles; i++ ) { | 932 | // for ( int i = 0; i < noOfFiles; i++ ) { |
915 | // QString entryName; | 933 | // QString entryName; |
916 | // entryName.sprintf( "File%i", i + 1 ); | 934 | // entryName.sprintf( "File%i", i + 1 ); |
917 | // QString linkFile = cfg.readEntry( entryName ); | 935 | // QString linkFile = cfg.readEntry( entryName ); |
918 | // AppLnk lnk( AppLnk(linkFile)); | 936 | // AppLnk lnk( AppLnk(linkFile)); |
919 | // if( lnk.name() == file ) { | 937 | // if( lnk.name() == file ) { |
920 | // LnkProperties prop( &lnk); | 938 | // LnkProperties prop( &lnk); |
921 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 939 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
922 | // prop.showMaximized(); | 940 | // prop.showMaximized(); |
923 | // prop.exec(); | 941 | // prop.exec(); |
924 | // } | 942 | // } |
925 | // } | 943 | // } |
926 | } | 944 | } |
927 | break; | 945 | break; |
928 | }; | 946 | }; |
929 | } | 947 | } |
930 | 948 | ||
931 | void PlayListWidget::populateAudioView() { | 949 | void PlayListWidget::populateAudioView() { |
932 | // if(files) | 950 | // if(files) |
933 | // files.~DocLnkSet(); | 951 | // files.~DocLnkSet(); |
934 | StorageInfo storageInfo; | 952 | StorageInfo storageInfo; |
935 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 953 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
936 | 954 | ||
937 | Global::findDocuments(&files, "audio/*"); | 955 | Global::findDocuments(&files, "audio/*"); |
938 | QListIterator<DocLnk> dit( files.children() ); | 956 | QListIterator<DocLnk> dit( files.children() ); |
939 | QListIterator<FileSystem> it ( fs ); | 957 | QListIterator<FileSystem> it ( fs ); |
940 | audioView->clear(); | 958 | audioView->clear(); |
941 | QString storage; | 959 | QString storage; |
942 | for ( ; dit.current(); ++dit ) { | 960 | for ( ; dit.current(); ++dit ) { |
943 | for( ; it.current(); ++it ){ | 961 | for( ; it.current(); ++it ){ |
944 | const QString name = (*it)->name(); | 962 | const QString name = (*it)->name(); |
945 | const QString path = (*it)->path(); | 963 | const QString path = (*it)->path(); |
946 | if(dit.current()->file().find(path) != -1 ) storage=name; | 964 | if(dit.current()->file().find(path) != -1 ) storage=name; |
947 | } | 965 | } |
948 | 966 | ||
949 | QListViewItem * newItem; | 967 | QListViewItem * newItem; |
950 | if ( QFile( dit.current()->file()).exists() ) { | 968 | if ( QFile( dit.current()->file()).exists() ) { |
951 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 969 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
952 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 970 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
953 | } | 971 | } |
954 | } | 972 | } |
955 | } | 973 | } |
956 | 974 | ||
957 | void PlayListWidget::populateVideoView() { | 975 | void PlayListWidget::populateVideoView() { |
958 | StorageInfo storageInfo; | 976 | StorageInfo storageInfo; |
959 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 977 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
960 | 978 | ||
961 | Global::findDocuments(&vFiles, "video/*"); | 979 | Global::findDocuments(&vFiles, "video/*"); |
962 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 980 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
963 | QListIterator<FileSystem> it ( fs ); | 981 | QListIterator<FileSystem> it ( fs ); |
964 | videoView->clear(); | 982 | videoView->clear(); |
965 | QString storage; | 983 | QString storage; |
966 | for ( ; Vdit.current(); ++Vdit ) { | 984 | for ( ; Vdit.current(); ++Vdit ) { |
967 | for( ; it.current(); ++it ){ | 985 | for( ; it.current(); ++it ){ |
968 | const QString name = (*it)->name(); | 986 | const QString name = (*it)->name(); |
969 | const QString path = (*it)->path(); | 987 | const QString path = (*it)->path(); |