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

Oliver Kellogg okellogg at users.sourceforge.net
Sat Sep 16 20:38:11 UTC 2006


SVN commit 585285 by okellogg:

Fix for the i18n interop problem mentioned in r581959:
Predefined root folder names are saved untranslated.
The localized name is only used on constructing the UMLListViewItem.
UMLFolder::{mark,is}Predefined(): Replace by {set,get}LocalName().


 M  +5 -7      folder.cpp  
 M  +6 -6      folder.h  
 M  +27 -37    umldoc.cpp  
 M  +0 -12     umldoc.h  
 M  +2 -2      umllistview.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/folder.cpp #585284:585285
@@ -35,7 +35,6 @@
 
 void UMLFolder::init() {
     m_BaseType = Uml::ot_Folder;
-    m_bPredefined = false;
     m_diagrams.setAutoDelete(true);
     UMLObject::setStereotype("folder");
 }
@@ -46,12 +45,12 @@
     return clone;
 }
 
-void UMLFolder::markPredefined() {
-    m_bPredefined = true;
+void UMLFolder::setLocalName(QString localName) {
+    m_localName = localName;
 }
 
-bool UMLFolder::isPredefined() {
-    return m_bPredefined;
+QString UMLFolder::getLocalName() {
+    return m_localName;
 }
 
 void UMLFolder::addView(UMLView *view) {
@@ -370,8 +369,7 @@
         UMLFolder *logicalView = umldoc->getRootFolder(Uml::mt_Logical);
         if (this == logicalView && Uml::tagEq(type, "Package")) {
             QString thisName = tempElement.attribute("name", "");
-            if (thisName == umldoc->datatypeFolderName() ||
-                thisName == "Datatypes") {  // @todo checking for name creates i18n problem
+            if (thisName == "Datatypes") {
                 UMLFolder *datatypeFolder = umldoc->getDatatypeFolder();
                 if (!datatypeFolder->loadFromXMI(tempElement))
                     totalSuccess = false;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/folder.h #585284:585285
@@ -59,18 +59,18 @@
     virtual UMLObject* clone() const;
 
     /**
-     * Mark this folder as being for Umbrello special use.
+     * Set the localized name of this folder.
      * This is set for the predefined root views (Logical,
      * UseCase, Component, Deployment, EntityRelationship,
      * and the Datatypes folder inside the Logical View.)
      */
-    void markPredefined();
+    void setLocalName(QString localName);
 
     /**
-     * Return whther this folder is one of the Umbrello special
-     * folders.
+     * Return the localized name of this folder.
+     * Only useful for the predefined root folders.
      */
-    bool isPredefined();
+    QString getLocalName();
 
     /**
      * Add a view to the diagram list.
@@ -184,7 +184,7 @@
     bool load(QDomElement & element);
 
 private:
-    bool m_bPredefined;
+    QString m_localName;  ///< i18n name, only used for predefined root folders
     /**
      * If m_folderFile is not empty then it contains a file name to which
      * this folder is saved.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umldoc.cpp #585284:585285
@@ -85,7 +85,6 @@
 UMLDoc::UMLDoc() {
     m_Name = i18n("UML Model");
     m_modelID = "m1";
-    m_datatypeFolderName = i18n("Datatypes");
     m_count = 0;
     m_pChangeLog = 0;
     m_Doc = "";
@@ -100,7 +99,14 @@
 
 void UMLDoc::init() {
     // Initialize predefined folders.
-    const QString predefinedName[Uml::N_MODELTYPES] = {
+    const QString nativeRootName[Uml::N_MODELTYPES] = {
+        "Logical View",
+        "Use Case View",
+        "Component View",
+        "Deployment View",
+        "Entity Relationship Model"
+    };
+    const QString localizedRootName[Uml::N_MODELTYPES] = {
         i18n("Logical View"),
         i18n("Use Case View"),
         i18n("Component View"),
@@ -108,11 +114,11 @@
         i18n("Entity Relationship Model")
     };
     for (int i = 0; i < Uml::N_MODELTYPES; i++) {
-        m_root[i] = new UMLFolder(predefinedName[i]);
-        m_root[i]->markPredefined();
+        m_root[i] = new UMLFolder(nativeRootName[i]);
+        m_root[i]->setLocalName(localizedRootName[i]);
     }
-    m_datatypeRoot = new UMLFolder(m_datatypeFolderName);
-    m_datatypeRoot->markPredefined();
+    m_datatypeRoot = new UMLFolder("Datatypes");
+    m_datatypeRoot->setLocalName(i18n("Datatypes"));
     m_datatypeRoot->setUMLPackage(m_root[Uml::mt_Logical]);
     m_root[Uml::mt_Logical]->addObject(m_datatypeRoot);
 
@@ -296,8 +302,8 @@
         for (int i = 0; i < Uml::N_MODELTYPES; i++)
             m_root[i]->removeAllObjects();
         // Restore the datatype folder, it has been deleted above.
-        m_datatypeRoot = new UMLFolder(m_datatypeFolderName);
-        m_datatypeRoot->markPredefined();
+        m_datatypeRoot = new UMLFolder("Datatypes");
+        m_datatypeRoot->setLocalName(i18n("Datatypes"));
         m_datatypeRoot->setUMLPackage(m_root[Uml::mt_Logical]);
         m_root[Uml::mt_Logical]->addObject(m_datatypeRoot);
         listView->theDatatypeFolder()->setUMLObject(m_datatypeRoot);
@@ -1185,7 +1191,7 @@
     if (currentView == NULL) {
         if (m_pCurrentRoot)
             return m_pCurrentRoot;
-        kdError() << "UMLDoc::currentRoot: currentView is NULL, assuming Logical View"
+        kdDebug() << "UMLDoc::currentRoot: currentView is NULL, assuming Logical View"
             << endl;
         return m_root[Uml::mt_Logical];
     }
@@ -1731,13 +1737,6 @@
     emit sigWriteToStatusBar( i18n("Loading UML elements...") );
 
     bool bNativityIsDetermined = false;
-    const QString nativeRootName[Uml::N_MODELTYPES] = {
-        "Logical View",
-        "Use Case View",
-        "Component View",
-        "Deployment View",
-        "Entity Relationship Model"
-    };
     for (QDomNode node = element.firstChild(); !node.isNull();
             node = node.nextSibling()) {
         if (node.isComment())
@@ -1748,8 +1747,7 @@
             bool foundUmbrelloRootFolder = false;
             QString name = tempElement.attribute("name");
             for (int i = 0; i < Uml::N_MODELTYPES; i++) {
-                if (name == m_root[i]->getName() ||
-                    name == nativeRootName[i]) {  // @todo checking for name creates i18n problem
+                if (name == m_root[i]->getName()) {
                     m_pCurrentRoot = m_root[i];
                     m_root[i]->loadFromXMI(tempElement);
                     foundUmbrelloRootFolder = true;
@@ -1800,35 +1798,27 @@
             QString xmiId = tempElement.attribute("xmi.id", "");
             bNativityIsDetermined = determineNativity(xmiId);
         }
+        Uml::Object_Type ot = pObject->getBaseType();
+        // Set the parent root folder.
+        UMLPackage *pkg = NULL;
+        if (ot == Uml::ot_Datatype) {
+            pkg = m_datatypeRoot;
+        } else {
+            Uml::Model_Type guess = Model_Utils::guessContainer(pObject);
+            pkg = m_root[guess];
+        }
+        pObject->setUMLPackage(pkg);
+
         bool status = pObject -> loadFromXMI( tempElement );
         if ( !status ) {
             delete pObject;
             return false;
         }
-        Uml::Object_Type ot = pObject->getBaseType();
         if (ot == ot_Stereotype) {
             UMLStereotype *s = static_cast<UMLStereotype*>(pObject);
             addStereotype(s);
             continue;
         }
-        UMLPackage *pkg = pObject->getUMLPackage();
-        if (pkg == NULL) {
-            if (ot == Uml::ot_Datatype) {
-                pkg = m_datatypeRoot;
-            } else {
-                Uml::Model_Type guess = Model_Utils::guessContainer(pObject);
-                pkg = m_root[guess];
-                /* Associations:
-                      "Association"
-                      "AssociationClass"
-                      "Generalization"
-                      "Realization"
-                      "Abstraction"
-                      "Dependency"
-                 */
-            }
-            pObject->setUMLPackage(pkg);
-        }
         pkg->addObject(pObject);
 
         /* FIXME see comment at loadUMLObjectsFromXMI
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umldoc.h #585284:585285
@@ -512,13 +512,6 @@
     }
 
     /**
-     * Return the name of the predefined Datatypes folder in the Logical View.
-     */
-    QString datatypeFolderName() const {
-        return m_datatypeFolderName;
-    }
-
-    /**
      * Returns a list of the concepts in this UMLDoc.
      *
      * @param includeNested             Whether to include the concepts from
@@ -813,11 +806,6 @@
     UMLFolder *m_datatypeRoot;
 
     /**
-     * Name of the predefined Datatypes folder in the Logical View
-     */
-    QString m_datatypeFolderName;
-
-    /**
      * The UMLDoc is the sole owner of all stereotypes.
      * UMLStereotype instances are reference counted.
      * When an UMLStereotype is no longer referenced anywhere,
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.cpp #585284:585285
@@ -1008,14 +1008,14 @@
             Uml::Model_Type mt = (Uml::Model_Type)i;
             UMLFolder *sysFolder = m_doc->getRootFolder(mt);
             Uml::ListView_Type lvt = Model_Utils::convert_MT_LVT(mt);
-            m_lv[i] = new UMLListViewItem(m_rv, sysFolder->getName(), lvt, sysFolder);
+            m_lv[i] = new UMLListViewItem(m_rv, sysFolder->getLocalName(), lvt, sysFolder);
         }
     } else {
         for (int i = 0; i < Uml::N_MODELTYPES; i++)
             deleteChildrenOf(m_lv[i]);
     }
     UMLFolder *datatypeFolder = m_doc->getDatatypeFolder();
-    m_datatypeFolder = new UMLListViewItem(m_lv[Uml::mt_Logical], datatypeFolder->getName(),
+    m_datatypeFolder = new UMLListViewItem(m_lv[Uml::mt_Logical], datatypeFolder->getLocalName(),
                                            Uml::lvt_Datatype_Folder, datatypeFolder);
     m_rv->setOpen(true);
     for (int i = 0; i < Uml::N_MODELTYPES; i++)




More information about the umbrello-devel mailing list