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

Merge menu selection code from state widget into class DiagramProxyWidget to reduce duplicated code

CCBUG:53369
parent a2e6b8c0
......@@ -353,6 +353,7 @@ void DiagramProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem
void DiagramProxyWidget::slotMenuSelection(QAction* action)
{
switch(ListPopupMenu::typeFromAction(action)) {
// classifier widget
case ListPopupMenu::mt_State_Diagram:
{
QString name = Widget_Utils::defaultWidgetName(WidgetBase::WidgetType::wt_State);
......@@ -372,7 +373,21 @@ void DiagramProxyWidget::slotMenuSelection(QAction* action)
}
break;
// state widget
case ListPopupMenu::mt_CombinedState:
{
QString diagramName = UMLApp::app()->document()->createDiagramName(Uml::DiagramType::State);
Uml::CmdCreateDiagram* d = new Uml::CmdCreateDiagram(UMLApp::app()->document(), Uml::DiagramType::State, diagramName);
UMLApp::app()->executeCommand(d);
setDiagramLink(d->view()->umlScene()->ID());
m_widget->asStateWidget()->setStateType(StateWidget::Combined);
}
break;
// classifier widget
case ListPopupMenu::mt_GoToStateDiagram:
// state widget
case ListPopupMenu::mt_EditCombinedState:
if (!linkedDiagram()) {
uError() << "no diagram id defined at widget '" << Uml::ID::toString(m_widget->id()) << "'";
break;
......
......@@ -601,27 +601,8 @@ void StateWidget::slotMenuSelection(QAction* action)
setDrawVertical(true);
break;
case ListPopupMenu::mt_CombinedState:
{
QString diagramName = m_doc->createDiagramName(Uml::DiagramType::State);
Uml::CmdCreateDiagram* d = new Uml::CmdCreateDiagram(m_doc, Uml::DiagramType::State, diagramName);
UMLApp::app()->executeCommand(d);
setDiagramLink(d->view()->umlScene()->ID());
setStateType(Combined);
}
break;
case ListPopupMenu::mt_EditCombinedState:
if (!linkedDiagram()) {
uError() << "no diagram id defined at widget '" << Uml::ID::toString(id()) << "'";
break;
}
linkedDiagram()->setWidgetLink(this);
UMLApp::app()->document()->changeCurrentView(diagramLink());
break;
default:
UMLWidget::slotMenuSelection(action);
DiagramProxyWidget::slotMenuSelection(action);
break;
}
}
......
Markdown is supported
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