Commit a6c4b6a8 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Fix 'No undo support for adding connected widgets'

BUG:415888
FIXED-IN:2.30.1 (KDE Applications 19.12.1)
parent 508dff46
......@@ -67,6 +67,8 @@ using namespace Uml;
DEBUG_REGISTER_DISABLED(UMLWidget)
#define I18N_NEXT_RELEASE(a,b) QString(QLatin1String(a)).arg(b))
const QSizeF UMLWidget::DefaultMinimumSize(50, 20);
const QSizeF UMLWidget::DefaultMaximumSize(1000, 5000);
const int UMLWidget::defaultMargin = 5;
......@@ -2133,6 +2135,12 @@ void UMLWidget::addConnectedWidget(UMLWidget *widget, Uml::AssociationType::Enum
umlScene()->addAssociation(assoc);
umlScene()->clearSelected();
umlScene()->selectWidget(widget);
UMLApp::app()->beginMacro(I18N_NEXT_RELEASE("Adding connected '%1'", widget->baseTypeStrWithoutPrefix());
UMLApp::app()->executeCommand(new CmdCreateWidget(widget));
UMLApp::app()->executeCommand(new CmdCreateWidget(assoc));
UMLApp::app()->endMacro();
m_doc->setModified();
}
/**
......
......@@ -118,6 +118,15 @@ QLatin1String WidgetBase::baseTypeStr() const
return QLatin1String(ENUM_NAME(WidgetBase, WidgetType, m_baseType));
}
/**
* @return The type as string without 'wt_' prefix.
*/
QString WidgetBase::baseTypeStrWithoutPrefix() const
{
QString rawType = baseTypeStr();
return rawType.remove(QLatin1String("wt_"));
}
/*
* Sets the state of whether the widget is selected.
*
......
......@@ -129,6 +129,7 @@ public:
WidgetType baseType() const;
void setBaseType(const WidgetType& baseType);
QLatin1String baseTypeStr() const;
QString baseTypeStrWithoutPrefix() const;
virtual void setSelected(bool select);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment