/** * Called when the release event happened on a widget. * If the button pressed isn't left button or the widget isn't an object * widget, the message is cleaned. * If the release event didn't happen on the line of an object and the first * object wasn't selected, nothing is done. If the first object was already * selected, a creation message is made. * If the event happened on the line of an object, the first object or the * second are set, depending on whether the first object was already set or * not. */ void ToolBarStateMessages::mouseReleaseWidget() { //TODO When an association between UMLObjects of invalid types is made, an error message //is shown. Shouldn't also a message be used here? if (m_pMouseEvent->button() != Qt::LeftButton || getCurrentWidget()->baseType() != WidgetBase::wt_Object) { cleanMessage(); return; } if (!m_isObjectWidgetLine && !m_firstObject) { return; } if (!m_isObjectWidgetLine) { setSecondWidget(static_cast<ObjectWidget*>(getCurrentWidget()), CreationMessage); return; } if (!m_firstObject) { setFirstWidget(static_cast<ObjectWidget*>(getCurrentWidget())); } else { setSecondWidget(static_cast<ObjectWidget*>(getCurrentWidget()), NormalMessage); } }
/** * Called when the release event happened on a widget. * If the button pressed isn't left button, the association is cleaned. If * it is left button, sets the first widget or the second, depending on * whether the first widget is already set or not. */ void ToolBarStateAssociation::mouseReleaseWidget() { if (m_pMouseEvent->button() != Qt::LeftButton) { cleanAssociation(); return; } // TODO In old code in ToolBarState there was a TODO that said: Should not //be called by a Sequence message Association. Here's the check for that, //although I don't know why it is needed, but it seems that it's not needed, //as the old code worked fine without it... if (getAssociationType() == Uml::AssociationType::Seq_Message) { return; } if (!m_firstWidget) { setFirstWidget(); } else { setSecondWidget(); } }