-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchipsmodel.h
42 lines (34 loc) · 839 Bytes
/
chipsmodel.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
#ifndef CHIPSMODEL_H
#define CHIPSMODEL_H
#include <QAbstractListModel>
#include <QColor>
class ChipsModel : public QAbstractListModel
{
Q_OBJECT
struct ChipData {
int idX;
int idY;
qreal xPos;
qreal yPos;
QColor color;
bool selected;
};
public:
enum ChipRoles {
IdXRole = Qt::UserRole + 1,
IdYRole,
XPosRole,
YPosRole,
ColorRole,
SelectedRole
};
ChipsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QHash<int, QByteArray> roleNames() const;
private:
void generateData();
QVector<ChipData> m_data;
};
#endif // CHIPSMODEL_H