Bug 107134 - Copy/Paste produce invalid diagrams
Summary: Copy/Paste produce invalid diagrams
Status: RESOLVED DUPLICATE of bug 107358
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 1.4.1
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-09 23:16 UTC by Reg. Charney
Modified: 2005-09-21 23:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reg. Charney 2005-06-09 23:16:35 UTC
Version:           1.4.1 (using KDE KDE 3.3.1)
Installed from:    SuSE RPMs
Compiler:          gcc 3.3.4 
OS:                Linux

On a new class diagram, 
1) add two classes, c1 and c2.
2) Create an association between c1 and c2.
3) Select all.
4) Copy all using Ctl-C or the Edit menu.
5) Paste to same diagram.
6) You should see TWO association lines, only one of which can be selected.
7) Clear the diagram. One of the associations will be left.
8) Quit the application.
9) Application crashes.
Comment 1 Oliver Kellogg 2005-06-10 07:30:53 UTC
Copy/paste in the diagram does not work at all, not even for single objects.
Also, after a "Duplicate" on a class with attributes and/or operations the duplicated class is missing its atts/ops in the list view.
Comment 2 Oliver Kellogg 2005-06-10 23:37:52 UTC
SVN commit 424123 by okellogg:

After a "Duplicate" on a class with attributes and/or operations the duplicated
class was missing its atts/ops in the list view. Here's the fix for that.
CCBUG:107134


 M  +5 -1      classifier.cpp  
 M  +7 -0      classifier.h  
 M  +13 -2     umlwidget.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/classifier.cpp #424122:424123
@@ -65,6 +65,10 @@
 	return (m_BaseType == ot_Interface);
 }
 
+void UMLClassifier::signalChildObjectAdded(UMLClassifierListItem *childObj) {
+	emit childObjectAdded(childObj);
+}
+
 UMLOperation * UMLClassifier::checkOperationSignature( QString name,
 						       UMLAttributeList *opParams,
 						       UMLOperation *exemptOp)
@@ -626,7 +630,7 @@
 	UMLClassifierListItemList resultList;
 	for (UMLClassifierListItemListIt lit(m_List); lit.current(); ++lit) {
 		UMLClassifierListItem *listItem = lit.current();
-		if (listItem->getBaseType() == ot)
+		if (ot == Uml::ot_UMLObject || listItem->getBaseType() == ot)
 			resultList.append(listItem);
 	}
 	return resultList;
--- trunk/KDE/kdesdk/umbrello/umbrello/classifier.h #424122:424123
@@ -341,6 +341,8 @@
 
 	/**
 	 * Returns the entries in m_List that are of the requested type.
+	 * If the requested type is Uml::ot_UMLObject then all entries
+	 * are returned.
 	 *
 	 * @return	The list of true operations for the Concept.
 	 */
@@ -432,6 +434,11 @@
 	 */
 	bool hasAbstractOps ();
 
+	/**
+	 * Emit the UMLObject::childObjectAdded signal for the given child object.
+	 */
+	void signalChildObjectAdded(UMLClassifierListItem *childObj);
+
 signals:
 	/** Signals that a new UMLOperation has been added to the classifer.
 	 * The signal is emitted in addition to the generic childObjectAdded()
--- trunk/KDE/kdesdk/umbrello/umbrello/umlwidget.cpp #424122:424123
@@ -24,7 +24,7 @@
 #include "umldoc.h"
 #include "umllistview.h"
 #include "umlview.h"
-
+#include "umlclassifierlistitemlist.h"
 #include "codegenerator.h"
 #include "codegenerators/simplecodegenerator.h"
 #include "listpopupmenu.h"
@@ -542,7 +542,18 @@
 
 		case ListPopupMenu::mt_Clone:
 			// In principle we clone all the uml objects.
-			m_pView->addObject(m_pObject->clone());
+			{
+				UMLObject *pClone = m_pObject->clone();
+				m_pView->addObject(pClone);
+				if (dynamic_cast<UMLClassifier*>(pClone)) {
+					UMLClassifier *c = static_cast<UMLClassifier*>(pClone);
+					UMLClassifierListItemList items = c->getFilteredList(Uml::ot_UMLObject);
+					for (UMLClassifierListItemListIt it(items); it.current(); ++it) {
+						UMLClassifierListItem *item = it.current();
+						c->signalChildObjectAdded(item);
+					}
+				}
+			}
 			break;
 
 		case ListPopupMenu::mt_Rename_MultiA:
Comment 3 Oliver Kellogg 2005-09-21 23:02:14 UTC
OTOH, it's not quite obvious what a Copy/Paste in a class diagram should do.
Each class can only appear _once_ in a class diagram.
IMHO it's probably best to map that operation to the Duplicate function.

*** This bug has been marked as a duplicate of 107358 ***