[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sun Feb 6 11:55:01 UTC 2005
CVS commit by okellogg:
toString(): Scope type names if from foreign scope.
M +23 -1 attribute.cpp 1.26
M +11 -3 operation.cpp 1.40
--- kdesdk/umbrello/umbrello/attribute.cpp #1.25:1.26
@@ -85,5 +85,26 @@ QString UMLAttribute::toString(Uml::Sign
if(sig == Uml::st_ShowSig || sig == Uml::st_SigNoScope) {
- QString string = s + getName() + " : " + getTypeName();
+ // Determine whether the type name needs to be scoped.
+ UMLObject *owningObject = static_cast<UMLObject*>(parent());
+ if (owningObject->getBaseType() == Uml::ot_Operation)
+ owningObject = static_cast<UMLObject*>(owningObject->parent());
+ UMLClassifier *ownParent = dynamic_cast<UMLClassifier*>(owningObject);
+ if (ownParent == NULL) {
+ kdError() << "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();
+ }
+ // Construct the attribute text.
+ QString string = s + getName() + " : " + typeName;
if(m_InitialValue.length() > 0)
string += " = " + m_InitialValue;
@@ -122,4 +143,5 @@ void UMLAttribute::copyInto(UMLAttribute
UMLObject* UMLAttribute::clone() const
{
+ //FIXME: The new attribute should be slaved to the NEW parent not the old.
UMLAttribute *clone = new UMLAttribute( (UMLAttribute *)parent() );
copyInto(clone);
--- kdesdk/umbrello/umbrello/operation.cpp #1.39:1.40
@@ -154,5 +154,14 @@ QString UMLOperation::toString(Uml::Sign
}
s.append(")");
- QString returnType = UMLClassifierListItem::getTypeName();
+ UMLClassifier *ownParent = static_cast<UMLClassifier*>(parent());
+ QString returnType;
+ UMLClassifier *retType = UMLClassifierListItem::getType();
+ if (retType) {
+ UMLPackage *retScope = retType->getUMLPackage();
+ if (retScope != ownParent && retScope != ownParent->getUMLPackage())
+ returnType = retType->getFullyQualifiedName(".");
+ else
+ returnType = retType->getName();
+ }
if (returnType.length() > 0 && returnType != "void") {
s.append(" : ");
@@ -213,6 +222,5 @@ void UMLOperation::copyInto(UMLOperation
UMLObject* UMLOperation::clone() const
{
- // TODO Why is this a UMLClassifier?
- // -- Huh? I don't understand this TODO --okellogg
+ //FIXME: The new operation should be slaved to the NEW parent not the old.
UMLOperation *clone = new UMLOperation( (UMLClassifier *) parent());
copyInto(clone);
More information about the umbrello-devel
mailing list