[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sun Nov 2 23:42:03 UTC 2003


CVS commit by okellogg: 

slotDropped(): Fix up UMLPackage memberships of the moved item.


  M +19 -6     umllistview.cpp   1.74


--- kdesdk/umbrello/umbrello/umllistview.cpp  #1.73:1.74
@@ -404,4 +404,6 @@ void UMLListView::slotObjectCreated(UMLO
                         UMLPackage *pkg = (UMLPackage*)parentItem->getUMLObject();
                         object->setUMLPackage(pkg);
+                        if (pkg)
+                                pkg->addObject(object);
                 } else if (lvt == Uml::lvt_Logical_Folder)
                         parentItem = current;
@@ -891,4 +893,13 @@ void UMLListView::slotDropped(QDropEvent
                 if(!move)
                         continue;
+
+                // Remove the source object at the old parent package.
+                UMLObject *srcObj = m_doc->findUMLObject(src->id);
+                if (srcObj) {
+                        UMLPackage *srcPkg = srcObj->getUMLPackage();
+                        if (srcPkg)
+                                srcPkg->removeObject(srcObj);
+                }
+
                 UMLListViewItem *newItem = NULL;
                 Uml::ListView_Type srcType = src->type;
@@ -947,13 +958,15 @@ void UMLListView::slotDropped(QDropEvent
                                         delete move;
                                         UMLObject *o = newItem->getUMLObject();
-                                        if (o == NULL)
+                                        if (o == NULL) {
                                                 kdDebug() << "slotDropped: newItem's UMLObject is NULL"
                                                           << endl;
-                                        else if (itemType == Uml::lvt_Package)
-                                                o->setUMLPackage(
-                                                        static_cast<UMLPackage*>(
-                                                                newParent->getUMLObject() ) );
-                                        else
+                                        } else if (itemType == Uml::lvt_Package) {
+                                                UMLPackage *pkg = static_cast<UMLPackage*>(
+                                                                   newParent->getUMLObject() );
+                                                o->setUMLPackage( pkg );
+                                                pkg->addObject( o );
+                                        } else {
                                                 o->setUMLPackage( NULL );
+                                        }
                                 }
                                 break;






More information about the umbrello-devel mailing list