Repository navigation
Expand file tree
/
Copy pathdirtree.cpp
More file actions
85 lines (74 loc) · 1.87 KB
/
Copy pathdirtree.cpp
File metadata and controls
85 lines (74 loc) · 1.87 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
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
#include "dirtree.h"
DirTree::DirTree(QString name, int localTesting, int localDocumented, int localTests, bool isIgnored, bgcolors color)
{
root = DirTree::createNode(name, localTesting, localDocumented, localTests, isIgnored, color);
}
void DirTree::addChild(DirNode *child, DirNode *parent)
{
if (!parent->childNode) {
parent->childNode = child;
} else {
DirNode *node = parent->childNode;
while (node->rightNode != NULL) {
node = node->rightNode;
}
node->rightNode = child;
}
child->parentNode = parent;
}
DirNode * DirTree::getRoot() const
{
return root;
}
DirTree::~DirTree()
{
delNode(root);
}
void DirTree::delNode(DirNode *node)
{
if (node->childNode) {
delNode(node->childNode);
}
if (node->rightNode){
delNode(node->rightNode);
}
delete node;
}
DirNode *DirTree::createNode(QString name, int localTesting, int localDocumented, int localTests, bool isIgnored, bgcolors color)
{
DirNode *node = new DirNode;
node->name = name;
node->localDocumented = localDocumented;
node->localTesting = localTesting;
node->parentNode = NULL;
node->rightNode = NULL;
node->childNode = NULL;
node->totalTesting = 0;
node->totalDocumented = 0;
node->totalTests = 0;
node->localTests = localTests;
node->isIgnored = isIgnored;
node->color = color;
return node;
}
void DirTree::calculateTotalData()
{
calculateTotalDataForNode(root);
}
void DirTree::calculateTotalDataForNode(DirNode *node)
{
if (node->childNode) {
calculateTotalDataForNode(node->childNode);
}
if (node->rightNode) {
calculateTotalDataForNode(node->rightNode);
}
node->totalDocumented += node->localDocumented;
node->totalTesting += node->localTesting;
node->totalTests += node->localTests;
if (node != root) {
node->parentNode->totalDocumented += node->totalDocumented;
node->parentNode->totalTesting += node->totalTesting;
node->parentNode->totalTests += node->totalTests;
}
}