Sayonara Player
CoverModel.h
1/* CoverModel.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef ALBUMCOVERMODEL_H
22#define ALBUMCOVERMODEL_H
23
24#include "Gui/Library/ItemModel.h"
25#include "Utils/Pimpl.h"
26#include <QtGlobal>
27
28class Album;
29class AlbumList;
30
31class QSize;
32
33namespace Cover
34{
35 class Location;
36 class Lookup;
37}
38
39namespace Library
40{
45 class CoverModel :
46 public ItemModel
47 {
48 Q_OBJECT
49 PIMPL(CoverModel)
50
51 public:
52 enum Role
53 {
54 AlbumRole = Qt::UserRole,
55 ArtistRole = Qt::UserRole + 1,
56 CoverRole = Qt::UserRole + 2
57 };
58
59 explicit CoverModel(QObject* parent, AbstractLibrary* library);
60 ~CoverModel() override;
61
62 public:
63 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
64 int columnCount(const QModelIndex& paren = QModelIndex()) const override;
65 QVariant data(const QModelIndex& index, int role) const override;
66 Qt::ItemFlags flags(const QModelIndex& index) const override;
67
68 QSize itemSize() const;
69 int zoom() const;
70
71 protected:
72 QModelIndex index(int row, int column, const QModelIndex& parent=QModelIndex()) const override;
73 const MetaDataList& selectedMetadata() const override;
74
75 QModelIndexList searchResults(const QString& substr) override;
76
77 int searchableColumn() const override;
78 QString searchableString(int index) const override;
79 int mapIndexToId(int index) const override;
80 Cover::Location cover(const QModelIndexList& indexes) const override;
81
82 private:
83 const AlbumList& albums() const;
84 bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
85 bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
86 bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
87 bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
88 void refreshData();
89
90 public slots:
91 void setZoom(int zoom, const QSize& view_size);
92 void reload();
93 void clear();
94
95 private slots:
96 void nextHash();
97 void coverLookupFinished(bool success);
98 void showArtistsChanged();
99 };
100}
101
102#endif // ALBUMCOVERMODEL_H
Definition: AbstractLibrary.h:44
Definition: Album.h:88
Definition: Album.h:37
Definition: CoverLocation.h:39
The CoverModel class.
Definition: CoverModel.h:47
int mapIndexToId(int index) const override
return the current id for a given row
Cover::Location cover(const QModelIndexList &indexes) const override
return the cover for multiple rows. if rows.size() > 1, an invalid, default constructed cover locatio...
QString searchableString(int index) const override
here, the searchable string can even be refined. Maybe we just want to search within a substring indi...
int searchableColumn() const override
the index of the searchable column. This is the column where the text is searched for a certain searc...
const MetaDataList & selectedMetadata() const override
return the tracks which belong to the selections. If an album is selected for example,...
The ItemModel is intended to abstract the various views. It supports searching, selections and a libr...
Definition: ItemModel.h:43
The MetaDataList class.
Definition: MetaDataList.h:39
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31