-
Notifications
You must be signed in to change notification settings - Fork 0
/
drinkmodel.h
55 lines (45 loc) · 1.15 KB
/
drinkmodel.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
45
46
47
48
49
50
51
52
53
54
55
#ifndef DRINKMODEL_H
#define DRINKMODEL_H
#include <QAbstractListModel>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QDateTime>
#include "settings.h"
class DrinkModel : public QAbstractListModel
{
Q_OBJECT
public:
enum DrinkRoles {
IdRole,
NameRole = Qt::UserRole + 1,
BottleSizeRole, //= Qt::UserRole + 1,
CaffeineRole,
PriceRole,
LogoUrl,
CreatedAtRole,
UpdatedAtRole,
};
explicit DrinkModel(QObject *parent = 0);
virtual int rowCount(const QModelIndex&) const { return drinks.size(); }
virtual QVariant data(const QModelIndex &index, int role) const;
QHash<int, QByteArray> roleNames() const;
Q_INVOKABLE void activate(const int i);
private:
struct Drink {
QString id;
QString name;
QString bottleSize;
QString caffeine;
QString price;
QString logoUrl;
QDateTime createdAtRole;
QDateTime updatedAtRole;
};
QVector<Drink> drinks;
};
#endif // DRINKMODEL_H