Commit 345e6ba0 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

keep enough data to check that received data are for the correct track

fix wrong data being displayed in metadata window or context view if
showing a track during database import of tracks
parent e674a748
......@@ -301,7 +301,11 @@ QHash<int, QByteArray> TrackMetadataModel::roleNames() const
QString TrackMetadataModel::fileUrl() const
{
return mFileUrl;
if (mFileUrl.isLocalFile()) {
return mFileUrl.toLocalFile();
} else {
return mFileUrl.toString();
}
}
QUrl TrackMetadataModel::coverUrl() const
......@@ -330,7 +334,9 @@ qulonglong TrackMetadataModel::databaseId() const
void TrackMetadataModel::trackData(const TrackMetadataModel::TrackDataType &trackData)
{
if (!mFullData.isEmpty() && trackData.databaseId() != mFullData.databaseId()) {
if ((mDatabaseId != 0 && trackData.databaseId() != mDatabaseId) ||
(!mFileUrl.isEmpty() && trackData.resourceURI() != mFileUrl) ||
(!mFullData.isEmpty() && trackData.databaseId() != mFullData.databaseId())) {
return;
}
......@@ -372,11 +378,7 @@ void TrackMetadataModel::fillDataFromTrackData(const TrackMetadataModel::TrackDa
auto rawFileUrl = trackData[DataTypes::ResourceRole].toUrl();
if (rawFileUrl.isLocalFile()) {
mFileUrl = rawFileUrl.toLocalFile();
} else {
mFileUrl = rawFileUrl.toString();
}
mFileUrl = rawFileUrl;
Q_EMIT fileUrlChanged();
}
......@@ -433,6 +435,9 @@ void TrackMetadataModel::initializeByIdAndUrl(ElisaUtils::PlayListEntryType type
Q_EMIT lyricsChanged();
mFileUrl = url;
mDatabaseId = databaseId;
Q_EMIT needDataByDatabaseIdAndUrl(type, databaseId, url);
}
......@@ -524,6 +529,8 @@ void TrackMetadataModel::initializeByUrl(ElisaUtils::PlayListEntryType type, con
Q_EMIT lyricsChanged();
mFileUrl = url;
Q_EMIT needDataByUrl(type, url);
}
......
......@@ -174,7 +174,7 @@ private:
QUrl mCoverImage;
QString mFileUrl;
QUrl mFileUrl;
qulonglong mDatabaseId = 0;
......
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