void undo() const override { auto& scenar = m_scenarioPath.find(); auto& globalEvent = scenar.event(m_destinationEventId); Deserializer<DataStream> s{m_serializedEvent}; auto recreatedEvent = new EventModel{s, &scenar}; auto states_in_event = recreatedEvent->states(); // we remove and re-add states in recreated event // to ensure correct parentship between elements. for(auto stateId : states_in_event) { recreatedEvent->removeState(stateId); globalEvent.removeState(stateId); } for(auto stateId : states_in_event) { recreatedEvent->addState(stateId); scenar.states.at(stateId).setEventId(m_movingEventId); } scenar.events.add(recreatedEvent); if(recreatedEvent->timeNode() != globalEvent.timeNode()) { auto& tn = scenar.timeNode(globalEvent.timeNode()); tn.addEvent(m_movingEventId); m_mergeTimeNodesCommand->undo(); } updateEventExtent(m_destinationEventId, scenar); }
void ScenarioModel::setDurationAndGrow(const TimeValue& newDuration) { ///* Should work but does not ? /*StandardDisplacementPolicy::setEventPosition(*this, endEvent()->id(), newDuration, endEvent()->heightPercentage(), [&] (ProcessModel* p, const TimeValue& t) { p->expandProcess(ExpandMode::Grow, t); }); */ auto& eev = endEvent(); eev.setDate(newDuration); timeNode(eev.timeNode()).setDate(newDuration); emit eventMoved(eev.id()); this->setDuration(newDuration); }