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

Method onAddButtonClicked

Gui/KnobGuiTable.cpp:352–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352void
353KnobGuiTable::onAddButtonClicked()
354{
355 KnobTablePtr knob = std::dynamic_pointer_cast<KnobTable>( getKnob() );
356
357 assert(knob);
358
359 const int numCols = knob->getColumnsCount();
360 std::string oldTable = knob->getValue();
361 QStringList row;
362
363 if (numCols == 1) {
364 QStringList existingEntries;
365 for (Variables::iterator it = _imp->items.begin(); it != _imp->items.end(); ++it) {
366 existingEntries.push_back( it->items[0]->text() );
367 }
368
369 QString newItemName = QString::fromUtf8("Placeholder");
370 int i = 1;
371 while ( existingEntries.contains(newItemName) ) {
372 newItemName = QString::fromUtf8("Placeholder") + QString::number(i);
373 ++i;
374 }
375 row.push_back(newItemName);
376 } else {
377 if ( !addNewUserEntry(row) ) {
378 return;
379 }
380 }
381
382 int rowCount = (int)_imp->items.size();
383
384 _imp->createItem(knob, rowCount, row);
385 std::string newTable = _imp->encodeTable(knob);
386 pushUndoCommand( new KnobUndoCommand<std::string>( shared_from_this(), oldTable, newTable) );
387}
388
389void
390KnobGuiTable::onEditButtonClicked()

Callers

nothing calls this directly

Calls 10

pushUndoCommandFunction · 0.85
encodeTableMethod · 0.80
getKnobFunction · 0.70
getValueMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
containsMethod · 0.45
sizeMethod · 0.45
createItemMethod · 0.45

Tested by

no test coverage detected