Sayonara Player
CoverModel.h
1 /* CoverModel.h */
2 
3 /* Copyright (C) 2011-2019 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 
28 class Album;
29 class AlbumList;
30 
31 class QSize;
32 
33 namespace Cover
34 {
35  class Location;
36  class Lookup;
37 }
38 
39 namespace Library
40 {
41  class CoverModel :
42  public ItemModel
43  {
44  Q_OBJECT
45  PIMPL(CoverModel)
46 
47  public:
48  enum Role
49  {
50  AlbumRole=Qt::UserRole,
51  ArtistRole=Qt::UserRole + 1
52  };
53 
54  explicit CoverModel(QObject* parent, AbstractLibrary* library);
55  virtual ~CoverModel();
56 
57  public:
58  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
59  int columnCount(const QModelIndex& paren=QModelIndex()) const override;
60  QVariant data(const QModelIndex& index, int role) const override;
61  Qt::ItemFlags flags(const QModelIndex &index) const override;
62 
63  QSize item_size() const;
64  int zoom() const;
65 
66 
67  protected:
68  // ItemModel
69  const MetaDataList& mimedata_tracks() const override;
70  const Util::Set<Id>& selections() const override;
71 
72  QModelIndexList search_results(const QString& substr) override;
73 
74  int searchable_column() const override;
75  QString searchable_string(int idx) const override;
76  int id_by_index(int idx) const override;
77  Cover::Location cover(const IndexSet& indexes) const override;
78 
79  private:
80  const AlbumList& albums() const;
81  void add_rows(int row, int count);
82  void remove_rows(int row, int count);
83  void add_columns(int column, int count);
84  void remove_columns(int column, int count);
85  void refresh_data();
86 
87  public slots:
88  void set_zoom(int zoom, const QSize& view_size);
89  void reload();
90  void clear();
91 
92  private slots:
93  void cover_ready(const QString& hash);
94  void next_hash();
95  void cover_lookup_finished(bool success);
96  void show_artists_changed();
97  };
98 }
99 
100 #endif // ALBUMCOVERMODEL_H
Definition: AbstractLibrary.h:38
The MetaDataList class.
Definition: MetaDataList.h:37
The CoverLocation class.
Definition: CoverLocation.h:37
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
The AlbumList class.
Definition: Album.h:89
The Album class.
Definition: Album.h:39
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:29
Definition: SomaFMStation.h:33
Definition: ItemModel.h:37
Definition: CoverModel.h:41