-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCRuleModel.cpp
More file actions
61 lines (50 loc) · 1021 Bytes
/
CRuleModel.cpp
File metadata and controls
61 lines (50 loc) · 1021 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
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "CRuleModel.h"
CRuleModel::CRuleModel(QObject *parent)
: QSqlTableModel(parent)
{
initData();
}
CRuleModel::~CRuleModel()
{
}
void CRuleModel::initData()
{
column1=0;
column2=0;
}
QVariant CRuleModel::headerData ( int section, Qt::Orientation orientation, int role) const
{
QVariant value=QSqlTableModel::headerData(section,orientation,role);
if (value.toString()=="KEYVALUE")
{
column1=section;
}
else if (value.toString()=="KEYMASK")
{
column2=section;
}
return value;
}
QVariant CRuleModel::data(const QModelIndex& index,int role) const
{
QVariant value=QSqlTableModel::data(index,role);
if(role==Qt::DisplayRole&&(index.column()==column1||index.column()==column2))
{
QByteArray ss=value.toByteArray();
QString str="0x";
QByteArray s1=ss.toHex();
char *data = s1.data();
while (*data) {
str.append(*data);
//qDebug()<<*data;
++data;
str.append(*data);
//qDebug()<<*data;
++data;
str=str.toUpper()+" ";
}
return str;
}
else
return value;
}