/** * Add the widget back */ void CmdRemoveWidget::undo() { QDomElement widgetElement = m_element.firstChild().toElement(); UMLScene* umlScene = scene(); UMLWidget* widget = umlScene->loadWidgetFromXMI(widgetElement); addWidgetToScene(widget); }
/** * Constructor. */ CmdCreateWidget::CmdCreateWidget(UMLWidget* widget) : CmdBaseWidgetCommand(widget) { setText(i18n("Create widget : %1", widget->name())); addWidgetToScene(widget); QDomDocument doc; m_element = doc.createElement(QLatin1String("widget")); widget->saveToXMI(doc, m_element); }
/** * Create the widget */ void CmdCreateWidget::redo() { UMLWidget* umlWidget = scene()->findWidget(m_widgetId); if (umlWidget == 0) { // If the widget is not found, the add command was undone. Load the // widget back from the saved XMI state. QDomElement widgetElement = m_element.firstChild().toElement(); umlWidget = scene()->loadWidgetFromXMI(widgetElement); addWidgetToScene(umlWidget); } }