-
Notifications
You must be signed in to change notification settings - Fork 4
/
paymentmodel.cpp
executable file
·55 lines (51 loc) · 1.65 KB
/
paymentmodel.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
#include "paymentmodel.h"
#include <QDate>
#include <QBrush>
PaymentModel::PaymentModel(QObject *parent, int namecolumn,
int moneycolumn, int datecolumn, int timecolumn, int naturecolumn) :
QSqlQueryModel(parent),
_dealercolumn(namecolumn),
_moneycolumn(moneycolumn),
_datecolumn(datecolumn),
_naturecolumn(naturecolumn)
{
}
QVariant PaymentModel::data(const QModelIndex &index, int role) const
{
//name
if(index.isValid() && index.column()==_dealercolumn &&
role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#3f9fd1");
return QVariant::fromValue(QBrush(text));
}
//money
if(index.isValid() && index.column()==_moneycolumn &&
role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#34a853");
return QVariant::fromValue(QBrush(text));
}
//date
if(index.isValid() && index.column()==_datecolumn &&
role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#ea4335");
return QVariant::fromValue(QBrush(text));
}
//time
if(index.isValid() && index.column()==_datecolumn &&
role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#bcbebf");
return QVariant::fromValue(QBrush(text));
}
//nature
if(index.isValid() && index.column()==_datecolumn &&
role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#bcbebf");
return QVariant::fromValue(QBrush(text));
}
return QSqlQueryModel::data(index,role);
}