-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibrarymodel.h
48 lines (38 loc) · 1.14 KB
/
librarymodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef LIBRARYMODEL_H
#define LIBRARYMODEL_H
#include <QAbstractListModel>
class Book;
class Library;
class LibraryModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit LibraryModel(QObject *parent = nullptr);
// list of accesable properties/roles/map/bindings
enum {
LibraryIndexRole,
TitleRole,
ChaptersRole,
DurationRole,
ArtistRole,
PathRole,
CurrentItemRole,
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void refresh();
// hashmap to store properties/roles
// map/bind qml to cpp
virtual QHash<int, QByteArray> roleNames() const override {
QHash<int, QByteArray> names;
names[LibraryIndexRole] = "libraryIndex";
names[TitleRole] = "title";
names[ChaptersRole] = "chapters";
names[DurationRole] = "duration";
names[ArtistRole] = "artist";
names[PathRole] = "path";
names[CurrentItemRole] = "isCurrentItem";
return names;
}
};
#endif // LIBRARYMODEL_H