[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg Oliver.Kellogg at t-online.de
Sun Sep 14 05:32:02 UTC 2003


CVS commit by okellogg: 

loadFromXMI(): In an early version of saveToXMI(), the assoctype
natural names were saved instead of the numbers.


  M +15 -6     association.cpp   1.17


--- kdesdk/umbrello/umbrello/association.cpp  #1.16:1.17
@@ -68,5 +68,6 @@ const QString UMLAssociation::assocTypeS
 };
 
-//FIXME needed??
+// Required by loadFromXMI(): In an early version of saveToXMI(),
+// the assoctype natural names were saved instead of the numbers.
 Uml::Association_Type UMLAssociation::toAssocType (QString atype) {
         for (unsigned i = 0; i < nAssocTypes; i++)
@@ -119,10 +120,18 @@ bool UMLAssociation::loadFromXMI( QDomEl
                 return false;
 
-        int atype = element.attribute( "assoctype", "-1" ).toInt();
-        if (atype < (int)atypeFirst | atype > (int)atypeLast) {
+        QString assocTypeStr = element.attribute( "assoctype", "-1" );
+        Uml::Association_Type assocType = Uml::at_Unknown;
+        if (assocTypeStr[0] >= 'a' && assocTypeStr[0] <= 'z') {
+                // In an earlier version, the natural assoctype names were saved.
+                assocType = toAssocType( assocTypeStr );
+        } else {
+                int assocTypeNum = assocTypeStr.toInt();
+                if (assocTypeNum < (int)atypeFirst | assocTypeNum > (int)atypeLast) {
                 kdWarning() << "bad assoctype of UML:Association " << getID() << endl;
                 return false;
         }
-        setAssocType( (Uml::Association_Type)atype );
+                assocType = (Uml::Association_Type)assocTypeNum;
+        }
+        setAssocType( assocType );
 
         int roleAObjID = element.attribute( "rolea", "-1" ).toInt();






More information about the umbrello-devel mailing list