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

Method InsertNode

Modules/QtWidgets/src/QmitkDataStorageComboBox.cpp:267–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void QmitkDataStorageComboBox::InsertNode(int index, const mitk::DataNode *dataNode)
268{
269 // check new or updated node first
270 if (m_Predicate.IsNotNull() && !m_Predicate->CheckNode(dataNode))
271 return;
272
273 bool addNewNode = false;
274 bool insertNewNode = false;
275 bool changedNode = false;
276
277 // if this->HasIndex(index), then a node shall be updated
278 if (this->HasIndex(index))
279 {
280 // if we really have another node at this position then ...
281 if (dataNode != m_Nodes.at(index))
282 {
283 // ... remove node, then proceed as usual
284 this->RemoveNode(index);
285 insertNewNode = true;
286 }
287 else
288 changedNode = true;
289 }
290 // otherwise a new node shall be added, let index point to the element after the last element
291 else
292 {
293 index = m_Nodes.size();
294 addNewNode = true;
295 }
296
297 // const cast because we need non const nodes
298 mitk::DataNode *nonConstDataNode = const_cast<mitk::DataNode *>(dataNode);
299 if (!changedNode)
300 {
301 // break on duplicated nodes (that doesn't make sense to have duplicates in the combobox)
302 if (this->Find(dataNode) != -1)
303 return;
304
305 // add modified observer
306 itk::MemberCommand<QmitkDataStorageComboBox>::Pointer propertyListChangedCommand =
307 itk::MemberCommand<QmitkDataStorageComboBox>::New();
308 propertyListChangedCommand->SetCallbackFunction(this, &QmitkDataStorageComboBox::OnPropertyListChanged);
309
310 // add observer for the data node property list
311 mitk::PropertyList* dataNodePropertyList = nonConstDataNode->GetPropertyList();
312 if (nullptr != dataNodePropertyList)
313 {
314 m_DataNodePropertyListObserverTags.push_back(dataNodePropertyList->AddObserver(itk::ModifiedEvent(),
315 propertyListChangedCommand));
316 }
317 else
318 {
319 // fill vector with invalid value
320 m_DataNodePropertyListObserverTags.push_back(-1);
321 }
322
323 mitk::PropertyList* baseDataPropertyList;
324 //add observer for the base data property list

Callers 2

AddNodeMethod · 0.95
SetNodeMethod · 0.95

Calls 13

HasIndexMethod · 0.95
RemoveNodeMethod · 0.95
FindMethod · 0.95
IsNotNullMethod · 0.80
atMethod · 0.80
AddObserverMethod · 0.80
NewFunction · 0.50
CheckNodeMethod · 0.45
sizeMethod · 0.45
GetPropertyListMethod · 0.45
GetDataMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected