forked from palindromiq/YATE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysisviewitem.cpp
70 lines (50 loc) · 1.18 KB
/
analysisviewitem.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
#include "analysisviewitem.h"
namespace Yate {
AnalysisViewItem::AnalysisViewItem(const QVector<QVariant> &data, AnalysisViewItem *parent)
: itemData_(data), parentItem_(parent)
{
}
AnalysisViewItem::~AnalysisViewItem()
{
qDeleteAll(childItems_);
}
void AnalysisViewItem::appendChild(AnalysisViewItem *item)
{
item->setParentItem(this);
childItems_.append(item);
}
AnalysisViewItem *AnalysisViewItem::child(int row)
{
if (row < 0 || row >= childItems_.size())
return nullptr;
return childItems_.at(row);
}
int AnalysisViewItem::childCount() const
{
return childItems_.count();
}
int AnalysisViewItem::columnCount() const
{
return itemData_.count();
}
QVariant AnalysisViewItem::data(int column) const
{
if (column < 0 || column >= itemData_.size())
return QVariant();
return itemData_.at(column);
}
AnalysisViewItem *AnalysisViewItem::parentItem()
{
return parentItem_;
}
void AnalysisViewItem::setParentItem(AnalysisViewItem *parent)
{
parentItem_ = parent;
}
int AnalysisViewItem::row() const
{
if (parentItem_)
return parentItem_->childItems_.indexOf(const_cast<AnalysisViewItem*>(this));
return 0;
}
}