1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-16 10:38:53 +01:00

Use album grouping function

This commit is contained in:
Jonas Kvinge 2020-05-06 22:35:55 +02:00
parent 4e4e596a1e
commit 54cce5e089
3 changed files with 4 additions and 13 deletions

View File

@ -670,11 +670,7 @@ QVariant CollectionModel::data(const QModelIndex &idx, const int role) const {
bool is_album_node = false;
if (role == Qt::DecorationRole && item->type == CollectionItem::Type_Container) {
GroupBy container_type = group_by_[item->container_level];
is_album_node = container_type == GroupBy_Album ||
container_type == GroupBy_AlbumDisc ||
container_type == GroupBy_YearAlbum ||
container_type == GroupBy_YearAlbumDisc ||
container_type == GroupBy_OriginalYearAlbum;
is_album_node = IsAlbumGrouping(container_type);
}
if (is_album_node) {
// It has const behaviour some of the time - that's ok right?

View File

@ -179,6 +179,8 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
quint64 icon_cache_disk_size() { return sIconCache->cacheSize(); }
static bool IsAlbumGrouping(const GroupBy group_by) { return group_by == GroupBy_Album || group_by == GroupBy_YearAlbum || group_by == GroupBy_OriginalYearAlbum || group_by == GroupBy_AlbumDisc || group_by == GroupBy_YearAlbumDisc; }
signals:
void TotalSongCountUpdated(const int count);
void TotalArtistCountUpdated(const int count);
@ -251,7 +253,6 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
QVariant data(const CollectionItem *item, const int role) const;
bool CompareItems(const CollectionItem *a, const CollectionItem *b) const;
int MaximumCacheSize(QSettings *s, const char *size_id, const char *size_unit_id, const int cache_size_default) const;
bool IsAlbumGrouping(const GroupBy group_by) const { return group_by == GroupBy_Album || group_by == GroupBy_YearAlbum || group_by == GroupBy_OriginalYearAlbum || group_by == GroupBy_AlbumDisc || group_by == GroupBy_YearAlbumDisc; }
private:
CollectionBackend *backend_;

View File

@ -803,13 +803,7 @@ void InternetSearchView::LazyLoadAlbumCover(const QModelIndex &proxy_index) {
// Is this an album?
const CollectionModel::GroupBy container_type = CollectionModel::GroupBy(proxy_index.data(CollectionModel::Role_ContainerType).toInt());
if (container_type != CollectionModel::GroupBy_Album &&
container_type != CollectionModel::GroupBy_AlbumDisc &&
container_type != CollectionModel::GroupBy_YearAlbum &&
container_type != CollectionModel::GroupBy_YearAlbumDisc &&
container_type != CollectionModel::GroupBy_OriginalYearAlbum) {
return;
}
if (!CollectionModel::IsAlbumGrouping(container_type)) return;
// Mark the item as loading art