QString UMLAttribute::toString(Uml::Signature_Type sig) { QString s; if(sig == Uml::st_ShowSig || sig == Uml::st_NoSig) { s = m_Vis.toString(true) + ' '; } if(sig == Uml::st_ShowSig || sig == Uml::st_SigNoVis) { // Determine whether the type name needs to be scoped. UMLObject *owningObject = static_cast<UMLObject*>(parent()); if (owningObject->getBaseType() == Uml::ot_Operation) { // The immediate parent() is the UMLOperation but we want // the UMLClassifier: owningObject = static_cast<UMLObject*>(owningObject->parent()); } UMLClassifier *ownParent = dynamic_cast<UMLClassifier*>(owningObject); if (ownParent == NULL) { kError() << "UMLAttribute::toString: parent " << owningObject->getName() << " is not a UMLClassifier" << endl; return ""; } QString typeName; UMLClassifier *type = UMLClassifierListItem::getType(); if (type) { UMLPackage *typeScope = type->getUMLPackage(); if (typeScope != ownParent && typeScope != ownParent->getUMLPackage()) typeName = type->getFullyQualifiedName(); else typeName = type->getName(); } // The default direction, "in", is not mentioned. // Perhaps we should include a pd_Unspecified in // Uml::Parameter_Direction to have better control over this. if (m_ParmKind == Uml::pd_InOut) s += "inout "; else if (m_ParmKind == Uml::pd_Out) s += "out "; // Construct the attribute text. QString string = s + getName() + " : " + typeName; if(m_InitialValue.length() > 0) string += " = " + m_InitialValue; return string; } return s + getName(); }
QString UMLAttribute::getFullyQualifiedName( const QString& separator, bool includeRoot /* = false */) const { UMLOperation *op = NULL; UMLObject *owningObject = static_cast<UMLObject*>(parent()); if (owningObject->getBaseType() == Uml::ot_Operation) { op = static_cast<UMLOperation*>(owningObject); owningObject = static_cast<UMLObject*>(owningObject->parent()); } UMLClassifier *ownParent = dynamic_cast<UMLClassifier*>(owningObject); if (ownParent == NULL) { kError() << "UMLAttribute::getFullyQualifiedName(" << m_Name << "): parent " << owningObject->getName() << " is not a UMLClassifier" << endl; return ""; } QString tempSeparator = separator; if (tempSeparator.isEmpty()) tempSeparator = UMLApp::app()->activeLanguageScopeSeparator(); QString fqn = ownParent->getFullyQualifiedName(tempSeparator, includeRoot); if (op) fqn.append(tempSeparator + op->getName()); fqn.append(tempSeparator + m_Name); return fqn; }
/** * Creates a UMLObject. * @param other object to created from */ UMLObject::UMLObject(const UMLObject &other) : QObject(other.parent()) { other.copyInto(this); }
int UMLListViewItem::compare(QTreeWidgetItem *other, int col, bool ascending) const { UMLListViewItem *ulvi = static_cast<UMLListViewItem*>(other); ListViewType ourType = type(); ListViewType otherType = ulvi->type(); if (ourType < otherType) return -1; if (ourType > otherType) return 1; // ourType == otherType const bool subItem = Model_Utils::typeIsClassifierList(ourType); const int alphaOrder = key(col, ascending).compare(other->key(col, ascending)); int retval = 0; QString dbgPfx = "compare(type=" + QString::number((int)ourType) + ", self=" + text() + ", other=" + ulvi->text() + "): return "; UMLObject *otherObj = ulvi->umlObject(); if (m_object == 0) { retval = (subItem ? 1 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (m_object==0)"; #endif return retval; } if (otherObj == 0) { retval = (subItem ? -1 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (otherObj==0)"; #endif return retval; } UMLClassifier *ourParent = dynamic_cast<UMLClassifier*>(m_object->parent()); UMLClassifier *otherParent = dynamic_cast<UMLClassifier*>(otherObj->parent()); if (ourParent == 0) { retval = (subItem ? 1 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (ourParent==0)"; #endif return retval; } if (otherParent == 0) { retval = (subItem ? -1 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (otherParent==0)"; #endif return retval; } if (ourParent != otherParent) { retval = (subItem ? 0 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (ourParent != otherParent)"; #endif return retval; } UMLClassifierListItem *thisUmlItem = dynamic_cast<UMLClassifierListItem*>(m_object); UMLClassifierListItem *otherUmlItem = dynamic_cast<UMLClassifierListItem*>(otherObj); if (thisUmlItem == 0) { retval = (subItem ? 1 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (thisUmlItem==0)"; #endif return retval; } if (otherUmlItem == 0) { retval = (subItem ? -1 : alphaOrder); #ifdef DEBUG_LVITEM_INSERTION_ORDER DEBUG(DBG_LVI) << dbgPfx << retval << " because (otherUmlItem==0)"; #endif return retval; } UMLClassifierListItemList items = ourParent->getFilteredList(thisUmlItem->baseType()); int myIndex = items.indexOf(thisUmlItem); int otherIndex = items.indexOf(otherUmlItem); if (myIndex < 0) { retval = (subItem ? -1 : alphaOrder); uError() << dbgPfx << retval << " because (myIndex < 0)"; return retval; } if (otherIndex < 0) { retval = (subItem ? 1 : alphaOrder); uError() << dbgPfx << retval << " because (otherIndex < 0)"; return retval; } return (myIndex < otherIndex ? -1 : myIndex > otherIndex ? 1 : 0); }