When emitting loaded signal, pass whole song not just artist+album
This commit is contained in:
committed by
craig.p.drummond
parent
1539339954
commit
cc53edfb2b
@@ -1055,7 +1055,7 @@ void Covers::updateCache(const Song &song, const QImage &img, bool dummyEntriesO
|
||||
cache.remove(key);
|
||||
if (!img.isNull()) {
|
||||
if (saveScaledCover(img.scaled(s, s, Qt::KeepAspectRatio, Qt::SmoothTransformation), song.albumArtist(), song.album, s)) {
|
||||
emit loaded(song.albumArtist(), song.album, s);
|
||||
emit loaded(song, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1416,7 +1416,7 @@ void Covers::loaded(const QList<LoadedCover> &covers)
|
||||
if (!cvr.img.isNull()) {
|
||||
cache.insert(cacheKey(cvr.song.albumArtist(), cvr.song.album, cvr.song.size), new QPixmap(QPixmap::fromImage(cvr.img)));
|
||||
cacheSizes.insert(cvr.song.size);
|
||||
emit loaded(cvr.song.albumArtist(), cvr.song.album, cvr.song.size);
|
||||
emit loaded(cvr.song, cvr.song.size);
|
||||
} else { // Failed to load a scaled cover, try locating non-scaled cover...
|
||||
tryToLocate(cvr.song);
|
||||
}
|
||||
@@ -1462,7 +1462,7 @@ void Covers::gotAlbumCover(const Song &song, const QImage &img, const QString &f
|
||||
if (song.isSpecificSizeRequest()) {
|
||||
if (!img.isNull() && saveScaledCover(img.scaled(song.size, song.size, Qt::KeepAspectRatio, Qt::SmoothTransformation), song.albumArtist(), song.album, song.size)) {
|
||||
DBUG << "loaded cover" << song.file << song.artist << song.albumartist << song.album << img.width() << img.height() << fileName << song.size;
|
||||
emit loaded(song.albumArtist(), song.album, song.size);
|
||||
emit loaded(song, song.size);
|
||||
}
|
||||
} else {
|
||||
DBUG << "emit cover" << song.file << song.artist << song.albumartist << song.album << img.width() << img.height() << fileName;
|
||||
@@ -1484,7 +1484,7 @@ void Covers::gotArtistImage(const Song &song, const QImage &img, const QString &
|
||||
if (song.isSpecificSizeRequest()) {
|
||||
if (!img.isNull() && saveScaledCover(img.scaled(song.size, song.size, Qt::KeepAspectRatio, Qt::SmoothTransformation), song.albumArtist(), QString(), song.size)) {
|
||||
DBUG << "loaded artistImage" << song.file << song.artist << song.albumartist << song.album << img.width() << img.height() << fileName << song.size;
|
||||
emit loaded(song.albumArtist(), QString(), song.size);
|
||||
emit loaded(song, song.size);
|
||||
}
|
||||
} else {
|
||||
DBUG << "emit artistImage" << song.file << song.artist << song.albumartist << song.album << img.width() << img.height() << fileName;
|
||||
|
||||
@@ -238,7 +238,7 @@ Q_SIGNALS:
|
||||
void download(const Song &s);
|
||||
void locate(const Song &s);
|
||||
void load(const Song &song);
|
||||
void loaded(const QString &ar, const QString &al, int s);
|
||||
void loaded(const Song &song, int s);
|
||||
void cover(const Song &song, const QImage &img, const QString &file);
|
||||
void coverUpdated(const Song &song, const QImage &img, const QString &file);
|
||||
void artistImage(const Song &song, const QImage &img, const QString &file);
|
||||
|
||||
@@ -456,14 +456,16 @@ void AlbumsModel::updateCover(const Song &song, const QImage &img, const QString
|
||||
}
|
||||
}
|
||||
|
||||
void AlbumsModel::coverLoaded(const QString &ar, const QString &al, int s)
|
||||
void AlbumsModel::coverLoaded(const Song &song, int s)
|
||||
{
|
||||
if (s==iconSize()) {
|
||||
if (s==iconSize() && !song.isArtistImageRequest()) {
|
||||
QList<AlbumItem *>::Iterator it=items.begin();
|
||||
QList<AlbumItem *>::Iterator end=items.end();
|
||||
QString albumArtist=song.albumArtist();
|
||||
QString album=song.album;
|
||||
|
||||
for (int row=0; it!=end; ++it, ++row) {
|
||||
if ((*it)->artist==ar && (*it)->album==al) {
|
||||
if ((*it)->artist==albumArtist && (*it)->album==album) {
|
||||
QModelIndex idx=index(row, 0, QModelIndex());
|
||||
emit dataChanged(idx, idx);
|
||||
}
|
||||
@@ -489,15 +491,15 @@ void AlbumsModel::setEnabled(bool e)
|
||||
if (enabled) {
|
||||
connect(Covers::self(), SIGNAL(coverUpdated(const Song &, const QImage &, const QString &)),
|
||||
this, SLOT(updateCover(const Song &, const QImage &, const QString &)));
|
||||
connect(Covers::self(), SIGNAL(loaded(QString,QString,int)),
|
||||
this, SLOT(coverLoaded(QString,QString,int)));
|
||||
connect(Covers::self(), SIGNAL(loaded(Song,int)),
|
||||
this, SLOT(coverLoaded(Song,int)));
|
||||
update(MusicLibraryModel::self()->root());
|
||||
} else {
|
||||
clear();
|
||||
disconnect(Covers::self(), SIGNAL(coverUpdated(const Song &, const QImage &, const QString &)),
|
||||
this, SLOT(updateCover(const Song &, const QImage &, const QString &)));
|
||||
disconnect(Covers::self(), SIGNAL(loaded(QString,QString,int)),
|
||||
this, SLOT(coverLoaded(QString,QString,int)));
|
||||
disconnect(Covers::self(), SIGNAL(loaded(Song,int)),
|
||||
this, SLOT(coverLoaded(Song,int)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ Q_SIGNALS:
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateCover(const Song &song, const QImage &img, const QString &file);
|
||||
void coverLoaded(const QString &ar, const QString &al, int s);
|
||||
void coverLoaded(const Song &song, int s);
|
||||
void update(const MusicLibraryItemRoot *root);
|
||||
|
||||
private:
|
||||
|
||||
@@ -478,10 +478,10 @@ void GroupedView::setModel(QAbstractItemModel *model)
|
||||
if (startClosed) {
|
||||
updateCollectionRows();
|
||||
}
|
||||
connect(Covers::self(), SIGNAL(loaded(QString,QString,int)), this, SLOT(coverLoaded(QString,QString,int)));
|
||||
connect(Covers::self(), SIGNAL(loaded(Song,int)), this, SLOT(coverLoaded(Song,int)));
|
||||
} else {
|
||||
controlledAlbums.clear();
|
||||
disconnect(Covers::self(), SIGNAL(loaded(QString,QString,int)), this, SLOT(coverLoaded(QString,QString,int)));
|
||||
disconnect(Covers::self(), SIGNAL(loaded(Song,int)), this, SLOT(coverLoaded(Song,int)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,13 +705,15 @@ void GroupedView::dropEvent(QDropEvent *event)
|
||||
model()->setData(parent, 0, Role_DropAdjust);
|
||||
}
|
||||
|
||||
void GroupedView::coverLoaded(const QString &albumArtist, const QString &album, int size)
|
||||
void GroupedView::coverLoaded(const Song &song, int size)
|
||||
{
|
||||
if (filterActive || !isVisible() || size!=constCoverSize || album.isEmpty()) {
|
||||
if (filterActive || !isVisible() || size!=constCoverSize || song.isArtistImageRequest()) {
|
||||
return;
|
||||
}
|
||||
quint32 count=model()->rowCount();
|
||||
quint16 lastKey=Song::constNullKey;
|
||||
QString albumArtist=song.albumArtist();
|
||||
QString album=song.album;
|
||||
|
||||
for (quint32 i=0; i<count; ++i) {
|
||||
QModelIndex index=model()->index(i, 0);
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateRows(const QModelIndex &parent);
|
||||
void coverLoaded(const QString &albumArtist, const QString &album, int size);
|
||||
void coverLoaded(const Song &song, int size);
|
||||
|
||||
private Q_SLOTS:
|
||||
void itemClicked(const QModelIndex &index);
|
||||
|
||||
Reference in New Issue
Block a user