| 350 | } |
| 351 | |
| 352 | void |
| 353 | KnobGuiTable::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 | |
| 389 | void |
| 390 | KnobGuiTable::onEditButtonClicked() |
nothing calls this directly
no test coverage detected