-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtreeitem.cpp
56 lines (43 loc) · 822 Bytes
/
treeitem.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 "treeitem.h"
TreeItem::TreeItem(const QList<QString> &data, TreeItem *parent)
{
this->parentItem = parent;
this->itemData = data;
}
TreeItem::TreeItem()
{
}
TreeItem::~TreeItem()
{
qDeleteAll(this->childItems);
}
void TreeItem::appendChild(TreeItem *child)
{
this->childItems.append(child);
}
int TreeItem::childCount() const
{
return childItems.count();
}
TreeItem* TreeItem::child(int row)
{
return childItems.value(row);
}
int TreeItem::row() const
{
if(parentItem)
return this->parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
return 0;
}
int TreeItem::columnCount() const
{
return itemData.count();
}
QVariant TreeItem::data(int column) const
{
return itemData.value(column);
}
TreeItem* TreeItem::parent()
{
return parentItem;
}