-
Notifications
You must be signed in to change notification settings - Fork 7
/
calibration_treewidget.cpp
151 lines (130 loc) · 6.07 KB
/
calibration_treewidget.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "calibration_treewidget.h"
CalibrationTreeWidget::CalibrationTreeWidget()
{
}
QTreeWidget *CalibrationTreeWidget::buildCalibrationFilesTree(int ecuCalDefIndex, QTreeWidget *filesTreeWidget, FileActions::EcuCalDefStructure *ecuCalDef)
{
QString filename(ecuCalDef->FileName);
/**************************
* Create files tree
*************************/
QTreeWidget *calFilesTree = filesTreeWidget;
calFilesTree->setAnimated(true);
calFilesTree->setFocusPolicy(Qt::NoFocus);
//calFilesTree->setStyleSheet("QListView::item:selected {background : transparent; border: solid 2px red;}");
QFont filesItemFont;
filesItemFont.setPixelSize(14);
calFilesTree->setFont(filesItemFont);
QTreeWidgetItem *topLevelFilesTreeItem = new QTreeWidgetItem();
topLevelFilesTreeItem->setText(2, QString::number(ecuCalDefIndex));
topLevelFilesTreeItem->setCheckState(0, Qt::Unchecked);
topLevelFilesTreeItem->setFirstColumnSpanned(true);
calFilesTree->addTopLevelItem(topLevelFilesTreeItem);
topLevelFilesTreeItem->setText(0, filename);
if (ecuCalDef->IdList.length())
topLevelFilesTreeItem->setText(1, ecuCalDef->IdList.at(0));
calFilesTree->expandItem(topLevelFilesTreeItem);
for (int i = 0; i < calFilesTree->topLevelItemCount(); i++)
{
calFilesTree->topLevelItem(i)->setCheckState(0, Qt::Unchecked);
calFilesTree->topLevelItem(i)->setSelected(false);
}
topLevelFilesTreeItem->setSelected(true);
topLevelFilesTreeItem->setCheckState(0, Qt::Checked);
return calFilesTree;
}
QTreeWidget *CalibrationTreeWidget::buildCalibrationDataTree(QTreeWidget *dataTreeWidget, FileActions::EcuCalDefStructure *ecuCalDef)
{
bool treeChildCreated = false;
/**************************
* Create data tree
*************************/
dataTreeWidget->clear();
QTreeWidget *calDataTree = dataTreeWidget;
calDataTree->setAnimated(true);
calDataTree->setFocusPolicy(Qt::NoFocus);
QFont dataItemFont;
dataItemFont.setPixelSize(12);
calDataTree->setFont(dataItemFont);
// If OEM ecu file, add ROM info
if (ecuCalDef->RomInfo.length())
{
QTreeWidgetItem * topLevelDataTreeItem = new QTreeWidgetItem();
topLevelDataTreeItem->setText(0, "ROM Info");
calDataTree->addTopLevelItem(topLevelDataTreeItem);
if (ecuCalDef->RomInfoExpanded == "1")
topLevelDataTreeItem->setExpanded(true);
for (int i = 2; i < ecuCalDef->RomInfo.length(); i++)
{
QTreeWidgetItem * item = new QTreeWidgetItem();
item->setText(0, ecuCalDef->RomInfoStrings.at(i) + ": " + ecuCalDef->RomInfo.at(i));
calDataTree->topLevelItem(0)->addChild(item);
}
}
for (int j = 0; j < ecuCalDef->NameList.count(); j++)
{
if (ecuCalDef->CategoryList[j] != "" && ecuCalDef->CategoryList[j] != " ")
{
if (ecuCalDef->NameList[j] != "")
{
treeChildCreated = false;
for (int i = 0; i < calDataTree->topLevelItemCount(); i++){
if (calDataTree->topLevelItem(i)->text(0) == ecuCalDef->CategoryList[j]){
treeChildCreated = true;
}
}
if (!treeChildCreated)
{
QTreeWidgetItem * topLevelDataTreeItem = new QTreeWidgetItem();
topLevelDataTreeItem->setText(0, ecuCalDef->CategoryList[j]);
calDataTree->addTopLevelItem(topLevelDataTreeItem);
treeChildCreated = false;
if (ecuCalDef->CategoryExpandedList.at(j) == "1")
topLevelDataTreeItem->setExpanded(true);
}
for (int i = 0; i < calDataTree->topLevelItemCount(); i++){
if (calDataTree->topLevelItem(i)->text(0) == ecuCalDef->CategoryList[j]){
QTreeWidgetItem * item = new QTreeWidgetItem();
if (ecuCalDef->TypeList[j] == "1D" || ecuCalDef->TypeList[j] == "Selectable" || (ecuCalDef->YSizeList.at(j).toInt() == 1 && ecuCalDef->XSizeList.at(j).toInt() == 1))
item->setIcon(0, QIcon(":/icons/1D-64.png"));
else if (ecuCalDef->TypeList[j] == "2D")
item->setIcon(0, QIcon(":/icons/2D-64.png"));
else if (ecuCalDef->TypeList[j] == "3D")
item->setIcon(0, QIcon(":/icons/3D-64.png"));
if (ecuCalDef->VisibleList.at(j) == "1")
item ->setCheckState(0,Qt::Checked);
else
item ->setCheckState(0,Qt::Unchecked);
item->setText(0, ecuCalDef->NameList[j]);
item->setText(1, QString::number(j));
calDataTree->topLevelItem(i)->addChild(item);
item->setToolTip(0, ecuCalDef->NameList[j] + ecuCalDef->DescriptionList[j]);
}
}
}
}
}
return calDataTree;
}
void *CalibrationTreeWidget::calibrationDataTreeWidgetItemExpanded(FileActions::EcuCalDefStructure *ecuCalDef, QString categoryName)
{
for (int i = 0; i < ecuCalDef->CategoryList.count(); i++)
{
if (ecuCalDef->CategoryList.at(i) == categoryName)
ecuCalDef->CategoryExpandedList.replace(i, "1");
}
if (categoryName == "ROM Info")
ecuCalDef->RomInfoExpanded = "1";
return NULL;
}
void *CalibrationTreeWidget::calibrationDataTreeWidgetItemCollapsed(FileActions::EcuCalDefStructure *ecuCalDef, QString categoryName)
{
for (int i = 0; i < ecuCalDef->CategoryList.count(); i++)
{
if (ecuCalDef->CategoryList.at(i) == categoryName)
ecuCalDef->CategoryExpandedList.replace(i, "0");
}
if (categoryName == "ROM Info")
ecuCalDef->RomInfoExpanded = "0";
return NULL;
}