parent
4ae54dbaad
commit
1f772081fd
|
@ -40,6 +40,7 @@ class CollectionPlaylistItem : public PlaylistItem {
|
|||
void Reload() override;
|
||||
|
||||
Song Metadata() const override;
|
||||
Song OriginalMetadata() const override { return song_; }
|
||||
void SetMetadata(const Song &song) { song_ = song; }
|
||||
|
||||
QUrl Url() const override;
|
||||
|
|
|
@ -40,6 +40,7 @@ class InternetPlaylistItem : public PlaylistItem {
|
|||
|
||||
bool InitFromQuery(const SqlRow &query) override;
|
||||
Song Metadata() const override;
|
||||
Song OriginalMetadata() const override { return metadata_; }
|
||||
QUrl Url() const override;
|
||||
void SetArtManual(const QUrl &cover_url) override;
|
||||
|
||||
|
|
|
@ -406,16 +406,8 @@ void Playlist::ItemReloadComplete(const QPersistentModelIndex &index) {
|
|||
if (index.isValid()) {
|
||||
|
||||
PlaylistItemPtr item = item_at(index.row());
|
||||
if (item) {
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
if (item && item->HasTemporaryMetadata()) { // Update temporary metadata.
|
||||
item->UpdateTemporaryMetadata(item->OriginalMetadata());
|
||||
}
|
||||
|
||||
emit dataChanged(index, index);
|
||||
|
|
|
@ -76,6 +76,8 @@ void PlaylistItem::SetTemporaryMetadata(const Song &metadata) {
|
|||
|
||||
void PlaylistItem::UpdateTemporaryMetadata(const Song &metadata) {
|
||||
|
||||
if (!temp_metadata_.is_valid()) return;
|
||||
|
||||
Song old_metadata = temp_metadata_;
|
||||
temp_metadata_ = metadata;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
|||
QFuture<void> BackgroundReload();
|
||||
|
||||
virtual Song Metadata() const = 0;
|
||||
virtual Song OriginalMetadata() const = 0;
|
||||
virtual QUrl Url() const = 0;
|
||||
|
||||
void SetTemporaryMetadata(const Song &metadata);
|
||||
|
|
|
@ -480,7 +480,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) {
|
|||
for (PlaylistItemPtr item : items) {
|
||||
if (item->Metadata().directory_id() != song.directory_id()) continue;
|
||||
static_cast<CollectionPlaylistItem*>(item.get())->SetMetadata(song);
|
||||
item->UpdateTemporaryMetadata(song);
|
||||
if (item->HasTemporaryMetadata()) item->UpdateTemporaryMetadata(song);
|
||||
data.p->ItemChanged(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,12 +41,15 @@ class SongPlaylistItem : public PlaylistItem {
|
|||
void Reload() override;
|
||||
|
||||
Song Metadata() const override;
|
||||
Song OriginalMetadata() const override { return song_; }
|
||||
|
||||
QUrl Url() const override;
|
||||
|
||||
Song DatabaseSongMetadata() const override { return song_; }
|
||||
void SetArtManual(const QUrl &cover_url) override;
|
||||
|
||||
protected:
|
||||
Song DatabaseSongMetadata() const override { return song_; }
|
||||
|
||||
private:
|
||||
Song song_;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue