1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-08 06:43:00 +01:00

Only update temporary metadata when set

Fixes #507
This commit is contained in:
Jonas Kvinge 2020-08-10 00:32:57 +02:00
parent 4ae54dbaad
commit 1f772081fd
7 changed files with 12 additions and 12 deletions

View File

@ -40,6 +40,7 @@ class CollectionPlaylistItem : public PlaylistItem {
void Reload() override; void Reload() override;
Song Metadata() const override; Song Metadata() const override;
Song OriginalMetadata() const override { return song_; }
void SetMetadata(const Song &song) { song_ = song; } void SetMetadata(const Song &song) { song_ = song; }
QUrl Url() const override; QUrl Url() const override;

View File

@ -40,6 +40,7 @@ class InternetPlaylistItem : public PlaylistItem {
bool InitFromQuery(const SqlRow &query) override; bool InitFromQuery(const SqlRow &query) override;
Song Metadata() const override; Song Metadata() const override;
Song OriginalMetadata() const override { return metadata_; }
QUrl Url() const override; QUrl Url() const override;
void SetArtManual(const QUrl &cover_url) override; void SetArtManual(const QUrl &cover_url) override;

View File

@ -406,16 +406,8 @@ void Playlist::ItemReloadComplete(const QPersistentModelIndex &index) {
if (index.isValid()) { if (index.isValid()) {
PlaylistItemPtr item = item_at(index.row()); PlaylistItemPtr item = item_at(index.row());
if (item) { if (item && item->HasTemporaryMetadata()) { // Update temporary metadata.
item->UpdateTemporaryMetadata(item->OriginalMetadata());
// Update temporary metadata for songs that are not in the collection.
// Songs that are in the collection is updated through the collection watcher/backend in playlist manager.
if (item->Metadata().source() != Song::Source_Collection) {
SongPlaylistItem *song_item = static_cast<SongPlaylistItem*>(item.get());
if (song_item) {
song_item->UpdateTemporaryMetadata(song_item->DatabaseSongMetadata());
}
}
} }
emit dataChanged(index, index); emit dataChanged(index, index);

View File

@ -76,6 +76,8 @@ void PlaylistItem::SetTemporaryMetadata(const Song &metadata) {
void PlaylistItem::UpdateTemporaryMetadata(const Song &metadata) { void PlaylistItem::UpdateTemporaryMetadata(const Song &metadata) {
if (!temp_metadata_.is_valid()) return;
Song old_metadata = temp_metadata_; Song old_metadata = temp_metadata_;
temp_metadata_ = metadata; temp_metadata_ = metadata;

View File

@ -73,6 +73,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
QFuture<void> BackgroundReload(); QFuture<void> BackgroundReload();
virtual Song Metadata() const = 0; virtual Song Metadata() const = 0;
virtual Song OriginalMetadata() const = 0;
virtual QUrl Url() const = 0; virtual QUrl Url() const = 0;
void SetTemporaryMetadata(const Song &metadata); void SetTemporaryMetadata(const Song &metadata);

View File

@ -480,7 +480,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) {
for (PlaylistItemPtr item : items) { for (PlaylistItemPtr item : items) {
if (item->Metadata().directory_id() != song.directory_id()) continue; if (item->Metadata().directory_id() != song.directory_id()) continue;
static_cast<CollectionPlaylistItem*>(item.get())->SetMetadata(song); static_cast<CollectionPlaylistItem*>(item.get())->SetMetadata(song);
item->UpdateTemporaryMetadata(song); if (item->HasTemporaryMetadata()) item->UpdateTemporaryMetadata(song);
data.p->ItemChanged(item); data.p->ItemChanged(item);
} }
} }

View File

@ -41,12 +41,15 @@ class SongPlaylistItem : public PlaylistItem {
void Reload() override; void Reload() override;
Song Metadata() const override; Song Metadata() const override;
Song OriginalMetadata() const override { return song_; }
QUrl Url() const override; QUrl Url() const override;
Song DatabaseSongMetadata() const override { return song_; }
void SetArtManual(const QUrl &cover_url) override; void SetArtManual(const QUrl &cover_url) override;
protected:
Song DatabaseSongMetadata() const override { return song_; }
private: private:
Song song_; Song song_;
}; };