Changeset View
Changeset View
Standalone View
Standalone View
src/mediaplaylist.cpp
Show First 20 Lines • Show All 581 Lines • ▼ Show 20 Line(s) | 579 | if (!newEntry.mIsValid) { | |||
---|---|---|---|---|---|
582 | if (!d->mCurrentTrack.isValid()) { | 582 | if (!d->mCurrentTrack.isValid()) { | ||
583 | resetCurrentTrack(); | 583 | resetCurrentTrack(); | ||
584 | } | 584 | } | ||
585 | } | 585 | } | ||
586 | } | 586 | } | ||
587 | 587 | | |||
588 | void MediaPlayList::enqueue(const MusicAlbum &album) | 588 | void MediaPlayList::enqueue(const MusicAlbum &album) | ||
589 | { | 589 | { | ||
590 | for (auto oneTrackIndex = 0; oneTrackIndex < album.tracksCount(); ++oneTrackIndex) { | 590 | enqueue(album.tracksList(), ElisaUtils::AppendPlayList, ElisaUtils::DoNotTriggerPlay); | ||
mgallien: Instead of that, please extend MusicAlbum to allow access to the list of tracks and just… | |||||
591 | enqueue(album.trackFromIndex(oneTrackIndex)); | | |||
592 | } | | |||
593 | } | 591 | } | ||
594 | 592 | | |||
595 | void MediaPlayList::enqueue(const MusicArtist &artist) | 593 | void MediaPlayList::enqueue(const MusicArtist &artist) | ||
596 | { | 594 | { | ||
597 | enqueue(artist.name()); | 595 | enqueue(artist.name()); | ||
598 | } | 596 | } | ||
599 | 597 | | |||
600 | void MediaPlayList::enqueue(const QString &artistName) | 598 | void MediaPlayList::enqueue(const QString &artistName) | ||
Show All 14 Lines | |||||
615 | } | 613 | } | ||
616 | 614 | | |||
617 | void MediaPlayList::enqueue(const QUrl &fileName) | 615 | void MediaPlayList::enqueue(const QUrl &fileName) | ||
618 | { | 616 | { | ||
619 | qDebug() << "MediaPlayList::enqueue" << fileName; | 617 | qDebug() << "MediaPlayList::enqueue" << fileName; | ||
620 | enqueue(MediaPlayListEntry(fileName)); | 618 | enqueue(MediaPlayListEntry(fileName)); | ||
621 | } | 619 | } | ||
622 | 620 | | |||
623 | void MediaPlayList::enqueue(const QStringList &files) | 621 | void MediaPlayList::enqueue(const QStringList &files) | ||
624 | { | 622 | { | ||
625 | qDebug() << "MediaPlayList::enqueue" << files; | 623 | qDebug() << "MediaPlayList::enqueue" << files; | ||
626 | for (const auto &oneFileName : files) { | 624 | QList<QUrl> fileUrls; | ||
627 | enqueue(QUrl::fromLocalFile(oneFileName)); | 625 | for (auto file : files) { | ||
626 | fileUrls.append(QUrl::fromLocalFile(file)); | ||||
628 | } | 627 | } | ||
628 | enqueue(fileUrls, ElisaUtils::AppendPlayList, ElisaUtils::DoNotTriggerPlay); | ||||
629 | } | 629 | } | ||
Instead of modifying it, it is possible to only keep one instead of having enqueue(QList<String>) and enqueue(QList<QUrl>) ? mgallien: Instead of modifying it, it is possible to only keep one instead of having enqueue… | |||||
You mean providing only one method for file urls, and getting rid of adding stringlists? that is certainly possible, but requires more changes throughout the code. for example, elisaapplication currently only gives a stringlist to the mediaplaylist. astippich: You mean providing only one method for file urls, and getting rid of adding stringlists? that… | |||||
mgallien: I agree. | |||||
630 | 630 | | |||
631 | void MediaPlayList::enqueueAndPlay(const QStringList &files) | 631 | void MediaPlayList::enqueueAndPlay(const QStringList &files) | ||
632 | { | 632 | { | ||
633 | if (files.size() > 0) { | 633 | if (files.size() > 0) { | ||
634 | int previousTrackNumber = tracksCount(); | 634 | int previousTrackNumber = tracksCount(); | ||
635 | enqueue(files); | 635 | enqueue(files); | ||
636 | switchTo(previousTrackNumber); | 636 | switchTo(previousTrackNumber); | ||
637 | Q_EMIT ensurePlay(); | 637 | Q_EMIT ensurePlay(); | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 780 | { | |||
783 | } | 783 | } | ||
784 | 784 | | |||
785 | if (enqueueMode == ElisaUtils::ReplacePlayList) { | 785 | if (enqueueMode == ElisaUtils::ReplacePlayList) { | ||
786 | clearPlayList(); | 786 | clearPlayList(); | ||
787 | } | 787 | } | ||
788 | 788 | | |||
789 | beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + trackUrls.size() - 1); | 789 | beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + trackUrls.size() - 1); | ||
790 | for (const auto &oneTrackUrl : trackUrls) { | 790 | for (const auto &oneTrackUrl : trackUrls) { | ||
791 | d->mData.push_back(MediaPlayListEntry{oneTrackUrl}); | 791 | auto newEntry = MediaPlayListEntry(oneTrackUrl); | ||
792 | d->mData.push_back(newEntry); | ||||
mgallien: Can you use auto here ? | |||||
792 | d->mTrackData.push_back({}); | 793 | d->mTrackData.push_back({}); | ||
793 | if (oneTrackUrl.isValid()) { | 794 | if (newEntry.mTrackUrl.isValid()) { | ||
794 | qDebug() << "MediaPlayList::enqueue" << "newTrackByFileNameInList" << oneTrackUrl; | 795 | qDebug() << "MediaPlayList::enqueue" << "newTrackByFileNameInList" << oneTrackUrl; | ||
795 | if (oneTrackUrl.isLocalFile()) { | 796 | if (newEntry.mTrackUrl.isLocalFile()) { | ||
796 | QFileInfo newTrackFile(oneTrackUrl.toLocalFile()); | 797 | QFileInfo newTrackFile(newEntry.mTrackUrl.toLocalFile()); | ||
797 | if (newTrackFile.exists()) { | 798 | if (newTrackFile.exists()) { | ||
798 | d->mData.last().mIsValid = true; | 799 | d->mData.last().mIsValid = true; | ||
799 | } | 800 | } | ||
800 | Q_EMIT newTrackByFileNameInList(oneTrackUrl); | 801 | Q_EMIT newTrackByFileNameInList(newEntry.mTrackUrl); | ||
Why do you want to change that ? It seems at least unrelated to your patch. mgallien: Why do you want to change that ? It seems at least unrelated to your patch. | |||||
This is needed to pass the tests and makes it more similar to the method adding a single file url. astippich: This is needed to pass the tests and makes it more similar to the method adding a single file… | |||||
801 | } | 802 | } | ||
802 | } | 803 | } | ||
803 | } | 804 | } | ||
804 | endInsertRows(); | 805 | endInsertRows(); | ||
805 | 806 | | |||
806 | restorePlayListPosition(); | 807 | restorePlayListPosition(); | ||
807 | if (!d->mCurrentTrack.isValid()) { | 808 | if (!d->mCurrentTrack.isValid()) { | ||
808 | resetCurrentTrack(); | 809 | resetCurrentTrack(); | ||
▲ Show 20 Lines • Show All 588 Lines • Show Last 20 Lines |
Instead of that, please extend MusicAlbum to allow access to the list of tracks and just enqueue a list of MusicAudioTrack. That would be the fastest solution.