Sayonara Player
ItemModel.h
1/* ItemModel.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 LIBRARYITEMMODEL_H_
22#define LIBRARYITEMMODEL_H_
23
24#include "Gui/Utils/SearchableWidget/SearchableModel.h"
25#include "Utils/Pimpl.h"
26
27namespace Cover
28{
29 class Location;
30}
31
32class AbstractLibrary;
33
34namespace Library
35{
41 class ItemModel :
43 {
44 Q_OBJECT
45 PIMPL(ItemModel)
46
47 public:
48 ItemModel(int columnCount, QObject* parent, AbstractLibrary* library);
49 ~ItemModel() override;
50
51 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
52 bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value,
53 int role = Qt::EditRole) override;
54
55 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
56
57 QModelIndexList searchResults(const QString& substr) override;
58
63 virtual int searchableColumn() const = 0;
64
71 virtual QString searchableString(int row) const = 0;
72
78 virtual Id mapIndexToId(int row) const = 0;
79
86 virtual Cover::Location cover(const QModelIndexList& indexList) const = 0;
87
93 virtual const MetaDataList& selectedMetadata() const = 0;
94 virtual QMimeData* mimeData(const QModelIndexList& indexList) const override;
95
96 void refreshData(int* rowCountBefore = nullptr, int* rowCountAfter = nullptr); //returns the size difference
97
98 protected:
99 AbstractLibrary* library();
100 const AbstractLibrary* library() const;
101
102 private:
103 bool removeRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
104 bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
105 };
106}
107
108#endif /* LIBRARYITEMMODEL_H_ */
Definition: AbstractLibrary.h:44
Definition: CoverLocation.h:39
The ItemModel is intended to abstract the various views. It supports searching, selections and a libr...
Definition: ItemModel.h:43
virtual Cover::Location cover(const QModelIndexList &indexList) const =0
return the cover for multiple rows. if rows.size() > 1, an invalid, default constructed cover locatio...
virtual int searchableColumn() const =0
the index of the searchable column. This is the column where the text is searched for a certain searc...
virtual QString searchableString(int row) const =0
here, the searchable string can even be refined. Maybe we just want to search within a substring indi...
virtual const MetaDataList & selectedMetadata() const =0
return the tracks which belong to the selections. If an album is selected for example,...
virtual Id mapIndexToId(int row) const =0
return the current id for a given row
The MetaDataList class.
Definition: MetaDataList.h:39
Definition: SearchableModel.h:50
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31