-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLightModel.h
More file actions
56 lines (46 loc) · 1.69 KB
/
LightModel.h
File metadata and controls
56 lines (46 loc) · 1.69 KB
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
49
50
51
52
53
54
55
56
#ifndef LIGHTMODEL_H
#define LIGHTMODEL_H
#include <QAbstractListModel>
#include <vector>
#include <memory>
#include "Light.h"
class LightModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int updateCounter READ updateCounter WRITE setUpdateCounter NOTIFY updateCounterChanged)
public:
enum LightRole
{
Name = Qt::UserRole + 1,
Position,
Direction,
LightType,
Visibility,
Color,
Brightness,
AttenuationRadius,
InnerConeAngle,
OuterConeAngle
};
Q_ENUM(LightRole)
LightModel(QObject* parent = nullptr);
int updateCounter() const;
void setUpdateCounter(int value);
void append(std::unique_ptr<Light> light);
Q_INVOKABLE void append(QVariant light);
Q_INVOKABLE void remove(quint32 index);
Q_INVOKABLE bool setLightProperty(int lightIndex, const QVariant& value, LightRole role);
Q_INVOKABLE QVariant getLightProperty(int lightIndex, LightRole role) const;
Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
signals:
void updateCounterChanged(int counter);
protected:
QHash<int, QByteArray> roleNames() const override;
private:
std::vector<std::unique_ptr<Light>> lights;
int counter = 0;
};
#endif // LIGHTMODEL_H