MCPcopy Create free account
hub / github.com/MITK/MITK / data

Method data

Modules/QtWidgets/src/QmitkRenderWindowDataStorageTreeModel.cpp:145–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145QVariant QmitkRenderWindowDataStorageTreeModel::data(const QModelIndex& index, int role) const
146{
147 auto baseRenderer = m_BaseRenderer.Lock();
148
149 if (baseRenderer.IsNull())
150 {
151 return QVariant();
152 }
153
154 if (!index.isValid() || this != index.model())
155 {
156 return QVariant();
157 }
158
159 auto item = GetItemByIndex(index);
160 if (nullptr == item)
161 {
162 return QVariant();
163 }
164
165 auto dataNode = item->GetDataNode();
166 if (nullptr == dataNode)
167 {
168 return QVariant();
169 }
170
171 if (Qt::CheckStateRole == role)
172 {
173 bool visibility = false;
174 dataNode->GetVisibility(visibility, baseRenderer);
175 if (visibility)
176 {
177 return Qt::Checked;
178 }
179 else
180 {
181 return Qt::Unchecked;
182 }
183 }
184 else if (Qt::DisplayRole == role)
185 {
186 return QVariant(QString::fromStdString(dataNode->GetName()));
187 }
188 else if (Qt::ToolTipRole == role)
189 {
190 return QVariant("Name of the data node.");
191 }
192 else if (Qt::DecorationRole == role)
193 {
194 QmitkNodeDescriptor* nodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(dataNode);
195 return nodeDescriptor->GetIcon(dataNode);
196 }
197 else if (Qt::UserRole == role || QmitkDataNodeRawPointerRole == role)
198 {
199 // user role always returns a reference to the data node,
200 // which can be used to modify the data node in the data storage
201 return QVariant::fromValue<mitk::DataNode*>(dataNode);
202 }

Callers 1

dropMimeDataMethod · 0.95

Calls 7

GetVisibilityMethod · 0.80
LockMethod · 0.45
IsNullMethod · 0.45
GetDataNodeMethod · 0.45
GetNameMethod · 0.45
GetDescriptorMethod · 0.45
GetIconMethod · 0.45

Tested by

no test coverage detected