Sayonara Player
ItemModel.h
1 /* ItemModel.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 LIBRARYITEMMODEL_H_
22 #define LIBRARYITEMMODEL_H_
23 
24 #include "Gui/Utils/SearchableWidget/SearchableModel.h"
25 #include "Utils/Pimpl.h"
26 
27 namespace Cover
28 {
29  class Location;
30 }
31 
32 class CustomMimeData;
33 class AbstractLibrary;
34 
35 namespace Library
36 {
37  class ItemModel :
39  {
40  Q_OBJECT
41  PIMPL(ItemModel)
42 
43  public:
44  ItemModel(QObject* parent, AbstractLibrary* library);
45  virtual ~ItemModel() override;
46 
48  QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const override;
49  bool set_header_data(const QStringList& names);
50 
51  virtual int columnCount(const QModelIndex& parent=QModelIndex()) const override;
52 
54  QModelIndexList search_results(const QString& substr) override;
55 
56  virtual bool is_selected(int id) const final;
57  virtual const Util::Set<Id>& selections() const=0;
58  virtual IndexSet selected_indexes() const;
59 
60  virtual int searchable_column() const=0;
61  virtual QString searchable_string(int row) const=0;
62  virtual Id id_by_index(int row) const=0;
63  virtual Cover::Location cover(const IndexSet& indexes) const=0;
64 
65  virtual const MetaDataList& mimedata_tracks() const=0;
66  CustomMimeData* custom_mimedata() const;
67 
68  void refresh_data(int* n_rows_before=nullptr, int* n_rows_after=nullptr); //returns the size difference
69 
70  protected:
71  AbstractLibrary* library();
72  const AbstractLibrary* library() const;
73 
74  private:
75  bool removeRows(int position, int rows, const QModelIndex& index=QModelIndex()) override;
76  bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override;
77  };
78 }
79 
80 #endif /* LIBRARYITEMMODEL_H_ */
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: SearchableModel.h:52
Definition: AbstractLibrary.h:38
The MetaDataList class.
Definition: MetaDataList.h:37
The CoverLocation class.
Definition: CoverLocation.h:37
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:32
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
QModelIndexList search_results(const QString &substr) override
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:29
Definition: SomaFMStation.h:33
Definition: ItemModel.h:37