MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
abstracttreeitem.cpp
Go to the documentation of this file.
1//=============================================================================================================
34//=============================================================================================================
35// INCLUDES
36//=============================================================================================================
37
38#include "abstracttreeitem.h"
39
40//=============================================================================================================
41// QT INCLUDES
42//=============================================================================================================
43
44//=============================================================================================================
45// EIGEN INCLUDES
46//=============================================================================================================
47
48//=============================================================================================================
49// USED NAMESPACES
50//=============================================================================================================
51
52using namespace DISP3DLIB;
53
54//=============================================================================================================
55// DEFINE MEMBER METHODS
56//=============================================================================================================
57
58AbstractTreeItem::AbstractTreeItem(int iType, const QString& text)
59: QStandardItem(text)
60, m_iType(iType)
61{
62 initItem();
63}
64
65//=============================================================================================================
66
68{
69 this->setToolTip("Abstract Tree Item");
70
71 //Do the connects
74}
75
76//=============================================================================================================
77
78void AbstractTreeItem::setData(const QVariant& value, int role)
79{
80 QStandardItem::setData(value, role);
81
82 switch(role) {
83 case Qt::CheckStateRole:{
84 emit checkStateChanged(this->checkState());
85 break;
86 }
87 }
88}
89
90//=============================================================================================================
91
92int AbstractTreeItem::type() const
93{
94 return m_iType;
95}
96
97//=============================================================================================================
98
99void AbstractTreeItem::addItemWithDescription(QStandardItem* pItemParent,
100 QStandardItem* pItemAdd)
101{
102 if(pItemParent && pItemAdd) {
103 QList<QStandardItem*> list;
104 list << pItemAdd;
105 list << new QStandardItem(pItemAdd->toolTip());
106 pItemParent->appendRow(list);
107 }
108}
109
110//=============================================================================================================
111
112QList<QStandardItem*> AbstractTreeItem::findChildren(int type)
113{
114 QList<QStandardItem*> itemList;
115
116 if(this->hasChildren()) {
117 for(int row = 0; row<this->rowCount(); row++) {
118 for(int col = 0; col<this->columnCount(); col++) {
119 if(this->child(row, col)->type() == type) {
120 itemList.append(this->child(row, col));
121 }
122 }
123 }
124 }
125
126 return itemList;
127}
128
129//=============================================================================================================
130
131QList<QStandardItem*> AbstractTreeItem::findChildren(const QString& text)
132{
133 QList<QStandardItem*> itemList;
134
135 if(this->hasChildren()) {
136 for(int row = 0; row<this->rowCount(); row++) {
137 for(int col = 0; col<this->columnCount(); col++) {
138 if(this->child(row, col)->text() == text) {
139 itemList.append(this->child(row, col));
140 }
141 }
142 }
143 }
144
145 return itemList;
146}
147
148//=============================================================================================================
149
151{
152 this->appendRow(newItem);
153
154 return *this;
155}
156
157//=============================================================================================================
158
160{
161 this->appendRow(&newItem);
162
163 return *this;
164}
165
166//=============================================================================================================
167
168void AbstractTreeItem::onCheckStateChanged(const Qt::CheckState& checkState)
169{
170 //Store old state
171 m_checkStateOld = this->checkState();
172
173 for(int i = 0; i<this->rowCount(); i++) {
174 if(this->child(i)->isCheckable()) {
175 this->child(i)->setCheckState(checkState);
176 }
177 }
178}
AbstractTreeItem class declaration.
Provides the basic tree item.
AbstractTreeItem & operator<<(AbstractTreeItem *newItem)
AbstractTreeItem(int iType=Data3DTreeModelItemTypes::UnknownItem, const QString &text="")
virtual void onCheckStateChanged(const Qt::CheckState &checkState)
static void addItemWithDescription(QStandardItem *pItemParent, QStandardItem *pItemAdd)
void checkStateChanged(const Qt::CheckState &checkState)
QList< QStandardItem * > findChildren(int type)
void setData(const QVariant &value, int role=Qt::UserRole+1)