Changeset View
Changeset View
Standalone View
Standalone View
src/mediaplaylist.cpp
Show First 20 Lines • Show All 622 Lines • ▼ Show 20 Line(s) | 622 | { | |||
---|---|---|---|---|---|
623 | if (files.size() > 0) { | 623 | if (files.size() > 0) { | ||
624 | int previousTrackNumber = tracksCount(); | 624 | int previousTrackNumber = tracksCount(); | ||
625 | enqueue(files); | 625 | enqueue(files); | ||
626 | switchTo(previousTrackNumber); | 626 | switchTo(previousTrackNumber); | ||
627 | Q_EMIT ensurePlay(); | 627 | Q_EMIT ensurePlay(); | ||
628 | } | 628 | } | ||
629 | } | 629 | } | ||
630 | 630 | | |||
631 | void MediaPlayList::enqueue(const QList<qulonglong> &newTrackIds) | ||||
632 | { | ||||
633 | beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + newTrackIds.size() - 1); | ||||
634 | for (auto newTrackId : newTrackIds) { | ||||
635 | d->mData.push_back(MediaPlayListEntry{newTrackId}); | ||||
636 | d->mTrackData.push_back({}); | ||||
637 | Q_EMIT newTrackByIdInList(newTrackId); | ||||
638 | } | ||||
639 | endInsertRows(); | ||||
640 | | ||||
641 | restorePlayListPosition(); | ||||
642 | if (!d->mCurrentTrack.isValid()) { | ||||
643 | resetCurrentTrack(); | ||||
644 | } | ||||
645 | | ||||
646 | Q_EMIT tracksCountChanged(); | ||||
647 | Q_EMIT persistentStateChanged(); | ||||
648 | | ||||
649 | Q_EMIT dataChanged(index(rowCount() - 1, 0), index(rowCount() - 1, 0), {MediaPlayList::HasAlbumHeader}); | ||||
650 | } | ||||
651 | | ||||
652 | void MediaPlayList::enqueue(const QList<MusicAlbum> &albums, | ||||
653 | ElisaUtils::PlayListEnqueueMode enqueueMode, | ||||
654 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | ||||
655 | { | ||||
656 | auto tracksCount = 0; | ||||
657 | for (const auto &oneAlbum : albums) { | ||||
658 | for (auto oneTrackIndex = 0; oneTrackIndex < oneAlbum.tracksCount(); ++oneTrackIndex) { | ||||
659 | ++tracksCount; | ||||
660 | } | ||||
661 | } | ||||
662 | | ||||
663 | if (enqueueMode == ElisaUtils::ReplacePlayList) { | ||||
664 | clearPlayList(); | ||||
665 | } | ||||
666 | | ||||
667 | beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + tracksCount - 1); | ||||
668 | for (const auto &oneAlbum : albums) { | ||||
669 | for (auto oneTrackIndex = 0; oneTrackIndex < oneAlbum.tracksCount(); ++oneTrackIndex) { | ||||
670 | const auto &oneTrack = oneAlbum.trackFromIndex(oneTrackIndex); | ||||
671 | d->mData.push_back(MediaPlayListEntry{oneTrack.databaseId()}); | ||||
672 | d->mTrackData.push_back(oneTrack); | ||||
673 | } | ||||
674 | } | ||||
675 | endInsertRows(); | ||||
676 | | ||||
677 | restorePlayListPosition(); | ||||
678 | if (!d->mCurrentTrack.isValid()) { | ||||
679 | resetCurrentTrack(); | ||||
680 | } | ||||
681 | | ||||
682 | Q_EMIT tracksCountChanged(); | ||||
683 | Q_EMIT persistentStateChanged(); | ||||
684 | | ||||
685 | Q_EMIT dataChanged(index(rowCount() - 1, 0), index(rowCount() - 1, 0), {MediaPlayList::HasAlbumHeader}); | ||||
686 | | ||||
687 | if (triggerPlay == ElisaUtils::TriggerPlay) { | ||||
688 | Q_EMIT ensurePlay(); | ||||
689 | } | ||||
690 | } | ||||
691 | | ||||
692 | void MediaPlayList::enqueue(const QList<MusicAudioTrack> &tracks, | ||||
693 | ElisaUtils::PlayListEnqueueMode enqueueMode, | ||||
694 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | ||||
695 | { | ||||
696 | if (enqueueMode == ElisaUtils::ReplacePlayList) { | ||||
697 | clearPlayList(); | ||||
698 | } | ||||
699 | | ||||
700 | beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + tracks.size() - 1); | ||||
701 | for (const auto &oneTrack : tracks) { | ||||
702 | d->mData.push_back(MediaPlayListEntry{oneTrack.databaseId()}); | ||||
703 | d->mTrackData.push_back(oneTrack); | ||||
704 | } | ||||
705 | endInsertRows(); | ||||
706 | | ||||
707 | restorePlayListPosition(); | ||||
708 | if (!d->mCurrentTrack.isValid()) { | ||||
709 | resetCurrentTrack(); | ||||
710 | } | ||||
711 | | ||||
712 | Q_EMIT tracksCountChanged(); | ||||
713 | Q_EMIT persistentStateChanged(); | ||||
714 | | ||||
715 | Q_EMIT dataChanged(index(rowCount() - 1, 0), index(rowCount() - 1, 0), {MediaPlayList::HasAlbumHeader}); | ||||
716 | | ||||
717 | if (triggerPlay == ElisaUtils::TriggerPlay) { | ||||
718 | Q_EMIT ensurePlay(); | ||||
719 | } | ||||
720 | } | ||||
721 | | ||||
722 | void MediaPlayList::enqueueArtists(const QList<QString> &artistNames, | ||||
723 | ElisaUtils::PlayListEnqueueMode enqueueMode, | ||||
724 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | ||||
725 | { | ||||
726 | if (enqueueMode == ElisaUtils::ReplacePlayList) { | ||||
727 | clearPlayList(); | ||||
728 | } | ||||
729 | | ||||
730 | beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + artistNames.size() - 1); | ||||
731 | for (const auto &artistName : artistNames) { | ||||
732 | d->mData.push_back(MediaPlayListEntry{artistName}); | ||||
733 | d->mTrackData.push_back({}); | ||||
734 | Q_EMIT newArtistInList(artistName); | ||||
735 | } | ||||
736 | endInsertRows(); | ||||
737 | | ||||
738 | restorePlayListPosition(); | ||||
739 | if (!d->mCurrentTrack.isValid()) { | ||||
740 | resetCurrentTrack(); | ||||
741 | } | ||||
742 | | ||||
743 | Q_EMIT tracksCountChanged(); | ||||
744 | Q_EMIT persistentStateChanged(); | ||||
745 | | ||||
746 | if (triggerPlay == ElisaUtils::TriggerPlay) { | ||||
747 | Q_EMIT ensurePlay(); | ||||
748 | } | ||||
749 | } | ||||
750 | | ||||
631 | void MediaPlayList::replaceAndPlay(qulonglong newTrackId) | 751 | void MediaPlayList::replaceAndPlay(qulonglong newTrackId) | ||
632 | { | 752 | { | ||
633 | clearPlayList(); | 753 | clearPlayList(); | ||
634 | enqueue(MediaPlayListEntry(newTrackId)); | 754 | enqueue(MediaPlayListEntry(newTrackId)); | ||
635 | Q_EMIT ensurePlay(); | 755 | Q_EMIT ensurePlay(); | ||
636 | } | 756 | } | ||
637 | 757 | | |||
638 | void MediaPlayList::replaceAndPlay(const MusicAudioTrack &newTrack) | 758 | void MediaPlayList::replaceAndPlay(const MusicAudioTrack &newTrack) | ||
▲ Show 20 Lines • Show All 564 Lines • Show Last 20 Lines |