-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporttree.cpp
More file actions
61 lines (47 loc) · 1.72 KB
/
reporttree.cpp
File metadata and controls
61 lines (47 loc) · 1.72 KB
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
#include "reporttree.h"
#include <iostream>
ReportTree::ReportTree(QWidget *parent) :
QTreeWidget(parent)
{
this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
this->connect(this,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(SlotItemClicked(QTreeWidgetItem*,int)));
this->headerItem()->setText(0,"Findings");
}
ReportTree::~ReportTree()
{
}
void ReportTree::UpdateTree(const QList<TreeInput>& input)
{
this->clear();
for(int i=0; i < input.size(); ++i)
{
QTreeWidgetItem* findingItem = new QTreeWidgetItem(QStringList(input.value(i).findingName));
std::cout << "TLI count before " << this->topLevelItemCount() << std::endl;
this->invisibleRootItem()->addChild(findingItem);
std::cout << "TLI count after " << this->topLevelItemCount() << std::endl;
for(int j=0; j < input.value(i).segmentationNames.size(); ++j)
{
QTreeWidgetItem* segmentationItem = new QTreeWidgetItem(QStringList(input.value(i).segmentationNames.at(j)));
findingItem->addChild(segmentationItem);
findingItem->setExpanded(true);
}
}
}
void ReportTree::SlotItemClicked(QTreeWidgetItem* item, int column)
{
QString positionCode;
for(int i=0; i < this->invisibleRootItem()->childCount(); ++i)
{
if(this->invisibleRootItem()->child(i) == item)
positionCode.setNum(i);
else
{
for(int j=0; j < this->invisibleRootItem()->child(i)->childCount(); ++j)
{
if(this->invisibleRootItem()->child(i)->child(j) == item)
positionCode.setNum(i) += QString().setNum(j);
}
}
}
emit SignalItemSelected(positionCode);
}