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