Refactor playlist items

Fix a bug where playlist items cover is not updated
This commit is contained in:
Jonas Kvinge
2025-04-27 03:03:58 +02:00
parent baec45f742
commit 04c6c862c4
28 changed files with 310 additions and 289 deletions

View File

@@ -108,7 +108,7 @@ void MoodbarItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
QPixmap MoodbarItemDelegate::PixmapForIndex(const QModelIndex &idx, const QSize size) {
// Pixmaps are keyed off URL.
const QUrl url = idx.sibling(idx.row(), static_cast<int>(Playlist::Column::Filename)).data().toUrl();
const QUrl url = idx.sibling(idx.row(), static_cast<int>(Playlist::Column::URL)).data().toUrl();
const bool has_cue = idx.sibling(idx.row(), static_cast<int>(Playlist::Column::HasCUE)).data().toBool();
Data *data = nullptr;
@@ -294,7 +294,7 @@ void MoodbarItemDelegate::ImageLoaded(const QUrl &url, const QImage &image) {
// Update all the indices with the new pixmap.
for (const QPersistentModelIndex &idx : std::as_const(data->indexes_)) {
if (idx.isValid() && idx.sibling(idx.row(), static_cast<int>(Playlist::Column::Filename)).data().toUrl() == url) {
if (idx.isValid() && idx.sibling(idx.row(), static_cast<int>(Playlist::Column::URL)).data().toUrl() == url) {
QModelIndex source_index = idx;
if (idx.model() == filter) {
source_index = filter->mapToSource(source_index);