Sayonara Player
LibraryItemModel.h
1 /* LibraryItemModel.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 #ifndef LIBRARYITEMMODEL_H_
23 #define LIBRARYITEMMODEL_H_
24 
25 
26 
27 #define COL_ALBUM_MACROS
28 #define COL_ALBUM_MULTI_DISC 0
29 #define COL_ALBUM_NAME 1
30 #define COL_ALBUM_DURATION 2
31 #define COL_ALBUM_N_SONGS 3
32 #define COL_ALBUM_YEAR 4
33 #define COL_ALBUM_RATING 5
34 
35 #define COL_ARTIST_MACROS
36 #define COL_ARTIST_N_ALBUMS 0
37 #define COL_ARTIST_NAME 1
38 #define COL_ARTIST_TRACKS 2
39 
40 #define COL_TRACK_NUM 0
41 #define COL_TITLE 1
42 #define COL_ARTIST 2
43 #define COL_ALBUM 3
44 //#define COL_DISCNUMBER 4
45 #define COL_YEAR 4
46 #define COL_LENGTH 5
47 #define COL_BITRATE 6
48 #define COL_FILESIZE 7
49 #define COL_TRACK_RATING 8
50 
51 #include "GUI/Helper/SearchableWidget/AbstractSearchModel.h"
52 #include "Helper/MetaData/MetaDataList.h"
53 #include "Helper/Set.h"
54 
55 class CustomMimeData;
56 class ColumnHeader;
59 {
60 
61  Q_OBJECT
62 
63 public:
64 
66  virtual ~LibraryItemModel();
67 
68  QStringList get_header_names() const;
69 
71  QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const override;
72  bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) override;
73 
74  int rowCount(const QModelIndex &parent=QModelIndex()) const override;
75  int columnCount(const QModelIndex& parent=QModelIndex()) const override;
76  bool insertColumns(int position, int cols, const QModelIndex &index=QModelIndex()) override;
77  bool removeColumns(int position, int cols, const QModelIndex &index=QModelIndex()) override;
78  bool removeRows(int position, int rows, const QModelIndex& index=QModelIndex()) override;
79  bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override;
80 
81  virtual void add_selections(const SP::Set<int>& rows) final;
82  virtual void add_selection(int row) final;
83  virtual bool is_selected(int id) final;
84  virtual bool has_selections() final;
85  virtual void remove_selection(int row) final;
86  virtual void clear_selections() final;
87 
88  virtual QString get_string(int row) const=0;
89  virtual int get_id_by_row(int row)=0;
90 
91  virtual QMap<QChar, QString> getExtraTriggers() override;
92 
93  void set_mimedata(const MetaDataList& v_md);
94 
95  CustomMimeData* get_mimedata();
96 
97 
98 protected:
99  QStringList _header_names;
100  MetaDataList _md_mimedata;
101  SP::Set<int> _selections;
102 
103  int _n_rows;
104  int _n_cols;
105 
106 protected:
107 
108 };
109 
110 #endif /* LIBRARYITEMMODEL_H_ */
Definition: MetaDataList.h:44
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:34
Definition: AbstractSearchModel.h:48
Definition: LibraryItemModel.h:57
Definition: ColumnHeader.h:40
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override