Commit 77c61f9f authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

unbreak automated tests of MediaPlayList proxy model

parent 680714b8
......@@ -616,7 +616,8 @@ void MediaPlayListProxyModelTest::enqueueTrackByUrl()
auto newTrackID = myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track6"), QStringLiteral("artist1 and artist2"), QStringLiteral("album2"), 6, 1);
auto trackData = myDatabaseContent.trackDataFromDatabaseId(newTrackID);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, trackData.resourceURI()}}, {}, {});
myPlayListProxyModel.enqueue({{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, trackData.resourceURI()}}, {}, {}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -717,8 +718,10 @@ void MediaPlayListProxyModelTest::enqueueTracksByUrl()
auto firstTrackData = myDatabaseContent.trackDataFromDatabaseId(firstNewTrackID);
auto secondNewTrackID = myDatabaseContent.trackIdFromTitleAlbumTrackDiscNumber(QStringLiteral("track1"), QStringLiteral("artist1"), QStringLiteral("album1"), 1, 1);
auto secondTrackData = myDatabaseContent.trackDataFromDatabaseId(secondNewTrackID);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, firstTrackData.resourceURI()},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, secondTrackData.resourceURI()}}, {}, {});
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, firstTrackData.resourceURI()}}, {}, {}},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, secondTrackData.resourceURI()}}, {}, {}}}, {}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -6674,8 +6677,10 @@ void MediaPlayListProxyModelTest::enqueueFiles()
QCOMPARE(newEntryInListSpy.count(), 0);
QCOMPARE(newUrlInListSpy.count(), 0);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral("/$1"))},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral("/$2"))}}, {}, {});
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral("/$1"))}}, {}, {}},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral("/$2"))}}, {}, {}}}, {}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeMovedSpy.count(), 0);
......@@ -6787,8 +6792,11 @@ void MediaPlayListProxyModelTest::enqueueSampleFiles()
QCOMPARE(newEntryInListSpy.count(), 0);
QCOMPARE(newUrlInListSpy.count(), 0);
myPlayListProxyModel.enqueue({{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test.ogg"))},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track}}, {}, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test2.ogg"))}},
myPlayListProxyModel.enqueue({
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test.ogg"))}}, {}, {}},
{{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, QUrl::fromLocalFile(QStringLiteral(MEDIAPLAYLIST_TESTS_SAMPLE_FILES_PATH) + QStringLiteral("/test2.ogg"))}}, {}, {}}},
{}, {});
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
......
......@@ -405,6 +405,7 @@ void MediaPlayList::enqueueMultipleEntries(const DataTypes::EntryDataList &entri
beginInsertRows(QModelIndex(), d->mData.size(), d->mData.size() + entriesData.size() - 1);
for (const auto &entryData : entriesData) {
qCDebug(orgKdeElisaPlayList()) << "MediaPlayList::enqueueMultipleEntries" << std::get<0>(entryData);
auto trackUrl = std::get<0>(entryData)[DataTypes::ResourceRole].toUrl();
if (!std::get<0>(entryData).databaseId() && trackUrl.isValid()) {
auto newEntry = MediaPlayListEntry{trackUrl};
......
......@@ -424,7 +424,7 @@ void MediaPlayListProxyModel::sourceDataChanged(const QModelIndex &topLeft, cons
auto startSourceRow = topLeft.row();
auto endSourceRow = bottomRight.row();
for (int i = startSourceRow; i <= endSourceRow; i++) {
Q_EMIT dataChanged(index(mapRowFromSource(i), 0), index(mapRowFromSource(i), 0), roles);
Q_EMIT dataChanged(index(mapRowFromSource(i), 0), index(mapRowFromSource(i), 0), roles);
if (i == d->mCurrentTrack.row()) {
Q_EMIT currentTrackDataChanged();
} else if (i == d->mNextTrack.row()) {
......@@ -707,9 +707,11 @@ void MediaPlayListProxyModel::loadPlayListLoaded()
auto newTracks = DataTypes::EntryDataList{};
for (int i = 0; i < d->mLoadPlaylist.mediaCount(); ++i) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName}}}, {}, d->mLoadPlaylist.media(i).canonicalUrl()});
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, d->mLoadPlaylist.media(i).request().url()}}}, {}, {}});
#else
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName}}}, {}, d->mLoadPlaylist.media(i).request().url()});
newTracks.push_back({{{{DataTypes::ElementTypeRole, ElisaUtils::FileName},
{DataTypes::ResourceRole, d->mLoadPlaylist.media(i).request().url()}}}, {}, {}});
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment