/** * Overrides the standard paint event. */ void UseCaseWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); setPenFromSettings(painter); if (UMLWidget::useFillColor()) painter->setBrush(UMLWidget::fillColor()); QFont font = UMLWidget::font(); font.setUnderline(false); font.setBold(false); font.setItalic(m_umlObject->isAbstract()); painter->setFont(font); const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing(); const int w = width(); const int h = height(); //int middleX = w / 2; bool drawStereotype = umlObject() && !umlObject()->stereotype().isEmpty(); const int textStartY = (h / 2) - (drawStereotype ? fontHeight / 4 : fontHeight / 2); painter->drawEllipse(0, 0, w, h); painter->setPen(textColor()); if (drawStereotype) painter->drawText(UC_MARGIN, textStartY-fontHeight, w - UC_MARGIN * 2, fontHeight, Qt::AlignCenter, umlObject()->stereotype(true)); painter->drawText(UC_MARGIN, textStartY, w - UC_MARGIN * 2, fontHeight, Qt::AlignCenter, name()); setPenFromSettings(painter); UMLWidget::paint(painter, option, widget); }
/** * Reimplemented from UMLWidget::updateTextItemGroups() to * calculate the texts and also show/hide the texts based on current * state. */ void NodeWidget::updateTextItemGroups() { TextItemGroup *grp = textItemGroupAt(GroupIndex); grp->setTextItemCount(NodeWidget::TextItemCount); if(umlObject()) { UMLNode *node = static_cast<UMLNode*>(umlObject()); TextItem *stereo = grp->textItemAt(NodeWidget::StereoItemIndex); stereo->setText(node->stereotype(true)); stereo->setBold(true); stereo->setExplicitVisibility(!node->stereotype(false).isEmpty()); TextItem *nameItem = grp->textItemAt(NodeWidget::NameItemIndex); QString nameText = name(); bool underline = false; if(isInstance()) { nameText.prepend(':'); nameText.prepend(instanceName()); underline = true; } nameItem->setBold(true); nameItem->setUnderline(underline); nameItem->setText(nameText); } UMLWidget::updateTextItemGroups(); }
/** * Overrides method from UMLWidget */ QSizeF UseCaseWidget::minimumSize() const { const UMLWidget::FontType ft = (m_umlObject->isAbstract() ? FT_BOLD_ITALIC : FT_BOLD); const QFontMetrics &fm = UMLWidget::getFontMetrics(ft); const int fontHeight = fm.lineSpacing(); const int textWidth = fm.width(name()); bool drawStereotype = umlObject() && !umlObject()->stereotype().isEmpty(); int width = textWidth > UC_WIDTH?textWidth:UC_WIDTH; int height = UC_HEIGHT + (drawStereotype ? 2 * fontHeight : fontHeight) + UC_MARGIN; width += UC_MARGIN * 2; return QSizeF(width, height); }
/** * Updates the representation of the object. */ void UMLListViewItem::updateObject() { if (m_object == 0) return; Uml::Visibility::Enum scope = m_object->visibility(); UMLObject::ObjectType ot = m_object->baseType(); QString modelObjText = m_object->name(); if (Model_Utils::isClassifierListitem(ot)) { UMLClassifierListItem *pNarrowed = static_cast<UMLClassifierListItem*>(m_object); modelObjText = pNarrowed->toString(Uml::SignatureType::SigNoVis); } setText(modelObjText); Icon_Utils::IconType icon = Icon_Utils::it_Home; switch (ot) { case UMLObject::ot_Package: if (m_object->stereotype() == QLatin1String("subsystem")) icon = Icon_Utils::it_Subsystem; else icon = Icon_Utils::it_Package; break; case UMLObject::ot_Operation: if (scope == Uml::Visibility::Public) icon = Icon_Utils::it_Public_Method; else if (scope == Uml::Visibility::Private) icon = Icon_Utils::it_Private_Method; else if (scope == Uml::Visibility::Implementation) icon = Icon_Utils::it_Private_Method; else icon = Icon_Utils::it_Protected_Method; break; case UMLObject::ot_Attribute: case UMLObject::ot_EntityAttribute: if (scope == Uml::Visibility::Public) icon = Icon_Utils::it_Public_Attribute; else if (scope == Uml::Visibility::Private) icon = Icon_Utils::it_Private_Attribute; else if (scope == Uml::Visibility::Implementation) icon = Icon_Utils::it_Private_Attribute; else icon = Icon_Utils::it_Protected_Attribute; break; case UMLObject::ot_UniqueConstraint: m_type = Model_Utils::convert_OT_LVT(umlObject()); icon = Model_Utils::convert_LVT_IT(m_type); break; case UMLObject::ot_Class: icon = Model_Utils::convert_LVT_IT(m_type, m_object); break; default: icon = Model_Utils::convert_LVT_IT(m_type); break; }//end switch if (icon) setIcon(icon); }
/** * Returns the signature of items that are operations. * @return signature of an operation item, else an empty string */ QString UMLListViewItem::toolTip() { UMLObject *obj = umlObject(); if (obj) { switch (obj->baseType()) { case UMLObject::ot_Class: return obj->doc(); case UMLObject::ot_Operation: { UMLOperation *op = static_cast<UMLOperation*>(obj); return op->toString(Uml::SignatureType::ShowSig); } case UMLObject::ot_Attribute: { UMLAttribute *at = static_cast<UMLAttribute*>(obj); return at->toString(Uml::SignatureType::ShowSig); } default: return QString(); } } else { return QString(); } }
/** * Reimplemented from UMLWidget::updateTextItemGroups to update * the text of TextItemGroups. */ void DatatypeWidget::updateTextItemGroups() { if(umlObject()) { TextItemGroup *grp = textItemGroupAt(DatatypeWidget::GroupIndex); grp->setTextItemCount(DatatypeWidget::TextItemCount); TextItem *stereo = grp->textItemAt(DatatypeWidget::StereoTypeItemIndex); stereo->setText(umlObject()->stereotype(true)); stereo->setBold(true); TextItem *nameItem = grp->textItemAt(DatatypeWidget::NameItemIndex); nameItem->setText(name()); nameItem->setItalic(umlObject()->isAbstract()); } UMLWidget::updateTextItemGroups(); }
/** * Create a deep copy of this UMLListViewItem, but using the * given parent instead of the parent of this UMLListViewItem. * Return the new UMLListViewItem created. */ UMLListViewItem* UMLListViewItem::deepCopy(UMLListViewItem *newParent) { QString nm = text(0); ListViewType t = type(); UMLObject *o = umlObject(); UMLListViewItem* newItem; if (o) newItem = new UMLListViewItem(newParent, nm, t, o); else newItem = new UMLListViewItem(newParent, nm, t, m_id); for (int i=0; i < childCount(); i++) { UMLListViewItem *childItem = static_cast<UMLListViewItem*>(child(i)); childItem->deepCopy(newItem); } return newItem; }
/** * @return the UMLClassifier which this ClassifierWidget represents. */ UMLClassifier *ClassifierWidget::classifier() const { return static_cast<UMLClassifier*>(umlObject()); }