Changeset View
Changeset View
Standalone View
Standalone View
src/databaseinterface.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 352 Lines • ▼ Show 20 Line(s) | 343 | { | |||
---|---|---|---|---|---|
353 | transactionResult = finishTransaction(); | 353 | transactionResult = finishTransaction(); | ||
354 | if (!transactionResult) { | 354 | if (!transactionResult) { | ||
355 | return result; | 355 | return result; | ||
356 | } | 356 | } | ||
357 | 357 | | |||
358 | return result; | 358 | return result; | ||
359 | } | 359 | } | ||
360 | 360 | | |||
361 | DatabaseInterface::ListTrackDataType DatabaseInterface::allTracksData() | 361 | DataTypes::ListTrackDataType DatabaseInterface::allTracksData() | ||
362 | { | 362 | { | ||
363 | auto result = ListTrackDataType{}; | 363 | auto result = DataTypes::ListTrackDataType{}; | ||
364 | 364 | | |||
365 | if (!d) { | 365 | if (!d) { | ||
366 | return result; | 366 | return result; | ||
367 | } | 367 | } | ||
368 | 368 | | |||
369 | auto transactionResult = startTransaction(); | 369 | auto transactionResult = startTransaction(); | ||
370 | if (!transactionResult) { | 370 | if (!transactionResult) { | ||
371 | return result; | 371 | return result; | ||
372 | } | 372 | } | ||
373 | 373 | | |||
374 | result = internalAllTracksPartialData(); | 374 | result = internalAllTracksPartialData(); | ||
375 | 375 | | |||
376 | transactionResult = finishTransaction(); | 376 | transactionResult = finishTransaction(); | ||
377 | if (!transactionResult) { | 377 | if (!transactionResult) { | ||
378 | return result; | 378 | return result; | ||
379 | } | 379 | } | ||
380 | 380 | | |||
381 | return result; | 381 | return result; | ||
382 | } | 382 | } | ||
383 | 383 | | |||
384 | DatabaseInterface::ListRadioDataType DatabaseInterface::allRadiosData() | 384 | DataTypes::ListRadioDataType DatabaseInterface::allRadiosData() | ||
385 | { | 385 | { | ||
386 | auto result = ListRadioDataType{}; | 386 | auto result = DataTypes::ListRadioDataType{}; | ||
387 | 387 | | |||
388 | if (!d) { | 388 | if (!d) { | ||
389 | return result; | 389 | return result; | ||
390 | } | 390 | } | ||
391 | 391 | | |||
392 | auto transactionResult = startTransaction(); | 392 | auto transactionResult = startTransaction(); | ||
393 | if (!transactionResult) { | 393 | if (!transactionResult) { | ||
394 | return result; | 394 | return result; | ||
395 | } | 395 | } | ||
396 | 396 | | |||
397 | result = internalAllRadiosPartialData(); | 397 | result = internalAllRadiosPartialData(); | ||
398 | 398 | | |||
399 | transactionResult = finishTransaction(); | 399 | transactionResult = finishTransaction(); | ||
400 | if (!transactionResult) { | 400 | if (!transactionResult) { | ||
401 | return result; | 401 | return result; | ||
402 | } | 402 | } | ||
403 | 403 | | |||
404 | return result; | 404 | return result; | ||
405 | } | 405 | } | ||
406 | 406 | | |||
407 | DatabaseInterface::ListTrackDataType DatabaseInterface::recentlyPlayedTracksData(int count) | 407 | DataTypes::ListTrackDataType DatabaseInterface::recentlyPlayedTracksData(int count) | ||
408 | { | 408 | { | ||
409 | auto result = ListTrackDataType{}; | 409 | auto result = DataTypes::ListTrackDataType{}; | ||
410 | 410 | | |||
411 | if (!d) { | 411 | if (!d) { | ||
412 | return result; | 412 | return result; | ||
413 | } | 413 | } | ||
414 | 414 | | |||
415 | auto transactionResult = startTransaction(); | 415 | auto transactionResult = startTransaction(); | ||
416 | if (!transactionResult) { | 416 | if (!transactionResult) { | ||
417 | return result; | 417 | return result; | ||
418 | } | 418 | } | ||
419 | 419 | | |||
420 | result = internalRecentlyPlayedTracksData(count); | 420 | result = internalRecentlyPlayedTracksData(count); | ||
421 | 421 | | |||
422 | transactionResult = finishTransaction(); | 422 | transactionResult = finishTransaction(); | ||
423 | if (!transactionResult) { | 423 | if (!transactionResult) { | ||
424 | return result; | 424 | return result; | ||
425 | } | 425 | } | ||
426 | 426 | | |||
427 | return result; | 427 | return result; | ||
428 | } | 428 | } | ||
429 | 429 | | |||
430 | DatabaseInterface::ListTrackDataType DatabaseInterface::frequentlyPlayedTracksData(int count) | 430 | DataTypes::ListTrackDataType DatabaseInterface::frequentlyPlayedTracksData(int count) | ||
431 | { | 431 | { | ||
432 | auto result = ListTrackDataType{}; | 432 | auto result = DataTypes::ListTrackDataType{}; | ||
433 | 433 | | |||
434 | if (!d) { | 434 | if (!d) { | ||
435 | return result; | 435 | return result; | ||
436 | } | 436 | } | ||
437 | 437 | | |||
438 | auto transactionResult = startTransaction(); | 438 | auto transactionResult = startTransaction(); | ||
439 | if (!transactionResult) { | 439 | if (!transactionResult) { | ||
440 | return result; | 440 | return result; | ||
441 | } | 441 | } | ||
442 | 442 | | |||
443 | result = internalFrequentlyPlayedTracksData(count); | 443 | result = internalFrequentlyPlayedTracksData(count); | ||
444 | 444 | | |||
445 | transactionResult = finishTransaction(); | 445 | transactionResult = finishTransaction(); | ||
446 | if (!transactionResult) { | 446 | if (!transactionResult) { | ||
447 | return result; | 447 | return result; | ||
448 | } | 448 | } | ||
449 | 449 | | |||
450 | return result; | 450 | return result; | ||
451 | } | 451 | } | ||
452 | 452 | | |||
453 | DatabaseInterface::ListAlbumDataType DatabaseInterface::allAlbumsData() | 453 | DataTypes::ListAlbumDataType DatabaseInterface::allAlbumsData() | ||
454 | { | 454 | { | ||
455 | auto result = ListAlbumDataType{}; | 455 | auto result = DataTypes::ListAlbumDataType{}; | ||
456 | 456 | | |||
457 | if (!d) { | 457 | if (!d) { | ||
458 | return result; | 458 | return result; | ||
459 | } | 459 | } | ||
460 | 460 | | |||
461 | auto transactionResult = startTransaction(); | 461 | auto transactionResult = startTransaction(); | ||
462 | if (!transactionResult) { | 462 | if (!transactionResult) { | ||
463 | return result; | 463 | return result; | ||
464 | } | 464 | } | ||
465 | 465 | | |||
466 | result = internalAllAlbumsPartialData(d->mSelectAllAlbumsShortQuery); | 466 | result = internalAllAlbumsPartialData(d->mSelectAllAlbumsShortQuery); | ||
467 | 467 | | |||
468 | transactionResult = finishTransaction(); | 468 | transactionResult = finishTransaction(); | ||
469 | if (!transactionResult) { | 469 | if (!transactionResult) { | ||
470 | return result; | 470 | return result; | ||
471 | } | 471 | } | ||
472 | 472 | | |||
473 | return result; | 473 | return result; | ||
474 | } | 474 | } | ||
475 | 475 | | |||
476 | DatabaseInterface::ListAlbumDataType DatabaseInterface::allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist) | 476 | DataTypes::ListAlbumDataType DatabaseInterface::allAlbumsDataByGenreAndArtist(const QString &genre, const QString &artist) | ||
477 | { | 477 | { | ||
478 | auto result = ListAlbumDataType{}; | 478 | auto result = DataTypes::ListAlbumDataType{}; | ||
479 | 479 | | |||
480 | if (!d) { | 480 | if (!d) { | ||
481 | return result; | 481 | return result; | ||
482 | } | 482 | } | ||
483 | 483 | | |||
484 | auto transactionResult = startTransaction(); | 484 | auto transactionResult = startTransaction(); | ||
485 | if (!transactionResult) { | 485 | if (!transactionResult) { | ||
486 | return result; | 486 | return result; | ||
487 | } | 487 | } | ||
488 | 488 | | |||
489 | d->mSelectAllAlbumsShortWithGenreArtistFilterQuery.bindValue(QStringLiteral(":artistFilter"), artist); | 489 | d->mSelectAllAlbumsShortWithGenreArtistFilterQuery.bindValue(QStringLiteral(":artistFilter"), artist); | ||
490 | d->mSelectAllAlbumsShortWithGenreArtistFilterQuery.bindValue(QStringLiteral(":genreFilter"), genre); | 490 | d->mSelectAllAlbumsShortWithGenreArtistFilterQuery.bindValue(QStringLiteral(":genreFilter"), genre); | ||
491 | 491 | | |||
492 | result = internalAllAlbumsPartialData(d->mSelectAllAlbumsShortWithGenreArtistFilterQuery); | 492 | result = internalAllAlbumsPartialData(d->mSelectAllAlbumsShortWithGenreArtistFilterQuery); | ||
493 | 493 | | |||
494 | transactionResult = finishTransaction(); | 494 | transactionResult = finishTransaction(); | ||
495 | if (!transactionResult) { | 495 | if (!transactionResult) { | ||
496 | return result; | 496 | return result; | ||
497 | } | 497 | } | ||
498 | 498 | | |||
499 | return result; | 499 | return result; | ||
500 | } | 500 | } | ||
501 | 501 | | |||
502 | DatabaseInterface::ListAlbumDataType DatabaseInterface::allAlbumsDataByArtist(const QString &artist) | 502 | DataTypes::ListAlbumDataType DatabaseInterface::allAlbumsDataByArtist(const QString &artist) | ||
503 | { | 503 | { | ||
504 | auto result = ListAlbumDataType{}; | 504 | auto result = DataTypes::ListAlbumDataType{}; | ||
505 | 505 | | |||
506 | if (!d) { | 506 | if (!d) { | ||
507 | return result; | 507 | return result; | ||
508 | } | 508 | } | ||
509 | 509 | | |||
510 | auto transactionResult = startTransaction(); | 510 | auto transactionResult = startTransaction(); | ||
511 | if (!transactionResult) { | 511 | if (!transactionResult) { | ||
512 | return result; | 512 | return result; | ||
513 | } | 513 | } | ||
514 | 514 | | |||
515 | d->mSelectAllAlbumsShortWithArtistFilterQuery.bindValue(QStringLiteral(":artistFilter"), artist); | 515 | d->mSelectAllAlbumsShortWithArtistFilterQuery.bindValue(QStringLiteral(":artistFilter"), artist); | ||
516 | 516 | | |||
517 | result = internalAllAlbumsPartialData(d->mSelectAllAlbumsShortWithArtistFilterQuery); | 517 | result = internalAllAlbumsPartialData(d->mSelectAllAlbumsShortWithArtistFilterQuery); | ||
518 | 518 | | |||
519 | transactionResult = finishTransaction(); | 519 | transactionResult = finishTransaction(); | ||
520 | if (!transactionResult) { | 520 | if (!transactionResult) { | ||
521 | return result; | 521 | return result; | ||
522 | } | 522 | } | ||
523 | 523 | | |||
524 | return result; | 524 | return result; | ||
525 | } | 525 | } | ||
526 | 526 | | |||
527 | DatabaseInterface::AlbumDataType DatabaseInterface::albumDataFromDatabaseId(qulonglong id) | 527 | DataTypes::AlbumDataType DatabaseInterface::albumDataFromDatabaseId(qulonglong id) | ||
528 | { | 528 | { | ||
529 | auto result = DatabaseInterface::AlbumDataType{}; | 529 | auto result = DataTypes::AlbumDataType{}; | ||
530 | 530 | | |||
531 | if (!d) { | 531 | if (!d) { | ||
532 | return result; | 532 | return result; | ||
533 | } | 533 | } | ||
534 | 534 | | |||
535 | auto transactionResult = startTransaction(); | 535 | auto transactionResult = startTransaction(); | ||
536 | if (!transactionResult) { | 536 | if (!transactionResult) { | ||
537 | return result; | 537 | return result; | ||
538 | } | 538 | } | ||
539 | 539 | | |||
540 | result = internalOneAlbumPartialData(id); | 540 | result = internalOneAlbumPartialData(id); | ||
541 | 541 | | |||
542 | transactionResult = finishTransaction(); | 542 | transactionResult = finishTransaction(); | ||
543 | if (!transactionResult) { | 543 | if (!transactionResult) { | ||
544 | return result; | 544 | return result; | ||
545 | } | 545 | } | ||
546 | 546 | | |||
547 | return result; | 547 | return result; | ||
548 | } | 548 | } | ||
549 | 549 | | |||
550 | DatabaseInterface::ListTrackDataType DatabaseInterface::albumData(qulonglong databaseId) | 550 | DataTypes::ListTrackDataType DatabaseInterface::albumData(qulonglong databaseId) | ||
551 | { | 551 | { | ||
552 | auto result = ListTrackDataType{}; | 552 | auto result = DataTypes::ListTrackDataType{}; | ||
553 | 553 | | |||
554 | if (!d) { | 554 | if (!d) { | ||
555 | return result; | 555 | return result; | ||
556 | } | 556 | } | ||
557 | 557 | | |||
558 | auto transactionResult = startTransaction(); | 558 | auto transactionResult = startTransaction(); | ||
559 | if (!transactionResult) { | 559 | if (!transactionResult) { | ||
560 | return result; | 560 | return result; | ||
Show All 22 Lines | |||||
583 | transactionResult = finishTransaction(); | 583 | transactionResult = finishTransaction(); | ||
584 | if (!transactionResult) { | 584 | if (!transactionResult) { | ||
585 | return result; | 585 | return result; | ||
586 | } | 586 | } | ||
587 | 587 | | |||
588 | return result; | 588 | return result; | ||
589 | } | 589 | } | ||
590 | 590 | | |||
591 | DatabaseInterface::ListArtistDataType DatabaseInterface::allArtistsData() | 591 | DataTypes::ListArtistDataType DatabaseInterface::allArtistsData() | ||
592 | { | 592 | { | ||
593 | auto result = ListArtistDataType{}; | 593 | auto result = DataTypes::ListArtistDataType{}; | ||
594 | 594 | | |||
595 | if (!d) { | 595 | if (!d) { | ||
596 | return result; | 596 | return result; | ||
597 | } | 597 | } | ||
598 | 598 | | |||
599 | auto transactionResult = startTransaction(); | 599 | auto transactionResult = startTransaction(); | ||
600 | if (!transactionResult) { | 600 | if (!transactionResult) { | ||
601 | return result; | 601 | return result; | ||
602 | } | 602 | } | ||
603 | 603 | | |||
604 | result = internalAllArtistsPartialData(d->mSelectAllArtistsQuery); | 604 | result = internalAllArtistsPartialData(d->mSelectAllArtistsQuery); | ||
605 | 605 | | |||
606 | transactionResult = finishTransaction(); | 606 | transactionResult = finishTransaction(); | ||
607 | if (!transactionResult) { | 607 | if (!transactionResult) { | ||
608 | return result; | 608 | return result; | ||
609 | } | 609 | } | ||
610 | 610 | | |||
611 | return result; | 611 | return result; | ||
612 | } | 612 | } | ||
613 | 613 | | |||
614 | DatabaseInterface::ListArtistDataType DatabaseInterface::allArtistsDataByGenre(const QString &genre) | 614 | DataTypes::ListArtistDataType DatabaseInterface::allArtistsDataByGenre(const QString &genre) | ||
615 | { | 615 | { | ||
616 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::allArtistsDataByGenre" << genre; | 616 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::allArtistsDataByGenre" << genre; | ||
617 | 617 | | |||
618 | auto result = ListArtistDataType{}; | 618 | auto result = DataTypes::ListArtistDataType{}; | ||
619 | 619 | | |||
620 | if (!d) { | 620 | if (!d) { | ||
621 | return result; | 621 | return result; | ||
622 | } | 622 | } | ||
623 | 623 | | |||
624 | auto transactionResult = startTransaction(); | 624 | auto transactionResult = startTransaction(); | ||
625 | if (!transactionResult) { | 625 | if (!transactionResult) { | ||
626 | return result; | 626 | return result; | ||
627 | } | 627 | } | ||
628 | 628 | | |||
629 | d->mSelectAllArtistsWithGenreFilterQuery.bindValue(QStringLiteral(":genreFilter"), genre); | 629 | d->mSelectAllArtistsWithGenreFilterQuery.bindValue(QStringLiteral(":genreFilter"), genre); | ||
630 | 630 | | |||
631 | result = internalAllArtistsPartialData(d->mSelectAllArtistsWithGenreFilterQuery); | 631 | result = internalAllArtistsPartialData(d->mSelectAllArtistsWithGenreFilterQuery); | ||
632 | 632 | | |||
633 | transactionResult = finishTransaction(); | 633 | transactionResult = finishTransaction(); | ||
634 | if (!transactionResult) { | 634 | if (!transactionResult) { | ||
635 | return result; | 635 | return result; | ||
636 | } | 636 | } | ||
637 | 637 | | |||
638 | return result; | 638 | return result; | ||
639 | } | 639 | } | ||
640 | 640 | | |||
641 | DatabaseInterface::ListGenreDataType DatabaseInterface::allGenresData() | 641 | DataTypes::ListGenreDataType DatabaseInterface::allGenresData() | ||
642 | { | 642 | { | ||
643 | auto result = ListGenreDataType{}; | 643 | auto result = DataTypes::ListGenreDataType{}; | ||
644 | 644 | | |||
645 | if (!d) { | 645 | if (!d) { | ||
646 | return result; | 646 | return result; | ||
647 | } | 647 | } | ||
648 | 648 | | |||
649 | auto transactionResult = startTransaction(); | 649 | auto transactionResult = startTransaction(); | ||
650 | if (!transactionResult) { | 650 | if (!transactionResult) { | ||
651 | return result; | 651 | return result; | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 665 | { | |||
695 | 695 | | |||
696 | d->mArtistMatchGenreQuery.finish(); | 696 | d->mArtistMatchGenreQuery.finish(); | ||
697 | 697 | | |||
698 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalArtistMatchGenre" << databaseId << (result ? "match" : "does not match"); | 698 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalArtistMatchGenre" << databaseId << (result ? "match" : "does not match"); | ||
699 | 699 | | |||
700 | return result; | 700 | return result; | ||
701 | } | 701 | } | ||
702 | 702 | | |||
703 | DatabaseInterface::ListTrackDataType DatabaseInterface::tracksDataFromAuthor(const QString &ArtistName) | 703 | DataTypes::ListTrackDataType DatabaseInterface::tracksDataFromAuthor(const QString &ArtistName) | ||
704 | { | 704 | { | ||
705 | auto allTracks = ListTrackDataType{}; | 705 | auto allTracks = DataTypes::ListTrackDataType{}; | ||
706 | 706 | | |||
707 | auto transactionResult = startTransaction(); | 707 | auto transactionResult = startTransaction(); | ||
708 | if (!transactionResult) { | 708 | if (!transactionResult) { | ||
709 | return allTracks; | 709 | return allTracks; | ||
710 | } | 710 | } | ||
711 | 711 | | |||
712 | allTracks = internalTracksFromAuthor(ArtistName); | 712 | allTracks = internalTracksFromAuthor(ArtistName); | ||
713 | 713 | | |||
714 | transactionResult = finishTransaction(); | 714 | transactionResult = finishTransaction(); | ||
715 | if (!transactionResult) { | 715 | if (!transactionResult) { | ||
716 | return allTracks; | 716 | return allTracks; | ||
717 | } | 717 | } | ||
718 | 718 | | |||
719 | return allTracks; | 719 | return allTracks; | ||
720 | } | 720 | } | ||
721 | 721 | | |||
722 | DatabaseInterface::TrackDataType DatabaseInterface::trackDataFromDatabaseId(qulonglong id) | 722 | DataTypes::TrackDataType DatabaseInterface::trackDataFromDatabaseId(qulonglong id) | ||
723 | { | 723 | { | ||
724 | auto result = TrackDataType(); | 724 | auto result = DataTypes::TrackDataType(); | ||
725 | 725 | | |||
726 | if (!d) { | 726 | if (!d) { | ||
727 | return result; | 727 | return result; | ||
728 | } | 728 | } | ||
729 | 729 | | |||
730 | auto transactionResult = startTransaction(); | 730 | auto transactionResult = startTransaction(); | ||
731 | if (!transactionResult) { | 731 | if (!transactionResult) { | ||
732 | return result; | 732 | return result; | ||
733 | } | 733 | } | ||
734 | 734 | | |||
735 | result = internalOneTrackPartialData(id); | 735 | result = internalOneTrackPartialData(id); | ||
736 | 736 | | |||
737 | transactionResult = finishTransaction(); | 737 | transactionResult = finishTransaction(); | ||
738 | if (!transactionResult) { | 738 | if (!transactionResult) { | ||
739 | return result; | 739 | return result; | ||
740 | } | 740 | } | ||
741 | 741 | | |||
742 | return result; | 742 | return result; | ||
743 | } | 743 | } | ||
744 | 744 | | |||
745 | DatabaseInterface::TrackDataType DatabaseInterface::radioDataFromDatabaseId(qulonglong id) | 745 | DataTypes::TrackDataType DatabaseInterface::radioDataFromDatabaseId(qulonglong id) | ||
746 | { | 746 | { | ||
747 | auto result = TrackDataType(); | 747 | auto result = DataTypes::TrackDataType(); | ||
748 | 748 | | |||
749 | if (!d) { | 749 | if (!d) { | ||
750 | return result; | 750 | return result; | ||
751 | } | 751 | } | ||
752 | 752 | | |||
753 | auto transactionResult = startTransaction(); | 753 | auto transactionResult = startTransaction(); | ||
754 | if (!transactionResult) { | 754 | if (!transactionResult) { | ||
755 | return result; | 755 | return result; | ||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Line(s) | 1019 | if (!transactionResult) { | |||
1021 | return; | 1021 | return; | ||
1022 | } | 1022 | } | ||
1023 | Q_EMIT finishInsertingTracksList(); | 1023 | Q_EMIT finishInsertingTracksList(); | ||
1024 | return; | 1024 | return; | ||
1025 | } | 1025 | } | ||
1026 | } | 1026 | } | ||
1027 | 1027 | | |||
1028 | if (!d->mInsertedArtists.isEmpty()) { | 1028 | if (!d->mInsertedArtists.isEmpty()) { | ||
1029 | ListArtistDataType newArtists; | 1029 | DataTypes::ListArtistDataType newArtists; | ||
1030 | 1030 | | |||
1031 | for (auto artistId : qAsConst(d->mInsertedArtists)) { | 1031 | for (auto artistId : qAsConst(d->mInsertedArtists)) { | ||
1032 | newArtists.push_back({{DatabaseIdRole, artistId}}); | 1032 | newArtists.push_back({{DataTypes::DatabaseIdRole, artistId}}); | ||
1033 | } | 1033 | } | ||
1034 | qCInfo(orgKdeElisaDatabase) << "artistsAdded" << newArtists.size(); | 1034 | qCInfo(orgKdeElisaDatabase) << "artistsAdded" << newArtists.size(); | ||
1035 | Q_EMIT artistsAdded(newArtists); | 1035 | Q_EMIT artistsAdded(newArtists); | ||
1036 | } | 1036 | } | ||
1037 | 1037 | | |||
1038 | if (!d->mInsertedAlbums.isEmpty()) { | 1038 | if (!d->mInsertedAlbums.isEmpty()) { | ||
1039 | ListAlbumDataType newAlbums; | 1039 | DataTypes::ListAlbumDataType newAlbums; | ||
1040 | 1040 | | |||
1041 | for (auto albumId : qAsConst(d->mInsertedAlbums)) { | 1041 | for (auto albumId : qAsConst(d->mInsertedAlbums)) { | ||
1042 | d->mModifiedAlbumIds.remove(albumId); | 1042 | d->mModifiedAlbumIds.remove(albumId); | ||
1043 | newAlbums.push_back(internalOneAlbumPartialData(albumId)); | 1043 | newAlbums.push_back(internalOneAlbumPartialData(albumId)); | ||
1044 | } | 1044 | } | ||
1045 | 1045 | | |||
1046 | qCInfo(orgKdeElisaDatabase) << "albumsAdded" << newAlbums.size(); | 1046 | qCInfo(orgKdeElisaDatabase) << "albumsAdded" << newAlbums.size(); | ||
1047 | Q_EMIT albumsAdded(newAlbums); | 1047 | Q_EMIT albumsAdded(newAlbums); | ||
1048 | } | 1048 | } | ||
1049 | 1049 | | |||
1050 | for (auto albumId : qAsConst(d->mModifiedAlbumIds)) { | 1050 | for (auto albumId : qAsConst(d->mModifiedAlbumIds)) { | ||
1051 | Q_EMIT albumModified({{DatabaseIdRole, albumId}}, albumId); | 1051 | Q_EMIT albumModified({{DataTypes::DatabaseIdRole, albumId}}, albumId); | ||
1052 | } | 1052 | } | ||
1053 | 1053 | | |||
1054 | if (!d->mInsertedTracks.isEmpty()) { | 1054 | if (!d->mInsertedTracks.isEmpty()) { | ||
1055 | ListTrackDataType newTracks; | 1055 | DataTypes::ListTrackDataType newTracks; | ||
1056 | 1056 | | |||
1057 | for (auto trackId : qAsConst(d->mInsertedTracks)) { | 1057 | for (auto trackId : qAsConst(d->mInsertedTracks)) { | ||
1058 | newTracks.push_back(internalOneTrackPartialData(trackId)); | 1058 | newTracks.push_back(internalOneTrackPartialData(trackId)); | ||
1059 | d->mModifiedTrackIds.remove(trackId); | 1059 | d->mModifiedTrackIds.remove(trackId); | ||
1060 | } | 1060 | } | ||
1061 | 1061 | | |||
1062 | qCInfo(orgKdeElisaDatabase) << "tracksAdded" << newTracks.size(); | 1062 | qCInfo(orgKdeElisaDatabase) << "tracksAdded" << newTracks.size(); | ||
1063 | Q_EMIT tracksAdded(newTracks); | 1063 | Q_EMIT tracksAdded(newTracks); | ||
Show All 19 Lines | 1081 | if (!transactionResult) { | |||
1083 | return; | 1083 | return; | ||
1084 | } | 1084 | } | ||
1085 | 1085 | | |||
1086 | initChangesTrackers(); | 1086 | initChangesTrackers(); | ||
1087 | 1087 | | |||
1088 | internalRemoveTracksList(removedTracks); | 1088 | internalRemoveTracksList(removedTracks); | ||
1089 | 1089 | | |||
1090 | if (!d->mInsertedArtists.isEmpty()) { | 1090 | if (!d->mInsertedArtists.isEmpty()) { | ||
1091 | ListArtistDataType newArtists; | 1091 | DataTypes::ListArtistDataType newArtists; | ||
1092 | for (auto artistId : qAsConst(d->mInsertedArtists)) { | 1092 | for (auto artistId : qAsConst(d->mInsertedArtists)) { | ||
1093 | newArtists.push_back({{DatabaseIdRole, artistId}}); | 1093 | newArtists.push_back({{DataTypes::DatabaseIdRole, artistId}}); | ||
1094 | } | 1094 | } | ||
1095 | Q_EMIT artistsAdded(newArtists); | 1095 | Q_EMIT artistsAdded(newArtists); | ||
1096 | } | 1096 | } | ||
1097 | 1097 | | |||
1098 | transactionResult = finishTransaction(); | 1098 | transactionResult = finishTransaction(); | ||
1099 | if (!transactionResult) { | 1099 | if (!transactionResult) { | ||
1100 | Q_EMIT finishRemovingTracksList(); | 1100 | Q_EMIT finishRemovingTracksList(); | ||
1101 | return; | 1101 | return; | ||
▲ Show 20 Lines • Show All 4869 Lines • ▼ Show 20 Line(s) | 5923 | { | |||
5971 | } | 5971 | } | ||
5972 | 5972 | | |||
5973 | result = d->mGenreId; | 5973 | result = d->mGenreId; | ||
5974 | 5974 | | |||
5975 | ++d->mGenreId; | 5975 | ++d->mGenreId; | ||
5976 | 5976 | | |||
5977 | d->mInsertGenreQuery.finish(); | 5977 | d->mInsertGenreQuery.finish(); | ||
5978 | 5978 | | |||
5979 | Q_EMIT genresAdded({{{DatabaseIdRole, result}}}); | 5979 | Q_EMIT genresAdded({{{DataTypes::DatabaseIdRole, result}}}); | ||
5980 | 5980 | | |||
5981 | return result; | 5981 | return result; | ||
5982 | } | 5982 | } | ||
5983 | 5983 | | |||
5984 | void DatabaseInterface::insertTrackOrigin(const QUrl &fileNameURI, const QDateTime &fileModifiedTime, | 5984 | void DatabaseInterface::insertTrackOrigin(const QUrl &fileNameURI, const QDateTime &fileModifiedTime, | ||
5985 | const QDateTime &importDate) | 5985 | const QDateTime &importDate) | ||
5986 | { | 5986 | { | ||
5987 | d->mInsertTrackMapping.bindValue(QStringLiteral(":fileName"), fileNameURI); | 5987 | d->mInsertTrackMapping.bindValue(QStringLiteral(":fileName"), fileNameURI); | ||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Line(s) | 6256 | { | |||
6319 | result.setAlbumId(trackRecord.value(2).toULongLong()); | 6319 | result.setAlbumId(trackRecord.value(2).toULongLong()); | ||
6320 | result.setHasEmbeddedCover(trackRecord.value(24).toBool()); | 6320 | result.setHasEmbeddedCover(trackRecord.value(24).toBool()); | ||
6321 | 6321 | | |||
6322 | result.setValid(true); | 6322 | result.setValid(true); | ||
6323 | 6323 | | |||
6324 | return result; | 6324 | return result; | ||
6325 | } | 6325 | } | ||
6326 | 6326 | | |||
6327 | DatabaseInterface::TrackDataType DatabaseInterface::buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const | 6327 | DataTypes::TrackDataType DatabaseInterface::buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const | ||
6328 | { | 6328 | { | ||
6329 | TrackDataType result; | 6329 | DataTypes::TrackDataType result; | ||
6330 | 6330 | | |||
6331 | result[TrackDataType::key_type::DatabaseIdRole] = trackRecord.value(0); | 6331 | result[DataTypes::TrackDataType::key_type::DatabaseIdRole] = trackRecord.value(0); | ||
6332 | result[TrackDataType::key_type::TitleRole] = trackRecord.value(1); | 6332 | result[DataTypes::TrackDataType::key_type::TitleRole] = trackRecord.value(1); | ||
6333 | if (!trackRecord.value(12).isNull()) { | 6333 | if (!trackRecord.value(12).isNull()) { | ||
6334 | result[TrackDataType::key_type::AlbumRole] = trackRecord.value(12); | 6334 | result[DataTypes::TrackDataType::key_type::AlbumRole] = trackRecord.value(12); | ||
6335 | result[TrackDataType::key_type::AlbumIdRole] = trackRecord.value(2); | 6335 | result[DataTypes::TrackDataType::key_type::AlbumIdRole] = trackRecord.value(2); | ||
6336 | } | 6336 | } | ||
6337 | if (!trackRecord.value(3).isNull()) { | 6337 | if (!trackRecord.value(3).isNull()) { | ||
6338 | result[TrackDataType::key_type::ArtistRole] = trackRecord.value(3); | 6338 | result[DataTypes::TrackDataType::key_type::ArtistRole] = trackRecord.value(3); | ||
6339 | } | 6339 | } | ||
6340 | 6340 | | |||
6341 | if (!trackRecord.value(6).isNull()) { | 6341 | if (!trackRecord.value(6).isNull()) { | ||
6342 | result[TrackDataType::key_type::IsValidAlbumArtistRole] = true; | 6342 | result[DataTypes::TrackDataType::key_type::IsValidAlbumArtistRole] = true; | ||
6343 | result[TrackDataType::key_type::AlbumArtistRole] = trackRecord.value(6); | 6343 | result[DataTypes::TrackDataType::key_type::AlbumArtistRole] = trackRecord.value(6); | ||
6344 | } else { | 6344 | } else { | ||
6345 | result[TrackDataType::key_type::IsValidAlbumArtistRole] = false; | 6345 | result[DataTypes::TrackDataType::key_type::IsValidAlbumArtistRole] = false; | ||
6346 | if (trackRecord.value(4).toInt() == 1) { | 6346 | if (trackRecord.value(4).toInt() == 1) { | ||
6347 | result[TrackDataType::key_type::AlbumArtistRole] = trackRecord.value(3); | 6347 | result[DataTypes::TrackDataType::key_type::AlbumArtistRole] = trackRecord.value(3); | ||
6348 | } else if (trackRecord.value(4).toInt() > 1) { | 6348 | } else if (trackRecord.value(4).toInt() > 1) { | ||
6349 | result[TrackDataType::key_type::AlbumArtistRole] = QStringLiteral("Various Artists"); | 6349 | result[DataTypes::TrackDataType::key_type::AlbumArtistRole] = QStringLiteral("Various Artists"); | ||
6350 | } | 6350 | } | ||
6351 | } | 6351 | } | ||
6352 | 6352 | | |||
6353 | result[TrackDataType::key_type::ResourceRole] = trackRecord.value(7); | 6353 | result[DataTypes::TrackDataType::key_type::ResourceRole] = trackRecord.value(7); | ||
6354 | if (!trackRecord.value(9).isNull()) { | 6354 | if (!trackRecord.value(9).isNull()) { | ||
6355 | result[TrackDataType::key_type::TrackNumberRole] = trackRecord.value(9); | 6355 | result[DataTypes::TrackDataType::key_type::TrackNumberRole] = trackRecord.value(9); | ||
6356 | } | 6356 | } | ||
6357 | if (!trackRecord.value(10).isNull()) { | 6357 | if (!trackRecord.value(10).isNull()) { | ||
6358 | result[TrackDataType::key_type::DiscNumberRole] = trackRecord.value(10); | 6358 | result[DataTypes::TrackDataType::key_type::DiscNumberRole] = trackRecord.value(10); | ||
6359 | } | 6359 | } | ||
6360 | result[TrackDataType::key_type::DurationRole] = QTime::fromMSecsSinceStartOfDay(trackRecord.value(11).toInt()); | 6360 | result[DataTypes::TrackDataType::key_type::DurationRole] = QTime::fromMSecsSinceStartOfDay(trackRecord.value(11).toInt()); | ||
6361 | result[TrackDataType::key_type::MilliSecondsDurationRole] = trackRecord.value(11).toInt(); | 6361 | result[DataTypes::TrackDataType::key_type::MilliSecondsDurationRole] = trackRecord.value(11).toInt(); | ||
6362 | result[TrackDataType::key_type::RatingRole] = trackRecord.value(13); | 6362 | result[DataTypes::TrackDataType::key_type::RatingRole] = trackRecord.value(13); | ||
6363 | if (!trackRecord.value(14).toString().isEmpty()) { | 6363 | if (!trackRecord.value(14).toString().isEmpty()) { | ||
6364 | result[TrackDataType::key_type::ImageUrlRole] = QUrl(trackRecord.value(14).toString()); | 6364 | result[DataTypes::TrackDataType::key_type::ImageUrlRole] = QUrl(trackRecord.value(14).toString()); | ||
6365 | } else if (!trackRecord.value(30).toString().isEmpty()) { | 6365 | } else if (!trackRecord.value(30).toString().isEmpty()) { | ||
6366 | result[TrackDataType::key_type::ImageUrlRole] = QVariant{QStringLiteral("image://cover/") + trackRecord.value(30).toUrl().toLocalFile()}; | 6366 | result[DataTypes::TrackDataType::key_type::ImageUrlRole] = QVariant{QStringLiteral("image://cover/") + trackRecord.value(30).toUrl().toLocalFile()}; | ||
6367 | } | 6367 | } | ||
6368 | result[TrackDataType::key_type::IsSingleDiscAlbumRole] = trackRecord.value(15); | 6368 | result[DataTypes::TrackDataType::key_type::IsSingleDiscAlbumRole] = trackRecord.value(15); | ||
6369 | if (!trackRecord.value(16).isNull()) { | 6369 | if (!trackRecord.value(16).isNull()) { | ||
6370 | result[TrackDataType::key_type::GenreRole] = trackRecord.value(16); | 6370 | result[DataTypes::TrackDataType::key_type::GenreRole] = trackRecord.value(16); | ||
6371 | } | 6371 | } | ||
6372 | if (!trackRecord.value(17).isNull()) { | 6372 | if (!trackRecord.value(17).isNull()) { | ||
6373 | result[TrackDataType::key_type::ComposerRole] = trackRecord.value(17); | 6373 | result[DataTypes::TrackDataType::key_type::ComposerRole] = trackRecord.value(17); | ||
6374 | } | 6374 | } | ||
6375 | if (!trackRecord.value(18).isNull()) { | 6375 | if (!trackRecord.value(18).isNull()) { | ||
6376 | result[TrackDataType::key_type::LyricistRole] = trackRecord.value(18); | 6376 | result[DataTypes::TrackDataType::key_type::LyricistRole] = trackRecord.value(18); | ||
6377 | } | 6377 | } | ||
6378 | if (!trackRecord.value(19).isNull()) { | 6378 | if (!trackRecord.value(19).isNull()) { | ||
6379 | result[TrackDataType::key_type::CommentRole] = trackRecord.value(19); | 6379 | result[DataTypes::TrackDataType::key_type::CommentRole] = trackRecord.value(19); | ||
6380 | } | 6380 | } | ||
6381 | if (!trackRecord.value(20).isNull()) { | 6381 | if (!trackRecord.value(20).isNull()) { | ||
6382 | result[TrackDataType::key_type::YearRole] = trackRecord.value(20); | 6382 | result[DataTypes::TrackDataType::key_type::YearRole] = trackRecord.value(20); | ||
6383 | } | 6383 | } | ||
6384 | if (!trackRecord.value(21).isNull()) { | 6384 | if (!trackRecord.value(21).isNull()) { | ||
6385 | result[TrackDataType::key_type::ChannelsRole] = trackRecord.value(21); | 6385 | result[DataTypes::TrackDataType::key_type::ChannelsRole] = trackRecord.value(21); | ||
6386 | } | 6386 | } | ||
6387 | if (!trackRecord.value(22).isNull()) { | 6387 | if (!trackRecord.value(22).isNull()) { | ||
6388 | result[TrackDataType::key_type::BitRateRole] = trackRecord.value(22); | 6388 | result[DataTypes::TrackDataType::key_type::BitRateRole] = trackRecord.value(22); | ||
6389 | } | 6389 | } | ||
6390 | if (!trackRecord.value(23).isNull()) { | 6390 | if (!trackRecord.value(23).isNull()) { | ||
6391 | result[TrackDataType::key_type::SampleRateRole] = trackRecord.value(23); | 6391 | result[DataTypes::TrackDataType::key_type::SampleRateRole] = trackRecord.value(23); | ||
6392 | } | 6392 | } | ||
6393 | result[TrackDataType::key_type::HasEmbeddedCover] = trackRecord.value(24); | 6393 | result[DataTypes::TrackDataType::key_type::HasEmbeddedCover] = trackRecord.value(24); | ||
6394 | result[TrackDataType::key_type::FileModificationTime] = trackRecord.value(8); | 6394 | result[DataTypes::TrackDataType::key_type::FileModificationTime] = trackRecord.value(8); | ||
6395 | if (!trackRecord.value(26).isNull()) { | 6395 | if (!trackRecord.value(26).isNull()) { | ||
6396 | result[TrackDataType::key_type::FirstPlayDate] = trackRecord.value(26); | 6396 | result[DataTypes::TrackDataType::key_type::FirstPlayDate] = trackRecord.value(26); | ||
6397 | } | 6397 | } | ||
6398 | if (!trackRecord.value(27).isNull()) { | 6398 | if (!trackRecord.value(27).isNull()) { | ||
6399 | result[TrackDataType::key_type::LastPlayDate] = trackRecord.value(27); | 6399 | result[DataTypes::TrackDataType::key_type::LastPlayDate] = trackRecord.value(27); | ||
6400 | } | 6400 | } | ||
6401 | result[TrackDataType::key_type::PlayCounter] = trackRecord.value(28); | 6401 | result[DataTypes::TrackDataType::key_type::PlayCounter] = trackRecord.value(28); | ||
6402 | result[TrackDataType::key_type::PlayFrequency] = trackRecord.value(29); | 6402 | result[DataTypes::TrackDataType::key_type::PlayFrequency] = trackRecord.value(29); | ||
6403 | result[TrackDataType::key_type::ElementTypeRole] = ElisaUtils::Track; | 6403 | result[DataTypes::TrackDataType::key_type::ElementTypeRole] = ElisaUtils::Track; | ||
6404 | 6404 | | |||
6405 | return result; | 6405 | return result; | ||
6406 | } | 6406 | } | ||
6407 | 6407 | | |||
6408 | DatabaseInterface::TrackDataType DatabaseInterface::buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const | 6408 | DataTypes::TrackDataType DatabaseInterface::buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const | ||
6409 | { | 6409 | { | ||
6410 | TrackDataType result; | 6410 | DataTypes::TrackDataType result; | ||
6411 | 6411 | | |||
6412 | result[TrackDataType::key_type::DatabaseIdRole] = trackRecord.value(0); | 6412 | result[DataTypes::TrackDataType::key_type::DatabaseIdRole] = trackRecord.value(0); | ||
6413 | result[TrackDataType::key_type::TitleRole] = trackRecord.value(1); | 6413 | result[DataTypes::TrackDataType::key_type::TitleRole] = trackRecord.value(1); | ||
6414 | 6414 | | |||
6415 | result[TrackDataType::key_type::AlbumRole] = QStringLiteral("Radios"); | 6415 | result[DataTypes::TrackDataType::key_type::AlbumRole] = QStringLiteral("Radios"); | ||
6416 | result[TrackDataType::key_type::ArtistRole] = trackRecord.value(1); | 6416 | result[DataTypes::TrackDataType::key_type::ArtistRole] = trackRecord.value(1); | ||
6417 | 6417 | | |||
6418 | result[TrackDataType::key_type::ResourceRole] = trackRecord.value(2); | 6418 | result[DataTypes::TrackDataType::key_type::ResourceRole] = trackRecord.value(2); | ||
6419 | result[TrackDataType::key_type::RatingRole] = trackRecord.value(3); | 6419 | result[DataTypes::TrackDataType::key_type::RatingRole] = trackRecord.value(3); | ||
6420 | if (!trackRecord.value(4).isNull()) { | 6420 | if (!trackRecord.value(4).isNull()) { | ||
6421 | result[TrackDataType::key_type::GenreRole] = trackRecord.value(4); | 6421 | result[DataTypes::TrackDataType::key_type::GenreRole] = trackRecord.value(4); | ||
6422 | } | 6422 | } | ||
6423 | result[TrackDataType::key_type::CommentRole] = trackRecord.value(5); | 6423 | result[DataTypes::TrackDataType::key_type::CommentRole] = trackRecord.value(5); | ||
6424 | result[TrackDataType::key_type::ElementTypeRole] = ElisaUtils::Radio; | 6424 | result[DataTypes::TrackDataType::key_type::ElementTypeRole] = ElisaUtils::Radio; | ||
6425 | 6425 | | |||
6426 | return result; | 6426 | return result; | ||
6427 | } | 6427 | } | ||
6428 | 6428 | | |||
6429 | void DatabaseInterface::internalRemoveTracksList(const QList<QUrl> &removedTracks) | 6429 | void DatabaseInterface::internalRemoveTracksList(const QList<QUrl> &removedTracks) | ||
6430 | { | 6430 | { | ||
6431 | QSet<qulonglong> modifiedAlbums; | 6431 | QSet<qulonglong> modifiedAlbums; | ||
6432 | 6432 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
6479 | } | 6479 | } | ||
6480 | 6480 | | |||
6481 | for (auto modifiedAlbumId : modifiedAlbums) { | 6481 | for (auto modifiedAlbumId : modifiedAlbums) { | ||
6482 | const auto &modifiedAlbumData = internalOneAlbumPartialData(modifiedAlbumId); | 6482 | const auto &modifiedAlbumData = internalOneAlbumPartialData(modifiedAlbumId); | ||
6483 | 6483 | | |||
6484 | auto tracksCount = fetchTrackIds(modifiedAlbumId).count(); | 6484 | auto tracksCount = fetchTrackIds(modifiedAlbumId).count(); | ||
6485 | 6485 | | |||
6486 | if (!modifiedAlbumData.isEmpty() && tracksCount) { | 6486 | if (!modifiedAlbumData.isEmpty() && tracksCount) { | ||
6487 | Q_EMIT albumModified({{DatabaseIdRole, modifiedAlbumId}}, modifiedAlbumId); | 6487 | Q_EMIT albumModified({{DataTypes::DatabaseIdRole, modifiedAlbumId}}, modifiedAlbumId); | ||
6488 | } else { | 6488 | } else { | ||
6489 | removeAlbumInDatabase(modifiedAlbumId); | 6489 | removeAlbumInDatabase(modifiedAlbumId); | ||
6490 | Q_EMIT albumRemoved(modifiedAlbumId); | 6490 | Q_EMIT albumRemoved(modifiedAlbumId); | ||
6491 | 6491 | | |||
6492 | const auto &allTracksFromArtist = internalTracksFromAuthor(modifiedAlbumData[AlbumDataType::key_type::ArtistRole].toString()); | 6492 | const auto &allTracksFromArtist = internalTracksFromAuthor(modifiedAlbumData[DataTypes::AlbumDataType::key_type::ArtistRole].toString()); | ||
6493 | const auto &allAlbumsFromArtist = internalAlbumIdsFromAuthor(modifiedAlbumData[AlbumDataType::key_type::ArtistRole].toString()); | 6493 | const auto &allAlbumsFromArtist = internalAlbumIdsFromAuthor(modifiedAlbumData[DataTypes::AlbumDataType::key_type::ArtistRole].toString()); | ||
6494 | const auto &removedArtistId = internalArtistIdFromName(modifiedAlbumData[AlbumDataType::key_type::ArtistRole].toString()); | 6494 | const auto &removedArtistId = internalArtistIdFromName(modifiedAlbumData[DataTypes::AlbumDataType::key_type::ArtistRole].toString()); | ||
6495 | 6495 | | |||
6496 | if (removedArtistId != 0 && allTracksFromArtist.isEmpty() && allAlbumsFromArtist.isEmpty()) { | 6496 | if (removedArtistId != 0 && allTracksFromArtist.isEmpty() && allAlbumsFromArtist.isEmpty()) { | ||
6497 | removeArtistInDatabase(removedArtistId); | 6497 | removeArtistInDatabase(removedArtistId); | ||
6498 | Q_EMIT artistRemoved(removedArtistId); | 6498 | Q_EMIT artistRemoved(removedArtistId); | ||
6499 | } | 6499 | } | ||
6500 | } | 6500 | } | ||
6501 | } | 6501 | } | ||
6502 | } | 6502 | } | ||
▲ Show 20 Lines • Show All 305 Lines • ▼ Show 20 Line(s) | 6805 | if (!result || !d->mUpdateTrackQuery.isActive()) { | |||
6808 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << d->mUpdateTrackQuery.lastQuery(); | 6808 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << d->mUpdateTrackQuery.lastQuery(); | ||
6809 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << d->mUpdateTrackQuery.boundValues(); | 6809 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << d->mUpdateTrackQuery.boundValues(); | ||
6810 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << d->mUpdateTrackQuery.lastError(); | 6810 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << d->mUpdateTrackQuery.lastError(); | ||
6811 | } | 6811 | } | ||
6812 | 6812 | | |||
6813 | d->mUpdateTrackQuery.finish(); | 6813 | d->mUpdateTrackQuery.finish(); | ||
6814 | } | 6814 | } | ||
6815 | 6815 | | |||
6816 | void DatabaseInterface::insertRadio(const TrackDataType &oneTrack) | 6816 | void DatabaseInterface::insertRadio(const DataTypes::TrackDataType &oneTrack) | ||
6817 | { | 6817 | { | ||
6818 | QSqlQuery query = d->mUpdateRadioQuery; | 6818 | QSqlQuery query = d->mUpdateRadioQuery; | ||
6819 | 6819 | | |||
6820 | if (oneTrack.databaseId() == -1ull) { | 6820 | if (oneTrack.databaseId() == -1ull) { | ||
6821 | query = d->mInsertRadioQuery; | 6821 | query = d->mInsertRadioQuery; | ||
6822 | } | 6822 | } | ||
6823 | 6823 | | |||
6824 | query.bindValue(QStringLiteral(":httpAddress"), oneTrack.resourceURI()); | 6824 | query.bindValue(QStringLiteral(":httpAddress"), oneTrack.resourceURI()); | ||
6825 | query.bindValue(QStringLiteral(":radioId"), oneTrack.databaseId()); | 6825 | query.bindValue(QStringLiteral(":radioId"), oneTrack.databaseId()); | ||
6826 | query.bindValue(QStringLiteral(":title"), oneTrack.title()); | 6826 | query.bindValue(QStringLiteral(":title"), oneTrack.title()); | ||
6827 | query.bindValue(QStringLiteral(":comment"), oneTrack.comment()); | 6827 | query.bindValue(QStringLiteral(":comment"), oneTrack.comment()); | ||
6828 | query.bindValue(QStringLiteral(":trackRating"), oneTrack.rating()); | 6828 | query.bindValue(QStringLiteral(":trackRating"), oneTrack.rating()); | ||
6829 | 6829 | | |||
6830 | auto result = execQuery(query); | 6830 | auto result = execQuery(query); | ||
6831 | 6831 | | |||
6832 | if (!result || !query.isActive()) { | 6832 | if (!result || !query.isActive()) { | ||
6833 | Q_EMIT databaseError(); | 6833 | Q_EMIT databaseError(); | ||
6834 | 6834 | | |||
6835 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << query.lastQuery(); | 6835 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << query.lastQuery(); | ||
6836 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << query.boundValues(); | 6836 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << query.boundValues(); | ||
6837 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << query.lastError(); | 6837 | qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::updateTrackInDatabase" << query.lastError(); | ||
6838 | } else { | 6838 | } else { | ||
6839 | if (oneTrack[TrackDataType::key_type::DatabaseIdRole] == -1) { | 6839 | if (oneTrack[DataTypes::TrackDataType::key_type::DatabaseIdRole] == -1) { | ||
6840 | auto radio = internalOneRadioPartialData(internalRadioIdFromHttpAddress(oneTrack.resourceURI().toString())); | 6840 | auto radio = internalOneRadioPartialData(internalRadioIdFromHttpAddress(oneTrack.resourceURI().toString())); | ||
6841 | 6841 | | |||
6842 | Q_EMIT radioAdded(radio); | 6842 | Q_EMIT radioAdded(radio); | ||
6843 | } else { | 6843 | } else { | ||
6844 | auto radio = internalOneRadioPartialData(oneTrack.databaseId()); | 6844 | auto radio = internalOneRadioPartialData(oneTrack.databaseId()); | ||
6845 | 6845 | | |||
6846 | Q_EMIT radioModified(radio); | 6846 | Q_EMIT radioModified(radio); | ||
6847 | } | 6847 | } | ||
▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Line(s) | 7240 | if (d->mSelectRadioIdFromHttpAddress.next()) { | |||
7244 | } | 7244 | } | ||
7245 | } | 7245 | } | ||
7246 | 7246 | | |||
7247 | d->mSelectRadioIdFromHttpAddress.finish(); | 7247 | d->mSelectRadioIdFromHttpAddress.finish(); | ||
7248 | 7248 | | |||
7249 | return result; | 7249 | return result; | ||
7250 | } | 7250 | } | ||
7251 | 7251 | | |||
7252 | DatabaseInterface::ListTrackDataType DatabaseInterface::internalTracksFromAuthor(const QString &ArtistName) | 7252 | DataTypes::ListTrackDataType DatabaseInterface::internalTracksFromAuthor(const QString &ArtistName) | ||
7253 | { | 7253 | { | ||
7254 | auto allTracks = ListTrackDataType{}; | 7254 | auto allTracks = DataTypes::ListTrackDataType{}; | ||
7255 | 7255 | | |||
7256 | d->mSelectTracksFromArtist.bindValue(QStringLiteral(":artistName"), ArtistName); | 7256 | d->mSelectTracksFromArtist.bindValue(QStringLiteral(":artistName"), ArtistName); | ||
7257 | 7257 | | |||
7258 | auto result = execQuery(d->mSelectTracksFromArtist); | 7258 | auto result = execQuery(d->mSelectTracksFromArtist); | ||
7259 | 7259 | | |||
7260 | if (!result || !d->mSelectTracksFromArtist.isSelect() || !d->mSelectTracksFromArtist.isActive()) { | 7260 | if (!result || !d->mSelectTracksFromArtist.isSelect() || !d->mSelectTracksFromArtist.isActive()) { | ||
7261 | Q_EMIT databaseError(); | 7261 | Q_EMIT databaseError(); | ||
7262 | 7262 | | |||
Show All 39 Lines | 7299 | while (d->mSelectAlbumIdsFromArtist.next()) { | |||
7302 | allAlbumIds.push_back(currentRecord.value(0).toULongLong()); | 7302 | allAlbumIds.push_back(currentRecord.value(0).toULongLong()); | ||
7303 | } | 7303 | } | ||
7304 | 7304 | | |||
7305 | d->mSelectAlbumIdsFromArtist.finish(); | 7305 | d->mSelectAlbumIdsFromArtist.finish(); | ||
7306 | 7306 | | |||
7307 | return allAlbumIds; | 7307 | return allAlbumIds; | ||
7308 | } | 7308 | } | ||
7309 | 7309 | | |||
7310 | DatabaseInterface::ListArtistDataType DatabaseInterface::internalAllArtistsPartialData(QSqlQuery &artistsQuery) | 7310 | DataTypes::ListArtistDataType DatabaseInterface::internalAllArtistsPartialData(QSqlQuery &artistsQuery) | ||
7311 | { | 7311 | { | ||
7312 | auto result = ListArtistDataType{}; | 7312 | auto result = DataTypes::ListArtistDataType{}; | ||
7313 | 7313 | | |||
7314 | if (!internalGenericPartialData(artistsQuery)) { | 7314 | if (!internalGenericPartialData(artistsQuery)) { | ||
7315 | return result; | 7315 | return result; | ||
7316 | } | 7316 | } | ||
7317 | 7317 | | |||
7318 | while(artistsQuery.next()) { | 7318 | while(artistsQuery.next()) { | ||
7319 | auto newData = ArtistDataType{}; | 7319 | auto newData = DataTypes::ArtistDataType{}; | ||
7320 | 7320 | | |||
7321 | const auto ¤tRecord = artistsQuery.record(); | 7321 | const auto ¤tRecord = artistsQuery.record(); | ||
7322 | 7322 | | |||
7323 | newData[DataType::key_type::DatabaseIdRole] = currentRecord.value(0); | 7323 | newData[DataTypes::DatabaseIdRole] = currentRecord.value(0); | ||
7324 | newData[DataType::key_type::TitleRole] = currentRecord.value(1); | 7324 | newData[DataTypes::TitleRole] = currentRecord.value(1); | ||
7325 | newData[DataType::key_type::GenreRole] = QVariant::fromValue(currentRecord.value(2).toString().split(QStringLiteral(", "))); | 7325 | newData[DataTypes::GenreRole] = QVariant::fromValue(currentRecord.value(2).toString().split(QStringLiteral(", "))); | ||
7326 | newData[DataType::key_type::ElementTypeRole] = ElisaUtils::Artist; | 7326 | newData[DataTypes::ElementTypeRole] = ElisaUtils::Artist; | ||
7327 | 7327 | | |||
7328 | result.push_back(newData); | 7328 | result.push_back(newData); | ||
7329 | } | 7329 | } | ||
7330 | 7330 | | |||
7331 | artistsQuery.finish(); | 7331 | artistsQuery.finish(); | ||
7332 | 7332 | | |||
7333 | return result; | 7333 | return result; | ||
7334 | } | 7334 | } | ||
7335 | 7335 | | |||
7336 | DatabaseInterface::ListAlbumDataType DatabaseInterface::internalAllAlbumsPartialData(QSqlQuery &query) | 7336 | DataTypes::ListAlbumDataType DatabaseInterface::internalAllAlbumsPartialData(QSqlQuery &query) | ||
7337 | { | 7337 | { | ||
7338 | auto result = ListAlbumDataType{}; | 7338 | auto result = DataTypes::ListAlbumDataType{}; | ||
7339 | 7339 | | |||
7340 | if (!internalGenericPartialData(query)) { | 7340 | if (!internalGenericPartialData(query)) { | ||
7341 | return result; | 7341 | return result; | ||
7342 | } | 7342 | } | ||
7343 | 7343 | | |||
7344 | while(query.next()) { | 7344 | while(query.next()) { | ||
7345 | auto newData = AlbumDataType{}; | 7345 | auto newData = DataTypes::AlbumDataType{}; | ||
7346 | 7346 | | |||
7347 | const auto ¤tRecord = query.record(); | 7347 | const auto ¤tRecord = query.record(); | ||
7348 | 7348 | | |||
7349 | newData[DataType::key_type::DatabaseIdRole] = currentRecord.value(0); | 7349 | newData[DataTypes::DatabaseIdRole] = currentRecord.value(0); | ||
7350 | newData[DataType::key_type::TitleRole] = currentRecord.value(1); | 7350 | newData[DataTypes::TitleRole] = currentRecord.value(1); | ||
7351 | if (!currentRecord.value(3).toString().isEmpty()) { | 7351 | if (!currentRecord.value(3).toString().isEmpty()) { | ||
7352 | newData[DataType::key_type::ImageUrlRole] = currentRecord.value(3); | 7352 | newData[DataTypes::ImageUrlRole] = currentRecord.value(3); | ||
7353 | } else if (!currentRecord.value(10).toString().isEmpty()) { | 7353 | } else if (!currentRecord.value(10).toString().isEmpty()) { | ||
7354 | newData[DataType::key_type::ImageUrlRole] = QVariant{QStringLiteral("image://cover/") + currentRecord.value(10).toUrl().toLocalFile()}; | 7354 | newData[DataTypes::ImageUrlRole] = QVariant{QStringLiteral("image://cover/") + currentRecord.value(10).toUrl().toLocalFile()}; | ||
7355 | } | 7355 | } | ||
7356 | auto allArtists = currentRecord.value(6).toString().split(QStringLiteral(", ")); | 7356 | auto allArtists = currentRecord.value(6).toString().split(QStringLiteral(", ")); | ||
7357 | allArtists.removeDuplicates(); | 7357 | allArtists.removeDuplicates(); | ||
7358 | newData[DataType::key_type::AllArtistsRole] = QVariant::fromValue(allArtists); | 7358 | newData[DataTypes::AllArtistsRole] = QVariant::fromValue(allArtists); | ||
7359 | if (!currentRecord.value(4).isNull()) { | 7359 | if (!currentRecord.value(4).isNull()) { | ||
7360 | newData[DataType::key_type::IsValidAlbumArtistRole] = true; | 7360 | newData[DataTypes::IsValidAlbumArtistRole] = true; | ||
7361 | newData[DataType::key_type::SecondaryTextRole] = currentRecord.value(4); | 7361 | newData[DataTypes::SecondaryTextRole] = currentRecord.value(4); | ||
7362 | } else { | 7362 | } else { | ||
7363 | newData[DataType::key_type::IsValidAlbumArtistRole] = false; | 7363 | newData[DataTypes::IsValidAlbumArtistRole] = false; | ||
7364 | if (currentRecord.value(5).toInt() == 1) { | 7364 | if (currentRecord.value(5).toInt() == 1) { | ||
7365 | newData[DataType::key_type::SecondaryTextRole] = allArtists.first(); | 7365 | newData[DataTypes::SecondaryTextRole] = allArtists.first(); | ||
7366 | } else if (currentRecord.value(5).toInt() > 1) { | 7366 | } else if (currentRecord.value(5).toInt() > 1) { | ||
7367 | newData[DataType::key_type::SecondaryTextRole] = QStringLiteral("Various Artists"); | 7367 | newData[DataTypes::SecondaryTextRole] = QStringLiteral("Various Artists"); | ||
7368 | } | 7368 | } | ||
7369 | } | 7369 | } | ||
7370 | newData[DataType::key_type::ArtistRole] = newData[DataType::key_type::SecondaryTextRole]; | 7370 | newData[DataTypes::ArtistRole] = newData[DataTypes::SecondaryTextRole]; | ||
7371 | newData[DataType::key_type::HighestTrackRating] = currentRecord.value(7); | 7371 | newData[DataTypes::HighestTrackRating] = currentRecord.value(7); | ||
7372 | newData[DataType::key_type::IsSingleDiscAlbumRole] = currentRecord.value(9); | 7372 | newData[DataTypes::IsSingleDiscAlbumRole] = currentRecord.value(9); | ||
7373 | newData[DataType::key_type::GenreRole] = QVariant::fromValue(currentRecord.value(8).toString().split(QStringLiteral(", "))); | 7373 | newData[DataTypes::GenreRole] = QVariant::fromValue(currentRecord.value(8).toString().split(QStringLiteral(", "))); | ||
7374 | newData[DataType::key_type::ElementTypeRole] = ElisaUtils::Album; | 7374 | newData[DataTypes::ElementTypeRole] = ElisaUtils::Album; | ||
7375 | 7375 | | |||
7376 | result.push_back(newData); | 7376 | result.push_back(newData); | ||
7377 | } | 7377 | } | ||
7378 | 7378 | | |||
7379 | query.finish(); | 7379 | query.finish(); | ||
7380 | 7380 | | |||
7381 | return result; | 7381 | return result; | ||
7382 | } | 7382 | } | ||
7383 | 7383 | | |||
7384 | DatabaseInterface::AlbumDataType DatabaseInterface::internalOneAlbumPartialData(qulonglong databaseId) | 7384 | DataTypes::AlbumDataType DatabaseInterface::internalOneAlbumPartialData(qulonglong databaseId) | ||
7385 | { | 7385 | { | ||
7386 | auto result = AlbumDataType{}; | 7386 | auto result = DataTypes::AlbumDataType{}; | ||
7387 | 7387 | | |||
7388 | d->mSelectAlbumQuery.bindValue(QStringLiteral(":albumId"), databaseId); | 7388 | d->mSelectAlbumQuery.bindValue(QStringLiteral(":albumId"), databaseId); | ||
7389 | 7389 | | |||
7390 | if (!internalGenericPartialData(d->mSelectAlbumQuery)) { | 7390 | if (!internalGenericPartialData(d->mSelectAlbumQuery)) { | ||
7391 | return result; | 7391 | return result; | ||
7392 | } | 7392 | } | ||
7393 | 7393 | | |||
7394 | if (d->mSelectAlbumQuery.next()) { | 7394 | if (d->mSelectAlbumQuery.next()) { | ||
7395 | const auto ¤tRecord = d->mSelectAlbumQuery.record(); | 7395 | const auto ¤tRecord = d->mSelectAlbumQuery.record(); | ||
7396 | 7396 | | |||
7397 | result[DataType::key_type::DatabaseIdRole] = currentRecord.value(0); | 7397 | result[DataTypes::DatabaseIdRole] = currentRecord.value(0); | ||
7398 | result[DataType::key_type::TitleRole] = currentRecord.value(1); | 7398 | result[DataTypes::TitleRole] = currentRecord.value(1); | ||
7399 | if (!currentRecord.value(4).toString().isEmpty()) { | 7399 | if (!currentRecord.value(4).toString().isEmpty()) { | ||
7400 | result[DataType::key_type::ImageUrlRole] = currentRecord.value(4); | 7400 | result[DataTypes::ImageUrlRole] = currentRecord.value(4); | ||
7401 | } else if (!currentRecord.value(11).toString().isEmpty()) { | 7401 | } else if (!currentRecord.value(11).toString().isEmpty()) { | ||
7402 | result[DataType::key_type::ImageUrlRole] = QVariant{QStringLiteral("image://cover/") + currentRecord.value(11).toUrl().toLocalFile()}; | 7402 | result[DataTypes::ImageUrlRole] = QVariant{QStringLiteral("image://cover/") + currentRecord.value(11).toUrl().toLocalFile()}; | ||
7403 | } | 7403 | } | ||
7404 | 7404 | | |||
7405 | auto allArtists = currentRecord.value(8).toString().split(QStringLiteral(", ")); | 7405 | auto allArtists = currentRecord.value(8).toString().split(QStringLiteral(", ")); | ||
7406 | allArtists.removeDuplicates(); | 7406 | allArtists.removeDuplicates(); | ||
7407 | result[DataType::key_type::AllArtistsRole] = QVariant::fromValue(allArtists); | 7407 | result[DataTypes::AllArtistsRole] = QVariant::fromValue(allArtists); | ||
7408 | 7408 | | |||
7409 | if (!currentRecord.value(2).isNull()) { | 7409 | if (!currentRecord.value(2).isNull()) { | ||
7410 | result[DataType::key_type::IsValidAlbumArtistRole] = true; | 7410 | result[DataTypes::IsValidAlbumArtistRole] = true; | ||
7411 | result[DataType::key_type::SecondaryTextRole] = currentRecord.value(2); | 7411 | result[DataTypes::SecondaryTextRole] = currentRecord.value(2); | ||
7412 | } else { | 7412 | } else { | ||
7413 | result[DataType::key_type::IsValidAlbumArtistRole] = false; | 7413 | result[DataTypes::IsValidAlbumArtistRole] = false; | ||
7414 | if (currentRecord.value(7).toInt() == 1) { | 7414 | if (currentRecord.value(7).toInt() == 1) { | ||
7415 | result[DataType::key_type::SecondaryTextRole] = allArtists.first(); | 7415 | result[DataTypes::SecondaryTextRole] = allArtists.first(); | ||
7416 | } else if (currentRecord.value(7).toInt() > 1) { | 7416 | } else if (currentRecord.value(7).toInt() > 1) { | ||
7417 | result[DataType::key_type::SecondaryTextRole] = QStringLiteral("Various Artists"); | 7417 | result[DataTypes::SecondaryTextRole] = QStringLiteral("Various Artists"); | ||
7418 | } | 7418 | } | ||
7419 | } | 7419 | } | ||
7420 | result[DataType::key_type::ArtistRole] = result[DataType::key_type::SecondaryTextRole]; | 7420 | result[DataTypes::ArtistRole] = result[DataTypes::SecondaryTextRole]; | ||
7421 | result[DataType::key_type::HighestTrackRating] = currentRecord.value(9); | 7421 | result[DataTypes::HighestTrackRating] = currentRecord.value(9); | ||
7422 | result[DataType::key_type::IsSingleDiscAlbumRole] = currentRecord.value(6); | 7422 | result[DataTypes::IsSingleDiscAlbumRole] = currentRecord.value(6); | ||
7423 | result[DataType::key_type::GenreRole] = QVariant::fromValue(currentRecord.value(10).toString().split(QStringLiteral(", "))); | 7423 | result[DataTypes::GenreRole] = QVariant::fromValue(currentRecord.value(10).toString().split(QStringLiteral(", "))); | ||
7424 | result[DataType::key_type::ElementTypeRole] = ElisaUtils::Album; | 7424 | result[DataTypes::ElementTypeRole] = ElisaUtils::Album; | ||
7425 | | ||||
7425 | } | 7426 | } | ||
7426 | 7427 | | |||
7427 | d->mSelectAlbumQuery.finish(); | 7428 | d->mSelectAlbumQuery.finish(); | ||
7428 | 7429 | | |||
7429 | return result; | 7430 | return result; | ||
7430 | } | 7431 | } | ||
7431 | 7432 | | |||
7432 | DatabaseInterface::ListTrackDataType DatabaseInterface::internalAllTracksPartialData() | 7433 | DataTypes::ListTrackDataType DatabaseInterface::internalAllTracksPartialData() | ||
7433 | { | 7434 | { | ||
7434 | auto result = ListTrackDataType{}; | 7435 | auto result = DataTypes::ListTrackDataType{}; | ||
7435 | 7436 | | |||
7436 | if (!internalGenericPartialData(d->mSelectAllTracksQuery)) { | 7437 | if (!internalGenericPartialData(d->mSelectAllTracksQuery)) { | ||
7437 | return result; | 7438 | return result; | ||
7438 | } | 7439 | } | ||
7439 | 7440 | | |||
7440 | while(d->mSelectAllTracksQuery.next()) { | 7441 | while(d->mSelectAllTracksQuery.next()) { | ||
7441 | const auto ¤tRecord = d->mSelectAllTracksQuery.record(); | 7442 | const auto ¤tRecord = d->mSelectAllTracksQuery.record(); | ||
7442 | 7443 | | |||
7443 | auto newData = buildTrackDataFromDatabaseRecord(currentRecord); | 7444 | auto newData = buildTrackDataFromDatabaseRecord(currentRecord); | ||
7444 | 7445 | | |||
7445 | result.push_back(newData); | 7446 | result.push_back(newData); | ||
7446 | } | 7447 | } | ||
7447 | 7448 | | |||
7448 | d->mSelectAllTracksQuery.finish(); | 7449 | d->mSelectAllTracksQuery.finish(); | ||
7449 | 7450 | | |||
7450 | return result; | 7451 | return result; | ||
7451 | } | 7452 | } | ||
7452 | 7453 | | |||
7453 | DatabaseInterface::ListRadioDataType DatabaseInterface::internalAllRadiosPartialData() | 7454 | DataTypes::ListRadioDataType DatabaseInterface::internalAllRadiosPartialData() | ||
7454 | { | 7455 | { | ||
7455 | auto result = ListRadioDataType{}; | 7456 | auto result = DataTypes::ListRadioDataType{}; | ||
7456 | 7457 | | |||
7457 | if (!internalGenericPartialData(d->mSelectAllRadiosQuery)) { | 7458 | if (!internalGenericPartialData(d->mSelectAllRadiosQuery)) { | ||
7458 | return result; | 7459 | return result; | ||
7459 | } | 7460 | } | ||
7460 | 7461 | | |||
7461 | while(d->mSelectAllRadiosQuery.next()) { | 7462 | while(d->mSelectAllRadiosQuery.next()) { | ||
7462 | const auto ¤tRecord = d->mSelectAllRadiosQuery.record(); | 7463 | const auto ¤tRecord = d->mSelectAllRadiosQuery.record(); | ||
7463 | 7464 | | |||
7464 | auto newData = buildRadioDataFromDatabaseRecord(currentRecord); | 7465 | auto newData = buildRadioDataFromDatabaseRecord(currentRecord); | ||
7465 | 7466 | | |||
7466 | result.push_back(newData); | 7467 | result.push_back(newData); | ||
7467 | } | 7468 | } | ||
7468 | 7469 | | |||
7469 | d->mSelectAllRadiosQuery.finish(); | 7470 | d->mSelectAllRadiosQuery.finish(); | ||
7470 | 7471 | | |||
7471 | return result; | 7472 | return result; | ||
7472 | } | 7473 | } | ||
7473 | 7474 | | |||
7474 | DatabaseInterface::ListTrackDataType DatabaseInterface::internalRecentlyPlayedTracksData(int count) | 7475 | DataTypes::ListTrackDataType DatabaseInterface::internalRecentlyPlayedTracksData(int count) | ||
7475 | { | 7476 | { | ||
7476 | auto result = ListTrackDataType{}; | 7477 | auto result = DataTypes::ListTrackDataType{}; | ||
7477 | 7478 | | |||
7478 | d->mSelectAllRecentlyPlayedTracksQuery.bindValue(QStringLiteral(":maximumResults"), count); | 7479 | d->mSelectAllRecentlyPlayedTracksQuery.bindValue(QStringLiteral(":maximumResults"), count); | ||
7479 | 7480 | | |||
7480 | if (!internalGenericPartialData(d->mSelectAllRecentlyPlayedTracksQuery)) { | 7481 | if (!internalGenericPartialData(d->mSelectAllRecentlyPlayedTracksQuery)) { | ||
7481 | return result; | 7482 | return result; | ||
7482 | } | 7483 | } | ||
7483 | 7484 | | |||
7484 | while(d->mSelectAllRecentlyPlayedTracksQuery.next()) { | 7485 | while(d->mSelectAllRecentlyPlayedTracksQuery.next()) { | ||
7485 | const auto ¤tRecord = d->mSelectAllRecentlyPlayedTracksQuery.record(); | 7486 | const auto ¤tRecord = d->mSelectAllRecentlyPlayedTracksQuery.record(); | ||
7486 | 7487 | | |||
7487 | auto newData = buildTrackDataFromDatabaseRecord(currentRecord); | 7488 | auto newData = buildTrackDataFromDatabaseRecord(currentRecord); | ||
7488 | 7489 | | |||
7489 | result.push_back(newData); | 7490 | result.push_back(newData); | ||
7490 | } | 7491 | } | ||
7491 | 7492 | | |||
7492 | d->mSelectAllRecentlyPlayedTracksQuery.finish(); | 7493 | d->mSelectAllRecentlyPlayedTracksQuery.finish(); | ||
7493 | 7494 | | |||
7494 | return result; | 7495 | return result; | ||
7495 | } | 7496 | } | ||
7496 | 7497 | | |||
7497 | DatabaseInterface::ListTrackDataType DatabaseInterface::internalFrequentlyPlayedTracksData(int count) | 7498 | DataTypes::ListTrackDataType DatabaseInterface::internalFrequentlyPlayedTracksData(int count) | ||
7498 | { | 7499 | { | ||
7499 | auto result = ListTrackDataType{}; | 7500 | auto result = DataTypes::ListTrackDataType{}; | ||
7500 | 7501 | | |||
7501 | d->mSelectAllFrequentlyPlayedTracksQuery.bindValue(QStringLiteral(":maximumResults"), count); | 7502 | d->mSelectAllFrequentlyPlayedTracksQuery.bindValue(QStringLiteral(":maximumResults"), count); | ||
7502 | 7503 | | |||
7503 | if (!internalGenericPartialData(d->mSelectAllFrequentlyPlayedTracksQuery)) { | 7504 | if (!internalGenericPartialData(d->mSelectAllFrequentlyPlayedTracksQuery)) { | ||
7504 | return result; | 7505 | return result; | ||
7505 | } | 7506 | } | ||
7506 | 7507 | | |||
7507 | while(d->mSelectAllFrequentlyPlayedTracksQuery.next()) { | 7508 | while(d->mSelectAllFrequentlyPlayedTracksQuery.next()) { | ||
7508 | const auto ¤tRecord = d->mSelectAllFrequentlyPlayedTracksQuery.record(); | 7509 | const auto ¤tRecord = d->mSelectAllFrequentlyPlayedTracksQuery.record(); | ||
7509 | 7510 | | |||
7510 | auto newData = buildTrackDataFromDatabaseRecord(currentRecord); | 7511 | auto newData = buildTrackDataFromDatabaseRecord(currentRecord); | ||
7511 | 7512 | | |||
7512 | result.push_back(newData); | 7513 | result.push_back(newData); | ||
7513 | } | 7514 | } | ||
7514 | 7515 | | |||
7515 | d->mSelectAllFrequentlyPlayedTracksQuery.finish(); | 7516 | d->mSelectAllFrequentlyPlayedTracksQuery.finish(); | ||
7516 | 7517 | | |||
7517 | return result; | 7518 | return result; | ||
7518 | } | 7519 | } | ||
7519 | 7520 | | |||
7520 | DatabaseInterface::TrackDataType DatabaseInterface::internalOneTrackPartialData(qulonglong databaseId) | 7521 | DataTypes::TrackDataType DatabaseInterface::internalOneTrackPartialData(qulonglong databaseId) | ||
7521 | { | 7522 | { | ||
7522 | auto result = TrackDataType{}; | 7523 | auto result = DataTypes::TrackDataType{}; | ||
7523 | 7524 | | |||
7524 | d->mSelectTrackFromIdQuery.bindValue(QStringLiteral(":trackId"), databaseId); | 7525 | d->mSelectTrackFromIdQuery.bindValue(QStringLiteral(":trackId"), databaseId); | ||
7525 | 7526 | | |||
7526 | if (!internalGenericPartialData(d->mSelectTrackFromIdQuery)) { | 7527 | if (!internalGenericPartialData(d->mSelectTrackFromIdQuery)) { | ||
7527 | return result; | 7528 | return result; | ||
7528 | } | 7529 | } | ||
7529 | 7530 | | |||
7530 | if (d->mSelectTrackFromIdQuery.next()) { | 7531 | if (d->mSelectTrackFromIdQuery.next()) { | ||
7531 | const auto ¤tRecord = d->mSelectTrackFromIdQuery.record(); | 7532 | const auto ¤tRecord = d->mSelectTrackFromIdQuery.record(); | ||
7532 | 7533 | | |||
7533 | result = buildTrackDataFromDatabaseRecord(currentRecord); | 7534 | result = buildTrackDataFromDatabaseRecord(currentRecord); | ||
7534 | } | 7535 | } | ||
7535 | 7536 | | |||
7536 | d->mSelectTrackFromIdQuery.finish(); | 7537 | d->mSelectTrackFromIdQuery.finish(); | ||
7537 | 7538 | | |||
7538 | return result; | 7539 | return result; | ||
7539 | } | 7540 | } | ||
7540 | 7541 | | |||
7541 | DatabaseInterface::TrackDataType DatabaseInterface::internalOneRadioPartialData(qulonglong databaseId) | 7542 | DataTypes::TrackDataType DatabaseInterface::internalOneRadioPartialData(qulonglong databaseId) | ||
7542 | { | 7543 | { | ||
7543 | auto result = TrackDataType{}; | 7544 | auto result = DataTypes::TrackDataType{}; | ||
7544 | 7545 | | |||
7545 | d->mSelectRadioFromIdQuery.bindValue(QStringLiteral(":radioId"), databaseId); | 7546 | d->mSelectRadioFromIdQuery.bindValue(QStringLiteral(":radioId"), databaseId); | ||
7546 | 7547 | | |||
7547 | if (!internalGenericPartialData(d->mSelectRadioFromIdQuery)) { | 7548 | if (!internalGenericPartialData(d->mSelectRadioFromIdQuery)) { | ||
7548 | return result; | 7549 | return result; | ||
7549 | } | 7550 | } | ||
7550 | 7551 | | |||
7551 | if (d->mSelectRadioFromIdQuery.next()) { | 7552 | if (d->mSelectRadioFromIdQuery.next()) { | ||
7552 | const auto ¤tRecord = d->mSelectRadioFromIdQuery.record(); | 7553 | const auto ¤tRecord = d->mSelectRadioFromIdQuery.record(); | ||
7553 | 7554 | | |||
7554 | result = buildRadioDataFromDatabaseRecord(currentRecord); | 7555 | result = buildRadioDataFromDatabaseRecord(currentRecord); | ||
7555 | } | 7556 | } | ||
7556 | 7557 | | |||
7557 | d->mSelectRadioFromIdQuery.finish(); | 7558 | d->mSelectRadioFromIdQuery.finish(); | ||
7558 | 7559 | | |||
7559 | return result; | 7560 | return result; | ||
7560 | } | 7561 | } | ||
7561 | 7562 | | |||
7562 | DatabaseInterface::ListGenreDataType DatabaseInterface::internalAllGenresPartialData() | 7563 | DataTypes::ListGenreDataType DatabaseInterface::internalAllGenresPartialData() | ||
7563 | { | 7564 | { | ||
7564 | ListGenreDataType result; | 7565 | DataTypes::ListGenreDataType result; | ||
7565 | 7566 | | |||
7566 | if (!internalGenericPartialData(d->mSelectAllGenresQuery)) { | 7567 | if (!internalGenericPartialData(d->mSelectAllGenresQuery)) { | ||
7567 | return result; | 7568 | return result; | ||
7568 | } | 7569 | } | ||
7569 | 7570 | | |||
7570 | while(d->mSelectAllGenresQuery.next()) { | 7571 | while(d->mSelectAllGenresQuery.next()) { | ||
7571 | auto newData = GenreDataType{}; | 7572 | auto newData = DataTypes::GenreDataType{}; | ||
7572 | 7573 | | |||
7573 | const auto ¤tRecord = d->mSelectAllGenresQuery.record(); | 7574 | const auto ¤tRecord = d->mSelectAllGenresQuery.record(); | ||
7574 | 7575 | | |||
7575 | newData[DataType::key_type::DatabaseIdRole] = currentRecord.value(0); | 7576 | newData[DataTypes::DatabaseIdRole] = currentRecord.value(0); | ||
7576 | newData[DataType::key_type::TitleRole] = currentRecord.value(1); | 7577 | newData[DataTypes::TitleRole] = currentRecord.value(1); | ||
7577 | newData[DataType::key_type::ElementTypeRole] = ElisaUtils::Genre; | 7578 | newData[DataTypes::ElementTypeRole] = ElisaUtils::Genre; | ||
7578 | 7579 | | |||
7579 | result.push_back(newData); | 7580 | result.push_back(newData); | ||
7580 | } | 7581 | } | ||
7581 | 7582 | | |||
7582 | d->mSelectAllGenresQuery.finish(); | 7583 | d->mSelectAllGenresQuery.finish(); | ||
7583 | 7584 | | |||
7584 | return result; | 7585 | return result; | ||
7585 | } | 7586 | } | ||
7586 | 7587 | | |||
7587 | DatabaseInterface::ListArtistDataType DatabaseInterface::internalAllComposersPartialData() | 7588 | DataTypes::ListArtistDataType DatabaseInterface::internalAllComposersPartialData() | ||
7588 | { | 7589 | { | ||
7589 | ListArtistDataType result; | 7590 | DataTypes::ListArtistDataType result; | ||
7590 | 7591 | | |||
7591 | if (!internalGenericPartialData(d->mSelectAllComposersQuery)) { | 7592 | if (!internalGenericPartialData(d->mSelectAllComposersQuery)) { | ||
7592 | return result; | 7593 | return result; | ||
7593 | } | 7594 | } | ||
7594 | 7595 | | |||
7595 | while(d->mSelectAllComposersQuery.next()) { | 7596 | while(d->mSelectAllComposersQuery.next()) { | ||
7596 | auto newData = ArtistDataType{}; | 7597 | auto newData = DataTypes::ArtistDataType{}; | ||
7597 | 7598 | | |||
7598 | const auto ¤tRecord = d->mSelectAllComposersQuery.record(); | 7599 | const auto ¤tRecord = d->mSelectAllComposersQuery.record(); | ||
7599 | 7600 | | |||
7600 | newData[DataType::key_type::DatabaseIdRole] = currentRecord.value(0); | 7601 | newData[DataTypes::DatabaseIdRole] = currentRecord.value(0); | ||
7601 | newData[DataType::key_type::TitleRole] = currentRecord.value(1); | 7602 | newData[DataTypes::TitleRole] = currentRecord.value(1); | ||
7602 | newData[DataType::key_type::ElementTypeRole] = ElisaUtils::Composer; | 7603 | newData[DataTypes::ElementTypeRole] = ElisaUtils::Composer; | ||
7603 | 7604 | | |||
7604 | result.push_back(newData); | 7605 | result.push_back(newData); | ||
7605 | } | 7606 | } | ||
7606 | 7607 | | |||
7607 | d->mSelectAllComposersQuery.finish(); | 7608 | d->mSelectAllComposersQuery.finish(); | ||
7608 | 7609 | | |||
7609 | return result; | 7610 | return result; | ||
7610 | } | 7611 | } | ||
7611 | 7612 | | |||
7612 | DatabaseInterface::ListArtistDataType DatabaseInterface::internalAllLyricistsPartialData() | 7613 | DataTypes::ListArtistDataType DatabaseInterface::internalAllLyricistsPartialData() | ||
7613 | { | 7614 | { | ||
7614 | ListArtistDataType result; | 7615 | DataTypes::ListArtistDataType result; | ||
7615 | 7616 | | |||
7616 | if (!internalGenericPartialData(d->mSelectAllLyricistsQuery)) { | 7617 | if (!internalGenericPartialData(d->mSelectAllLyricistsQuery)) { | ||
7617 | return result; | 7618 | return result; | ||
7618 | } | 7619 | } | ||
7619 | 7620 | | |||
7620 | while(d->mSelectAllLyricistsQuery.next()) { | 7621 | while(d->mSelectAllLyricistsQuery.next()) { | ||
7621 | auto newData = ArtistDataType{}; | 7622 | auto newData = DataTypes::ArtistDataType{}; | ||
7622 | 7623 | | |||
7623 | const auto ¤tRecord = d->mSelectAllLyricistsQuery.record(); | 7624 | const auto ¤tRecord = d->mSelectAllLyricistsQuery.record(); | ||
7624 | 7625 | | |||
7625 | newData[DataType::key_type::DatabaseIdRole] = currentRecord.value(0); | 7626 | newData[DataTypes::DatabaseIdRole] = currentRecord.value(0); | ||
7626 | newData[DataType::key_type::TitleRole] = currentRecord.value(1); | 7627 | newData[DataTypes::TitleRole] = currentRecord.value(1); | ||
7627 | newData[DataType::key_type::ElementTypeRole] = ElisaUtils::Lyricist; | 7628 | newData[DataTypes::ElementTypeRole] = ElisaUtils::Lyricist; | ||
7628 | 7629 | | |||
7629 | result.push_back(newData); | 7630 | result.push_back(newData); | ||
7630 | } | 7631 | } | ||
7631 | 7632 | | |||
7632 | d->mSelectAllLyricistsQuery.finish(); | 7633 | d->mSelectAllLyricistsQuery.finish(); | ||
7633 | 7634 | | |||
7634 | return result; | 7635 | return result; | ||
7635 | } | 7636 | } | ||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |