-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticketmodel.h
41 lines (33 loc) · 995 Bytes
/
ticketmodel.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
#ifndef TICKETMODEL_H
#define TICKETMODEL_H
#include "ticket.h"
#include <QAbstractListModel>
#include <QJsonArray>
#include <QList>
class TicketModel : public QAbstractListModel
{
Q_OBJECT
QList<Ticket> m_tickets;
public:
enum TicketRole {
IdRole = Qt::UserRole+1,
StatusRole,
FirstNameRole,
LastNameRole,
EmailRole,
TimeIdRole,
TimeRole,
TimeOfReservationRole,
YearRole
};
explicit TicketModel(QObject *parent = nullptr);
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
// bool setData(const QModelIndex &index, const QVariant &value, int role) override;
void loadFromArray(QJsonArray array);
Q_INVOKABLE void loadFromJson(QString json);
void clear();
};
#endif // TICKETMODEL_H