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

Oliver Kellogg okellogg at users.sourceforge.net
Sat Aug 26 12:05:09 UTC 2006


SVN commit 577359 by okellogg:

Fix loading of pre-1.5.5 XMI files where the contents of user created folders 
appeared okay in the listview but were not located inside the proper UMLFolder
in the document.


 M  +22 -19    umllistview.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.cpp #577358:577359
@@ -1199,6 +1199,13 @@
         kdDebug() << "UMLListView::addAtContainer(" << item->getText()
             << "): item's UMLObject is NULL" << endl;
     } else if (typeIsContainer(parent->getType())) {
+        /**** TBC: Do this here?
+                   If yes then remove that logic at the callers
+                   and rename this method to moveAtContainer()
+        UMLPackage *oldPkg = o->getUMLPackage();
+        if (oldPkg)
+            oldPkg->removeObject(o);
+         *********/
         UMLPackage *pkg = static_cast<UMLPackage*>(parent->getUMLObject());
         o->setUMLPackage(pkg);
         pkg->addObject(o);
@@ -1206,7 +1213,9 @@
         kdError() << "UMLListView::addAtContainer(" << item->getText()
             << "): parent type is " << parent->getType() << endl;
     }
-    m_doc->getCurrentView()->updateContainment(o);
+    UMLView *currentView = m_doc->getCurrentView();
+    if (currentView)
+        currentView->updateContainment(o);
 }
 
 UMLListViewItem * UMLListView::moveObject(Uml::IDType srcId, Uml::ListView_Type srcType,
@@ -1252,8 +1261,7 @@
                 newParentType == Uml::lvt_UseCase_View) {
             newItem = move->deepCopy(newParent);
             delete move;
-            if (srcType == Uml::lvt_UseCase_Folder)
-                addAtContainer(newItem, newParent);
+            addAtContainer(newItem, newParent);
         }
         break;
     case Uml::lvt_Component_Folder:
@@ -1263,8 +1271,7 @@
                 newParentType == Uml::lvt_Component_View) {
             newItem = move->deepCopy(newParent);
             delete move;
-            if (srcType == Uml::lvt_Component_Folder)
-                addAtContainer(newItem, newParent);
+            addAtContainer(newItem, newParent);
         }
         break;
     case Uml::lvt_Subsystem:
@@ -1293,8 +1300,7 @@
                 newParentType == Uml::lvt_Deployment_View) {
             newItem = move->deepCopy(newParent);
             delete move;
-            if (srcType == Uml::lvt_Deployment_Folder)
-                addAtContainer(newItem, newParent);
+            addAtContainer(newItem, newParent);
         }
         break;
     case Uml::lvt_EntityRelationship_Folder:
@@ -1304,8 +1310,7 @@
                 newParentType == Uml::lvt_EntityRelationship_Model) {
             newItem = move->deepCopy(newParent);
             delete move;
-            if (srcType == Uml::lvt_EntityRelationship_Folder)
-                addAtContainer(newItem, newParent);
+            addAtContainer(newItem, newParent);
         }
         break;
     case Uml::lvt_Collaboration_Diagram:
@@ -1318,8 +1323,7 @@
                 newParentType == Uml::lvt_Logical_View) {
             newItem = move->deepCopy(newParent);
             delete move;
-            if (srcType == Uml::lvt_Logical_Folder)
-                addAtContainer(newItem, newParent);
+            addAtContainer(newItem, newParent);
         }
         break;
     case Uml::lvt_Class:
@@ -1343,7 +1347,9 @@
                 o->setUMLPackage( pkg );
                 pkg->addObject( o );
             }
-            m_doc->getCurrentView()->updateContainment(o);
+            UMLView *currentView = m_doc->getCurrentView();
+            if (currentView)
+                currentView->updateContainment(o);
         }
         break;
     case Uml::lvt_Attribute:
@@ -2673,7 +2679,8 @@
                 parentPkg->addObject(f);
                 pObject = f;
                 item = new UMLListViewItem(parent, label, lvType, pObject);
-                // @todo move all relevant UMLObjects to the new UMLFolder
+                // Moving all relevant UMLObjects to the new UMLFolder is done below,
+                // in the switch(lvType)
             }
         } else if (typeIsRootView(lvType)) {
             // Predefined folders did not have their ID set.
@@ -2734,8 +2741,7 @@
                  */
             }
             else if (parent != item->parent()) {
-                ////// PRE-1.5.5 CODE
-                /* The existing item was created by the slot event triggered
+                // The existing item was created by the slot event triggered
                 // by the loading of the corresponding model object from the
                 // XMI file.
                 // This early creation is done in order to support the loading
@@ -2746,11 +2752,8 @@
                 // one of the default predefined folders, but the actual
                 // listview item might be located in a user created folder.
                 // Thanks to Achim Spangler for spotting the problem.
-                UMLListViewItem *newItem = item->deepCopy(parent);
-                delete item;
+                UMLListViewItem *newItem = moveObject(nID, lvType, parent);
                 item = newItem;
-                /////////////////// */
-                // From version 1.5.5 on, this is an error
                 UMLListViewItem *currentParent = static_cast<UMLListViewItem*>(item->parent());
                 kdError() << pfx << "Attempted reparenting of " << item->getText()
                     << "(current parent: " << currentParent->getText()




More information about the umbrello-devel mailing list