void FormWindowBase::deleteWidgetList(const QWidgetList &widget_list) { switch (widget_list.size()) { case 0: break; case 1: { commandHistory()->beginMacro(tr("Delete '%1'").arg(widget_list.front()->objectName())); emit widgetRemoved(widget_list.front()); DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this); cmd->init(widget_list.front()); commandHistory()->push(cmd); commandHistory()->endMacro(); } break; default: commandHistory()->beginMacro(tr("Delete")); foreach (QWidget *w, widget_list) { emit widgetRemoved(w); DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this); cmd->init(w); commandHistory()->push(cmd); } commandHistory()->endMacro(); break; }
void FormWindowBase::deleteWidgetList(const QWidgetList &widget_list) { // We need a macro here even for single widgets because the some components (for example, // the signal slot editor are connected to widgetRemoved() and add their // own commands (for example, to delete w's connections) const QString description = widget_list.size() == 1 ? tr("Delete '%1'").arg(widget_list.front()->objectName()) : tr("Delete"); commandHistory()->beginMacro(description); foreach (QWidget *w, widget_list) { emit widgetRemoved(w); DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this); cmd->init(w); commandHistory()->push(cmd); }