-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdealermodel.cpp
executable file
·55 lines (48 loc) · 1.24 KB
/
dealermodel.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 "dealermodel.h"
#include <QBrush>
#include <QColor>
#include <QModelIndex>
#include <QFont>
DealerModel::DealerModel(QObject *parent, short namecolumn,
short balancecoulumn) :
QSqlQueryModel(parent),
_namecol(namecolumn),
_balancecol(balancecoulumn)
{
}
QVariant DealerModel::data(const QModelIndex &index, int role) const
{
if(index.isValid() && index.column()==_namecol
&& role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#3f9fd1");
return QBrush(text);
}
if(index.isValid() && index.column()==_balancecol
&& role==Qt::ForegroundRole){
QColor text;
text.setNamedColor("#ba6000");
return QBrush(text);
}
//font
if(index.isValid() && role==Qt::FontRole){
return QFont("times",12,QFont::DemiBold);
}
return QSqlQueryModel::data(index,role);
}
short DealerModel::balancecol() const
{
return _balancecol;
}
void DealerModel::setBalancecol(short balancecol)
{
_balancecol = balancecol;
}
short DealerModel::namecol() const
{
return _namecol;
}
void DealerModel::setNamecol(short namecol)
{
_namecol = namecol;
}