[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Thu Nov 18 20:19:28 UTC 2004


CVS commit by okellogg: 

createUMLObject(): various refinements.


  M +19 -12    classimport.cpp   1.53


--- kdesdk/umbrello/umbrello/classimport.cpp  #1.52:1.53
@@ -80,8 +80,10 @@ UMLObject *ClassImport::createUMLObject(
         UMLObject * o = m_umldoc->findUMLObject(name);
         if (o == NULL) {
+                int isConst = name.contains(QRegExp("^const "));
+                name.remove(QRegExp("^const\\s+"));
                 QString typeName(name);
                 int isPointer = typeName.contains('*');
-                typeName.replace(QRegExp("^const\\s+"), "");
-                typeName.replace(QRegExp("[^:\\w].*$"), "");
+                int isRef = typeName.contains('&');
+                typeName.remove(QRegExp("[^:\\w].*$"));
                 o = m_umldoc->findUMLObject(typeName,
                                             Uml::ot_UMLObject,
@@ -95,4 +97,9 @@ UMLObject *ClassImport::createUMLObject(
                                         QString scopeName = components.front();
                                         components.pop_front();
+                                        o = m_umldoc->findUMLObject(scopeName, Uml::ot_UMLObject, parentPkg);
+                                        if (o) {
+                                                parentPkg = static_cast<UMLPackage*>(o);
+                                                continue;
+                                        }
                                         int wantNamespace = KMessageBox::questionYesNo(NULL,
                                                 i18n("Is the scope %1 a namespace or a class?").arg(scopeName),
@@ -101,12 +108,16 @@ UMLObject *ClassImport::createUMLObject(
                                         Uml::Object_Type ot = (wantNamespace == KMessageBox::Yes ? Uml::ot_Package : Uml::ot_Class);
                                         o = m_umldoc->createUMLObject(ot, scopeName, parentPkg);
-                                        parentPkg = dynamic_cast<UMLPackage*>(o);  //static_cast?
+                                        parentPkg = static_cast<UMLPackage*>(o);
                                 }
+                                name.remove(QRegExp("^.*::"));  // may also zap "const "
                         }
-                        if (isPointer)
+                        if (isPointer || isRef) {
+                                m_umldoc->createUMLObject(Uml::ot_Class, typeName, parentPkg);
                                 type = Uml::ot_Datatype;
-                        else if (type == Uml::ot_UMLObject)
+                        } else if (type == Uml::ot_UMLObject)
                                 type = Uml::ot_Class;
-                        o = m_umldoc->createUMLObject(type, typeName, parentPkg);
+                        if (isConst)
+                                name.prepend("const ");
+                        o = m_umldoc->createUMLObject(type, name, parentPkg);
                 }
                 /* if (isPointer) {
@@ -233,10 +244,6 @@ void ClassImport::addEnumLiteral(UMLEnum
 
 void ClassImport::createGeneralization(UMLClass *child, const QString &parentName) {
-        UMLObject *parent = m_umldoc->findUMLObject( parentName, Uml::ot_Class );
-        if (parent == NULL) {
-            kdDebug() << "ClassImport::createGeneralization: Could not find UML object for "
-                      << parentName << endl;
-            parent = m_umldoc->createUMLObject(Uml::ot_Class, parentName);
-        }
+        UMLObject *parentObj = createUMLObject( Uml::ot_Class, parentName );
+        UMLClass *parent = static_cast<UMLClass*>(parentObj);
         UMLAssociation *assoc = new UMLAssociation( Uml::at_Generalization,
                                                     child, parent );






More information about the umbrello-devel mailing list