MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / createItemForKnob

Method createItemForKnob

Gui/ManageUserParamsDialog.cpp:396–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396QTreeWidgetItem*
397ManageUserParamsDialogPrivate::createItemForKnob(const KnobIPtr& knob,
398 int insertIndex)
399{
400 QTreeWidgetItem* parent = 0;
401 KnobIPtr parentKnob;
402
403 if (knob) {
404 parentKnob = knob->getParentKnob();
405 }
406 if (parentKnob) {
407 for (std::list<TreeItem>::iterator it = items.begin(); it != items.end(); ++it) {
408 if ( it->knob.get() == parentKnob.get() ) {
409 parent = it->item;
410 break;
411 }
412 }
413 }
414
415 KnobPage* isPage = dynamic_cast<KnobPage*>( knob.get() );
416 if (!parent && !isPage) {
417 //Default to first user page
418 for (std::list<TreeItem>::iterator it = items.begin(); it != items.end(); ++it) {
419 KnobPage* isPage = dynamic_cast<KnobPage*>(it->knob.get());
420 if (!isPage) {
421 continue;
422 }
423 if (!isPage->isUserKnob()) {
424 continue;
425 }
426
427 parent = it->item;
428 break;
429 }
430 }
431 TreeItem i;
432 i.knob = knob;
433 i.item = new QTreeWidgetItem;
434 if (parent) {
435 if ( (insertIndex == -1) || ( insertIndex >= parent->childCount() ) ) {
436 parent->addChild(i.item);
437 } else {
438 parent->insertChild(insertIndex, i.item);
439 }
440 parent->setExpanded(true);
441 } else {
442 if ( (insertIndex == -1) || ( insertIndex >= tree->topLevelItemCount() ) ) {
443 tree->addTopLevelItem(i.item);
444 } else {
445 tree->insertTopLevelItem(insertIndex, i.item);
446 }
447 }
448 i.item->setExpanded(true);
449 i.scriptName = QString::fromUtf8( knob->getName().c_str() );
450
451 i.item->setText( 0, createTextForKnob(i.knob) );
452 items.push_back(i);
453

Callers 5

onPickClickedMethod · 0.80
onAddClickedMethod · 0.80
onEditClickedInternalMethod · 0.80
onUpClickedMethod · 0.80
onDownClickedMethod · 0.80

Calls 11

createTextForKnobFunction · 0.85
getParentKnobMethod · 0.80
childCountMethod · 0.80
addChildMethod · 0.80
getNameMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
isUserKnobMethod · 0.45
setTextMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected