-
Notifications
You must be signed in to change notification settings - Fork 4
/
salesmodel.cpp
executable file
·117 lines (102 loc) · 2.58 KB
/
salesmodel.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "salesmodel.h"
SalesModel::SalesModel(QObject *parent, int serial, int name,
int weight, int total, int paid, int remaining) :
QSqlQueryModel(parent),
_serial(serial),
_name(name),
_weight(weight),
_total(total),
_paid(paid),
_remaining(remaining)
{
}
QVariant SalesModel::data(const QModelIndex &index, int role) const
{
//serial no
if(index.isValid() && index.column()==_serial && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#ea4335");//google red
return QBrush(text);
}
//name
if(index.isValid() && index.column()==_name && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#4285f4");//google blue
return QBrush(text);
}
//paid price
if(index.isValid() && index.column()==_paid && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#ba6000");//qt orange
return QBrush(text);
}
//total price
if(index.isValid() && index.column()==_total && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#34a853");//google green
return QBrush(text);
}
//weight
if(index.isValid() && index.column()==_paid && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#ba6000");//qt orange
return QBrush(text);
}
// cash remaining
if(index.isValid() && index.column()==_remaining && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#ea4335");//google red
return QBrush(text);
}
//other color
if(index.isValid() && role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#404244");//maingery
return QBrush(text);
}
//font
if(index.isValid() && role==Qt::FontRole){
return QFont("times",12,QFont::DemiBold);
}
return QSqlQueryModel::data(index,role);
}
int SalesModel::weight() const
{
return _weight;
}
void SalesModel::setWeight(int weight)
{
_weight = weight;
}
int SalesModel::paid() const
{
return _paid;
}
void SalesModel::setPaid(int paid)
{
_paid = paid;
}
int SalesModel::total() const
{
return _total;
}
void SalesModel::setTotal(int total)
{
_total = total;
}
int SalesModel::name() const
{
return _name;
}
void SalesModel::setName(int name)
{
_name = name;
}
int SalesModel::serial() const
{
return _serial;
}
void SalesModel::setSerial(int serial)
{
_serial = serial;
}