Preserve user stats like play/skip counts when reloading song metadata when opening the edit tag dialog. Fixes issue 3359.
This commit is contained in:
parent
9e9b7f7fa6
commit
e3c8caa613
|
@ -1180,3 +1180,12 @@ void Song::ToXesam(QVariantMap* map) const {
|
||||||
AddMetadata("xesam:userRating", rating(), map);
|
AddMetadata("xesam:userRating", rating(), map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Song::MergeUserSetData(const Song& other) {
|
||||||
|
set_playcount(other.playcount());
|
||||||
|
set_skipcount(other.skipcount());
|
||||||
|
set_lastplayed(other.lastplayed());
|
||||||
|
set_rating(other.rating());
|
||||||
|
set_score(other.score());
|
||||||
|
set_art_manual(other.art_manual());
|
||||||
|
}
|
||||||
|
|
|
@ -130,6 +130,11 @@ class Song {
|
||||||
void ToWmdm(IWMDMMetaData* metadata) const;
|
void ToWmdm(IWMDMMetaData* metadata) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Copies important statistics from the other song to this one, overwriting
|
||||||
|
// any data that already exists. Useful when you want updated tags from disk
|
||||||
|
// but you want to keep user stats.
|
||||||
|
void MergeUserSetData(const Song& other);
|
||||||
|
|
||||||
static QString Decode(const QString& tag, const QTextCodec* codec = NULL);
|
static QString Decode(const QString& tag, const QTextCodec* codec = NULL);
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
|
|
|
@ -514,12 +514,7 @@ void LibraryWatcher::PreserveUserSetData(const QString& file, const QString& ima
|
||||||
if (!out->has_embedded_cover())
|
if (!out->has_embedded_cover())
|
||||||
out->set_art_automatic(image);
|
out->set_art_automatic(image);
|
||||||
|
|
||||||
out->set_playcount(matching_song.playcount());
|
out->MergeUserSetData(matching_song);
|
||||||
out->set_skipcount(matching_song.skipcount());
|
|
||||||
out->set_lastplayed(matching_song.lastplayed());
|
|
||||||
out->set_rating(matching_song.rating());
|
|
||||||
out->set_score(matching_song.score());
|
|
||||||
out->set_art_manual(matching_song.art_manual());
|
|
||||||
|
|
||||||
// The song was deleted from the database (e.g. due to an unmounted
|
// The song was deleted from the database (e.g. due to an unmounted
|
||||||
// filesystem), but has been restored.
|
// filesystem), but has been restored.
|
||||||
|
|
|
@ -216,10 +216,12 @@ QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList& songs) const
|
||||||
Song copy(song);
|
Song copy(song);
|
||||||
TagReaderClient::Instance()->ReadFileBlocking(copy.url().toLocalFile(), ©);
|
TagReaderClient::Instance()->ReadFileBlocking(copy.url().toLocalFile(), ©);
|
||||||
|
|
||||||
if (copy.is_valid())
|
if (copy.is_valid()) {
|
||||||
|
copy.MergeUserSetData(song);
|
||||||
ret << Data(copy);
|
ret << Data(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue