-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevelmodel.h
More file actions
46 lines (37 loc) · 897 Bytes
/
levelmodel.h
File metadata and controls
46 lines (37 loc) · 897 Bytes
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
#pragma once
#include <QAbstractListModel>
#include <QUrl>
class LevelDescription
{
Q_GADGET
Q_PROPERTY(QString name MEMBER name)
Q_PROPERTY(QUrl preview MEMBER preview)
Q_PROPERTY(QString path MEMBER path)
public:
QString name;
QUrl preview;
QString path;
};
class LevelModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles
{
Name,
Preview,
Path
};
Q_ENUM(Roles)
explicit LevelModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
void addLevel(const LevelDescription &level);
void clear();
LevelDescription levelAtIndex(int index) const;
int indexOf(const QString &name) const;
void removeLevel(int index);
private:
QList<LevelDescription> m_data;
};