void RemoveItemsCommand::redo() { KnobItemsTablePtr model = _items.begin()->item->getModel(); KnobTableItemPtr nextItem; { KnobTableItemPtr item = _items.back().item; assert(item); int index = item->getIndexInParent(); std::vector<KnobTableItemPtr> topLevel = model->getTopLevelItems(); if (!topLevel.empty()) { if (index + 1 < (int)topLevel.size()) { nextItem = topLevel[index + 1]; } else { if (topLevel[0] != item) { nextItem = topLevel[0]; } } } } model->beginEditSelection(); model->clearSelection(eTableChangeReasonInternal); for (std::list<ItemToRemove>::const_iterator it = _items.begin(); it != _items.end(); ++it) { model->removeItem(it->item, eTableChangeReasonInternal); } if (nextItem) { model->addToSelection(nextItem, eTableChangeReasonInternal); } model->endEditSelection(eTableChangeReasonInternal); model->getNode()->getApp()->triggerAutoSave(); }
void NodeAnim::initializeTableItems() { NodeGuiPtr nodeGui = _imp->nodeGui.lock(); KnobItemsTableGuiPtr table = nodeGui->getKnobItemsTable(); if (!table) { return; } KnobItemsTablePtr internalTable = table->getInternalTable(); if (!internalTable) { return; } connect(internalTable.get(), SIGNAL(itemRemoved(KnobTableItemPtr,TableChangeReasonEnum)), this, SLOT(onTableItemRemoved(KnobTableItemPtr,TableChangeReasonEnum))); connect(internalTable.get(), SIGNAL(itemInserted(int,KnobTableItemPtr,TableChangeReasonEnum)), this, SLOT(onTableItemInserted(int,KnobTableItemPtr,TableChangeReasonEnum))); NodeAnimPtr thisShared = shared_from_this(); std::vector<KnobTableItemPtr> allItems = internalTable->getTopLevelItems(); for (std::size_t i = 0; i < allItems.size(); ++i) { TableItemAnimPtr anim(TableItemAnim::create(getModel(), table, thisShared, allItems[i], _imp->nameItem)); _imp->topLevelTableItems.push_back(anim); } } // initializeTableItems