[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sun Oct 5 12:09:01 UTC 2003


CVS commit by okellogg: 

deepCopy(), findUMLObject(): New.


  M +30 -0     umllistviewitem.cpp   1.28
  M +14 -0     umllistviewitem.h   1.10


--- kdesdk/umbrello/umbrello/umllistviewitem.cpp  #1.27:1.28
@@ -393,4 +393,34 @@ int UMLListViewItem::compare(QListViewIt
 }
 
+UMLListViewItem* UMLListViewItem::deepCopy(UMLListViewItem *newParent) {
+        QString nm = getText();
+        Uml::ListView_Type t = getType();
+        UMLObject *o = getUMLObject();
+        UMLListViewItem* newItem;
+        if (o)
+                newItem = new UMLListViewItem(newParent, nm, t, o);
+        else
+                newItem = new UMLListViewItem(newParent, nm, t, m_nId);
+        UMLListViewItem *childItem = static_cast<UMLListViewItem*>(firstChild());
+        while (childItem) {
+                childItem->deepCopy(newItem);
+                childItem = static_cast<UMLListViewItem*>(childItem->nextSibling());
+        }
+        return newItem;
+}
+
+UMLListViewItem* UMLListViewItem::findUMLObject(UMLObject *o) {
+        if (m_pObject == o)
+                return this;
+        UMLListViewItem *childItem = static_cast<UMLListViewItem*>(firstChild());
+        while (childItem) {
+                UMLListViewItem *inner = childItem->findUMLObject(o);
+                if (inner)
+                        return inner;
+                childItem = static_cast<UMLListViewItem*>(childItem->nextSibling());
+        }
+        return NULL;
+}
+
 bool UMLListViewItem::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
         QDomElement itemElement = qDoc.createElement( "listitem" );

--- kdesdk/umbrello/umbrello/umllistviewitem.h  #1.9:1.10
@@ -171,4 +171,18 @@ public:
 
         /**
+         * Create a deep copy of this UMLListViewItem, but using the
+         * given parent instead of the parent of this UMLListViewItem.
+         * Return the new UMLListViewItem created.
+         */
+        UMLListViewItem* deepCopy(UMLListViewItem *newParent);
+
+        /**
+         * Find the UMLListViewItem that is related to the given UMLObject
+         * in the tree rooted at the current UMLListViewItem.
+         * Return a pointer to the item or NULL if not found.
+         */
+        UMLListViewItem* findUMLObject(UMLObject *o);
+
+        /**
          * saves the listview item to a <listitem> tag
          */






More information about the umbrello-devel mailing list