Skip to content

Commit

Permalink
Playlist: Grey invalid song entries when updating items.
Browse files Browse the repository at this point in the history
  • Loading branch information
smithjd15 committed Mar 18, 2022
1 parent c159439 commit 2e7ce3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/playlist/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,

settings.endGroup();

settings.beginGroup(kSettingsGroup);

grey_unfound_ = settings.value("greyoutdeleted", false).toBool();

settings.endGroup();

qLog(Debug) << "k_max_scrobble_point"
<< (max_play_count_point_nsecs_ / kNsecPerSec);
}
Expand Down Expand Up @@ -1223,6 +1229,9 @@ void Playlist::UpdateItems(const SongList& songs) {
} else {
new_item = PlaylistItemPtr(new SongPlaylistItem(song));
}
if (grey_unfound_ && !song.is_valid()) {
new_item->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
}
items_[i] = new_item;
emit dataChanged(index(i, 0), index(i, ColumnCount - 1));
// Also update undo actions
Expand Down Expand Up @@ -1626,11 +1635,7 @@ void Playlist::ItemsLoaded(QFuture<PlaylistItemList> future) {

emit RestoreFinished();

QSettings s;
s.beginGroup(kSettingsGroup);

// should we gray out deleted songs asynchronously on startup?
if (s.value("greyoutdeleted", false).toBool()) {
if (grey_unfound_) {
QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/playlist/playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ class Playlist : public QAbstractListModel {

// Cancel async restore if songs are already replaced
bool cancel_restore_;

bool grey_unfound_;
};

// QDataStream& operator <<(QDataStream&, const Playlist*);
Expand Down

0 comments on commit 2e7ce3b

Please sign in to comment.