-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCarModel.h
More file actions
48 lines (35 loc) · 1006 Bytes
/
CarModel.h
File metadata and controls
48 lines (35 loc) · 1006 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
47
48
#ifndef CARMODEL_H
#define CARMODEL_H
#include "ListItem.h"
class CarModel : public Models::ListItem
{
Q_OBJECT
Q_PROPERTY(QString carName WRITE setCarName CONSTANT)
Q_PROPERTY(QString carBrand WRITE setCarBrand CONSTANT)
Q_PROPERTY(int carPrice WRITE setCarPrice CONSTANT)
public:
explicit CarModel(QObject *parent = NULL);
explicit CarModel(int id, const QString &name, const QString &brand, int price, QObject *parent = NULL);
// ListItem interface
enum CarEnum
{
car_name = Qt::UserRole + 1,
car_brand,
car_price,
car_id
};
public:
int id() const;
QVariant data(int role) const;
bool setData(int role, const QVariant &value);
QHash<int, QByteArray> roleNames() const;
void setCarName(const QString &carName);
void setCarBrand(const QString &carBrand);
void setCarPrice(int price);
private:
int carId;
QString name;
QString brand;
int price;
};
#endif // CARMODEL_H