void PreconditionWidget::slotMenuSelection(QAction* action) { bool ok = false; QString name = m_Text; ListPopupMenu::MenuType sel = m_pMenu->getMenuType(action); switch( sel ) { case ListPopupMenu::mt_Rename: name = KInputDialog::getText( i18n("Enter Precondition Name"), i18n("Enter the precondition :"), m_Text, &ok ); if( ok && name.length() > 0 ) m_Text = name; calculateWidget(); break; default: UMLWidget::slotMenuSelection(action); } }
/** * Captures any popup menu signals for menus it created. */ void PreconditionWidget::slotMenuSelection(QAction* action) { ListPopupMenu::MenuType sel = ListPopupMenu::typeFromAction(action); switch(sel) { case ListPopupMenu::mt_Rename: { QString text = name(); bool ok = Dialog_Utils::askName(i18n("Enter Precondition Name"), i18n("Enter the precondition :"), text); if (ok && !text.isEmpty()) { setName(text); } calculateWidget(); } break; default: UMLWidget::slotMenuSelection(action); } }
/** * Constructs a MessageWidget. * * This method is used for creation, synchronous and synchronous message types. * * @param scene The parent to this class. * @param a The role A widget for this message. * @param b The role B widget for this message. * @param y The vertical position to display this message. * @param sequenceMessageType Whether synchronous or asynchronous * @param id A unique id used for deleting this object cleanly. * The default (-1) will prompt generation of a new ID. */ MessageWidget::MessageWidget(UMLScene * scene, ObjectWidget* a, ObjectWidget* b, int y, Uml::SequenceMessage::Enum sequenceMessageType, Uml::ID::Type id /* = Uml::id_None */) : UMLWidget(scene, WidgetBase::wt_Message, id) { init(); m_pOw[Uml::RoleType::A] = a; m_pOw[Uml::RoleType::B] = b; m_sequenceMessageType = sequenceMessageType; if (m_sequenceMessageType == Uml::SequenceMessage::Creation) { y -= m_pOw[Uml::RoleType::B]->height() / 2; m_pOw[Uml::RoleType::B]->setY(y); } updateResizability(); calculateWidget(); y = y < getMinY() ? getMinY() : y; y = y > getMaxY() ? getMaxY() : y; setY(y); this->activate(); }
void MessageWidget::slotWidgetMoved(Uml::ID::Type id) { const Uml::ID::Type idA = m_pOw[Uml::RoleType::A]->localID(); const Uml::ID::Type idB = m_pOw[Uml::RoleType::B]->localID(); if (idA != id && idB != id) { DEBUG(DBG_SRC) << "id=" << Uml::ID::toString(id) << ": ignoring for idA=" << Uml::ID::toString(idA) << ", idB=" << Uml::ID::toString(idB); return; } qreal y = this->y(); if (y < getMinY()) y = getMinY(); if (y > getMaxY()) y = getMaxY(); setPos(x(), y); calculateWidget(); if(!m_pFText) return; if (m_scene->selectedCount(true) > 1) return; setTextPosition(); }
/** * Constructs a Lost or Found MessageWidget. * * @param scene The parent to this class. * @param a The role A widget for this message. * @param xclick The horizontal position clicked by the user * @param yclick The vertical position clicked by the user * @param sequenceMessageType Whether lost or found * @param id The ID to assign (-1 will prompt a new ID.) */ MessageWidget::MessageWidget(UMLScene * scene, ObjectWidget* a, int xclick, int yclick, Uml::SequenceMessage::Enum sequenceMessageType, Uml::ID::Type id /*= Uml::id_None*/) : UMLWidget(scene, WidgetBase::wt_Message, id) { init(); m_pOw[Uml::RoleType::A] = a; m_pOw[Uml::RoleType::B] = a; m_sequenceMessageType = sequenceMessageType; m_xclicked = xclick; m_yclicked = yclick; updateResizability(); calculateWidget(); yclick = yclick < getMinY() ? getMinY() : yclick; yclick = yclick > getMaxY() ? getMaxY() : yclick; setY(yclick); m_yclicked = yclick; this->activate(); }
/** * Overridden from UMLWidget. * Resizes the height of the message widget and emits the message moved signal. * Message widgets can only be resized vertically, so width isn't modified. * * @param newW The new width for the widget (isn't used). * @param newH The new height for the widget. */ void MessageWidget::resizeWidget(qreal newW, qreal newH) { if (sequenceMessageType() == Uml::SequenceMessage::Creation) setSize(width(), newH); else { qreal x1 = m_pOw[Uml::RoleType::A]->x(); qreal x2 = getxclicked(); qreal diffX = 0; if (x1 < x2) { diffX = x2 + (newW - width()); } else { diffX = x2 - (newW - width()); } if (diffX <= 0 ) diffX = 10; setxclicked (diffX); setSize(newW, newH); calculateWidget(); } emit sigMessageMoved(); }