[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sat Aug 13 12:00:12 UTC 2005


SVN commit 448967 by okellogg:

Import_Utils::createGeneralization(UMLClassifier*, UMLClassifier*): New.
Import_Utils::putAtGlobalScope(): New.
UMLApp::activeLanguageIsCaseSensitive(): New. Lets us support case
 insensitive languages such as Ada.


 M  +3 -1      adaimport.cpp  
 M  +11 -3     import_utils.cpp  
 M  +14 -0     import_utils.h  
 M  +16 -3     model_utils.cpp  
 M  +6 -1      package.cpp  
 M  +8 -0      uml.cpp  
 M  +10 -0     uml.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/adaimport.cpp #448966:448967
@@ -179,6 +179,7 @@
                 UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Class,
                                 name, m_scope[m_scopeIndex], m_comment);
                 ns->setAbstract(m_isAbstract);
+                m_isAbstract = false;
                 m_comment = QString::null;
             }
             if (m_source[m_srcIndex] == "limited") {
@@ -206,8 +207,9 @@
                                     base, NULL);
                     parent = static_cast<UMLClassifier*>(ns);
                     ns = Import_Utils::createUMLObject(Uml::ot_Class, name,
-                                                       parent, m_comment);
+                                           m_scope[m_scopeIndex], m_comment);
                     m_klass = static_cast<UMLClassifier*>(ns);
+                    Import_Utils::createGeneralization(m_klass, parent);
                 }
             }
             // Datatypes: TO BE DONE
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/import_utils.cpp #448966:448967
@@ -52,6 +52,10 @@
  */
 bool bPutAtGlobalScope = false;
 
+void putAtGlobalScope(bool yesno) {
+    bPutAtGlobalScope = yesno;
+}
+
 bool newUMLObjectWasCreated() {
     return bNewUMLObjectWasCreated;
 }
@@ -299,15 +303,19 @@
     enumType->addEnumLiteral( literal );
 }
 
-void createGeneralization(UMLClassifier *child, const QString &parentName) {
-    UMLObject *parentObj = createUMLObject( Uml::ot_Class, parentName );
-    UMLClassifier *parent = static_cast<UMLClassifier*>(parentObj);
+void createGeneralization(UMLClassifier *child, UMLClassifier *parent) {
     UMLAssociation *assoc = new UMLAssociation( Uml::at_Generalization,
                             child, parent );
     UMLDoc *umldoc = UMLApp::app()->getDocument();
     umldoc->addAssociation(assoc);
 }
 
+void createGeneralization(UMLClassifier *child, const QString &parentName) {
+    UMLObject *parentObj = createUMLObject( Uml::ot_Class, parentName );
+    UMLClassifier *parent = static_cast<UMLClassifier*>(parentObj);
+    createGeneralization(child, parent);
+}
+
 QStringList includePathList() {
     QStringList includePathList;
     char *umbrello_incpath = getenv( "UMBRELLO_INCPATH" );
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/import_utils.h #448966:448967
@@ -41,6 +41,14 @@
                                UMLPackage *parentPkg = NULL,
                                QString comment = QString::null,
                                QString stereotype = QString::null);
+    /**
+     * Control whether an object which is newly created by createUMLObject()
+     * is put at the global scope.
+     *
+     * @param yesno  When set to false, the object is created at the scope
+     *               given by the parentPkg argument of createUMLObject().
+     */
+    void putAtGlobalScope(bool yesno);
 
     /**
      * Create a UMLAttribute and insert it into the document.
@@ -85,6 +93,12 @@
     void addEnumLiteral(UMLEnum *enumType, const QString &literal);
 
     /**
+     * Create a generalization from the given child classifier to the given
+     * parent classifier.
+     */
+    void createGeneralization(UMLClassifier *child, UMLClassifier *parent);
+
+    /**
      * Create a generalization from the existing child UMLObject to the given
      * parent class name.
      */
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.cpp #448966:448967
@@ -97,6 +97,7 @@
 UMLObject* findUMLObject(UMLObjectList inList, QString name,
                          Uml::Object_Type type /* = ot_UMLObject */,
                          UMLObject *currentObj /* = NULL */) {
+    const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
     QStringList components;
     if (name.contains("::"))
         components = QStringList::split("::", name);
@@ -109,8 +110,12 @@
             // Scope qualified datatypes live in the global scope.
             for (UMLObjectListIt oit(inList); oit.current(); ++oit) {
                 UMLObject *obj = oit.current();
-                if (obj->getName() == name)
+                if (caseSensitive) {
+                    if (obj->getName() == name)
+                        return obj;
+                } else if (obj->getName().lower() == name.lower()) {
                     return obj;
+                }
             }
             return NULL;
         }
@@ -138,8 +143,12 @@
             UMLObjectList objectsInCurrentScope = pkg->containedObjects();
             for (UMLObjectListIt oit(objectsInCurrentScope); oit.current(); ++oit) {
                 UMLObject *obj = oit.current();
-                if (obj->getName() != name)
+                if (caseSensitive) {
+                    if (obj->getName() != name)
+                        continue;
+                } else if (obj->getName().lower() != name.lower()) {
                     continue;
+                }
                 Uml::Object_Type foundType = obj->getBaseType();
                 if (nameWithoutFirstPrefix.isEmpty()) {
                     if (type != Uml::ot_UMLObject && type != foundType) {
@@ -167,8 +176,12 @@
     }
     for (UMLObjectListIt oit(inList); oit.current(); ++oit) {
         UMLObject *obj = oit.current();
-        if (obj->getName() != name)
+        if (caseSensitive) {
+            if (obj->getName() != name)
+                continue;
+        } else if (obj->getName().lower() != name.lower()) {
             continue;
+        }
         Uml::Object_Type foundType = obj->getBaseType();
         if (nameWithoutFirstPrefix.isEmpty()) {
             if (type != Uml::ot_UMLObject && type != foundType) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/package.cpp #448966:448967
@@ -79,10 +79,15 @@
 }
 
 UMLObject * UMLPackage::findObject(const QString &name) {
+    const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
     for (UMLObjectListIt oit(m_objects); oit.current(); ++oit) {
         UMLObject *obj = oit.current();
-        if (obj->getName() == name)
+        if (caseSensitive) {
+            if (obj->getName() == name)
+                return obj;
+        } else if (obj->getName().lower() == name.lower()) {
             return obj;
+        }
     }
     return NULL;
 }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/uml.cpp #448966:448967
@@ -1337,6 +1337,14 @@
     setGenerator(createGenerator());
 }
 
+QString UMLApp::getActiveLanguage() const {
+    return m_activeLanguage;
+}
+
+bool UMLApp::activeLanguageIsCaseSensitive() const {
+    return (m_activeLanguage != "Ada");
+}
+
 void UMLApp::slotCurrentViewClearDiagram() {
     m_doc->getCurrentView()->clearDiagram();
 }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/uml.h #448966:448967
@@ -594,6 +594,16 @@
     void setActiveLanguage( const QString &activeLanguage );
 
     /**
+     * Get the language for import and code generation.
+     */
+    QString getActiveLanguage() const;
+
+    /**
+     * Return true if the active language is case sensitive.
+     */
+    bool activeLanguageIsCaseSensitive() const;
+
+    /**
      * Menu selection for clear current view.
      */
     void slotCurrentViewClearDiagram();




More information about the umbrello-devel mailing list