Track* Tracker::createTrack() { KnobItemsTablePtr model = getInternalModel(); if (!model) { PythonSetNullError(); return 0; } TrackMarkerPtr track = TrackMarker::create(model); track->resetCenter(); model->addItem(track, KnobTableItemPtr(), eTableChangeReasonInternal); Track* ret = dynamic_cast<Track*>( ItemsTable::createPyItemWrapper(track) ); assert(ret); return ret; }
void RemoveItemsCommand::undo() { KnobItemsTablePtr model = _items.begin()->item->getModel(); model->beginEditSelection(); model->clearSelection(eTableChangeReasonInternal); for (std::list<ItemToRemove>::const_iterator it = _items.begin(); it != _items.end(); ++it) { int prevIndex = -1; KnobTableItemPtr prevItem = it->prevItem.lock(); if (prevItem) { prevIndex = prevItem->getIndexInParent(); } if (prevIndex != -1) { model->insertItem(prevIndex, it->item, it->item->getParent(), eTableChangeReasonInternal); } else { model->addItem(it->item, it->item->getParent(), eTableChangeReasonInternal); } model->addToSelection(it->item, eTableChangeReasonInternal); } model->endEditSelection(eTableChangeReasonInternal); model->getNode()->getApp()->triggerAutoSave(); }