-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchaptermodel.h
44 lines (34 loc) · 1.03 KB
/
chaptermodel.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
#ifndef CHAPTERMODEL_H
#define CHAPTERMODEL_H
#include <QAbstractListModel>
class Book;
class Library;
class ChapterModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit ChapterModel(QObject *parent = nullptr);
// list of accesable properties/roles/map/bindings
enum {
ChapterIndexRole,
TitleRole,
FileNameRole,
DurationRole,
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[ChapterIndexRole] = "chapterIndex";
names[TitleRole] = "title";
names[FileNameRole] = "fileName";
names[DurationRole] = "duration";
names[CurrentItemRole] = "isCurrentItem";
return names;
}
};
#endif // CHAPTERMODEL_H