-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtreewidgetitem.cpp
37 lines (28 loc) · 908 Bytes
/
treewidgetitem.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
#include "treewidgetitem.h"
TreeWidgetItem::TreeWidgetItem(QTreeWidget *parent) :
QTreeWidgetItem(parent)
{
}
TreeWidgetItem::TreeWidgetItem(QTreeWidgetItem *parent, int type)
:QTreeWidgetItem(parent,type)
{
}
void TreeWidgetItem::setData(int column, int role, const QVariant &value)
{
QTreeWidgetItem::setData(column, role, value);
if(role==Qt::CheckStateRole)
{
if(checkState(column)!= Qt::PartiallyChecked)
for(int i=0; i<childCount(); ++i)
{
QTreeWidgetItem *childItem = child(i);
childItem->setCheckState(column,checkState(column));
}
QTreeWidgetItem* parentItem = dynamic_cast<QTreeWidgetItem*>(parent());
if(parentItem)
{
if(checkState(column) != parentItem->checkState(column) )
parentItem->setCheckState(column,Qt::PartiallyChecked);
}
}
}