| 349 | } |
| 350 | |
| 351 | void |
| 352 | ManageUserParamsDialog::onAddClicked() |
| 353 | { |
| 354 | if (!ensureHasUserPage()) { |
| 355 | AddKnobDialog dialog(_imp->panel, KnobIPtr(), std::string(), std::string(), this); |
| 356 | dialog.setVisibleType(false); |
| 357 | dialog.setType(AddKnobDialog::eParamDataTypePage); |
| 358 | dialog.setWindowTitle(tr("Add Page")); |
| 359 | if (!dialog.exec() ) { |
| 360 | return; |
| 361 | } |
| 362 | KnobIPtr knob = dialog.getKnob(); |
| 363 | _imp->createItemForKnob(knob); |
| 364 | |
| 365 | } |
| 366 | std::string selectedPageName, selectedGroupName; |
| 367 | |
| 368 | QList<QTreeWidgetItem*> selection = _imp->tree->selectedItems(); |
| 369 | if ( !selection.isEmpty() ) { |
| 370 | std::list<TreeItem>::const_iterator item = _imp->findItemForTreeItem( selection.front() ); |
| 371 | if ( item != _imp->items.end() ) { |
| 372 | KnobPage* isPage = dynamic_cast<KnobPage*>( item->knob.get() ); |
| 373 | if (isPage) { |
| 374 | selectedPageName = isPage->getName(); |
| 375 | } else { |
| 376 | KnobGroup* isGrp = dynamic_cast<KnobGroup*>( item->knob.get() ); |
| 377 | if (isGrp) { |
| 378 | selectedGroupName = isGrp->getName(); |
| 379 | KnobPagePtr topLevelPage = isGrp->getTopLevelPage(); |
| 380 | if (topLevelPage) { |
| 381 | selectedPageName = topLevelPage->getName(); |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | AddKnobDialog dialog(_imp->panel, KnobIPtr(), selectedPageName, selectedGroupName, this); |
| 389 | if ( dialog.exec() ) { |
| 390 | KnobIPtr knob = dialog.getKnob(); |
| 391 | _imp->createItemForKnob(knob); |
| 392 | _imp->saveAndRebuildPages(); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | QTreeWidgetItem* |
| 397 | ManageUserParamsDialogPrivate::createItemForKnob(const KnobIPtr& knob, |
nothing calls this directly
no test coverage detected