Commit 0c042a86 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

allow database to contain and get tracks without metadata

display only the filename

I plan to add on top the work done by astippich that uses a sligthly
different approach

the tests are KO

the tracks without metadata are imported again and again. Needs fixing.

use url everywhere we refer to tracks or radios

allow to handle tracks without databaseId like the case of a track
without metadata

BUG: 415180
parent 6fb031bc
......@@ -4405,10 +4405,10 @@ private Q_SLOTS:
QCOMPARE(musicDb.allAlbumsData().count(), 5);
QCOMPARE(musicDb.allArtistsData().count(), 7);
QCOMPARE(musicDb.allTracksData().count(), 22);
QCOMPARE(musicDb.allTracksData().count(), 23);
QCOMPARE(musicDbArtistAddedSpy.count(), 1);
QCOMPARE(musicDbAlbumAddedSpy.count(), 1);
QCOMPARE(musicDbTrackAddedSpy.count(), 1);
QCOMPARE(musicDbTrackAddedSpy.count(), 2);
QCOMPARE(musicDbArtistRemovedSpy.count(), 0);
QCOMPARE(musicDbAlbumRemovedSpy.count(), 0);
QCOMPARE(musicDbTrackRemovedSpy.count(), 0);
......@@ -5248,6 +5248,76 @@ private Q_SLOTS:
QCOMPARE(albumFromGenreAndArtist.size(), 1);
}
void testTracksWithoutMetadata()
{
QTemporaryFile databaseFile;
databaseFile.open();
qDebug() << "testTracksWithoutMetadata" << databaseFile.fileName();
DatabaseInterface musicDb;
musicDb.init(QStringLiteral("testDb"), databaseFile.fileName());
QSignalSpy musicDbArtistAddedSpy(&musicDb, &DatabaseInterface::artistsAdded);
QSignalSpy musicDbAlbumAddedSpy(&musicDb, &DatabaseInterface::albumsAdded);
QSignalSpy musicDbTrackAddedSpy(&musicDb, &DatabaseInterface::tracksAdded);
QSignalSpy musicDbArtistRemovedSpy(&musicDb, &DatabaseInterface::artistRemoved);
QSignalSpy musicDbAlbumRemovedSpy(&musicDb, &DatabaseInterface::albumRemoved);
QSignalSpy musicDbTrackRemovedSpy(&musicDb, &DatabaseInterface::trackRemoved);
QSignalSpy musicDbAlbumModifiedSpy(&musicDb, &DatabaseInterface::albumModified);
QSignalSpy musicDbTrackModifiedSpy(&musicDb, &DatabaseInterface::trackModified);
QSignalSpy musicDbDatabaseErrorSpy(&musicDb, &DatabaseInterface::databaseError);
QCOMPARE(musicDb.allAlbumsData().count(), 0);
QCOMPARE(musicDb.allArtistsData().count(), 0);
QCOMPARE(musicDb.allTracksData().count(), 0);
QCOMPARE(musicDbArtistAddedSpy.count(), 0);
QCOMPARE(musicDbAlbumAddedSpy.count(), 0);
QCOMPARE(musicDbTrackAddedSpy.count(), 0);
QCOMPARE(musicDbArtistRemovedSpy.count(), 0);
QCOMPARE(musicDbAlbumRemovedSpy.count(), 0);
QCOMPARE(musicDbTrackRemovedSpy.count(), 0);
QCOMPARE(musicDbAlbumModifiedSpy.count(), 0);
QCOMPARE(musicDbTrackModifiedSpy.count(), 0);
QCOMPARE(musicDbDatabaseErrorSpy.count(), 0);
auto newTracks = DataTypes::ListTrackDataType {
{true, {}, {}, {}, {}, {}, {}, 0, 0, {}, {QUrl::fromLocalFile(QStringLiteral("/test/$23"))}, QDateTime::fromMSecsSinceEpoch(23), {}, 0, true, {}, {}, {}, false},
{true, {}, {}, {}, {}, {}, {}, 0, 0, {}, {QUrl::fromLocalFile(QStringLiteral("/test/$24"))}, QDateTime::fromMSecsSinceEpoch(24), {}, 0, true, {}, {}, {}, false},
{true, {}, {}, {}, {}, {}, {}, 0, 0, {}, {QUrl::fromLocalFile(QStringLiteral("/test/$25"))}, QDateTime::fromMSecsSinceEpoch(25), {}, 0, true, {}, {}, {}, false}};
auto newCovers = mNewCovers;
musicDb.insertTracksList(newTracks, newCovers);
musicDbTrackAddedSpy.wait(300);
QCOMPARE(musicDb.allAlbumsData().count(), 0);
QCOMPARE(musicDb.allArtistsData().count(), 0);
QCOMPARE(musicDb.allTracksData().count(), 3);
QCOMPARE(musicDbArtistAddedSpy.count(), 0);
QCOMPARE(musicDbAlbumAddedSpy.count(), 0);
QCOMPARE(musicDbTrackAddedSpy.count(), 1);
QCOMPARE(musicDbArtistRemovedSpy.count(), 0);
QCOMPARE(musicDbAlbumRemovedSpy.count(), 0);
QCOMPARE(musicDbTrackRemovedSpy.count(), 0);
QCOMPARE(musicDbAlbumModifiedSpy.count(), 0);
QCOMPARE(musicDbTrackModifiedSpy.count(), 0);
QCOMPARE(musicDbDatabaseErrorSpy.count(), 0);
auto allTracks = musicDb.allTracksData();
QVERIFY(allTracks[0].title().isEmpty());
QCOMPARE(allTracks[0].resourceURI(), QUrl::fromLocalFile(QStringLiteral("/test/$23")));
QCOMPARE(allTracks[0].fileModificationTime(), QDateTime::fromMSecsSinceEpoch(23));
QVERIFY(allTracks[1].title().isEmpty());
QCOMPARE(allTracks[1].resourceURI(), QUrl::fromLocalFile(QStringLiteral("/test/$24")));
QCOMPARE(allTracks[1].fileModificationTime(), QDateTime::fromMSecsSinceEpoch(24));
QVERIFY(allTracks[2].title().isEmpty());
QCOMPARE(allTracks[2].resourceURI(), QUrl::fromLocalFile(QStringLiteral("/test/$25")));
QCOMPARE(allTracks[2].fileModificationTime(), QDateTime::fromMSecsSinceEpoch(25));
}
};
QTEST_GUILESS_MAIN(DatabaseInterfaceTests)
......
......@@ -84,7 +84,8 @@ public:
mQueryMaximumGenreIdQuery(mTracksDatabase), mSelectAllArtistsWithGenreFilterQuery(mTracksDatabase),
mSelectAllAlbumsShortWithGenreArtistFilterQuery(mTracksDatabase), mSelectAllAlbumsShortWithArtistFilterQuery(mTracksDatabase),
mSelectAllRecentlyPlayedTracksQuery(mTracksDatabase), mSelectAllFrequentlyPlayedTracksQuery(mTracksDatabase),
mClearTracksTable(mTracksDatabase), mClearAlbumsTable(mTracksDatabase), mClearArtistsTable(mTracksDatabase),
mClearTracksDataTable(mTracksDatabase), mClearTracksTable(mTracksDatabase),
mClearAlbumsTable(mTracksDatabase), mClearArtistsTable(mTracksDatabase),
mClearComposerTable(mTracksDatabase), mClearGenreTable(mTracksDatabase), mClearLyricistTable(mTracksDatabase),
mArtistMatchGenreQuery(mTracksDatabase), mSelectTrackIdQuery(mTracksDatabase),
mInsertRadioQuery(mTracksDatabase), mDeleteRadioQuery(mTracksDatabase),
......@@ -244,6 +245,8 @@ public:
QSqlQuery mSelectAllFrequentlyPlayedTracksQuery;
QSqlQuery mClearTracksDataTable;
QSqlQuery mClearTracksTable;
QSqlQuery mClearAlbumsTable;
......@@ -919,6 +922,18 @@ void DatabaseInterface::clearData()
d->mClearTracksTable.finish();
queryResult = execQuery(d->mClearTracksDataTable);
if (!queryResult || !d->mClearTracksDataTable.isActive()) {
Q_EMIT databaseError();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::clearData" << d->mClearTracksDataTable.lastQuery();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::clearData" << d->mClearTracksDataTable.boundValues();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::clearData" << d->mClearTracksDataTable.lastError();
}
d->mClearTracksDataTable.finish();
queryResult = execQuery(d->mClearAlbumsTable);
if (!queryResult || !d->mClearAlbumsTable.isActive()) {
......@@ -3634,9 +3649,12 @@ void DatabaseInterface::initRequest()
"tracksCover.`AlbumPath` = album.`AlbumPath` "
") as EmbeddedCover "
"FROM "
"`Tracks` tracks, "
"`TracksData` tracksMapping "
"LEFT JOIN "
"`Tracks` tracks "
"ON "
"tracksMapping.`FileName` = tracks.`FileName` "
"LEFT JOIN "
"`Albums` album "
"ON "
"tracks.`AlbumTitle` = album.`Title` AND "
......@@ -3646,7 +3664,7 @@ void DatabaseInterface::initRequest()
"LEFT JOIN `Composer` trackComposer ON trackComposer.`Name` = tracks.`Composer` "
"LEFT JOIN `Lyricist` trackLyricist ON trackLyricist.`Name` = tracks.`Lyricist` "
"WHERE "
"tracksMapping.`FileName` = tracks.`FileName` AND "
"tracks.`Title` IS NULL OR "
"tracks.`Priority` = ("
" SELECT "
" MIN(`Priority`) "
......@@ -4009,6 +4027,19 @@ void DatabaseInterface::initRequest()
}
}
{
auto clearTracksDataTableText = QStringLiteral("DELETE FROM `TracksData`");
auto result = prepareQuery(d->mClearTracksDataTable, clearTracksDataTableText);
if (!result) {
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::initRequest" << d->mClearTracksDataTable.lastQuery();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::initRequest" << d->mClearTracksDataTable.lastError();
Q_EMIT databaseError();
}
}
{
auto clearTracksTableText = QStringLiteral("DELETE FROM `Tracks`");
......@@ -6198,7 +6229,6 @@ qulonglong DatabaseInterface::internalInsertTrack(const DataTypes::TrackDataType
if (oneTrack.title().isEmpty()) {
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is not inserted";
return resultId;
}
QUrl::FormattingOptions currentOptions = QUrl::PreferLocalFile |
......@@ -6221,7 +6251,7 @@ qulonglong DatabaseInterface::internalInsertTrack(const DataTypes::TrackDataType
auto existingTrackId = internalTrackIdFromFileName(oneTrack.resourceURI());
bool isModifiedTrack = (existingTrackId != 0);
if (isModifiedTrack) {
if (isModifiedTrack && !oneTrack.title().isEmpty()) {
resultId = existingTrackId;
auto oldTrack = internalTrackFromDatabaseId(existingTrackId);
......@@ -6311,107 +6341,115 @@ qulonglong DatabaseInterface::internalInsertTrack(const DataTypes::TrackDataType
resultId = existingTrackId;
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackId"), existingTrackId);
d->mInsertTrackQuery.bindValue(QStringLiteral(":fileName"), oneTrack.resourceURI());
d->mInsertTrackQuery.bindValue(QStringLiteral(":priority"), priority);
d->mInsertTrackQuery.bindValue(QStringLiteral(":title"), oneTrack.title());
insertArtist(oneTrack.artist());
d->mInsertTrackQuery.bindValue(QStringLiteral(":artistName"), oneTrack.artist());
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumTitle"), oneTrack.album());
if (oneTrack.hasAlbumArtist()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumArtistName"), oneTrack.albumArtist());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumArtistName"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumPath"), trackPath);
if (oneTrack.hasTrackNumber()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackNumber"), oneTrack.trackNumber());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackNumber"), {});
}
if (oneTrack.hasDiscNumber()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":discNumber"), oneTrack.discNumber());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":discNumber"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackDuration"), QVariant::fromValue<qlonglong>(oneTrack.duration().msecsSinceStartOfDay()));
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackRating"), oneTrack.rating());
if (insertGenre(oneTrack.genre()) != 0) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":genre"), oneTrack.genre());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":genre"), {});
}
if (insertComposer(oneTrack.composer()) != 0) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":composer"), oneTrack.composer());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":composer"), {});
}
if (insertLyricist(oneTrack.lyricist()) != 0) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":lyricist"), oneTrack.lyricist());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":lyricist"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":comment"), oneTrack.comment());
d->mInsertTrackQuery.bindValue(QStringLiteral(":year"), oneTrack.year());
if (oneTrack.hasChannels()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":channels"), oneTrack.channels());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":channels"), {});
}
if (oneTrack.hasBitRate()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":bitRate"), oneTrack.bitRate());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":bitRate"), {});
}
if (oneTrack.hasSampleRate()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":sampleRate"), oneTrack.sampleRate());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":sampleRate"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":hasEmbeddedCover"), oneTrack.hasEmbeddedCover());
if (!oneTrack.title().isEmpty()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackId"), existingTrackId);
d->mInsertTrackQuery.bindValue(QStringLiteral(":fileName"), oneTrack.resourceURI());
d->mInsertTrackQuery.bindValue(QStringLiteral(":priority"), priority);
d->mInsertTrackQuery.bindValue(QStringLiteral(":title"), oneTrack.title());
insertArtist(oneTrack.artist());
d->mInsertTrackQuery.bindValue(QStringLiteral(":artistName"), oneTrack.artist());
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumTitle"), oneTrack.album());
if (oneTrack.hasAlbumArtist()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumArtistName"), oneTrack.albumArtist());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumArtistName"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":albumPath"), trackPath);
if (oneTrack.hasTrackNumber()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackNumber"), oneTrack.trackNumber());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackNumber"), {});
}
if (oneTrack.hasDiscNumber()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":discNumber"), oneTrack.discNumber());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":discNumber"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackDuration"), QVariant::fromValue<qlonglong>(oneTrack.duration().msecsSinceStartOfDay()));
d->mInsertTrackQuery.bindValue(QStringLiteral(":trackRating"), oneTrack.rating());
if (insertGenre(oneTrack.genre()) != 0) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":genre"), oneTrack.genre());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":genre"), {});
}
if (insertComposer(oneTrack.composer()) != 0) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":composer"), oneTrack.composer());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":composer"), {});
}
if (insertLyricist(oneTrack.lyricist()) != 0) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":lyricist"), oneTrack.lyricist());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":lyricist"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":comment"), oneTrack.comment());
d->mInsertTrackQuery.bindValue(QStringLiteral(":year"), oneTrack.year());
if (oneTrack.hasChannels()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":channels"), oneTrack.channels());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":channels"), {});
}
if (oneTrack.hasBitRate()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":bitRate"), oneTrack.bitRate());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":bitRate"), {});
}
if (oneTrack.hasSampleRate()) {
d->mInsertTrackQuery.bindValue(QStringLiteral(":sampleRate"), oneTrack.sampleRate());
} else {
d->mInsertTrackQuery.bindValue(QStringLiteral(":sampleRate"), {});
}
d->mInsertTrackQuery.bindValue(QStringLiteral(":hasEmbeddedCover"), oneTrack.hasEmbeddedCover());
auto result = execQuery(d->mInsertTrackQuery);
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is inserted";
auto result = execQuery(d->mInsertTrackQuery);
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is inserted";
if (result && d->mInsertTrackQuery.isActive()) {
d->mInsertTrackQuery.finish();
if (result && d->mInsertTrackQuery.isActive()) {
d->mInsertTrackQuery.finish();
if (!isModifiedTrack) {
++d->mTrackId;
}
if (!isModifiedTrack) {
++d->mTrackId;
}
updateTrackOrigin(oneTrack.resourceURI(), oneTrack.fileModificationTime());
updateTrackOrigin(oneTrack.resourceURI(), oneTrack.fileModificationTime());
if (isModifiedTrack) {
recordModifiedTrack(existingTrackId);
if (albumId != 0) {
recordModifiedAlbum(albumId);
}
if (oldAlbumId != 0) {
recordModifiedAlbum(oldAlbumId);
if (isModifiedTrack) {
recordModifiedTrack(existingTrackId);
if (albumId != 0) {
recordModifiedAlbum(albumId);
}
if (oldAlbumId != 0) {
recordModifiedAlbum(oldAlbumId);
}
}
}
if (albumId != 0) {
if (updateAlbumFromId(albumId, covers[oneTrack.resourceURI().toString()], oneTrack, trackPath)) {
auto modifiedTracks = fetchTrackIds(albumId);
for (auto oneModifiedTrack : modifiedTracks) {
if (oneModifiedTrack != resultId) {
recordModifiedTrack(oneModifiedTrack);
if (albumId != 0) {
if (updateAlbumFromId(albumId, covers[oneTrack.resourceURI().toString()], oneTrack, trackPath)) {
auto modifiedTracks = fetchTrackIds(albumId);
for (auto oneModifiedTrack : modifiedTracks) {
if (oneModifiedTrack != resultId) {
recordModifiedTrack(oneModifiedTrack);
}
}
}
recordModifiedAlbum(albumId);
}
recordModifiedAlbum(albumId);
} else {
d->mInsertTrackQuery.finish();
Q_EMIT databaseError();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << oneTrack.resourceURI();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << d->mInsertTrackQuery.lastQuery();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << d->mInsertTrackQuery.boundValues();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << d->mInsertTrackQuery.lastError();
}
} else {
d->mInsertTrackQuery.finish();
Q_EMIT databaseError();
if (!isModifiedTrack) {
++d->mTrackId;
}
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << oneTrack.resourceURI();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << d->mInsertTrackQuery.lastQuery();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << d->mInsertTrackQuery.boundValues();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << d->mInsertTrackQuery.lastError();
updateTrackOrigin(oneTrack.resourceURI(), oneTrack.fileModificationTime());
}
return resultId;
......
......@@ -64,7 +64,8 @@ void AllTracksProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMo
for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) {
auto currentIndex = index(rowIndex, 0);
allTracks.push_back(ElisaUtils::EntryData{data(currentIndex, DataTypes::FullDataRole).value<DataTypes::TrackDataType>(),
data(currentIndex, DataTypes::ColumnsRoles::TitleRole).toString(), {}});
data(currentIndex, DataTypes::ColumnsRoles::TitleRole).toString(),
data(currentIndex, DataTypes::ColumnsRoles::ResourceRole).toUrl()});
}
Q_EMIT entriesToEnqueue(allTracks, ElisaUtils::Track, enqueueMode, triggerPlay);
});
......
......@@ -145,6 +145,9 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
{
case ElisaUtils::Track:
result = d->mAllTrackData[index.row()][TrackDataType::key_type::TitleRole];
if (result.toString().isEmpty()) {
result = d->mAllTrackData[index.row()][TrackDataType::key_type::ResourceRole].toUrl().fileName();
}
break;
case ElisaUtils::Album:
result = d->mAllAlbumData[index.row()][AlbumDataType::key_type::TitleRole];
......@@ -273,6 +276,26 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
break;
}
break;
case DataTypes::ColumnsRoles::ResourceRole:
{
switch (d->mModelType)
{
case ElisaUtils::Track:
case ElisaUtils::Radio:
case ElisaUtils::FileName:
result = d->mAllTrackData[index.row()][TrackDataType::key_type::ResourceRole];
break;
case ElisaUtils::Album:
case ElisaUtils::Artist:
case ElisaUtils::Genre:
case ElisaUtils::Lyricist:
case ElisaUtils::Composer:
case ElisaUtils::Unknown:
result = QUrl{};
break;
}
break;
}
default:
switch(d->mModelType)
{
......
......@@ -38,32 +38,31 @@ FocusScope {
property bool displaySingleAlbum: false
property alias radioCase: listView.showCreateRadioButton
function openMetaDataView(databaseId, url) {
if (viewHeader.radioCase) {
metadataLoader.setSource("MediaTrackMetadataView.qml",
{
"initialDatabaseId": databaseId,
"fileName": url,
"modelType": viewHeader.modelType,
"showImage": false,
"showTrackFileName": false,
"showDeleteButton": databaseId !== -1,
"showApplyButton": true,
"editableMetadata": true,
});
} else {
metadataLoader.setSource("MediaTrackMetadataView.qml",
{
"initialDatabaseId": databaseId,
"fileName": url,
"modelType": viewHeader.modelType,
"showImage": true,
"showTrackFileName": true,
"showDeleteButton": false,
"showApplyButton": false,
"editableMetadata": false,
});
}
function openMetaDataView(databaseId, url, entryType) {
metadataLoader.setSource("MediaTrackMetadataView.qml",
{
"fileName": url,
"modelType": entryType,
"showImage": entryType !== ElisaUtils.Radio,
"showTrackFileName": entryType !== ElisaUtils.Radio,
"showDeleteButton": entryType === ElisaUtils.Radio,
"showApplyButton": entryType === ElisaUtils.Radio,
"editableMetadata": entryType === ElisaUtils.Radio,
});
metadataLoader.active = true
}
function openCreateRadioView()
{
metadataLoader.setSource("MediaTrackMetadataView.qml",
{
"modelType": ElisaUtils.Radio,
"isCreation": true,
"showImage": true,
"showTrackFileName": false,
"showDeleteButton": false,
"showApplyButton": true,
"editableMetadata": true,
});
metadataLoader.active = true
}
......@@ -95,8 +94,9 @@ FocusScope {
focus: true
databaseId: model.databaseId
title: model.title ? model.title : ''
trackUrl: model.url
dataType: model.dataType
title: model.display ? model.display : ''
artist: model.artist ? model.artist : ''
album: model.album ? model.album : ''
albumArtist: model.albumArtist ? model.albumArtist : ''
......@@ -109,13 +109,13 @@ FocusScope {
isAlternateColor: (index % 2) === 1
detailedView: false
onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track,
ElisaUtils.AppendPlayList,
ElisaUtils.DoNotTriggerPlay)
onEnqueue: elisa.mediaPlayList.enqueue(url, entryType,
ElisaUtils.AppendPlayList,
ElisaUtils.DoNotTriggerPlay)
onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track,
ElisaUtils.ReplacePlayList,
ElisaUtils.TriggerPlay)
onReplaceAndPlay: elisa.mediaPlayList.enqueue(url, entryType,
ElisaUtils.ReplacePlayList,
ElisaUtils.TriggerPlay)
onClicked: listView.currentIndex = index
......@@ -127,7 +127,7 @@ FocusScope {
}
onCallOpenMetaDataView: {
openMetaDataView(databaseId, model.url)
openMetaDataView(databaseId, model.url, entryType)
}
}
}
......@@ -143,8 +143,9 @@ FocusScope {
focus: true
databaseId: model.databaseId
title: model.title ? model.title : ''
trackUrl: model.url
dataType: model.dataType
title: model.display ? model.display : ''
artist: model.artist ? model.artist : ''
album: model.album ? model.album : ''
albumArtist: model.albumArtist ? model.albumArtist : ''
......@@ -157,11 +158,11 @@ FocusScope {
isSelected: listView.currentIndex === index
isAlternateColor: (index % 2) === 1
onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, modelType,
onEnqueue: elisa.mediaPlayList.enqueue(url, entryType,
ElisaUtils.AppendPlayList,
ElisaUtils.DoNotTriggerPlay)
onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, modelType,
onReplaceAndPlay: elisa.mediaPlayList.enqueue(url, entryType,
ElisaUtils.ReplacePlayList,
ElisaUtils.TriggerPlay)
......@@ -171,7 +172,7 @@ FocusScope {
}
onCallOpenMetaDataView: {
openMetaDataView(databaseId, model.url)
openMetaDataView(databaseId, model.url, entryType)
}
}
}
......@@ -191,6 +192,9 @@ FocusScope {
allowArtistNavigation: isSubPage
showCreateRadioButton: modelType === ElisaUtils.Radio
showEnqueueButton: modelType !== ElisaUtils.Radio
onShowArtist: {
viewManager.openChildView(secondaryTitle, '', elisaTheme.artistIcon, 0, ElisaUtils.Artist, ViewManager.NoDiscHeaders)
}
......@@ -223,7 +227,7 @@ FocusScope {
target: listView.navigationBar
onCreateRadio: {
openMetaDataView(-1, '')
openCreateRadioView()
}
}
......
......@@ -181,7 +181,7 @@ FocusScope {
}
}
onOpen: isDirectory ? loadFolderAndClear(model.fileUrl) : elisa.mediaPlayList.enqueue(0, model.fileUrl, ElisaUtils.FileName, ElisaUtils.AppendPlayList,