Bug 291749

Summary: classes copy & paste bug in Tree View
Product: umbrello Reporter: Ralf Habacker <ralf.habacker>
Component: generalAssignee: Joris Steyn <kde>
Status: RESOLVED FIXED    
Severity: normal CC: kde, okellogg, ralf.habacker
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: All   
Latest Commit: Version Fixed In: 4.12.0
Attachments: Fix copy-paste bugs and inconsistencies in tree view

Description Ralf Habacker 2012-01-17 09:26:26 UTC
Version:           unspecified (using Devel) 
OS:                All

Copy and paste of a class in the Logical view results into an entry below the original entry with the same name from which it has been copied. 
Below the original class entry there is a new entry with the same name, which seems to be a separate class (one can add attributes and operations independently from the original class). 


Reproducible: Always

Steps to Reproduce:
1. Add a class to a class diagram
2. select the class in the tree view and press STRG-C then STRG-V


Actual Results:  
When dragging this class onto a class diagram, a class with the original class name is shown. It is impossible to add the pasted class into a class diagram.




Expected Results:  
The pasted class should be addable to the class diagram.
Comment 1 Joris Steyn 2013-09-08 10:06:11 UTC
Created attachment 82215 [details]
Fix copy-paste bugs and inconsistencies in tree view
Comment 2 Joris Steyn 2013-09-08 10:06:43 UTC
The problem with copy-pasting in the tree view is not limited to the logical
view. Also, different behaviour can be observed depending on the type of item
copied and what item it's pasted on.

Issue 1: Classes and interfaces act as containers in tree view
Copy/paste of a class or interface on itself results in a nested hierarchy:
-> Logical View
->-> new_class
->->-> new_class
This container-like behaviour is only implemented in the tree view, and only
when pasting the items on itself. I'll assume pasted classes and interfaces
should always be siblings, never children (except when pasted on true
containers like folders, packages, etc).

Issue 2: Inconsistent rename behaviour
When pasting an item (for example, an actor in a use case diagram) on itself, a
new item is created with the exact same name. This is different from pasting on
the container (the Use Case View in this example) where the rename dialog is
shown. 

Issue 3: Unable to drag all items onto the diagram
Either original or pasted items can be dragged onto the diagram, but not both.

Attached patch fixes these three issues and a slightly related bug where
categories could not be dragged onto ER models.
Comment 3 Oliver Kellogg 2013-09-08 17:04:32 UTC
(In reply to comment #2)
> The problem with copy-pasting in the tree view is not limited to the logical
> view. Also, different behaviour can be observed depending on the type of item
> copied and what item it's pasted on.
> 
> Issue 1: Classes and interfaces act as containers in tree view
> Copy/paste of a class or interface on itself results in a nested hierarchy:
> -> Logical View
> ->-> new_class
> ->->-> new_class
> This container-like behaviour is only implemented in the tree view, and only
> when pasting the items on itself. I'll assume pasted classes and interfaces
> should always be siblings, never children (except when pasted on true
> containers like folders, packages, etc).

Actually, years ago there had been enhancement requests to support nested classes, and the existing code was implementing that. Back in the old KDE3 days it did work - but some time later (most likely in the course of migrating to KDE4) it broke, and nobody has fixed it again.

Thanks for your patch.
Comment 4 Andi Fischer 2013-09-09 17:53:29 UTC
Git commit c63e77ca04b691b304a391d5b926ac0f0667e974 by Andi Fischer, on behalf of Joris Steyn.
Committed on 08/09/2013 at 19:12.
Pushed by fischer into branch 'master'.

The problem with copy-pasting in the tree view is fixed.

M  +10   -5    umbrello/model_utils.cpp
M  +1    -0    umbrello/umlobject.cpp
M  +3    -1    umbrello/umlview.cpp

http://commits.kde.org/umbrello/c63e77ca04b691b304a391d5b926ac0f0667e974
Comment 5 Ralf Habacker 2013-10-06 12:21:07 UTC
Git commit c4de1a6c78e8f8435aeb5f4ba6477ffdeedbef3d by Ralf Habacker, on behalf of Joris Steyn.
Committed on 08/09/2013 at 19:12.
Pushed by habacker into branch 'KDE/4.11'.

The problem with copy-pasting in the tree view is fixed.
FIXED-IN:4.11.3

M  +10   -5    umbrello/model_utils.cpp
M  +1    -0    umbrello/umlobject.cpp
M  +3    -1    umbrello/umlview.cpp

http://commits.kde.org/umbrello/c4de1a6c78e8f8435aeb5f4ba6477ffdeedbef3d
Comment 6 Joris Steyn 2013-11-10 19:20:34 UTC
Git commit 1bfad17b6e6891a316ea56ac906980175ae5a058 by Joris Steyn.
Committed on 13/10/2013 at 15:09.
Pushed by jorissteyn into branch 'master'.

Fix copy/paste between Umbrello instances

Clip4 now contains all the UMLObjects corresponding to the copied widgets.

Some related but obviously unused code removed. Involves a better fix than
c63e77c for broken copy/paste of listview items.
Related: bug 70926, bug 279788, bug 195803, bug 128068

M  +7    -48   umbrello/clipboard/umlclipboard.cpp
M  +18   -14   umbrello/clipboard/umldragdata.cpp
M  +6    -0    umbrello/uml.cpp
M  +0    -111  umbrello/umllistview.cpp
M  +0    -5    umbrello/umllistview.h
M  +1    -2    umbrello/umlobject.cpp

http://commits.kde.org/umbrello/1bfad17b6e6891a316ea56ac906980175ae5a058
Comment 7 Ralf Habacker 2013-11-10 23:40:53 UTC
Git commit 9b2d14372905fc49076025488983fb5859637eba by Ralf Habacker, on behalf of Joris Steyn.
Committed on 13/10/2013 at 15:09.
Pushed by habacker into branch 'KDE/4.12'.

Fix copy/paste between Umbrello instances

Clip4 now contains all the UMLObjects corresponding to the copied widgets.

Some related but obviously unused code removed. Involves a better fix than
c63e77c for broken copy/paste of listview items.
Related: bug 70926, bug 279788, bug 195803, bug 128068

M  +7    -48   umbrello/clipboard/umlclipboard.cpp
M  +18   -14   umbrello/clipboard/umldragdata.cpp
M  +6    -0    umbrello/uml.cpp
M  +0    -111  umbrello/umllistview.cpp
M  +0    -5    umbrello/umllistview.h
M  +1    -2    umbrello/umlobject.cpp

http://commits.kde.org/umbrello/9b2d14372905fc49076025488983fb5859637eba