Update online and devices views when cover size, or show year setting, is changed
This commit is contained in:
committed by
craig.p.drummond
parent
12183ef874
commit
aa0796d79e
@@ -247,6 +247,17 @@ void DevicesPage::addSelectionToPlaylist(const QString &name, bool replace, quin
|
||||
}
|
||||
}
|
||||
|
||||
void DevicesPage::refresh()
|
||||
{
|
||||
view->setLevel(0);
|
||||
DevicesModel::self()->clearImages();
|
||||
if (ItemView::Mode_SimpleTree==view->viewMode() || ItemView::Mode_DetailedTree==view->viewMode()) {
|
||||
for (int i=0; i<DevicesModel::self()->rowCount(QModelIndex()); ++i) {
|
||||
view->setExpanded(proxy.mapFromSource(DevicesModel::self()->index(i, 0, QModelIndex())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DevicesPage::itemDoubleClicked(const QModelIndex &)
|
||||
{
|
||||
// const QModelIndexList selected = view->selectedIndexes();
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
void setView(int v) { view->setMode((ItemView::Mode)v); }
|
||||
void focusSearch() { view->focusSearch(); }
|
||||
void goBack() { view->backActivated(); }
|
||||
void refresh();
|
||||
|
||||
public Q_SLOTS:
|
||||
void itemDoubleClicked(const QModelIndex &);
|
||||
|
||||
@@ -1413,6 +1413,12 @@ void MainWindow::updateSettings()
|
||||
loaded|=TAB_LIBRARY;
|
||||
libraryPage->refresh();
|
||||
}
|
||||
if (diffLibCovers || diffLibYear || Settings::self()->libraryArtistImage()!=MusicLibraryModel::self()->useArtistImages()) {
|
||||
onlinePage->refresh();
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
devicesPage->refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wasAutoExpand=playQueue->isAutoExpand();
|
||||
bool wasStartClosed=playQueue->isStartClosed();
|
||||
|
||||
@@ -225,3 +225,12 @@ QStringList MultiMusicModel::filenames(const QModelIndexList &indexes, bool play
|
||||
}
|
||||
return fnames;
|
||||
}
|
||||
|
||||
void MultiMusicModel::clearImages()
|
||||
{
|
||||
beginResetModel();
|
||||
foreach (MusicLibraryItemRoot *c, collections) {
|
||||
c->clearImages();
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
QStringList filenames(const QModelIndexList &indexes, bool playableOnly=false, bool fullPath=false) const;
|
||||
const QSet<QString> & genres() { return colGenres; }
|
||||
int row(void *i) const { return collections.indexOf((MusicLibraryItemRoot *)i); }
|
||||
void clearImages();
|
||||
|
||||
Q_SIGNALS:
|
||||
void updateGenres(const QSet<QString> &genres);
|
||||
|
||||
@@ -467,6 +467,18 @@ bool MusicLibraryItemAlbum::containsArtist(const QString &a)
|
||||
return m_artists.contains(a);
|
||||
}
|
||||
|
||||
void MusicLibraryItemAlbum::clearImage()
|
||||
{
|
||||
if (!m_coverIsDefault) {
|
||||
m_coverIsDefault=true;
|
||||
delete m_cover;
|
||||
m_cover=0;
|
||||
if (theDefaultIcon) {
|
||||
m_cover=theDefaultIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MusicLibraryItemAlbum::setYear(const MusicLibraryItemSong *song)
|
||||
{
|
||||
if (m_childItems.isEmpty() || (m_yearOfDisc>song->disc() || (m_yearOfDisc==song->disc() && m_yearOfTrack>song->track()))) {
|
||||
|
||||
@@ -89,6 +89,7 @@ public:
|
||||
void setImageUrl(const QString &u) { m_imageUrl=u; }
|
||||
bool updateYear();
|
||||
bool containsArtist(const QString &a);
|
||||
void clearImage();
|
||||
|
||||
private:
|
||||
void setCoverImage(const QImage &img) const;
|
||||
|
||||
@@ -179,6 +179,23 @@ const QPixmap & MusicLibraryItemArtist::cover()
|
||||
return *m_cover;
|
||||
}
|
||||
|
||||
void MusicLibraryItemArtist::clearImages()
|
||||
{
|
||||
if (!m_coverIsDefault) {
|
||||
m_coverIsDefault=true;
|
||||
delete m_cover;
|
||||
m_cover=0;
|
||||
if (theDefaultIcon) {
|
||||
m_cover=theDefaultIcon;
|
||||
}
|
||||
}
|
||||
foreach (MusicLibraryItem *i, m_childItems) {
|
||||
if (MusicLibraryItem::Type_Album==i->itemType()) {
|
||||
static_cast<MusicLibraryItemAlbum *>(i)->clearImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MusicLibraryItemAlbum * MusicLibraryItemArtist::album(const Song &s, bool create)
|
||||
{
|
||||
QHash<QString, int>::ConstIterator it=m_indexes.find(s.album);
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
bool hasRealCover() const { return !m_coverIsDefault; }
|
||||
const QString & imageUrl() const { return m_imageUrl; }
|
||||
void setImageUrl(const QString &u) { m_imageUrl=u; }
|
||||
void clearImages();
|
||||
|
||||
private:
|
||||
mutable bool m_coverIsDefault;
|
||||
|
||||
@@ -949,6 +949,15 @@ void MusicLibraryItemRoot::removeSongFromList(const Song &s)
|
||||
}
|
||||
}
|
||||
|
||||
void MusicLibraryItemRoot::clearImages()
|
||||
{
|
||||
foreach (MusicLibraryItem *i, m_childItems) {
|
||||
if (MusicLibraryItem::Type_Artist==i->itemType()) {
|
||||
static_cast<MusicLibraryItemArtist *>(i)->clearImages();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString MusicLibraryItemRoot::songArtist(const Song &s) const
|
||||
{
|
||||
if (isFlat || !supportsAlbumArtist) {
|
||||
|
||||
@@ -108,6 +108,7 @@ public:
|
||||
bool updateSong(const Song &orig, const Song &edit);
|
||||
void addSongToList(const Song &s);
|
||||
void removeSongFromList(const Song &s);
|
||||
void clearImages();
|
||||
|
||||
protected:
|
||||
QString songArtist(const Song &s) const;
|
||||
|
||||
@@ -195,6 +195,12 @@ void OnlineServicesPage::addSelectionToPlaylist(const QString &name, bool replac
|
||||
}
|
||||
}
|
||||
|
||||
void OnlineServicesPage::refresh()
|
||||
{
|
||||
view->setLevel(0);
|
||||
OnlineServicesModel::self()->clearImages();
|
||||
}
|
||||
|
||||
void OnlineServicesPage::itemDoubleClicked(const QModelIndex &)
|
||||
{
|
||||
const QModelIndexList selected = view->selectedIndexes();
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
void setView(int v) { view->setMode((ItemView::Mode)v); }
|
||||
void focusSearch() { view->focusSearch(); }
|
||||
void goBack() { view->backActivated(); }
|
||||
void refresh();
|
||||
|
||||
public Q_SLOTS:
|
||||
void itemDoubleClicked(const QModelIndex &);
|
||||
|
||||
Reference in New Issue
Block a user