Sayonara Player
CoverModel.h
1 /* CoverModel.h */
2 
3 /* Copyright (C) 2011-2017 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/Models/ItemModel.h"
25 #include "Utils/Pimpl.h"
26 
27 class Album;
28 class AlbumList;
29 
30 class QSize;
31 
32 namespace Cover
33 {
34  class Location;
35  class Lookup;
36 }
37 
38 namespace Library
39 {
40  class CoverModel :
41  public ItemModel
42  {
43  Q_OBJECT
44  PIMPL(CoverModel)
45 
46  public:
47  explicit CoverModel(QObject* parent, AbstractLibrary* library);
48  virtual ~CoverModel();
49 
50  public:
51  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
52  int columnCount(const QModelIndex& paren=QModelIndex()) const override;
53  QVariant data(const QModelIndex& index, int role) const override;
54  Qt::ItemFlags flags(const QModelIndex &index) const override;
55 
56  int zoom() const;
57  void refresh_data();
58 
59  protected:
60  const MetaDataList& mimedata_tracks() const override;
61  const IndexSet& selections() const override;
62 
63  QModelIndex getNextRowIndexOf(const QString& substr, int cur_row, const QModelIndex& parent=QModelIndex()) override;
64  QModelIndex getPrevRowIndexOf(const QString& substr, int cur_row, const QModelIndex& parent=QModelIndex()) override;
65  int getNumberResults(const QString& str) override;
66 
67  int searchable_column() const override;
68  QString searchable_string(int idx) const override;
69  int id_by_row(int idx) override;
70  Cover::Location cover(const IndexSet& indexes) const override;
71 
72  private:
73  const AlbumList& albums() const;
74  void add_rows(int row, int count);
75  void remove_rows(int row, int count);
76  void add_columns(int column, int count);
77  void remove_columns(int column, int count);
78 
79  public slots:
80  void set_zoom(int zoom, const QSize& view_size);
81  void reload();
82 
83  private slots:
84  void next_hash();
85 
86 
87 
88  };
89 }
90 
91 #endif // ALBUMCOVERMODEL_H
Definition: AbstractLibrary.h:47
The MetaDataList class.
Definition: MetaDataList.h:38
The CoverLocation class.
Definition: CoverLocation.h:41
The AlbumList class.
Definition: Album.h:85
The Album class.
Definition: Album.h:38
An interface class needed when implementing a library plugin.
Definition: LibraryManager.h:36
Definition: SomaFMStation.h:33
Definition: ItemModel.h:39
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:36
QModelIndex getNextRowIndexOf(const QString &substr, int cur_row, const QModelIndex &parent=QModelIndex()) override
Definition: CoverModel.h:40